问:
All together now
Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a digit doesn't appear at all. Fewest bytes wins.

Input: A non-empty list of digits 1 through 9. This can be as a decimal number, string, list, or similar sequence.

Output: A consistent Truthy value if all the digits are grouped in contiguous blocks, and a consistent Falsey value if they are not.

True cases:

```<code>3
51
44999911
123456789
222222222222222222222
</code>```

False cases:

```<code>818
8884443334
4545
554553
1234567891
</code>```

var QUESTION_ID=77608,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/77608/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Pyth, 7 bytes

```<code>{IeMrz8
</code>```

Test Suite.

Title: All together now

Body:
Pyth, 7 bytes

{IeMrz8

Test Suite.


问:
Convert phrases to reverse style

The Challenge

Convert a phrase of two words to reverse style: candy bar -> bar le candy.

Specifications

There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.

For equal length, score is used to determine winner.

Test cases:

```<code>candy bar -> bar le candy
code golf -> golf le code
programming puzzles -> puzzles le programming
</code>```

答:
Pyth - 9 bytes

```<code>j" le "_c
</code>```

Test Suite.

ContentLicense: CC BY-SA 3.0

Title: Convert phrases to reverse style

Body:
Pyth - 9 bytes

j" le "_c

Test Suite.


答:
Python 2, 34 bytes

a,b=input().split();print b,"le",a
```
<p>Expects input in quotes.</p>
```>> "code golf"
golf le code
```

Title: Convert phrases to reverse style

Body:
The Challenge

Convert a phrase of two words to reverse style: candy bar -> bar le candy.

Specifications

There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.

For equal length, score is used to determine winner.

Test cases:

```<code>candy bar -> bar le candy
code golf -> golf le code
programming puzzles -> puzzles le programming
</code>```

Body:
Python 2, 34 bytes

a,b=input().split();print b,"le",a

Expects input in quotes.

>> "code golf"
golf le code


问:
Find the program that prints this integer sequence (Cops' thread)
This is the cops' thread. The robbers' thread goes here.

The last cops-and-robbers thread was already 4 months ago.

The cop's task

The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.

The cop must state it if the program is intolerant towards zero.

The cop will provide at least 2 sample inputs/outputs.

For example, if I have decided to write the Fibonacci sequence, I would write this in my answer:

```
a(0) returns 0
a(3) returns 2
```

The number of examples is up to the cop's discretion.

However, the sequence must actually exist in the On-Line Encyclopedia of Integer Sequences®, so no pseudo-random number generator for you. :(

The cop can hide as many characters as is so wished.

For example, if my program is:

```<code>function a(n)
    if n>2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Then I would hide these characters as I want:

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

The robber's task

is obviously to find the original source code.

However, any proposed source code that produces the same set of output also counts as valid, as long as it is also found in OEIS.

Tips for the cops

<s>The search function in the OEIS only works for consecutive terms, so if you want to hide your sequence, then just leave a hole anywhere.</s>

Apparently there is no way to hide the sequence. Put this in mind when you choose the sequence.

Your score is the number of bytes in your code.

The winner will be the submission with the lowest score that hasn't been cracked in 7 days.

Only submissions that are posted in 2016 April are eligible for the win. Submissions that are posted later than this are welcome, but cannot win.

In order to claim the win you need to reveal the full code and the OEIS sequence (after 7 days).

Your post should be formatted like this (NN is the number of characters):

Lua, 98 bytes

Output:

```<code>a(0) returns 0
a(3) returns 2
</code>```

Code (# marks unrevealed characters):

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

If the code is cracked, insert [Cracked](link to cracker) in the header.
If the submission is safe, insert "Safe" in the header and reveal the full code in your answer. Only answers that have revealed the full code will be eligible for the win.

答:
Javascript, 30 bytes, Cracked

# marks unrevealed characters.

n=>M###.##w(n#!#[#+!#[#)-(n##)

Examples:

```<code>0 -> 1
1 -> 1
7 -> 43
18 -> 307
</code>```

Original Code:

```<code>n=>Math.pow(n,!+[]+!+[])-(n-1)
</code>```

Body:
Javascript, 30 bytes, Cracked

# marks unrevealed characters.

n=>M###.##w(n#!#[#+!#[#)-(n##)

Examples:

0 -> 1
1 -> 1
7 -> 43
18 -> 307

Original Code:

n=>Math.pow(n,!+[]+!+[])-(n-1)


问:
Find the program that prints this integer sequence (Robbers' thread)
This is the robbers' thread. The cops' thread goes here.

In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.

The cracked code doesn't have to be identical, as long as it has the same length and any revealed characters are in the correct positions. The language must also be the same (version numbers can be different). The output must of course be identical.

No-ops can be used in robber's solution.

The winner of the robbers thread will be the user who has cracked the
most submissions by May 7th 2016. If there's a tie, the user who has cracked submissions with the longest combined code will win.

The submission should be formatted like this:

Language, nn characters (including link to answer), Cop's username

Code:

```<code>function a(n)
    if n<2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Output

```<code>a(0) returns 0
a(3) returns 2
</code>```

Optional explanation and comments.

Body:
Haskell, 51 bytes, Zgarb, A063866

f e=sum[1|1<-sum<$>mapM(flip(:)=<<pure.(0-))[1..e]]

Output: map f [0..6]: [0,1,1,0,0,3,5].


答:
Jelly, 5 bytes

```<code>ĠIFPỊ
</code>```

Try it online!

How it works

```<code>ĠIFPỊ  Main link. Input: n (list of digits or integer)

Ġ      Group the indices of n by their corresponding values, in ascending order.
       For 8884443334, this yields [[7, 8, 9], [4, 5, 6, 10], [1, 2, 3]].
 I     Increments; compute the all differences of consecutive numbers.
       For 8884443334, this yields [[1, 1], [1, 1, 4], [1, 1]].
  F    Flatten the resulting 2D list of increments.
   P   Product; multiply all increments.
    Ị  Insignificant; check if the product's absolute value is 1 or smaller.
</code>```

Title: All together now

Body:
Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a digit doesn't appear at all. Fewest bytes wins.

Input: A non-empty list of digits 1 through 9. This can be as a decimal number, string, list, or similar sequence.

Output: A consistent Truthy value if all the digits are grouped in contiguous blocks, and a consistent Falsey value if they are not.

True cases:

```<code>3
51
44999911
123456789
222222222222222222222
</code>```

False cases:

```<code>818
8884443334
4545
554553
1234567891
</code>```

var QUESTION_ID=77608,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/77608/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
Jelly, 5 bytes

ĠIFPỊ

Try it online!

How it works

ĠIFPỊ  Main link. Input: n (list of digits or integer)

Ġ      Group the indices of n by their corresponding values, in ascending order.
       For 8884443334, this yields [[7, 8, 9], [4, 5, 6, 10], [1, 2, 3]].
 I     Increments; compute the all differences of consecutive numbers.
       For 8884443334, this yields [[1, 1], [1, 1, 4], [1, 1]].
  F    Flatten the resulting 2D list of increments.
   P   Product; multiply all increments.
    Ị  Insignificant; check if the product's absolute value is 1 or smaller.


答:
Python, 56 55 bytes

```<code>a=lambda s:~(s[0]in s.lstrip(s[0]))&a(s[1:])if s else 1
</code>```

Title: All together now

Body:
Python, 56 55 bytes

a=lambda s:~(s[0]in s.lstrip(s[0]))&a(s[1:])if s else 1


答:
MATL, 12 bytes

```<code>Yb'le'h7L)Zc
</code>```

Try it online!

```<code>Yb       % Take input implicitly. Split by spaces. Gives a cell array
'le'     % Push this string
h        % Concatenate horizontally into cell array
7L       % Push [2 3 1]
)        % Apply as index, to change order
Zc       % Join with spaces. Gives a string. Display implicitly
</code>```

Title: Convert phrases to reverse style

Body:
MATL, 12 bytes

Yb'le'h7L)Zc

Try it online!

Yb       % Take input implicitly. Split by spaces. Gives a cell array
'le'     % Push this string
h        % Concatenate horizontally into cell array
7L       % Push [2 3 1]
)        % Apply as index, to change order
Zc       % Join with spaces. Gives a string. Display implicitly


答:
JavaScript ES6, <s>71</s> 69 bytes

```<code>h=y=>y.match(/(.)\1*/g);x=>h((u=h(x)).sort().join``).length==u.length
</code>```

Or, equivalently:

```<code>x=>((u=x.match(r=/(.)\1*/g)).sort().join``).match(r).length==u.length
x=>(h=y=>y.match(/(.)\1*/g))((u=h(x)).sort().join``).length==u.length
</code>```

Golfing in progress.

Verify test cases

var truthy = `3
51
44999911
123456789
222222222222222222222`.split `
`;
var falsey = `818
8884443334
4545
554553
1234567891`.split `
`;

var Q = x => ((u = x.match(r = /(.)\1*/g)).sort().join ``).match(r).length == u.length;
truthy.concat(falsey).forEach(e => {
  t = document.createTextNode(`${e} => ${Q(e)}`);
  o.appendChild(t);
  o.appendChild(document.createElement("br"));
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  font-family: Consolas, monospace;
}</code>```

```

Title: All together now

Body:
JavaScript ES6, <s>71</s> 69 bytes

h=y=>y.match(/(.)\1*/g);x=>h((u=h(x)).sort().join``).length==u.length

Or, equivalently:

x=>((u=x.match(r=/(.)\1*/g)).sort().join``).match(r).length==u.length
x=>(h=y=>y.match(/(.)\1*/g))((u=h(x)).sort().join``).length==u.length

Golfing in progress.

Verify test cases

var truthy = `3
51
44999911
123456789
222222222222222222222`.split `
`;
var falsey = `818
8884443334
4545
554553
1234567891`.split `
`;

var Q = x => ((u = x.match(r = /(.)\1*/g)).sort().join ``).match(r).length == u.length;
truthy.concat(falsey).forEach(e => {
  t = document.createTextNode(`${e} => ${Q(e)}`);
  o.appendChild(t);
  o.appendChild(document.createElement("br"));
});

* {
  font-family: Consolas, monospace;
}

<div id=o></div>


答:
Ruby, 38 bytes, histocrat, A008592

```<code>->o{(s="+o++o"*5).sum==03333&&eval(s)}
</code>```

Could be different from the intended solution as I found this by hand.

Title: Find the program that prints this integer sequence (Robbers' thread)

Body:
This is the robbers' thread. The cops' thread goes here.

In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.

The cracked code doesn't have to be identical, as long as it has the same length and any revealed characters are in the correct positions. The language must also be the same (version numbers can be different). The output must of course be identical.

No-ops can be used in robber's solution.

The winner of the robbers thread will be the user who has cracked the
most submissions by May 7th 2016. If there's a tie, the user who has cracked submissions with the longest combined code will win.

The submission should be formatted like this:

Language, nn characters (including link to answer), Cop's username

Code:

```<code>function a(n)
    if n<2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Output

```<code>a(0) returns 0
a(3) returns 2
</code>```

Optional explanation and comments.

Body:
Ruby, 38 bytes, histocrat, A008592

->o{(s="+o++o"*5).sum==03333&&eval(s)}

Could be different from the intended solution as I found this by hand.


答:
JavaScript (ES6), 27 bytes

```<code>s=>!/(.)(?!\1).*\1/.test(s)
</code>```

Uses negative lookahead to look for two non-contiguous digits. If at least two such digits exist, then they can be chosen so that the first digit precedes a different digit.

Title: All together now

Body:
JavaScript (ES6), 27 bytes

s=>!/(.)(?!\1).*\1/.test(s)

Uses negative lookahead to look for two non-contiguous digits. If at least two such digits exist, then they can be chosen so that the first digit precedes a different digit.


答:
Python 3, <s>38</s> <s>34</s> 33 bytes

```<code>lambda s:s==sorted(s,key=s.index)
</code>```

This expects a list of digits or singleton strings as argument. Test it on Ideone.

Thanks to @xsot for golfing off 4 bytes!

Thanks to @immibis for golfing off 1 byte!

Title: All together now

Body:
Python 3, <s>38</s> <s>34</s> 33 bytes

lambda s:s==sorted(s,key=s.index)

This expects a list of digits or singleton strings as argument. Test it on Ideone.

Thanks to @xsot for golfing off 4 bytes!

Thanks to @immibis for golfing off 1 byte!


答:
Haskell, 44 bytes

```<code>import Data.List
((==)<*>nub).map head.group
</code>```

Usage example: ((==)<*>nub).map head.group $ "44999911" -> True.

A non-pointfree version:

```<code>f x = q == nub q                -- True if q equals q with duplicates removed
  where
  q = map head $ group x        -- group identical digits and take the first
                                -- e.g. "44999911" -> ["44","9999","11"] -> "491"
                                -- e.g  "3443311" -> ["3","44","33","11"] -> "3431"
</code>```

Title: All together now

Body:
Haskell, 44 bytes

import Data.List
((==)<*>nub).map head.group

Usage example: ((==)<*>nub).map head.group $ "44999911" -> True.

A non-pointfree version:

f x = q == nub q                -- True if q equals q with duplicates removed
  where
  q = map head $ group x        -- group identical digits and take the first
                                -- e.g. "44999911" -> ["44","9999","11"] -> "491"
                                -- e.g  "3443311" -> ["3","44","33","11"] -> "3431"


答:
CJam, 9 bytes

```<code>rr" le "@
</code>```

Try it online!

Pushes first 2 tokens and then the " le " literal to stack, and then rotates the stack, moving the first word to the end of the stack. Output of the resulting stack is implied.

Title: Convert phrases to reverse style

Body:
CJam, 9 bytes

rr" le "@

Try it online!

Pushes first 2 tokens and then the " le " literal to stack, and then rotates the stack, moving the first word to the end of the stack. Output of the resulting stack is implied.


问:
Concatenating Primes
Challenge:

You are given a string containing only digits. Your task is to output the minimum number of primes which must be concatenated to form the string. If this is impossible, output 0.

Test Cases:

Input -> Output:

```<code>252 -> 3
235 -> 2
92 -> 0
31149 -> 2
</code>```

答:
MATL, <s>26</s> 24 bytes

```<code>0in:"GUtZq@Z^V10ZA=a?x@.
</code>```

It takes a few seconds for some of the test cases.

Try it online!

Explanation

```<code>0       % Push 0
in:     % Take input. Generate array [1,2,...,N] where N is input length
"       % For each. In each iteration the number of used primes is increased
  GU    %   Push input. Convert to number
  tZq   %   Duplicate. Array of primes smaller than the input
  @     %   Push number of primes to bes tested in this iteration
  Z^    %   Cartesian power
  V     %   Convert to 2D array. Each row is a combination of primes
  10ZA  %   Convert each row to base 10, disregarding spaces
  =a    %   Do any of the results equal the input number?
  ?     %   If so
    x   %     Remove the 0 that's at the bottom of the stack
    .   %     Break for each loop
        %   Implicitly end if
        % Implicitly end for each
        % Implicitly display
</code>```

Title: Concatenating Primes

Body:
MATL, <s>26</s> 24 bytes

0in:"GUtZq@Z^V10ZA=a?x@.

It takes a few seconds for some of the test cases.

Try it online!

Explanation

0       % Push 0
in:     % Take input. Generate array [1,2,...,N] where N is input length
"       % For each. In each iteration the number of used primes is increased
  GU    %   Push input. Convert to number
  tZq   %   Duplicate. Array of primes smaller than the input
  @     %   Push number of primes to bes tested in this iteration
  Z^    %   Cartesian power
  V     %   Convert to 2D array. Each row is a combination of primes
  10ZA  %   Convert each row to base 10, disregarding spaces
  =a    %   Do any of the results equal the input number?
  ?     %   If so
    x   %     Remove the 0 that's at the bottom of the stack
    .   %     Break for each loop
        %   Implicitly end if
        % Implicitly end for each
        % Implicitly display


答:
R, 30 bytes

cat(rev(scan(,"")),sep=" le ")
```

This is a full program that accepts reads a string from STDIN and prints to STDOUT. The scan function implicitly separates space-delimited input into elements of an array. We then just reverse the array and print it, using le as a separator between elements in the output.

Title: Convert phrases to reverse style

Body:
R, 30 bytes

cat(rev(scan(,"")),sep=" le ")

This is a full program that accepts reads a string from STDIN and prints to STDOUT. The scan function implicitly separates space-delimited input into elements of an array. We then just reverse the array and print it, using le as a separator between elements in the output.


答:
IPOS, 13 bytes

```<code>rS!r%S" le "R
</code>```

Could < 10 bytes if I had implemented all the builtins that I have planned...

Explanation

```
r         # Reverse the input
S!r%      # Reverse every word -> Word order is now swapped
S" le "R  # insert a " le " between the two words by replacing the space
```

Non-competing 9-byte version

This only works with the version I pushed just now (implemented C).

```<code>SC"le"@Sj
</code>```

This works by splitting the input on spaces to obtain the two words (SC), pushing the literal le, rotating the stack (@) so the words are swapped and the le is between them and finally joining the stack on spaces (SJ).

Again, could be shorter since I also plan to add commands for joining and splitting on spaces which would make this 7 bytes. But since those are probably gonna be non-ASCII characters and I haven't fully figured out the codepage I am gonna use, those have to wait a bit.

Title: Convert phrases to reverse style

Body:
The Challenge

Convert a phrase of two words to reverse style: candy bar -> bar le candy.

Specifications

There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.

For equal length, score is used to determine winner.

Test cases:

```<code>candy bar -> bar le candy
code golf -> golf le code
programming puzzles -> puzzles le programming
</code>```

Body:
IPOS, 13 bytes

rS!r%S" le "R

Could < 10 bytes if I had implemented all the builtins that I have planned...

Explanation

r         # Reverse the input
S!r%      # Reverse every word -> Word order is now swapped
S" le "R  # insert a " le " between the two words by replacing the space

Non-competing 9-byte version

This only works with the version I pushed just now (implemented C).

SC"le"@Sj

This works by splitting the input on spaces to obtain the two words (SC), pushing the literal le, rotating the stack (@) so the words are swapped and the le is between them and finally joining the stack on spaces (SJ).

Again, could be shorter since I also plan to add commands for joining and splitting on spaces which would make this 7 bytes. But since those are probably gonna be non-ASCII characters and I haven't fully figured out the codepage I am gonna use, those have to wait a bit.


答:
Pyth - <s>19</s> <s>17</s> 16 bytes

```<code>lhf.AmP_sdTa./zY
</code>```

Test Suite.

Title: Concatenating Primes

Body:
Challenge:

You are given a string containing only digits. Your task is to output the minimum number of primes which must be concatenated to form the string. If this is impossible, output 0.

Test Cases:

Input -> Output:

```<code>252 -> 3
235 -> 2
92 -> 0
31149 -> 2
</code>```

Body:
Pyth - <s>19</s> <s>17</s> 16 bytes

lhf.AmP_sdTa./zY

Test Suite.


答:
Pyth, 16 bytes

```<code>lhaf!f!P_sYT./zY
</code>```

Test suite

Explanation to follow.

Title: Concatenating Primes

Body:
Pyth, 16 bytes

lhaf!f!P_sYT./zY

Test suite

Explanation to follow.


答:
R, <s>66</s> <s>48</s> <s>46</s> <s>43</s> 38 bytes

function(s)!any(duplicated(rle(s)$v))
```

This is a function that accepts the input as a vector of digits and returns a boolean. To call it, assign it to a variable.

Not the shortest but I thought it was a fun approach. We run length encode the input and extract the values. If the list of values contains duplicates then return FALSE, otherwise return TRUE.

Verify all test cases online

Saved 20 bytes thanks to MickyT, 3 thanks to Albert Masclans, and 5 thanks to mnel!

Title: All together now

Body:
Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a digit doesn't appear at all. Fewest bytes wins.

Input: A non-empty list of digits 1 through 9. This can be as a decimal number, string, list, or similar sequence.

Output: A consistent Truthy value if all the digits are grouped in contiguous blocks, and a consistent Falsey value if they are not.

True cases:

```<code>3
51
44999911
123456789
222222222222222222222
</code>```

False cases:

```<code>818
8884443334
4545
554553
1234567891
</code>```

var QUESTION_ID=77608,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/77608/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
R, <s>66</s> <s>48</s> <s>46</s> <s>43</s> 38 bytes

function(s)!any(duplicated(rle(s)$v))

This is a function that accepts the input as a vector of digits and returns a boolean. To call it, assign it to a variable.

Not the shortest but I thought it was a fun approach. We run length encode the input and extract the values. If the list of values contains duplicates then return FALSE, otherwise return TRUE.

Verify all test cases online

Saved 20 bytes thanks to MickyT, 3 thanks to Albert Masclans, and 5 thanks to mnel!


答:
Ruby, 23 bytes

Anonymous function. Accepts a string. Regex strat.

```<code>->n{/(.)(?!\1).*\1/!~n}
</code>```

Regex breakdown

```<code>/(.)(?!\1).*\1/
 (.)            # Match a character and save it to group 1
    (?!\1)      # Negative lookahead, match if next character isn't
                #  the same character from group 1
          .*    # Any number of matches
            \1  # The same sequence as group 1
</code>```

!~ means if there are no matches of the regex within the string, return true, and otherwise return false.

Title: All together now

Body:
Ruby, 23 bytes

Anonymous function. Accepts a string. Regex strat.

->n{/(.)(?!\1).*\1/!~n}

Regex breakdown

/(.)(?!\1).*\1/
 (.)            # Match a character and save it to group 1
    (?!\1)      # Negative lookahead, match if next character isn't
                #  the same character from group 1
          .*    # Any number of matches
            \1  # The same sequence as group 1

!~ means if there are no matches of the regex within the string, return true, and otherwise return false.


答:
Pyth, <s>6</s> 5 bytes

1 bytes thanks to FryAmTheEggman

```<code>SIxLQ
</code>```

Inspired by the Python solution here.

Test suite

Explanation:

```<code>SIxLQ
  xLQ   Map each element in the input to its index in the input. Input is implicit.
SI      Check whether this list is sorted.
</code>```

Title: All together now

Body:
Pyth, <s>6</s> 5 bytes

1 bytes thanks to FryAmTheEggman

SIxLQ

Inspired by the Python solution here.

Test suite

Explanation:

SIxLQ
  xLQ   Map each element in the input to its index in the input. Input is implicit.
SI      Check whether this list is sorted.


答:
MATL, <s>13</s> 11 bytes

```<code>u"G@=fd2<vA
</code>```

Thanks to Luis Mendo for saving two bytes!

Try it Online!

Explanation

```<code>        % Grab the input implicitly
u       % Find the unique characters
"       % For each of the unique characters
    G   % Grab the input again
    @=  % Determine which chars equal the current char
    f   % Find the locations of these characters
    d   % Compute the difference between the locations
    2<  % Find all index differences < 2 (indicating consecutive chars)
    v   % Vertically concatenate all stack contents
    A   % Ensure that they are all true
        % Implicit end of the for loop
</code>```

Title: All together now

Body:
MATL, <s>13</s> 11 bytes

u"G@=fd2<vA

Thanks to Luis Mendo for saving two bytes!

Try it Online!

Explanation

        % Grab the input implicitly
u       % Find the unique characters
"       % For each of the unique characters
    G   % Grab the input again
    @=  % Determine which chars equal the current char
    f   % Find the locations of these characters
    d   % Compute the difference between the locations
    2<  % Find all index differences < 2 (indicating consecutive chars)
    v   % Vertically concatenate all stack contents
    A   % Ensure that they are all true
        % Implicit end of the for loop


答:
Python 3, 41 bytes

```<code>print(' le '.join(input().split()[::-1]))
</code>```

Title: Convert phrases to reverse style

Body:
Python 3, 41 bytes

print(' le '.join(input().split()[::-1]))


答:
Vim  9 keystrokes

```<code>dwA le <esc>p
</code>```

I'm so close to beating pyth and Cjam! Unfortunately, I can't figure out how to take any more off, so I'll have to be satisfied with tying. =)

Explanation:

```<code>dw             'Delete a word
  A le <esc>   'Enter " le " at the end of the current line
            p  'Paste the previously deleted text
</code>```

Title: Convert phrases to reverse style

Body:
Vim  9 keystrokes

dwA le <esc>p

I'm so close to beating pyth and Cjam! Unfortunately, I can't figure out how to take any more off, so I'll have to be satisfied with tying. =)

Explanation:

dw             'Delete a word
  A le <esc>   'Enter " le " at the end of the current line
            p  'Paste the previously deleted text


答:
Julia, 35 bytes

```<code>s->issorted(s,by=x->findfirst(s,x))
</code>```

For whatever reason, sort does not take a string, but issorted does...

Title: All together now

Body:
Julia, 35 bytes

s->issorted(s,by=x->findfirst(s,x))

For whatever reason, sort does not take a string, but issorted does...


答:
JavaScript (ES6), <s>123</s> <s>121</s> 120 bytes

f=(s,v)=>(p=n=>--n-1?s%n&&p(n):1)(s)||[...s].map((_,i)=>!(n=i&&(a=f(s.slice(0,i)))&&(b=f(s.slice(i)))&&a+b)|n>v?0:v=n)|v
```

<p><em>Saved a byte thanks to @Neil!</em></p>

<h2>Explanation</h2>

<p>Takes a single string as input. Due to the prime checking method (recursive trial division), the greatest number that can be safely checked is <code>13840</code>. Some numbers above this will fail due to the maximum call stack size being exceeded. It does, however, finish instantly for every case it can handle.</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>f=(s,v)=>
  (p=n=>--n-1?s%n&&p(n):1)(s) // if s is prime, return 1
  ||[...s].map((_,i)=>        // else for each index in s, split s into 2
    !(n=i&&                   // v = return value (initialised to undefined)
      (a=f(s.slice(0,i)))&&
      (b=f(s.slice(i)))&&
      a+b
    )|n>v?0:v=n               // if i, a, b and n are all > 0 and !(n > v), v = n
  )|v                         // cast v to an integer and return it

// Test
var testCases = [ "252", "235", "92", "3149", "24747" ];
document.write("```" + testCases.map(c => c + ": " + f(c)).join("\n"));```

Title: Concatenating Primes

Body:
JavaScript (ES6), <s>123</s> <s>121</s> 120 bytes

f=(s,v)=>(p=n=>--n-1?s%n&&p(n):1)(s)||[...s].map((_,i)=>!(n=i&&(a=f(s.slice(0,i)))&&(b=f(s.slice(i)))&&a+b)|n>v?0:v=n)|v

Saved a byte thanks to @Neil!

Explanation

Takes a single string as input. Due to the prime checking method (recursive trial division), the greatest number that can be safely checked is 13840. Some numbers above this will fail due to the maximum call stack size being exceeded. It does, however, finish instantly for every case it can handle.

f=(s,v)=>
  (p=n=>--n-1?s%n&&p(n):1)(s) // if s is prime, return 1
  ||[...s].map((_,i)=>        // else for each index in s, split s into 2
    !(n=i&&                   // v = return value (initialised to undefined)
      (a=f(s.slice(0,i)))&&
      (b=f(s.slice(i)))&&
      a+b
    )|n>v?0:v=n               // if i, a, b and n are all > 0 and !(n > v), v = n
  )|v                         // cast v to an integer and return it

// Test
var testCases = [ "252", "235", "92", "3149", "24747" ];
document.write("<pre>" + testCases.map(c => c + ": " + f(c)).join("\n"));


答:
Jolf, 10 bytes

Try it here!

```<code>R_pti" le
  pti      input split by spaces
 _         reversed
R    " le  joined by that string
</code>```

Title: Convert phrases to reverse style

Body:
Jolf, 10 bytes

Try it here!

R_pti" le
  pti      input split by spaces
 _         reversed
R    " le  joined by that string


答:
GS2, 9 bytes

```<code>, ♦ le ♣2
</code>```

Try it online!

Title: Convert phrases to reverse style

Body:
GS2, 9 bytes

, ♦ le ♣2

Try it online!


答:
Reng v.3.3, 55 bytes

Try it here!

```<code>1#zaií1ø
):Weq!vz1+#z
br[zÀz/]; !o
le"Wro/ !ob"
    ~;/
</code>```

I can probably golf it by taking input until a space is found, as this approach takes all input at once.

Explanation

Input & init

```<code>1#zaií1ø
</code>```

1#z stores 1 to z. a is a one-sided mirror from the left side, meaning you can pass through it from left-to-right, but not otherwise. i takes a char of input, and í mirrors iff there is input on the input stack. Otherwise, it proceeds. 1ø goes to the next line.

Print first word

```<code>):Weq!vz1+#z
</code>```

) rotates the stack left one, : duplicates it, We checks for the equality with a space, and !v goes down iff it is a space and goes to the next phase. z1+#z increments z otherwise.

(more to come)

Here's a GIF:

Title: Convert phrases to reverse style

Body:
Reng v.3.3, 55 bytes

Try it here!

1#zaií1ø
):Weq!vz1+#z
br[zÀz/]; !o
le"Wro/ !ob"
    ~;/

I can probably golf it by taking input until a space is found, as this approach takes all input at once.

Explanation

Input & init

1#zaií1ø

1#z stores 1 to z. a is a one-sided mirror from the left side, meaning you can pass through it from left-to-right, but not otherwise. i takes a char of input, and í mirrors iff there is input on the input stack. Otherwise, it proceeds. 1ø goes to the next line.

Print first word

):Weq!vz1+#z

) rotates the stack left one, : duplicates it, We checks for the equality with a space, and !v goes down iff it is a space and goes to the next phase. z1+#z increments z otherwise.

(more to come)

Here's a GIF:


答:
BATCH file, 14 bytes

```<code>@ECHO %2 le %1
</code>```

Save to a file and invoke as notFrench word1 word2.

```<code>C:\Users\Conor O'Brien\Documents\Programming\PPCG>notFrench code golf
golf le code

C:\Users\Conor O'Brien\Documents\Programming\PPCG>
</code>```

Title: Convert phrases to reverse style

Body:
BATCH file, 14 bytes

@ECHO %2 le %1

Save to a file and invoke as notFrench word1 word2.

C:\Users\Conor O'Brien\Documents\Programming\PPCG>notFrench code golf
golf le code

C:\Users\Conor O'Brien\Documents\Programming\PPCG>


答:
JavaScript (ES6), <s>34</s> 32 bytes

s=>(a=s.split` `)[1]+" le "+a[0]
```

Saved 2 bytes thanks to @jrich!

Title: Convert phrases to reverse style

Body:
The Challenge

Convert a phrase of two words to reverse style: candy bar -> bar le candy.

Specifications

There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.

For equal length, score is used to determine winner.

Test cases:

```<code>candy bar -> bar le candy
code golf -> golf le code
programming puzzles -> puzzles le programming
</code>```

Body:
JavaScript (ES6), <s>34</s> 32 bytes

s=>(a=s.split` `)[1]+" le "+a[0]

Saved 2 bytes thanks to @jrich!


问:
Need help golfing Python 3 code to calculate volume & surface of spheroids in <150 bytes
I want to write a function golf(C, A) that takes the height (C = 2*c) and the width (A = 2*a) of an oblate (left image) or prolate (right image) spheroid or a sphere as parameters and returns the volume V and the surface area S of the shape as tuple. The output must be rounded to two decimal places.

All input and output numbers are floating point decimals.

The input numbers (A and C) are guaranteed to be greater than 0 and lower than 100.

Here are some example calls of the function (golf(C, A)) in Python 3 and the expected outputs given as test cases:

```<code>golf(4, 2)  # expected output (8.38, 21.48)
golf(2, 2)  # expected output (4.19, 12.57)
golf(2, 4)  # expected output (16.76, 34.69)
</code>```

The challenge requires my code to be smaller than 150 characters.

I could not manage to solve it myself yet, my best solution in Python 3 still takes 220 characters:

```<code>from math import *
def golf(C,A):
 c,a,V=C/2,A/2,pi/6*A*A*C;F=c*c/a**2;E=sqrt(1-(F if a>c else 1/F));S=4*pi*a*a if a==c else 2*pi*a*a*(1+(((1-E**2)/E)*atanh(E)if a>c else(c/(a*E))*asin(E)))
 return round(V,2),round(S,2)
</code>```

The necessary formulas are taken from Wikipedia: Spheroid, here's a summary:

Vall spheroids = 4 π/3 a²c = π/6 A²C as A=2a and C=2c.

This challenge was originally from checkio.org and got refactored into a code-golf challenge for empireofcode.com.

答:
122 bytes

```<code>from cmath import*
def golf(C,A):e=sqrt(1-A*A/C/C);return round(pi/6*A*A*C,2),round(pi*A*abs(A+(e and C*asin(e)/e-A)/2),2)
</code>```

The sphere can be special-cased by returning surface area πA² if e = 0.

While there are two different formulae for oblate and prolate spheroids, they are mathematically equivalent. If the involved operations support complex numbers, each formula can be used for both cases.

Since asin(e)/e will return a complex number of the form x+0j for prolate spheroids, abs can be used to turn it into the float x.

Body:
122 bytes

from cmath import*
def golf(C,A):e=sqrt(1-A*A/C/C);return round(pi/6*A*A*C,2),round(pi*A*abs(A+(e and C*asin(e)/e-A)/2),2)

The sphere can be special-cased by returning surface area πA² if e = 0.

While there are two different formulae for oblate and prolate spheroids, they are mathematically equivalent. If the involved operations support complex numbers, each formula can be used for both cases.

Since asin(e)/e will return a complex number of the form x+0j for prolate spheroids, abs can be used to turn it into the float x.


答:
Go, 81 bytes

```<code>import."strings"
func f(s string)string{h:=Split(s," ")
return h[1]+" le "+h[0]}
</code>```

Title: Convert phrases to reverse style

Body:
Go, 81 bytes

import."strings"
func f(s string)string{h:=Split(s," ")
return h[1]+" le "+h[0]}


答:
Mathematica, 26 bytes

```<code>0<##&@@Sort[#&@@@Split@#]&
</code>```

Title: All together now

Body:
Mathematica, 26 bytes

0<##&@@Sort[#&@@@Split@#]&


答:
05AB1E, 4 bytes

Code:

```<code>Ô¹ÙQ
</code>```

Explanation:

```<code>Ô     # Push connected uniquified input. E.g. 111223345565 would give 1234565.
 ¹    # Push input again.
  Ù   # Uniquify the input. E.g. 111223345565 would give 123456.
   Q  # Check if equal, which yields 1 or 0.
</code>```

Uses CP-1252 encoding.

Try it online!

Title: All together now

Body:
Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a digit doesn't appear at all. Fewest bytes wins.

Input: A non-empty list of digits 1 through 9. This can be as a decimal number, string, list, or similar sequence.

Output: A consistent Truthy value if all the digits are grouped in contiguous blocks, and a consistent Falsey value if they are not.

True cases:

```<code>3
51
44999911
123456789
222222222222222222222
</code>```

False cases:

```<code>818
8884443334
4545
554553
1234567891
</code>```

var QUESTION_ID=77608,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/77608/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
05AB1E, 4 bytes

Code:

Ô¹ÙQ

Explanation:

Ô     # Push connected uniquified input. E.g. 111223345565 would give 1234565.
 ¹    # Push input again.
  Ù   # Uniquify the input. E.g. 111223345565 would give 123456.
   Q  # Check if equal, which yields 1 or 0.

Uses CP-1252 encoding.

Try it online!


答:
Jelly, 9 bytes

```<code>ṣ⁶Ṛj“ le
</code>```

Try it online!

Title: Convert phrases to reverse style

Body:
Jelly, 9 bytes

ṣ⁶Ṛj“ le

Try it online!


答:
Perl, 18 bytes

```<code>/ /;$_="$' le $`"
</code>```

This program is 17 bytes long and requires the -p switch (+1 byte).

Title: Convert phrases to reverse style

Body:
Perl, 18 bytes

/ /;$_="$' le $`"

This program is 17 bytes long and requires the -p switch (+1 byte).


问:
{Curly Numbers};
In the esoteric programming language Curly, programs consist solely of curly braces {} and semicolons ;. Despite this humble toolset, Curly has literals that can represent any nonnegative integer. The format is a little hard for the uninitiated to read, though, so let's write some code to do the conversion for us.

Format of numbers

Curly numbers are structured according to the following rules:

Adding a semicolon adds one to the number.

A number enclosed in curly braces is multiplied by four.

Curly-brace groups may be nested but not concatenated. Braces must match properly.

Semicolons outside a set of curly braces must come afterward, not before.

To avoid ambiguity in parsing, a number must always start with a curly brace.

Some examples:

```<code>{;;}     2*4 = 8
{{;};};  (1*4+1)*4+1 = 21
{};;;    0*4+3 = 3
</code>```

(Note that rule 5 means the numbers 0 to 3 must start with an empty pair of curly braces.)

And some invalid examples:

```<code>{{;}{;;}}  Curly brace groups side-by-side, not nested
{;}}       Unmatched brace
{;{;}}     Semicolon before curly-brace group
;;;        Number does not start with curly brace
</code>```

Here's a BNF grammar for Curly numbers:

```<code><number> ::= "{" <inner> "}" <semis>
<inner>  ::= <semis>
           | <number>
<semis>  ::= ";" <semis>
           | ""
</code>```

Numbers like {;;;;} (more than 3 semicolons in a row) or {{};} (unnecessary empty brace groups) are called improper Curly numbers. They obey the above grammar and can be evaluated in the usual way, but they are also capable of shorter representations (for the above examples, {{;}} and {;} respectively).

The challenge

Write a program or function that inputs/receives a string. If the string is a nonnegative decimal integer, output/return the proper (i.e. shortest possible) Curly representation for that integer. If the string is a Curly number, output/return its decimal representation.

Input can be received via STDIN, command-line argument, or function parameter. It must be a string; that is, you may not write a function that accepts strings for Curly numbers but integers for decimal numbers.

Output can be printed to STDOUT or returned from the function. A function may return an integer when appropriate, or it may return strings in all situations.

Your program does not have to handle bad input (Curly numbers that break the formatting rules, floating point numbers, negative integers, random text), and it is not required to handle improper Curly numbers (but see below). Input will consist only of printable ASCII characters.

Scoring

The shortest code in bytes wins. If your program can do both of the following:

correctly handle improper Curly numbers, and

when given a Curly number, ignore any extra characters that aren't {};

then subtract 10% from your score. (Integer input will never have extraneous characters, even for the bonus.)

Test cases

```<code>Input       Output
{;;}        8
{{;};};     21
{};;;       3
{{{{;}}};}  260
{}          0
4           {;}
17          {{;}};
1           {};
0           {}
96          {{{;};;}}
</code>```

For the bonus:

```<code>{};;;;;     5
{{;;;;};;}  72
c{u;r;l}y;! 9
42{;} ;;;;  8
</code>```

Note: Curly is not yet implemented. But if this question does well, I may develop it further.

答:
Ruby, <s>126.9</s> 129.6 (144 - 10%)

Uses recursion to convert decimal into curly form. Removing the check for ignoring characters outside of /[;{}]/ increases the score by 0.4 at the moment.

```<code>f=->s{s=~/^\d+$/?(n=s.to_i
"{#{n<1?'':f[(n/4).to_s].gsub('{}','')}}#{?;*(n%4)}"):eval(s.tr("^{;}","").gsub(/./){|c|c<?A?"+1":c>?|?")*4":"+(0"})}
</code>```

Title: {Curly Numbers};

Body:
Ruby, <s>126.9</s> 129.6 (144 - 10%)

Uses recursion to convert decimal into curly form. Removing the check for ignoring characters outside of /[;{}]/ increases the score by 0.4 at the moment.

f=->s{s=~/^\d+$/?(n=s.to_i
"{#{n<1?'':f[(n/4).to_s].gsub('{}','')}}#{?;*(n%4)}"):eval(s.tr("^{;}","").gsub(/./){|c|c<?A?"+1":c>?|?")*4":"+(0"})}


答:
Java, 161 156 bytes

Because Java...

Shamelessly stealing borrowing the regex from this answer because I started out trying to do this with arrays and math manipulation, but it got hideously complex, and regex is as good a tool as any for this problem.

```<code>import java.util.regex.*;public class a{public static void main(String[] a){System.out.println(!Pattern.compile("(.)(?!\\1).*\\1").matcher(a[0]).find());}}
</code>```

Ungolfed:

```<code>import java.util.regex.*;

public class a {
    public static void main(String[] args) {
        System.out.println(!Pattern.compile("(.)(?!\\1).*\\1").matcher(args[0]).find());
    }
</code>```

Laid out like a sensible Java person:

```<code>import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class  {
    public static void main(String[] args) {
        Pattern p = Pattern.compile("(.)(?!\\1).*\\1");
        Matcher m = p.matcher(args[0]);
        System.out.println(!m.find());
    }
}
</code>```

Title: All together now

Body:
Java, 161 156 bytes

Because Java...

Shamelessly stealing borrowing the regex from this answer because I started out trying to do this with arrays and math manipulation, but it got hideously complex, and regex is as good a tool as any for this problem.

import java.util.regex.*;public class a{public static void main(String[] a){System.out.println(!Pattern.compile("(.)(?!\\1).*\\1").matcher(a[0]).find());}}

Ungolfed:

import java.util.regex.*;

public class a {
    public static void main(String[] args) {
        System.out.println(!Pattern.compile("(.)(?!\\1).*\\1").matcher(args[0]).find());
    }

Laid out like a sensible Java person:

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class  {
    public static void main(String[] args) {
        Pattern p = Pattern.compile("(.)(?!\\1).*\\1");
        Matcher m = p.matcher(args[0]);
        System.out.println(!m.find());
    }
}


答:
Lua, 46 Bytes

a=(...):gsub("(%w+) (%w+)","%2 le %1")print(a)
```
<p>I save the result of <code>gsub</code> to a variable because it returns 2 values, and would therefore print a <code>1</code> which is the number of changes made to the string. The other work around is about disallowing <code>gsub</code>'s return to unpack. Also, it is actually longer by 1 byte:</p>
<pre class="lang-lua prettyprint-override"><code>print((...):gsub("(%w+) (%w+)","%2 le %1")..'')
</code>```

Title: Convert phrases to reverse style

Body:
Lua, 46 Bytes

a=(...):gsub("(%w+) (%w+)","%2 le %1")print(a)

I save the result of gsub to a variable because it returns 2 values, and would therefore print a 1 which is the number of changes made to the string. The other work around is about disallowing gsub's return to unpack. Also, it is actually longer by 1 byte:

print((...):gsub("(%w+) (%w+)","%2 le %1")..'')


问:
Express a number with only 0-9 and the four operations

Explanation

Befunge is a two-dimensional program that uses stacks.

That means, to do 5 + 6, you write 56+, meaning:

```<code>56+
5    push 5 into stack
 6   push 6 into stack
  +  pop the first two items in the stack and add them up, and push the result into stack

(to those of you who do not know stacks, "push" just means add and "pop" just means take off)
</code>```

However, as the intelligent of you have observed, we cannot push the number 56 directly into the stack.

To do so, we must write 78* instead, which multiplies 7 and 8 and pushes the product into the stack.

Details

Input can be taken in any format, meaning it can be STDIN or not, at the programmer's discretion.

The input will be a positive integer (no bonus for including 0 or negative integers).

The output will be a string consisting of only these characters: 0123456789+-*/ (I would not use % modulo.)

The goal is to find the shortest string that can represent the input, using the format described above.

For example, if the input is 123, then the output would be 67*99*+. The output should be evaluated from left to right.

If there are more than one acceptable outputs (e.g. 99*67*+ is also acceptable), any one can be printed (no bonus for printing all of them).

Further Explanation

If you still do not understand how 67*99*+ evaluates to 123, here is a detailed explanation.

```<code>stack    |operation|explanation
          67*99*+
[6]       6         push 6 to stack
[6,7]      7        push 7 to stack
[42]        *       pop two from stack and multiply, then put result to stack
[42,9]       9      push 9 to stack
[42,9,9]      9     push 9 to stack
[42,81]        *    pop two from stack and multiply, then put result to stack
[123]           +   pop two from stack and add, then put result to stack
</code>```

TL;DR

The program needs to find the shortest string that can represent the input (number), using the format specified above.

Notes

This is a code-golf challenge, so the shortest code in bytes wins.

Disambiguation

The - can either be x-y or y-x, at the programmer's discretion. However, the choice must be consistent within the solution. Likewise for the /.

Sample program

Lua, 1862 bytes (try it online)

Since I am the author, I will not golf it at all.

Explanation:

```<code>This uses the depth-first search method.
</code>```

More about depth-first search: here.

The program:

```<code>local input = (...) or 81

local function div(a,b)
    if b == 0 then
        return "error"
    end
    local result = a/b
    if result > 0 then
        return math.floor(result)
    else
        return math.ceil(result)
    end
end

local function eval(expr)
    local stack = {}
    for i=1,#expr do
        local c = expr:sub(i,i)
        if c:match('[0-9]') then
            table.insert(stack, tonumber(c))
        else
            local a = table.remove(stack)
            local b = table.remove(stack)
            if a and b then
                if c == '+' then
                    table.insert(stack, a+b)
                elseif c == '-' then
                    table.insert(stack, b-a)
                elseif c == '*' then
                    table.insert(stack, a*b)
                elseif c == '/' then
                    local test = div(b,a)
                    if test == "error" then
                        return -1
                    else
                        table.insert(stack, a+b)
                    end
                end
            else
                return -1
            end
        end
    end
    return table.remove(stack) or -1
end

local samples, temp = {""}, {}

while true do
    temp = {}
    for i=1,#samples do
        local s = samples[i]
        table.insert(temp, s..'0')
        table.insert(temp, s..'1')
        table.insert(temp, s..'2')
        table.insert(temp, s..'3')
        table.insert(temp, s..'4')
        table.insert(temp, s..'5')
        table.insert(temp, s..'6')
        table.insert(temp, s..'7')
        table.insert(temp, s..'8')
        table.insert(temp, s..'9')
        table.insert(temp, s..'+')
        table.insert(temp, s..'-')
        table.insert(temp, s..'*')
        table.insert(temp, s..'/')
    end
    for i=1,#temp do
        if input == eval(temp[i]) then
            print(temp[i])
            return
        end
    end
    samples = temp
end
</code>```

Bonus

A cake for you if you use Befunge (or any variant of it) to write the code.

答:
CJam, 79

```<code>ri:M;A,:s:L;{L2m*{s,Y=},{~:A+AS*~!"/+-*">\f{\+}~}%Y2+:Y;_L@+:L;{S*~M=},:R!}gR0=
</code>```

Try it online

This is horribly inefficient, but given enough memory and time, it eventually works. 123 runs out of memory with 16GB, but 120 and 125 are ok.

Body:
CJam, 79

ri:M;A,:s:L;{L2m*{s,Y=},{~:A+AS*~!"/+-*">\f{\+}~}%Y2+:Y;_L@+:L;{S*~M=},:R!}gR0=

Try it online

This is horribly inefficient, but given enough memory and time, it eventually works. 123 runs out of memory with 16GB, but 120 and 125 are ok.


答:
Retina, 17 bytes

```<code>M`(.)(?!\1).+\1
0
</code>```

Try it online! (Slightly modified to run all test cases at once.)

The first regex matches digits which are separated by other digits, so we get a 0 for valid inputs and anywhere between 1 and 9 for invalid inputs (due to the greediness of the the .+, we can't get more than n-1 matches for n different digits).

To invert the truthiness of the result, we count the number of 0s, which is 1 for valid inputs and 0 for invalid ones.

Title: All together now

Body:
Retina, 17 bytes

M`(.)(?!\1).+\1
0

Try it online! (Slightly modified to run all test cases at once.)

The first regex matches digits which are separated by other digits, so we get a 0 for valid inputs and anywhere between 1 and 9 for invalid inputs (due to the greediness of the the .+, we can't get more than n-1 matches for n different digits).

To invert the truthiness of the result, we count the number of 0s, which is 1 for valid inputs and 0 for invalid ones.


答:
Retina, 14 bytes

Byte count assumes ISO 8859-1 encoding.

```<code>M!r`\S+
¶
 le
</code>```

Try it online! (Slightly modified to process all test cases at once.)

The first stage reverses the two words and separates them by a linefeed (this is done by matching them with right-to-left mode and printing all matches).

The second stage replaces the linefeed (¶) with  le .

Title: Convert phrases to reverse style

Body:
Retina, 14 bytes

Byte count assumes ISO 8859-1 encoding.

M!r`\S+
¶
 le

Try it online! (Slightly modified to process all test cases at once.)

The first stage reverses the two words and separates them by a linefeed (this is done by matching them with right-to-left mode and printing all matches).

The second stage replaces the linefeed (¶) with  le .


答:
JavaScript, 30 bytes, Aplet123, A002061

It's the sequence A002061:

Central polygonal numbers: n^2 - n + 1.

```<code>n=>Math.pow(n,!![]+!![])-(n-1)
</code>```

See it in action on JSFiddle.

Body:
This is the robbers' thread. The cops' thread goes here.

In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.

The cracked code doesn't have to be identical, as long as it has the same length and any revealed characters are in the correct positions. The language must also be the same (version numbers can be different). The output must of course be identical.

No-ops can be used in robber's solution.

The winner of the robbers thread will be the user who has cracked the
most submissions by May 7th 2016. If there's a tie, the user who has cracked submissions with the longest combined code will win.

The submission should be formatted like this:

Language, nn characters (including link to answer), Cop's username

Code:

```<code>function a(n)
    if n<2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Output

```<code>a(0) returns 0
a(3) returns 2
</code>```

Optional explanation and comments.

Body:
JavaScript, 30 bytes, Aplet123, A002061

It's the sequence A002061:

Central polygonal numbers: n^2 - n + 1.

n=>Math.pow(n,!![]+!![])-(n-1)

See it in action on JSFiddle.


答:
MATL, 8 bytes

```<code>t!=tXSP=
</code>```

The output is an array containing only ones for truthy, or an array containing at least one zero for falsey.

Try it online!

Explanation

Consider the input 22331, which satisfies the condition. Testing if each character equals each other gives the 2D array

```<code>1 1 0 0 0
1 1 0 0 0
0 0 1 1 0
0 0 1 1 0
0 0 0 0 1
</code>```

The final result should be truthy if the rows of that array (considered as atomic) are in (lexicographical) decreasing order. For comparison, input 22321 gives the array

```<code>1 1 0 1 0
1 1 0 1 0
0 0 1 0 0
1 1 0 1 0
0 0 0 0 1
</code>```

in which the rows are not sorted.

```<code>t!   % Take string input. Duplicate and tranpose
=    % Test for equality, element-wise with broadcast: gives a 2D array that
     % contains 0 or 1, for all pairs of characters in the input
t    % Duplicate
XS   % Sort rows (as atomic) in increasing order
P    % Flip vertically to obtain decreasing order
=    % Test for equality, element-wise
</code>```

Title: All together now

Body:
MATL, 8 bytes

t!=tXSP=

The output is an array containing only ones for truthy, or an array containing at least one zero for falsey.

Try it online!

Explanation

Consider the input 22331, which satisfies the condition. Testing if each character equals each other gives the 2D array

1 1 0 0 0
1 1 0 0 0
0 0 1 1 0
0 0 1 1 0
0 0 0 0 1

The final result should be truthy if the rows of that array (considered as atomic) are in (lexicographical) decreasing order. For comparison, input 22321 gives the array

1 1 0 1 0
1 1 0 1 0
0 0 1 0 0
1 1 0 1 0
0 0 0 0 1

in which the rows are not sorted.

t!   % Take string input. Duplicate and tranpose
=    % Test for equality, element-wise with broadcast: gives a 2D array that
     % contains 0 or 1, for all pairs of characters in the input
t    % Duplicate
XS   % Sort rows (as atomic) in increasing order
P    % Flip vertically to obtain decreasing order
=    % Test for equality, element-wise


答:
Lua, <s>107</s> <s>94</s> 85 Bytes

13 bytes saved thanks to @LeakyNun

At least, it beats Java :D. Lua sucks at manipulating strings, but I think it is good enough :).

It takes its input as a command-line argument, <s>and outputs 1 for truthy cases and false for falsy ones.</s> Now outputs using its exit code. Exit code 0 for truthy, and 1 for falsy

o=os.exit;(...):gsub("(.)(.+)%1",function(a,b)if 0<#b:gsub(a,"")then o(1)end end)o(0)
```

<h3>Ungolfed</h3>

<p>Be care, there's two magic-variables called <code>...</code>, the first one contains the argument of the program, the second one is local to the anonymous function and contains its parameters</p>

<pre class="lang-lua prettyprint-override"><code>o=os.exit;               -- ; mandatory, else it would exit instantly
(...):gsub("(.)(.+)%1",  -- iterate over each group of the form x.*x and apply an anonymous
  function(a,b)          -- function that takes the captured group as parameters
  if 0<#b:gsub(a,"")     -- if the captured group (.+) contain other character than
  then                   -- the one captured by (.)
    o(1)                 -- exit with falsy
  end
end)
o(0)                     -- exit with truthy, reached only when the string is okay
</code>```

Title: All together now

Body:
Lua, <s>107</s> <s>94</s> 85 Bytes

13 bytes saved thanks to @LeakyNun

At least, it beats Java :D. Lua sucks at manipulating strings, but I think it is good enough :).

It takes its input as a command-line argument, <s>and outputs 1 for truthy cases and false for falsy ones.</s> Now outputs using its exit code. Exit code 0 for truthy, and 1 for falsy

o=os.exit;(...):gsub("(.)(.+)%1",function(a,b)if 0<#b:gsub(a,"")then o(1)end end)o(0)

Ungolfed

Be care, there's two magic-variables called ..., the first one contains the argument of the program, the second one is local to the anonymous function and contains its parameters

o=os.exit;               -- ; mandatory, else it would exit instantly
(...):gsub("(.)(.+)%1",  -- iterate over each group of the form x.*x and apply an anonymous
  function(a,b)          -- function that takes the captured group as parameters
  if 0<#b:gsub(a,"")     -- if the captured group (.+) contain other character than
  then                   -- the one captured by (.)
    o(1)                 -- exit with falsy
  end
end)
o(0)                     -- exit with truthy, reached only when the string is okay


问:
Roman Numeral Line Segments
Write a program or function that accepts an integer in the range 1..3999 as input and returns the number of line segments required to express that integer in standard Roman numerals (so you would use XL but not VM). Examples:

```<code>   1 -> 1
   4 -> 3
   5 -> 2
   9 -> 3
  10 -> 2
  40 -> 4
  50 -> 2
  90 -> 3
 100 -> 1
 400 -> 3
 500 -> 2
 900 -> 5
1000 -> 4
</code>```

Roman number conversion builtins are permitted, but you can solve the problem without them by repeatedly subtracting the largest remaining number from the above list. Example: 1234 = 4 + 1 + 1 + 2 + 2 + 2 + 3 = 15.

This is code-golf, so the shortest program wins.

答:
JavaScript (ES6), 79 bytes

```<code>n=>"0123323453"[[,a,b,c,d]=1e4+n+'',d]-(-"0246424683"[c]-"0123323455"[b])+a*4
</code>```

The strings represent the number of line segments for the units, tens and hundreds digits. (Thousands is simply four times the thousands digit.) This method seems to be shorter than other options such as the algorithm suggested in the question.

Edit: Saved 2 bytes thanks to @user81655.

Title: Roman Numeral Line Segments

Body:
JavaScript (ES6), 79 bytes

n=>"0123323453"[[,a,b,c,d]=1e4+n+'',d]-(-"0246424683"[c]-"0123323455"[b])+a*4

The strings represent the number of line segments for the units, tens and hundreds digits. (Thousands is simply four times the thousands digit.) This method seems to be shorter than other options such as the algorithm suggested in the question.

Edit: Saved 2 bytes thanks to @user81655.


问:
How many IP addresses are in a given range?
Inspired by...

Networking - How can I work out how many IP addresses there are in a given range?

Write a program or function that takes two strings as input, each being an IPv4 address expressed in standard dotted notation and outputs or returns the number of IP addresses covered by this range, including the two IP addresses input.

You must not use any external code, libraries or services designed to parse an IP address. (Other string processing standard library functions are acceptable.)

All 2^32 IP addresses are equal. No distinction is made to broadcast, class E, etc.

Normal code-golf rules apply.

For example:

```<code>"0.0.0.0","255.255.255.255" returns 4294967296.
"255.255.255.255","0.0.0.0" also returns 4294967296.
"1.2.3.4","1.2.3.4" returns 1.
"56.57.58.59","60.61.62.63" returns 67372037.
"1","2" is invalid input. Your code may do anything you like.
</code>```

Body:
Javascript ES6, 81 chars

(a,b)=>Math.abs(eval(`(((((${a})>>>0)-(((((${b})>>>0)`.replace(/\./g,")<<8|")))+1

Test:

f=(a,b)=>Math.abs(eval(`(((((${a})>>>0)-(((((${b})>>>0)`.replace(/\./g,")<<8|")))+1
;`0.0.0.0,255.255.255.255,4294967296
255.255.255.255,0.0.0.0,4294967296
1.2.3.4,1.2.3.4,1
56.57.58.59,60.61.62.63,67372037`.split`
`.map(x=>x.split`,`).every(x=>f(x[0],x[1])==x[2])

PS: I'll try to optimise it a bit later.


答:
Bash + coreutils, <s>169</s> <s>158</s> 149 bytes

```<code>c()
{
test $1||echo a
for i in `seq ${#1}`
do factor ${1::$i}|grep -q ': \w*$'&&printf b%s\\n `c ${1:$i}`
done
}
c $1|sort|sed '/a/!d;s/..//;q'|wc -c
</code>```

We count in unary, outputting a line with one b for each prime and a terminating a at the end of line (so that printf has a token to work with).

The primality test is factor $n | grep -q ': \w*$', which determines whether the number has exactly one prime factor.

We recursively partition the input; if the left half is prime, we filter the results of the right half by adding one to each value.  Returning a for a zero-length input terminates the recursion.

Finally, we take all the results and sort to find the shortest (ignoring any that don't have the a to indicate success); we must delete two (for the inserted a and for the newline), then count characters to give the result.

Tests

```<code>$ for i in 252 235 92 31149 111; do echo "$i:"$'\t'"$(./77623.sh $i)"; done
252:    3
235:    2
92:     0
31149:  2
111:    0
</code>```

I added 111 to the tests to show that 1 is correctly considered non-prime.

Title: Concatenating Primes

Body:
Challenge:

You are given a string containing only digits. Your task is to output the minimum number of primes which must be concatenated to form the string. If this is impossible, output 0.

Test Cases:

Input -> Output:

```<code>252 -> 3
235 -> 2
92 -> 0
31149 -> 2
</code>```

Body:
Bash + coreutils, <s>169</s> <s>158</s> 149 bytes

c()
{
test $1||echo a
for i in `seq ${#1}`
do factor ${1::$i}|grep -q ': \w*$'&&printf b%s\\n `c ${1:$i}`
done
}
c $1|sort|sed '/a/!d;s/..//;q'|wc -c

We count in unary, outputting a line with one b for each prime and a terminating a at the end of line (so that printf has a token to work with).

The primality test is factor $n | grep -q ': \w*$', which determines whether the number has exactly one prime factor.

We recursively partition the input; if the left half is prime, we filter the results of the right half by adding one to each value.  Returning a for a zero-length input terminates the recursion.

Finally, we take all the results and sort to find the shortest (ignoring any that don't have the a to indicate success); we must delete two (for the inserted a and for the newline), then count characters to give the result.

Tests

$ for i in 252 235 92 31149 111; do echo "$i:"$'\t'"$(./77623.sh $i)"; done
252:    3
235:    2
92:     0
31149:  2
111:    0

I added 111 to the tests to show that 1 is correctly considered non-prime.


答:
Mathematica, 30 bytes

```<code>#2<>" le "<>#&@@StringSplit@#&
</code>```

Not very complicated...

Title: Convert phrases to reverse style

Body:
The Challenge

Convert a phrase of two words to reverse style: candy bar -> bar le candy.

Specifications

There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.

For equal length, score is used to determine winner.

Test cases:

```<code>candy bar -> bar le candy
code golf -> golf le code
programming puzzles -> puzzles le programming
</code>```

Body:
Mathematica, 30 bytes

#2<>" le "<>#&@@StringSplit@#&

Not very complicated...


答:
Python, 123 bytes, ASCIIThenANSI, A089911

Code:

```<code>def f(n):
 if n<2:
  return n
 else:
  return f(n-1)+f(n-2)

def g(n):
 if n<2:
  return n
 else:
  return (f(n-1)+f(n-2))%12
</code>```

The formula for this sequence is g(n) = f(n) % 12, whereas f(n) is the nth Fibonacci number.

This was actually a really nice puzzle! :)

Body:
Python, 123 bytes, ASCIIThenANSI, A089911

Code:

def f(n):
 if n<2:
  return n
 else:
  return f(n-1)+f(n-2)

def g(n):
 if n<2:
  return n
 else:
  return (f(n-1)+f(n-2))%12

The formula for this sequence is g(n) = f(n) % 12, whereas f(n) is the nth Fibonacci number.

This was actually a really nice puzzle! :)


答:
Lua, 153 Bytes

It's a shame that lua doesn't have a split function, I had to define mine!

```<code>a,b=...r=0y=8^8x={}t={}function f(t,s)s:gsub("%d+",function(d)t[#t+1]=d end)end
f(x,a)f(t,b)for i=1,4 do r=r+y*math.abs(t[i]-x[i])y=y/256 end print(r+1)
</code>```

Ungolfed

```<code>a,b=...                    -- unpack the arguments into two variables
r=0                        -- initialise the sume of ip adress
y=8^8                      -- weight for the rightmost value
x={}t={}                   -- two empty arrays -> will contains the splittedip adresses
function f(t,s)            -- define a split function that takes:
                           --   a pointer to an array
                           --   a string
  s:gsub("%d+",function(d) -- iterate over the group of digits in the string
    t[#t+1]=d              -- and insert them into the array
  end)
end
f(x,a)                     -- fill the array x with the first address
f(t,b)                     -- fill the array t with the second address
for i=1,4                  -- iterate over t and x
do
  r=r+y*math.abs(t[i]-x[i])-- incr r by weight*abs(range a- range b)
  y=y/256                  -- reduce the weight
end
print(r+1)                 -- output the result
</code>```

Title: How many IP addresses are in a given range?

Body:
Inspired by...

Networking - How can I work out how many IP addresses there are in a given range?

Write a program or function that takes two strings as input, each being an IPv4 address expressed in standard dotted notation and outputs or returns the number of IP addresses covered by this range, including the two IP addresses input.

You must not use any external code, libraries or services designed to parse an IP address. (Other string processing standard library functions are acceptable.)

All 2^32 IP addresses are equal. No distinction is made to broadcast, class E, etc.

Normal code-golf rules apply.

For example:

```<code>"0.0.0.0","255.255.255.255" returns 4294967296.
"255.255.255.255","0.0.0.0" also returns 4294967296.
"1.2.3.4","1.2.3.4" returns 1.
"56.57.58.59","60.61.62.63" returns 67372037.
"1","2" is invalid input. Your code may do anything you like.
</code>```

Body:
Lua, 153 Bytes

It's a shame that lua doesn't have a split function, I had to define mine!

a,b=...r=0y=8^8x={}t={}function f(t,s)s:gsub("%d+",function(d)t[#t+1]=d end)end
f(x,a)f(t,b)for i=1,4 do r=r+y*math.abs(t[i]-x[i])y=y/256 end print(r+1)

Ungolfed

a,b=...                    -- unpack the arguments into two variables
r=0                        -- initialise the sume of ip adress
y=8^8                      -- weight for the rightmost value
x={}t={}                   -- two empty arrays -> will contains the splittedip adresses
function f(t,s)            -- define a split function that takes:
                           --   a pointer to an array
                           --   a string
  s:gsub("%d+",function(d) -- iterate over the group of digits in the string
    t[#t+1]=d              -- and insert them into the array
  end)
end
f(x,a)                     -- fill the array x with the first address
f(t,b)                     -- fill the array t with the second address
for i=1,4                  -- iterate over t and x
do
  r=r+y*math.abs(t[i]-x[i])-- incr r by weight*abs(range a- range b)
  y=y/256                  -- reduce the weight
end
print(r+1)                 -- output the result


答:
Pyth - 35 bytes

Brute force. A weird thing is that the new implicit input actually hurts my score because it seems to be working for .v pyth_eval also.

```<code>.V1IKfqQ.x.v+jd_T\;N^s+"+-*/"UTbhKB
</code>```

Try it online here.

Title: Express a number with only 0-9 and the four operations

Body:
Explanation

Befunge is a two-dimensional program that uses stacks.

That means, to do 5 + 6, you write 56+, meaning:

```<code>56+
5    push 5 into stack
 6   push 6 into stack
  +  pop the first two items in the stack and add them up, and push the result into stack

(to those of you who do not know stacks, "push" just means add and "pop" just means take off)
</code>```

However, as the intelligent of you have observed, we cannot push the number 56 directly into the stack.

To do so, we must write 78* instead, which multiplies 7 and 8 and pushes the product into the stack.

Details

Input can be taken in any format, meaning it can be STDIN or not, at the programmer's discretion.

The input will be a positive integer (no bonus for including 0 or negative integers).

The output will be a string consisting of only these characters: 0123456789+-*/ (I would not use % modulo.)

The goal is to find the shortest string that can represent the input, using the format described above.

For example, if the input is 123, then the output would be 67*99*+. The output should be evaluated from left to right.

If there are more than one acceptable outputs (e.g. 99*67*+ is also acceptable), any one can be printed (no bonus for printing all of them).

Further Explanation

If you still do not understand how 67*99*+ evaluates to 123, here is a detailed explanation.

```<code>stack    |operation|explanation
          67*99*+
[6]       6         push 6 to stack
[6,7]      7        push 7 to stack
[42]        *       pop two from stack and multiply, then put result to stack
[42,9]       9      push 9 to stack
[42,9,9]      9     push 9 to stack
[42,81]        *    pop two from stack and multiply, then put result to stack
[123]           +   pop two from stack and add, then put result to stack
</code>```

TL;DR

The program needs to find the shortest string that can represent the input (number), using the format specified above.

Notes

This is a code-golf challenge, so the shortest code in bytes wins.

Disambiguation

The - can either be x-y or y-x, at the programmer's discretion. However, the choice must be consistent within the solution. Likewise for the /.

Sample program

Lua, 1862 bytes (try it online)

Since I am the author, I will not golf it at all.

Explanation:

```<code>This uses the depth-first search method.
</code>```

More about depth-first search: here.

The program:

```<code>local input = (...) or 81

local function div(a,b)
    if b == 0 then
        return "error"
    end
    local result = a/b
    if result > 0 then
        return math.floor(result)
    else
        return math.ceil(result)
    end
end

local function eval(expr)
    local stack = {}
    for i=1,#expr do
        local c = expr:sub(i,i)
        if c:match('[0-9]') then
            table.insert(stack, tonumber(c))
        else
            local a = table.remove(stack)
            local b = table.remove(stack)
            if a and b then
                if c == '+' then
                    table.insert(stack, a+b)
                elseif c == '-' then
                    table.insert(stack, b-a)
                elseif c == '*' then
                    table.insert(stack, a*b)
                elseif c == '/' then
                    local test = div(b,a)
                    if test == "error" then
                        return -1
                    else
                        table.insert(stack, a+b)
                    end
                end
            else
                return -1
            end
        end
    end
    return table.remove(stack) or -1
end

local samples, temp = {""}, {}

while true do
    temp = {}
    for i=1,#samples do
        local s = samples[i]
        table.insert(temp, s..'0')
        table.insert(temp, s..'1')
        table.insert(temp, s..'2')
        table.insert(temp, s..'3')
        table.insert(temp, s..'4')
        table.insert(temp, s..'5')
        table.insert(temp, s..'6')
        table.insert(temp, s..'7')
        table.insert(temp, s..'8')
        table.insert(temp, s..'9')
        table.insert(temp, s..'+')
        table.insert(temp, s..'-')
        table.insert(temp, s..'*')
        table.insert(temp, s..'/')
    end
    for i=1,#temp do
        if input == eval(temp[i]) then
            print(temp[i])
            return
        end
    end
    samples = temp
end
</code>```

Bonus

A cake for you if you use Befunge (or any variant of it) to write the code.

Body:
Pyth - 35 bytes

Brute force. A weird thing is that the new implicit input actually hurts my score because it seems to be working for .v pyth_eval also.

.V1IKfqQ.x.v+jd_T\;N^s+"+-*/"UTbhKB

Try it online here.


答:
Mathematica, <s>142</s> 135 bytes

```<code>Min[Length/@Select[Join@@@Permutations/@IntegerPartitions@Length[a=#],And@@PrimeQ@*FromDigits/@a~Internal`PartitionRagged~#&]]/.∞->0&
</code>```

As you can see, Mathematica was not built for this task. Takes a list of digits.

Title: Concatenating Primes

Body:
Mathematica, <s>142</s> 135 bytes

Min[Length/@Select[Join@@@Permutations/@IntegerPartitions@Length[a=#],And@@PrimeQ@*FromDigits/@a~Internal`PartitionRagged~#&]]/.∞->0&

As you can see, Mathematica was not built for this task. Takes a list of digits.


答:
><>, 35 bytes

```<code>i:" "=?v
ov?(0:i<
"\~~r" el
o>l?!;
</code>```

The first line reads a character of the first word and put it on the stack, then goes to the second line if it encounters " " or otherwise loops.

The second line reads a character of the second word and prints it right away, then goes to the third line when if encounters EOF or otherwise loops.

The third line removes the space and the EOF from the stack, reverts it and pushes " le " backward, then goes to the fourth line.

The fourth line stops execution if the stack is empty, otherwise it prints a character of the stack (poping it) and loops.

Title: Convert phrases to reverse style

Body:
><>, 35 bytes

i:" "=?v
ov?(0:i<
"\~~r" el
o>l?!;

The first line reads a character of the first word and put it on the stack, then goes to the second line if it encounters " " or otherwise loops.

The second line reads a character of the second word and prints it right away, then goes to the third line when if encounters EOF or otherwise loops.

The third line removes the space and the EOF from the stack, reverts it and pushes " le " backward, then goes to the fourth line.

The fourth line stops execution if the stack is empty, otherwise it prints a character of the stack (poping it) and loops.


答:
05AB1E, 5 bytes, Adnan, A102669

Code:

```<code>TA«-g
</code>```

Output:

```<code>a(0) = 0
a(1) = 0
a(2) = 1
a(3) = 1
a(4) = 1
a(5) = 1
a(6) = 1
a(7) = 1
a(8) = 1
a(9) = 1
a(10) = 0
a(11) = 0
</code>```

Too bad you have designed the language in this inconvenient way.

Body:
This is the robbers' thread. The cops' thread goes here.

In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.

The cracked code doesn't have to be identical, as long as it has the same length and any revealed characters are in the correct positions. The language must also be the same (version numbers can be different). The output must of course be identical.

No-ops can be used in robber's solution.

The winner of the robbers thread will be the user who has cracked the
most submissions by May 7th 2016. If there's a tie, the user who has cracked submissions with the longest combined code will win.

The submission should be formatted like this:

Language, nn characters (including link to answer), Cop's username

Code:

```<code>function a(n)
    if n<2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Output

```<code>a(0) returns 0
a(3) returns 2
</code>```

Optional explanation and comments.

Body:
05AB1E, 5 bytes, Adnan, A102669

Code:

TA«-g

Output:

a(0) = 0
a(1) = 0
a(2) = 1
a(3) = 1
a(4) = 1
a(5) = 1
a(6) = 1
a(7) = 1
a(8) = 1
a(9) = 1
a(10) = 0
a(11) = 0

Too bad you have designed the language in this inconvenient way.


问:
Call a method without calling it
Inspired by a now deleted StackOverflow question. Can you come up with a way to get a particular method executed, without explicitly calling it? The more indirect it is, the better.

Here's what I mean, exactly (C used just for exemplification, all languages accepted):

// Call this.
void the_function(void)
{
    printf("Hi there!\n");
}

int main(int argc, char** argv)
{
    the_function(); // NO! Bad! This is a direct call.
    return 0;
}
```

Original question:

答:
ForceLang with the Javascript module

```<code>cons js require njs
def wr io.write
set str "Hello, World!"
js function f(a){print("Hi");return null;}
js (function(){var io=Java.type("lang.ForceLang").parse("io");var mfield=Java.type("lang.FObj").class.getDeclaredField("fields");mfield.setAccessible(true);var map=mfield.get(io);map["put"](String.fromCharCode(119,114,105,116,101),new (Java.type("lang.Function"))(f))})()
wr str
</code>```

Title: Call a method without calling it

Body:
ForceLang with the Javascript module

cons js require njs
def wr io.write
set str "Hello, World!"
js function f(a){print("Hi");return null;}
js (function(){var io=Java.type("lang.ForceLang").parse("io");var mfield=Java.type("lang.FObj").class.getDeclaredField("fields");mfield.setAccessible(true);var map=mfield.get(io);map["put"](String.fromCharCode(119,114,105,116,101),new (Java.type("lang.Function"))(f))})()
wr str


问:
Code that will only execute once
Goal

The goal of this challenge is to write code that will execute once and only once.  This means basically that it damages the program, script, or environment in some way.  If rebooting the system allows the code to run again that is permitted.

Scoring

Number of votes.  All assumptions must be clearly listed.  Any answers just initiating a reboot or halt will be disqualified.

Additional Rules because Greg Hewgill is a demi-god

No root access is permitted.

End Date

The contest will close on May 31, 2014.

Edit

This contest has been changed to popularity contest.

答:
R, 7 Bytes

```<code>`=`=`$`
</code>```

The code makes the "=" (used for assigning) become the "$" (used for subseting).
After that it gives error.

Title: Code that will only execute once

Body:
R, 7 Bytes

`=`=`$`

The code makes the "=" (used for assigning) become the "$" (used for subseting).
After that it gives error.


问:
1/N probability
Because there are not enough simple code-golf challenges:

Create an optionally unnamed program or function that, given (by any means) an integer 1 ≤ N ≤ 10000, outputs your language's True value with a pseudo-random probability of 1/N, False otherwise.

Please note that the requirement for naming has been removed. Feel free to edit answers and scores accordingly.

Some languages use 1 (or -1) and 0 for True and False, that is fine too.

Example:

Example input tests:

```<code>4 -> True
4 -> False
4 -> False
4 -> False
4 -> False
4 -> True
4 -> False
4 -> False
</code>```

I.e. given 4; it returns True with a 25% chance and False with a 75% chance.

答:
Reng v.3.3, noncompeting, 6 bytes

```<code>iu0en~
</code>```

i takes input, u pushes a random integer in [0,i), 0e checks if the value is equal to 0, n outputs that value, and ~ terminates the program.

Try it here!

Title: 1/N probability

Body:
Reng v.3.3, noncompeting, 6 bytes

iu0en~

i takes input, u pushes a random integer in [0,i), 0e checks if the value is equal to 0, n outputs that value, and ~ terminates the program.

Try it here!


Title: All together now

Body:
Given a list of digits 1 through 9, output whether each digit is grouped together as a single contiguous block. In other words, no two of the same digit are separated by different digits. It's OK if a digit doesn't appear at all. Fewest bytes wins.

Input: A non-empty list of digits 1 through 9. This can be as a decimal number, string, list, or similar sequence.

Output: A consistent Truthy value if all the digits are grouped in contiguous blocks, and a consistent Falsey value if they are not.

True cases:

```<code>3
51
44999911
123456789
222222222222222222222
</code>```

False cases:

```<code>818
8884443334
4545
554553
1234567891
</code>```

var QUESTION_ID=77608,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/77608/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
Perl 5, 20 bytes

19, plus 1 for -pe instead of -e.

$_=!/(.)(?!\1).+\1/


Title: Find the program that prints this integer sequence (Cops' thread)

Body:
This is the cops' thread. The robbers' thread goes here.

The last cops-and-robbers thread was already 4 months ago.

The cop's task

The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.

The cop must state it if the program is intolerant towards zero.

The cop will provide at least 2 sample inputs/outputs.

For example, if I have decided to write the Fibonacci sequence, I would write this in my answer:

```
a(0) returns 0
a(3) returns 2
```

The number of examples is up to the cop's discretion.

However, the sequence must actually exist in the On-Line Encyclopedia of Integer Sequences®, so no pseudo-random number generator for you. :(

The cop can hide as many characters as is so wished.

For example, if my program is:

```<code>function a(n)
    if n>2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Then I would hide these characters as I want:

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

The robber's task

is obviously to find the original source code.

However, any proposed source code that produces the same set of output also counts as valid, as long as it is also found in OEIS.

Tips for the cops

<s>The search function in the OEIS only works for consecutive terms, so if you want to hide your sequence, then just leave a hole anywhere.</s>

Apparently there is no way to hide the sequence. Put this in mind when you choose the sequence.

Your score is the number of bytes in your code.

The winner will be the submission with the lowest score that hasn't been cracked in 7 days.

Only submissions that are posted in 2016 April are eligible for the win. Submissions that are posted later than this are welcome, but cannot win.

In order to claim the win you need to reveal the full code and the OEIS sequence (after 7 days).

Your post should be formatted like this (NN is the number of characters):

Lua, 98 bytes

Output:

```<code>a(0) returns 0
a(3) returns 2
</code>```

Code (# marks unrevealed characters):

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

If the code is cracked, insert [Cracked](link to cracker) in the header.
If the submission is safe, insert "Safe" in the header and reveal the full code in your answer. Only answers that have revealed the full code will be eligible for the win.

Body:
Python, 17 bytes, Cracked

####a(n):########

Test cases:

a(1) -> 1
a(2) -> 2


答:
Python, 60 bytes, Cracked

```<code>def a(n):
 if n<#:
  return #
 else:
  return a(n-#)+a(n-#)
</code>```

Test cases:

```<code>a(0) -> 1
a(1) -> 1
a(3) -> 2
a(6) -> 6
</code>```

Body:
Python, 60 bytes, Cracked

def a(n):
 if n<#:
  return #
 else:
  return a(n-#)+a(n-#)

Test cases:

a(0) -> 1
a(1) -> 1
a(3) -> 2
a(6) -> 6