答:
C++, 91 bytes

Golfed:

#include<iostream>
int main(){int c;std::cin>>c;for(int x=1;x<=c;x++){std::cout<<x<<"\n";}}
```

<h3>Ungolfed:</h3>

<pre class="lang-cpp prettyprint-override"><code>#include<iostream>
int main(){
    int c;
    std::cin>>c;
    for(int x = 1; x <= c; x++){
        std::cout<<x<<"\n";
    }
}
</code>```

Title: Count up folks!

Body:
C++, 91 bytes

Golfed:

#include<iostream>
int main(){int c;std::cin>>c;for(int x=1;x<=c;x++){std::cout<<x<<"\n";}}

Ungolfed:

#include<iostream>
int main(){
    int c;
    std::cin>>c;
    for(int x = 1; x <= c; x++){
        std::cout<<x<<"\n";
    }
}


问:
Tips for golfing in Jolf
Jolf is a procedural golfing language made by @CᴏɴᴏʀO'Bʀɪᴇɴ.

What tips do you have for golfing in Jolf?

Please post one tip per answer.

These tips should be at least somewhat specific to Jolf, e.g. remove comments is an answer, but not a very good one.

答:
Use @

@ is a command that takes the next character in the source code and returns that character's code point. (For example, @X returns 88.) This is often very useful since you can express any number between 0 and 255 in two bytes.

ContentLicense: CC BY-SA 3.0

Title: Tips for golfing in Jolf


答:
Read the source

As of right now, there are a lot of undocumented things -- the mysterious m module among them, which has a lot of builtins. However, they do exist in the source, and it's really not hard to read once you get the hang of it, so read the source.

Title: Tips for golfing in Jolf

Body:
Jolf is a procedural golfing language made by @CᴏɴᴏʀO'Bʀɪᴇɴ.

What tips do you have for golfing in Jolf?

Please post one tip per answer.

These tips should be at least somewhat specific to Jolf, e.g. remove comments is an answer, but not a very good one.


答:
Know your auto-assigning variables!

Jolf has many ways to "auto assign" variables. The standard one is γ, which takes the value of the next expression. Β is the same thing, but converts the next expression to a number.

Also, ζ (zeta) is a variable initialized to -1/12 (guess why), and can be re-assigned with Ζ (Zeta).

For example, let's say you want to compare I (the input string) to an operation over itself. For now, let's see if I + I = reverse(I + I). This is written as, conventionally:

```<code>=+II_+II
</code>```

But this can be golfed down to:

```<code>=γ+II_γ
</code>```

Title: Tips for golfing in Jolf

Body:
Know your auto-assigning variables!

Jolf has many ways to "auto assign" variables. The standard one is γ, which takes the value of the next expression. Β is the same thing, but converts the next expression to a number.

Also, ζ (zeta) is a variable initialized to -1/12 (guess why), and can be re-assigned with Ζ (Zeta).

For example, let's say you want to compare I (the input string) to an operation over itself. For now, let's see if I + I = reverse(I + I). This is written as, conventionally:

=+II_+II

But this can be golfed down to:

=γ+II_γ


问:
Count up folks!

Introduction

It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.

This is not the same thing. That one is a (closed) not well-explained challenge.

This is not the same thing. That one is about counting up indefinitely.

Challenge

Write a program or function that prints every integer from 1 to n inclusive.

Rules

You can get n any way.

You can assume that n will always be a positive integer.

You can get n in any base, but you should always output in decimal.

Output must be separated by any character (or pattern) not in 0123456789. Non-decimal leading or trailing characters are allowed (for example when using arrays such as [1, 2, 3, 4, 5, 6]).

Standard loopholes are denied.

We want to find the shortest approach in each language, not the shortest language, so I will not accept any answer.

You must update your answer(s) after this edit, answers posted before the last edit must comply with the change rule about standard loopholes (I didn't want to deny them, but I didn't want to make the community roar, so I denied them).

You can use any post-dating language version (or language). You cannot use any language or language version made just for this challenge.

Bonuses

20%

Your program must be able to count at least up to 18446744073709551615 (2^64-1). For example, if a new datatype is the only way to support big integers, you must construct it. If your language does not have any way to support huge integers up to 2^64-1, the upper limit of that particular language must be supported instead.

EDIT: I've changed the limit from 2^64 to 2^64-1 to allow more answers.

EDIT: I made the 2^64-1 rule a bonus, since there has not been much interest in this challenge. If your answer supports 2^64-1, you can now edit it to include the bonus. Also, you can post an answer not supporting it, if it is shorter.

答:
AutoHotKey, 58 bytes

Golfed and ungolfed are the same.

Golfed:

Ungolfed:

```<code>c:=0
x:=0
InputBox, x
while c<x{
    c:=c+1
    tooltip %c%
}
</code>```

Title: Count up folks!

Body:
AutoHotKey, 58 bytes

Golfed and ungolfed are the same.

Golfed:

Ungolfed:

c:=0
x:=0
InputBox, x
while c<x{
    c:=c+1
    tooltip %c%
}


答:
TI-Basic, 11 bytes

```<code>For(I,1,Ans:Disp I:End
</code>```

I would do seq(I,I,1,Ans for 8 bytes but lists can't support 2^64 elements

Title: Count up folks!

Body:
Introduction

It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.

This is not the same thing. That one is a (closed) not well-explained challenge.

This is not the same thing. That one is about counting up indefinitely.

Challenge

Write a program or function that prints every integer from 1 to n inclusive.

Rules

You can get n any way.

You can assume that n will always be a positive integer.

You can get n in any base, but you should always output in decimal.

Output must be separated by any character (or pattern) not in 0123456789. Non-decimal leading or trailing characters are allowed (for example when using arrays such as [1, 2, 3, 4, 5, 6]).

Standard loopholes are denied.

We want to find the shortest approach in each language, not the shortest language, so I will not accept any answer.

You must update your answer(s) after this edit, answers posted before the last edit must comply with the change rule about standard loopholes (I didn't want to deny them, but I didn't want to make the community roar, so I denied them).

You can use any post-dating language version (or language). You cannot use any language or language version made just for this challenge.

Bonuses

20%

Your program must be able to count at least up to 18446744073709551615 (2^64-1). For example, if a new datatype is the only way to support big integers, you must construct it. If your language does not have any way to support huge integers up to 2^64-1, the upper limit of that particular language must be supported instead.

EDIT: I've changed the limit from 2^64 to 2^64-1 to allow more answers.

EDIT: I made the 2^64-1 rule a bonus, since there has not been much interest in this challenge. If your answer supports 2^64-1, you can now edit it to include the bonus. Also, you can post an answer not supporting it, if it is shorter.

Body:
TI-Basic, 11 bytes

For(I,1,Ans:Disp I:End

I would do seq(I,I,1,Ans for 8 bytes but lists can't support 2^64 elements


问:
Create a Boolean parser (continued)
Continuation of this challenge because the author is gone and the question is closed.

What you need to do is create a Boolean parser.

Boolean expressions, in case you haven't heard of them yet, have two inputs and one output.

There are four "gates" in boolean arithmetic, namely:

OR (represented by |) (binary operator, between arguments)

AND (represented by &) (binary operator, between arguments)

XOR (represented by ^) (binary operator, between arguments)

NOT (represented by !) (unary operator, argument on right)

These gates operate on their inputs which are either true (represented by 1) or false (represented by 0). We can list the possible inputs (A and B in this case) and the outputs (O) using a truth table as follows:

```<code>XOR
A|B|O
-----
0|0|0
0|1|1
1|0|1
1|1|0

OR
A|B|O
-----
0|0|0
0|1|1
1|0|1
1|1|1

AND
A|B|O
-----
0|0|0
0|1|0
1|0|0
1|1|1

NOT
A|O
---
0|1
1|0
</code>```

An example input would be 1^((1|0&0)^!(1&!0&1)), which would evaluate to:

```<code> 1^((1|0&0)^!(1&!0&1))
=1^(( 1 &0)^!(1&!0&1))
=1^(   0   ^!(1&!0&1))
=1^(   0   ^!(1& 1&1))
=1^(   0   ^!(  1 &1))
=1^(   0   ^!    1   )
=1^(   0   ^    0    )
=1^0
=1
</code>```

The output would be 1.

Details

As seen in the example, there is no order of prevalence. All are evaluated from left to right, except when inside parentheses, which should be evaluated first.

The input will only contain ()!^&|01.

You can choose any 8-byte character to replace the 8 characters above, but they must have a 1-to-1 mapping and must be stated.

Specifically, the function eval is not allowed to be used on any string derived from the input. Specifically, the function input (or the equivalent in the language) and any function that calls it cannot be used by eval. You also cannot concatenate the input into your string inside the eval.

Scoring

This is code-golf. Shortest solution in bytes wins.

答:
C, 247

Golfed:

b(char*s){int i,j,k,l;if(*s==40){for(j=i=1;i+=s[++j]==41?-1:s[j]==40?1:0,i;);s[j++]=0;b(s+1);sprintf(s,"%s%s",s+1,s+j);}!s[1]?:(b(s+1),i=*s,j=1,k=s[1],i>47&i<50?:(s[1]=i==33?(j=0,k^1):(l=s[-1],i==38?k&l:i==94?k^l|'0':k|l),sprintf(s-j,"%s",s+1)));}
```
<p>Ungolfed, with <code>main()</code> (takes expression as 1st arg). The golfed version has no debugging printfs and uses 2-digit ascii codes instead of char literals (<code>40 == '('</code>). I could have saved some characters by mapping <code>()|^&!</code> to <code>234567</code> - this would have made many manipulations and tests easier after subtracting <code>48</code> from each.</p>
<pre class="lang-c prettyprint-override"><code>char*z;                 // tracks recursion depth; not used in golfed version
b(char*s){
    int i,j,k,l;
    printf("%u> '%s'\n", s-z, s);
    if(*s=='('){        // handles parenthesis
        for(j=i=1;i+=s[++j]==')'?-1:s[j]=='('?1:0,i;);
        s[j++]=0;
        b(s+1);         // s+1 to s+j gets substituted for its evaluation
        sprintf(s,"%s%s",s+1,s+j);
    }
    !s[1]?:(            // if 1 char left, return
        b(s+1),         // evaluate rest of expression
        i=*s,
        j=1,
        k=s[1],
        printf("%u: '%c'\n", s-z, i),
        i>47&i<50?:(    // if 0 or 1, skip substitution
                        // otherwise, perform boolean operation
            s[1]=i=='!'?(j=0,k^1):(l=s[-1],i=='&'?k&l:i=='|'?k|l:k^l|'0'),
                        // and replace operation with result
            sprintf(s-j,"%s",s+1),printf("%u= '%s'\n", s-z, s-j)));
    printf("%u< '%s'\n", s-z, s);
}
int main(int argc, char **argv){
    char *s;
    sscanf(argv[1],"%ms",&s);
    z=s;
    b(s);
    printf("%s => %s\n", argv[1], s);
}
</code>```

Title: Create a Boolean parser (continued)

Body:
C, 247

Golfed:

b(char*s){int i,j,k,l;if(*s==40){for(j=i=1;i+=s[++j]==41?-1:s[j]==40?1:0,i;);s[j++]=0;b(s+1);sprintf(s,"%s%s",s+1,s+j);}!s[1]?:(b(s+1),i=*s,j=1,k=s[1],i>47&i<50?:(s[1]=i==33?(j=0,k^1):(l=s[-1],i==38?k&l:i==94?k^l|'0':k|l),sprintf(s-j,"%s",s+1)));}

Ungolfed, with main() (takes expression as 1st arg). The golfed version has no debugging printfs and uses 2-digit ascii codes instead of char literals (40 == '('). I could have saved some characters by mapping ()|^&! to 234567 - this would have made many manipulations and tests easier after subtracting 48 from each.

char*z;                 // tracks recursion depth; not used in golfed version
b(char*s){
    int i,j,k,l;
    printf("%u> '%s'\n", s-z, s);
    if(*s=='('){        // handles parenthesis
        for(j=i=1;i+=s[++j]==')'?-1:s[j]=='('?1:0,i;);
        s[j++]=0;
        b(s+1);         // s+1 to s+j gets substituted for its evaluation
        sprintf(s,"%s%s",s+1,s+j);
    }
    !s[1]?:(            // if 1 char left, return
        b(s+1),         // evaluate rest of expression
        i=*s,
        j=1,
        k=s[1],
        printf("%u: '%c'\n", s-z, i),
        i>47&i<50?:(    // if 0 or 1, skip substitution
                        // otherwise, perform boolean operation
            s[1]=i=='!'?(j=0,k^1):(l=s[-1],i=='&'?k&l:i=='|'?k|l:k^l|'0'),
                        // and replace operation with result
            sprintf(s-j,"%s",s+1),printf("%u= '%s'\n", s-z, s-j)));
    printf("%u< '%s'\n", s-z, s);
}
int main(int argc, char **argv){
    char *s;
    sscanf(argv[1],"%ms",&s);
    z=s;
    b(s);
    printf("%s => %s\n", argv[1], s);
}


答:
Use o to store values

Similar to how other languages can assign variables for easy/short referencing, Jolf has o.

For example, oThx prints the input plus 1.

This is a useless example, but when the expression is more complicated than hx, it can save some serious byteage.

Also, v"var name"<val> allows for a multi-char variable name, and V"var name" gets a variable from the scope.

Thanks to Conor for explaining this to me, and giving the previous sentence.

Title: Tips for golfing in Jolf


答:
GameMaker Language, 38 bytes

```<code>for(i=0;i<argument0;show_message(++i))
</code>```

Title: Count up folks!

Body:
GameMaker Language, 38 bytes

for(i=0;i<argument0;show_message(++i))


答:
Increase Function Arity

Every function has an arity. For example, + has an arity of 2. If you want to (say) add 5 elements, you could use 5 +s... or do +θ12345. Specifically:

θ incrases the arity of the function by 3.

~θ increases the arity of the parent function by 3. (So *+~θ345678 increases the arity of the * by 3)

M increases the arity of the function by 2.

~M increases the arity of the parent function by 2.

; increases the arity of the function by 1.

~; increases the arity of the parent function by 1.

η decreases the arity of the function by 1.

~η decreases the arity of the parent function by 1.

\xad sets the arity of the parent function to the next character's charcode.

Title: Tips for golfing in Jolf


答:
GNU Coreutils, 6 bytes

```<code>seq $1
</code>```

split answer to pure bash, see below...

Title: Count up folks!

Body:
GNU Coreutils, 6 bytes

seq $1

split answer to pure bash, see below...


答:
J, 4 bytes

```<code>>:i.
</code>```

Try it online!

Title: Count up folks!

Body:
J, 4 bytes

>:i.

Try it online!


问:
Count up forever
Write a program that counts up forever, starting from one.

Rules:

Your program must log to STDOUT or an acceptable alternative, if STDOUT is not available.

Your program must be a full, runnable program, and not a function or snippet.

Your program must output each number with a separating character in between (a newline, space, tab or comma), but this must be consistent for all numbers.

You may print the numbers in decimal, in unary or in base 256 where each digit is represented by a byte value.

Your program must count at least as far as 2128 (inclusive) without problems and without running out of memory on a reasonable desktop PC. In particular, this means if you're using unary, you cannot store a unary representation of the current number in memory.

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Title: Count up forever

Body:
JavaScript (ES6), <s>74</s> 69 chars

Output is binary.

for(r="1";;r=r.replace(/(?:(^1)|.)(?=1*$)/g,(m,f)=>f?10:m^1))alert(r)


答:
Bash, 34 Bytes

for ((i=1;i<=$1;i++)); { echo $i;}
```

Split answer from GNU coreutils, this is pure bash.

Title: Count up folks!

Body:
Bash, 34 Bytes

for ((i=1;i<=$1;i++)); { echo $i;}

Split answer from GNU coreutils, this is pure bash.


答:
Bash, 17 bytes

```<code>eval echo {1..$1}
</code>```

Title: Count up folks!

Body:
Bash, 17 bytes

eval echo {1..$1}


问:
Print NxN spiral of ascending numbers
The numbers should be printed with leading zeroes in a field with length = (number of digits of N^2).

Input (N):

```<code>4
</code>```

Output:

```<code>01 12 11 10
02 13 16 09
03 14 15 08
04 05 06 07
</code>```

I am interested in the algorithm and the cleanliness of the implementation.
So, the white space does not count and the upper limit for N is 42.

Title: Print NxN spiral of ascending numbers

Body:
In Ruby:

N=gets.to_i

index = -N
width = N
result = []
n = 0
dir=-1

while n < N*N
        dir = (dir + 1) % 4
        dir_x, dir_y = [[0,1],[1,0],[0,-1],[-1,0]][dir]
        width -= 1 if [1,3].include?(dir)

        1.upto(width) { |m|
                n += 1
                index += dir_y * N + dir_x
                result[index] = n
        }
end

width = (N*N).to_s.size
result.each_slice(N) { |l|
        print l.map {|n| "%0#{width}d" % n }.join(" "), "\n"
}

Test:

$ ruby1.9 769.rb <<< 9
01 32 31 30 29 28 27 26 25
02 33 56 55 54 53 52 51 24
03 34 57 72 71 70 69 50 23
04 35 58 73 80 79 68 49 22
05 36 59 74 81 78 67 48 21
06 37 60 75 76 77 66 47 20
07 38 61 62 63 64 65 46 19
08 39 40 41 42 43 44 45 18
09 10 11 12 13 14 15 16 17

An other solution using calculations from here :

N=gets.to_i
r=[]

tr=->x,y{ x+(N-1)/2 + (y+(N-1)/2+(N-1)%2)*N }

r[tr[0,0]] = N*N

1.upto(N*N-1) { |n|
        shell = ((Math.sqrt(n)+1)/2).to_i
        leg = (n-(2*shell-1)**2)/(2*shell)
        element = (n-(2*shell-1)**2)-2*shell*leg-shell+1
        x,y = [[element,-shell],[shell,element],[-element,shell],[-shell,-element]][leg]
        r[tr[x,y]] = N*N-n
}

r.each_slice(N) {|l|
        puts l.map { |n|
                "%0#{(N*N).to_s.size}d" % (n or 0)
        }.join(" ")
}

Test:

$ ruby1.9 769-2.rb <<< 5
01 16 15 14 13
02 17 24 23 12
03 18 25 22 11
04 19 20 21 10
05 06 07 08 09

ContentLicense: CC BY-SA 2.5


答:
Zsh, 12 bytes

```<code>echo {1..$1}
</code>```

This works because variables are expanded before the braces.

Title: Count up folks!

Body:
Zsh, 12 bytes

echo {1..$1}

This works because variables are expanded before the braces.


答:
Take advantage of implicit input

If a function does not have enough arguments, it will look to the input for the remainder of the arguments. For example:

```<code>+uz
</code>```

Would transpile to:

```<code>add(sum(unaryRange(x)), x)
</code>```

It's equivalent to

```<code>+uzxx
</code>```

Title: Tips for golfing in Jolf

Body:
Take advantage of implicit input

If a function does not have enough arguments, it will look to the input for the remainder of the arguments. For example:

+uz

Would transpile to:

add(sum(unaryRange(x)), x)

It's equivalent to

+uzxx


答:
JavaScript (ES6), <s>84</s> 80 bytes

x=>{for(n=[r=i=0];r!=x;)(n[i]=-~n[i++]%10)&&alert(r=[...n].reverse(i=0).join``)}
```

Input is a string. Outputs as alert. Change alert to console.log if you want to keep your sanity.

I tried a few different methods then went to the print to infinity question to see how the JS answer there did it and found that I was the one who answered it. *facepalm* This approach is actually shorter though, so it worked out fine.

Title: Count up folks!

Body:
JavaScript (ES6), <s>84</s> 80 bytes

x=>{for(n=[r=i=0];r!=x;)(n[i]=-~n[i++]%10)&&alert(r=[...n].reverse(i=0).join``)}

Input is a string. Outputs as alert. Change alert to console.log if you want to keep your sanity.

I tried a few different methods then went to the print to infinity question to see how the JS answer there did it and found that I was the one who answered it. *facepalm* This approach is actually shorter though, so it worked out fine.


答:
JavaScript fall back

If for some strange reason Jolf isn't golfy enough, or simply cannot cope, it may be of use to use JavaScript eval. This can happen in one of two ways.

1. Designed eval

Anything inside of $...$ is literally carried over to the JS transpilation. For example, +3$~$5 transpiles to add(3, ~5). Equivalently, +3:~5.

2. Array eval

You can use JS arrays in Jolf! Mostly. It's kind of a bug, but I'm not going to fix it. For example:

```<code>u[3*5,5/6,(3+4)/5]
</code>```

Transpiles to:

```<code>sum([2 * 3, 5 / 3, (3 + 4) / 5]);
</code>```

Title: Tips for golfing in Jolf

Body:
JavaScript fall back

If for some strange reason Jolf isn't golfy enough, or simply cannot cope, it may be of use to use JavaScript eval. This can happen in one of two ways.

1. Designed eval

Anything inside of $...$ is literally carried over to the JS transpilation. For example, +3$~$5 transpiles to add(3, ~5). Equivalently, +3:~5.

2. Array eval

You can use JS arrays in Jolf! Mostly. It's kind of a bug, but I'm not going to fix it. For example:

u[3*5,5/6,(3+4)/5]

Transpiles to:

sum([2 * 3, 5 / 3, (3 + 4) / 5]);


问:
Watson-Crick palindromes

Problem

Create a function that can determine whether or not an arbitrary DNA string is a Watson-Crick palindrome. The function will take a DNA string and output a true  value if the string is a Watson-Crick palindrome and a false value if it is not. (True and False can also be represented as 1 and 0, respectively.)

The DNA string may either be in all uppercase or all lowercase depending on your preference.

Also, the DNA string will not be empty.

Explanation

A DNA string is a Watson-Crick palindrome when the complement of its reverse is equal to itself.

Given a DNA string, first reverse it, and then complement each character according to the DNA bases (A ↔ T and C ↔ G). If the original string is equal to the complemented-reverse string, it is a Watson-Crick palindrome.

For more, see this question. It is a different challenge where you must find the longest substring of a DNA string where that substring is a Watson-Crick palindrome.

Goal

This is code-golf and the shortest code wins.

Test Cases

The format is <input> = <output>.

```<code>ATCGCGAT = true
AGT = false
GTGACGTCAC = true
GCAGTGA = false
GCGC = true
AACTGCGTTTAC = false
ACTG = false
</code>```

答:
R, 101 bytes

```<code>g=function(x){y=unlist(strsplit(x,""));all(sapply(rev(y),switch,"C"="G","G"="C","A"="T","T"="A")==y)}
</code>```

Test Cases

```<code>g("ATCGCGAT")
[1] TRUE
g("AGT")
[1] FALSE
g("GTGACGTCAC")
[1] TRUE
g("GCAGTGA")
[1] FALSE
g("GCGC")
[1] TRUE
g("AACTGCGTTTAC")
[1] FALSE
g("ACTG")
[1] FALSE
</code>```

Title: Watson-Crick palindromes

Body:
R, 101 bytes

g=function(x){y=unlist(strsplit(x,""));all(sapply(rev(y),switch,"C"="G","G"="C","A"="T","T"="A")==y)}

Test Cases

g("ATCGCGAT")
[1] TRUE
g("AGT")
[1] FALSE
g("GTGACGTCAC")
[1] TRUE
g("GCAGTGA")
[1] FALSE
g("GCGC")
[1] TRUE
g("AACTGCGTTTAC")
[1] FALSE
g("ACTG")
[1] FALSE


问:
Co-primality and the number pi

Introduction

Number theory is full of wonders, in the form of unexpected connections. Here's one of them.

Two integers are co-prime if they have no factors in common other than 1. Given a number \$N\$, consider all integers from 1 to \$N\$. Draw two such integers at random (all integers have the same probability of being selected at each draw; draws are independent and with replacement). Let \$p\$ denote the probability that the two selected integers are co-prime. Then \$p\$ tends to \${6} / {\pi^2} \approx 0.6079...\$ as \$N\$ tends to infinity.

The challenge

The purpose of this challenge is to compute \$p\$ as a function of \$N\$.

As an example, consider \$N = 4\$. There are 16 possible pairs obtained from the integers 1,2,3,4. 11 of those pairs are co-prime, namely \$(1,1)\$, \$(1,2)\$, \$(1,3)\$, \$(1,4)\$, \$(2,1)\$, \$(3,1)\$, \$(4,1)\$, \$(2,3)\$, \$(3,2)\$, \$(3,4)\$, \$(4,3)\$. Thus \$p = {11} / {16} = 0.6875\$ for \$N = 4\$.

The exact value of \$p\$ needs to be computed with at least \$4\$ decimals. This implies that the computation has to be deterministic (as opposed to Monte Carlo). But it need not be a direct enumeration of all pairs as above; any method can be used.

Function arguments or stdin/stdout may be used. If displaying the output, trailing zeros may be omitted. So for example \$0.6300\$ can be displayed as 0.63. It should be displayed as a decimal number, not as a fraction (displaying the string 63/100 is not allowed).

Winning criterion is fewest bytes. There are no restrictions on the use of built-in functions.

Test cases

Input / output (only four decimals are mandatory, as indicated above):

```<code>1    / 1.000000000000000
2    / 0.750000000000000
4    / 0.687500000000000
10   / 0.630000000000000
100  / 0.608700000000000
1000 / 0.608383000000000
</code>```

答:
Factor, <s>120</s> 113 bytes

I've spent class golfing this and I can't get it shorter.

Translation of: Julia.

```<code>[ [a,b] dup append 2 <combinations> [ members ] keep [ first2 coprime? ] filter [ length ] bi@ 2 /i 1 + swap /f ]
</code>```

Example runs on the first 5 test cases (a value of 1000 causes it to freeze the editor, and I can't be bothered to compile an executable right now):

```<code>! with floating point division
IN: scratchpad auto-use {
      1
      2
      4
      10
      100
    }
    [
      [1,b] dup append 2 <combinations> [ members ] keep
      [ first2 coprime? ] filter [ length ] bi@ 2 /i 1 + swap /f
    ]
    map

--- Data stack:
{ 1.0 0.75 0.6875 0.63 0.6087 }
! with rational division
IN: scratchpad auto-use {
      1
      2
      4
      10
      100
    }
    [
      [1,b] dup append 2 <combinations> [ members ] keep
      [ first2 coprime? ] filter [ length ] bi@ 2 /i 1 + swap /
    ]
    map

--- Data stack:
{ 1.0 0.75 0.6875 0.63 0.6087 }
{ 1 3/4 11/16 63/100 6087/10000 }
</code>```

ContentLicense: CC BY-SA 4.0

Title: Co-primality and the number pi

Body:
Factor, <s>120</s> 113 bytes

I've spent class golfing this and I can't get it shorter.

Translation of: Julia.

[ [a,b] dup append 2 <combinations> [ members ] keep [ first2 coprime? ] filter [ length ] bi@ 2 /i 1 + swap /f ]

Example runs on the first 5 test cases (a value of 1000 causes it to freeze the editor, and I can't be bothered to compile an executable right now):

! with floating point division
IN: scratchpad auto-use {
      1
      2
      4
      10
      100
    }
    [
      [1,b] dup append 2 <combinations> [ members ] keep
      [ first2 coprime? ] filter [ length ] bi@ 2 /i 1 + swap /f
    ]
    map

--- Data stack:
{ 1.0 0.75 0.6875 0.63 0.6087 }
! with rational division
IN: scratchpad auto-use {
      1
      2
      4
      10
      100
    }
    [
      [1,b] dup append 2 <combinations> [ members ] keep
      [ first2 coprime? ] filter [ length ] bi@ 2 /i 1 + swap /
    ]
    map

--- Data stack:
{ 1.0 0.75 0.6875 0.63 0.6087 }
{ 1 3/4 11/16 63/100 6087/10000 }


答:
Java, 218

Uses pattern-matching, but avoids the out-of-order replacements of my previous failed Java attempt (sharp eyes there, @Kenny Lau!).

Golfed:

String e(String s){Matcher m=Pattern.compile("(<1>|1o[01]|0o1|1a1|1x0|0x1|n0)|(<0>|0o0|0a[01]|1a0|1x1|0x0|n1)").matcher(s);return m.find()?e(s.substring(0,m.start())+(m.group(1)==null?"0":"1")+s.substring(m.end())):s;}
```
<p>Ungolfed, reads input from arguments and applies the mapping <code>oaxn</code> for <code>|&^!</code> and <code><></code> for <code>()</code>:</p>
<pre class="lang-c prettyprint-override"><code>import java.util.regex.*;

public class B{
    String e(String s){
        System.out.println(s);
        Matcher m=Pattern
            .compile(
                "(<1>|1o[01]|0o1|1a1|1x0|0x1|n0)|"+
                "(<0>|0o0|0a[01]|1a0|1x1|0x0|n1)")
            .matcher(s);
        return m.find()?e(s.substring(0,m.start())+(m.group(1)==null?"0":"1")+s.substring(m.end())):s;
    }

    public static String map(String s, String ... replacements) {
        for (String r: replacements) {
            s = s.replace(r.substring(0,1), r.substring(1));
        }
        return s;
    }

    public static void main(String ... args){
        for (String s: args) System.out.println(new B().e(
            map(s,"(<",")>","|o","&a","!n","^x")
        ));
    }
}
</code>```

Java's m.group(i) tells you which group matched; the 1st group is for true substitutions and the 2nd one for false ones. This is iterated in strict left-to-right order until no substitutions are performed.

Title: Create a Boolean parser (continued)

Body:
Continuation of this challenge because the author is gone and the question is closed.

What you need to do is create a Boolean parser.

Boolean expressions, in case you haven't heard of them yet, have two inputs and one output.

There are four "gates" in boolean arithmetic, namely:

OR (represented by |) (binary operator, between arguments)

AND (represented by &) (binary operator, between arguments)

XOR (represented by ^) (binary operator, between arguments)

NOT (represented by !) (unary operator, argument on right)

These gates operate on their inputs which are either true (represented by 1) or false (represented by 0). We can list the possible inputs (A and B in this case) and the outputs (O) using a truth table as follows:

```<code>XOR
A|B|O
-----
0|0|0
0|1|1
1|0|1
1|1|0

OR
A|B|O
-----
0|0|0
0|1|1
1|0|1
1|1|1

AND
A|B|O
-----
0|0|0
0|1|0
1|0|0
1|1|1

NOT
A|O
---
0|1
1|0
</code>```

An example input would be 1^((1|0&0)^!(1&!0&1)), which would evaluate to:

```<code> 1^((1|0&0)^!(1&!0&1))
=1^(( 1 &0)^!(1&!0&1))
=1^(   0   ^!(1&!0&1))
=1^(   0   ^!(1& 1&1))
=1^(   0   ^!(  1 &1))
=1^(   0   ^!    1   )
=1^(   0   ^    0    )
=1^0
=1
</code>```

The output would be 1.

Details

As seen in the example, there is no order of prevalence. All are evaluated from left to right, except when inside parentheses, which should be evaluated first.

The input will only contain ()!^&|01.

You can choose any 8-byte character to replace the 8 characters above, but they must have a 1-to-1 mapping and must be stated.

Specifically, the function eval is not allowed to be used on any string derived from the input. Specifically, the function input (or the equivalent in the language) and any function that calls it cannot be used by eval. You also cannot concatenate the input into your string inside the eval.

Scoring

This is code-golf. Shortest solution in bytes wins.

Body:
Java, 218

Uses pattern-matching, but avoids the out-of-order replacements of my previous failed Java attempt (sharp eyes there, @Kenny Lau!).

Golfed:

String e(String s){Matcher m=Pattern.compile("(<1>|1o[01]|0o1|1a1|1x0|0x1|n0)|(<0>|0o0|0a[01]|1a0|1x1|0x0|n1)").matcher(s);return m.find()?e(s.substring(0,m.start())+(m.group(1)==null?"0":"1")+s.substring(m.end())):s;}

Ungolfed, reads input from arguments and applies the mapping oaxn for |&^! and <> for ():

import java.util.regex.*;

public class B{
    String e(String s){
        System.out.println(s);
        Matcher m=Pattern
            .compile(
                "(<1>|1o[01]|0o1|1a1|1x0|0x1|n0)|"+
                "(<0>|0o0|0a[01]|1a0|1x1|0x0|n1)")
            .matcher(s);
        return m.find()?e(s.substring(0,m.start())+(m.group(1)==null?"0":"1")+s.substring(m.end())):s;
    }

    public static String map(String s, String ... replacements) {
        for (String r: replacements) {
            s = s.replace(r.substring(0,1), r.substring(1));
        }
        return s;
    }

    public static void main(String ... args){
        for (String s: args) System.out.println(new B().e(
            map(s,"(<",")>","|o","&a","!n","^x")
        ));
    }
}

Java's m.group(i) tells you which group matched; the 1st group is for true substitutions and the 2nd one for false ones. This is iterated in strict left-to-right order until no substitutions are performed.


问:
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.

答:
05AB1E, 3 bytes, Cracked

Output:

```<code>a(4) = 4
a(6) = 7
</code>```

Code:

```<code>___
</code>```

_ (underscore) indicates an obfuscated character

Try it online

Body:
05AB1E, 3 bytes, Cracked

Output:

a(4) = 4
a(6) = 7

Code:

___

_ (underscore) indicates an obfuscated character

Try it online


答:
Pyke, <s>5</s> 3 bytes

```<code>ohr
</code>```

Try it here!

Title: Count up forever

Body:
Write a program that counts up forever, starting from one.

Rules:

Your program must log to STDOUT or an acceptable alternative, if STDOUT is not available.

Your program must be a full, runnable program, and not a function or snippet.

Your program must output each number with a separating character in between (a newline, space, tab or comma), but this must be consistent for all numbers.

You may print the numbers in decimal, in unary or in base 256 where each digit is represented by a byte value.

Your program must count at least as far as 2128 (inclusive) without problems and without running out of memory on a reasonable desktop PC. In particular, this means if you're using unary, you cannot store a unary representation of the current number in memory.

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
Pyke, <s>5</s> 3 bytes

ohr

Try it here!


问:
Reverse positive runs

Input

Your input is a list of single-digit numbers in any reasonable format, including a string of digits.
The input will not be empty.

Output

Your output shall be the input list, but with each maximal run of nonzero digits being reversed.

Example

Consider the input

```<code>95883007414830
<--->  <---->
</code>```

where the nonzero runs have been marked with arrows.
Reversing each of these runs, we obtain the output

```<code>38859003841470
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

This challenge is related, but much more complex, since it includes additional string processing.

Test cases

```<code>4 -> 4
00 -> 00
123 -> 321
0010 -> 0010
12000345 -> 21000543
18161604 -> 61618104
95883007414830 -> 38859003841470
010230456078912 -> 010320654021987
357509902003550 -> 575309902005530
2492882377675046 -> 5767732882942064
03026302053000357099 -> 03036202035000753099
</code>```

Leaderboard

Here's a Stack Snippet to generate a leaderboard and list of winners by language.
To make sure your answer shows up, start it with a header of the form

```<code>## Language, N bytes
</code>```

You can keep old scores in the header by using the strikethrough tags: <s>57</s> will appear as <s>57</s>.

/* Configuration */

var QUESTION_ID = 78510; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 32014; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (! /<a/.test(lang)) lang = '' + lang + '';
    lang = jQuery(lang).text().toLowerCase();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.uniq > b.uniq) return 1;
    if (a.uniq < b.uniq) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Pyth, 8

```<code>j0_Mcz\0
</code>```

Split on zeros, reverse and join back on zeros.

Test Suite

Title: Reverse positive runs

Body:
Pyth, 8

j0_Mcz\0

Split on zeros, reverse and join back on zeros.

Test Suite


答:
05AB1E, 6 bytes

Code:

```<code>0¡€R0ý
</code>```

Explanation:

```<code>0¡      # Split on zeros
  €R    # For each item in the array, reverse it
    0ý  # Join by zeros
</code>```

Uses CP-1252 encoding. Try it online!.

Title: Reverse positive runs

Body:
Input

Your input is a list of single-digit numbers in any reasonable format, including a string of digits.
The input will not be empty.

Output

Your output shall be the input list, but with each maximal run of nonzero digits being reversed.

Example

Consider the input

```<code>95883007414830
<--->  <---->
</code>```

where the nonzero runs have been marked with arrows.
Reversing each of these runs, we obtain the output

```<code>38859003841470
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

This challenge is related, but much more complex, since it includes additional string processing.

Test cases

```<code>4 -> 4
00 -> 00
123 -> 321
0010 -> 0010
12000345 -> 21000543
18161604 -> 61618104
95883007414830 -> 38859003841470
010230456078912 -> 010320654021987
357509902003550 -> 575309902005530
2492882377675046 -> 5767732882942064
03026302053000357099 -> 03036202035000753099
</code>```

Leaderboard

Here's a Stack Snippet to generate a leaderboard and list of winners by language.
To make sure your answer shows up, start it with a header of the form

```<code>## Language, N bytes
</code>```

You can keep old scores in the header by using the strikethrough tags: <s>57</s> will appear as <s>57</s>.

/* Configuration */

var QUESTION_ID = 78510; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 32014; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (! /<a/.test(lang)) lang = '' + lang + '';
    lang = jQuery(lang).text().toLowerCase();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.uniq > b.uniq) return 1;
    if (a.uniq < b.uniq) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
05AB1E, 6 bytes

Code:

0¡€R0ý

Explanation:

0¡      # Split on zeros
  €R    # For each item in the array, reverse it
    0ý  # Join by zeros

Uses CP-1252 encoding. Try it online!.


答:
Molecule (v5.5), 25 bytes (UTF-8)

```<code>"ᘰᜟᘄఄሳÝ̲"C`n
</code>```

No characters are hidden here ;)

An input of 0 is allowed.

Output of 1: 16

Output of 2: 21

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:
Molecule (v5.5), 25 bytes (UTF-8)

"ᘰᜟᘄఄሳÝ̲"C`n

No characters are hidden here ;)

An input of 0 is allowed.

Output of 1: 16

Output of 2: 21


答:
Mathematica, 30 bytes

```<code>Join@@Reverse/@#~SplitBy~Sign&
</code>```

e.g. Join@@Reverse/@#~SplitBy~Sign&[{1,2,3,0,0,5,9,0}] = {3, 2, 1, 0, 0, 9, 5, 0}

Title: Reverse positive runs

Body:
Mathematica, 30 bytes

Join@@Reverse/@#~SplitBy~Sign&

e.g. Join@@Reverse/@#~SplitBy~Sign&[{1,2,3,0,0,5,9,0}] = {3, 2, 1, 0, 0, 9, 5, 0}


问:
Compute the histogram entropy estimation of a string
Write a program or function that estimates the Shannon entropy of a given string.

If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability of that character occuring in the string, then our Shannon entropy estimate for that string is given by:

For the estimation in this challenge we assume that the probability of a character occurring in a string is simply the number of times it occurs divided by the total number of characters.

Your answer must be accurate to at least 3 digits after the period.

Test cases:

```<code>"This is a test.", 45.094
"00001111", 8.000
"cwmfjordbankglyphsvextquiz", 122.211
"             ", 0.0
</code>```

答:
Perl 5, 58 bytes

A subroutine:

```<code>{for$a(@a=split'',pop){$t+=(log@a/grep/\Q$a/,@a)/log 2}$t}
</code>```

A tip of my hat to xnor for the formula.

Body:
Perl 5, 58 bytes

A subroutine:

{for$a(@a=split'',pop){$t+=(log@a/grep/\Q$a/,@a)/log 2}$t}

A tip of my hat to xnor for the formula.


答:
IPOS, 5 bytes

```<code>'0!r%
</code>```

% splits the input string on zeroes, applies the command r (reverse) to every substring and joins the result back on zeroes.

Title: Reverse positive runs

Body:
IPOS, 5 bytes

'0!r%

% splits the input string on zeroes, applies the command r (reverse) to every substring and joins the result back on zeroes.


答:
Ruby, 29 bytes

```<code>->x{x.gsub /[^0]*/,&:reverse}
</code>```

Title: Reverse positive runs

Body:
Ruby, 29 bytes

->x{x.gsub /[^0]*/,&:reverse}


答:
J, <s>20</s> 18 bytes

```<code>0}:@;@(<@|.;.1)@,]
</code>```

Thanks to Zgarb for helping with this! Takes a space-separated list as a right argument.

-2 bytes thanks to Zgarb!

Title: Reverse positive runs

Body:
J, <s>20</s> 18 bytes

0}:@;@(<@|.;.1)@,]

Thanks to Zgarb for helping with this! Takes a space-separated list as a right argument.

-2 bytes thanks to Zgarb!


问:
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.

答:
05AB1E, 3 bytes, Emigna, A022559

Code:

```<code>!ÓO
</code>```

Explanation:

```<code>!    # Compute the factorial of the implicit input.
 Ó   # Compute the exponents of the prime factors.
  O  # Sum that up together.
</code>```

Resulting into A022559. Try it online!

Body:
05AB1E, 3 bytes, Emigna, A022559

Code:

!ÓO

Explanation:

!    # Compute the factorial of the implicit input.
 Ó   # Compute the exponents of the prime factors.
  O  # Sum that up together.

Resulting into A022559. Try it online!


答:
Pyke, 8 bytes

```<code>\0cm_\0J
</code>```

Explanation:

```<code>\0c      -   input().split("0")
   m_    -  map(reversed, ^)
     \0J - "0".join(^)
</code>```

Try it here!

Title: Reverse positive runs

Body:
Pyke, 8 bytes

\0cm_\0J

Explanation:

\0c      -   input().split("0")
   m_    -  map(reversed, ^)
     \0J - "0".join(^)

Try it here!


答:
Jolf, 8 bytes

```<code>RΜGi0λ_0
</code>```

Try it here!

Explanation

```<code>RΜGi0λ_0
  Gi0     split input on zeroes
 Μ   λ_   map over reversal as a lambda
R      0  join by zeroes
</code>```

The code explanation looks sort of like a lambda if you squint.

An equivalent 8-byte answer:

```<code>RΜGi0΅O0
</code>```

Same thing, but it uses ΅O (string mirror lambda) instead.

Title: Reverse positive runs

Body:
Jolf, 8 bytes

RΜGi0λ_0

Try it here!

Explanation

RΜGi0λ_0
  Gi0     split input on zeroes
 Μ   λ_   map over reversal as a lambda
R      0  join by zeroes

The code explanation looks sort of like a lambda if you squint.

An equivalent 8-byte answer:

RΜGi0΅O0

Same thing, but it uses ΅O (string mirror lambda) instead.


答:
PowerShell v2+, 45 bytes

```<code>($args-split0|%{-join$_[$_.length..0]})-join0
</code>```

Abusing the implicit casting like there's no tomorrow. Likely can't get much shorter, as there's no builtin for reverse that's shorter than this indexing trick.

Explanation

An example of how this works -- suppose 123045 was the input $args. After the -split on 0, the pipeline would contain an array (123,45). The first loop with |%{...} has the current element $_ equal to 123, which is then implicitly cast as a string, then reversed with the [] indexing. That makes it ('3','2','1') as a char-array. The loop's -join puts that back into a string "321" and leaves it on the pipeline. The next (last) loop iteration reverses the input to "54". So now our pipeline is "321", "54". That's encapsulated in parens () so it's reformed into an array, and re-joined back together with zeros to produce the resultant output string "321054". That's left on the pipeline and output to the console is implicit.

If there are subsequent zeros in the original input, the array would be populated with null elements, so there are the correct number of zeros on the output. For example, 1230045-split0 turns into (123,,45) and things continue as above.

Title: Reverse positive runs

Body:
PowerShell v2+, 45 bytes

($args-split0|%{-join$_[$_.length..0]})-join0

Abusing the implicit casting like there's no tomorrow. Likely can't get much shorter, as there's no builtin for reverse that's shorter than this indexing trick.

Explanation

An example of how this works -- suppose 123045 was the input $args. After the -split on 0, the pipeline would contain an array (123,45). The first loop with |%{...} has the current element $_ equal to 123, which is then implicitly cast as a string, then reversed with the [] indexing. That makes it ('3','2','1') as a char-array. The loop's -join puts that back into a string "321" and leaves it on the pipeline. The next (last) loop iteration reverses the input to "54". So now our pipeline is "321", "54". That's encapsulated in parens () so it's reformed into an array, and re-joined back together with zeros to produce the resultant output string "321054". That's left on the pipeline and output to the console is implicit.

If there are subsequent zeros in the original input, the array would be populated with null elements, so there are the correct number of zeros on the output. For example, 1230045-split0 turns into (123,,45) and things continue as above.


答:
JavaScript (ES6), <s>50</s> 49 bytes

String version:

s=>s.replace(/[^0]+/g,r=>[...r].reverse().join``)
```

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

<p>Array version (60 bytes):</p>

<pre class="lang-js prettyprint-override"><code>a=>a.map((n,i)=>n?a[z-i+[...a,0].indexOf(0,i)]:(z=i,0),z=-1)
</code>```

Title: Reverse positive runs

Body:
JavaScript (ES6), <s>50</s> 49 bytes

String version:

s=>s.replace(/[^0]+/g,r=>[...r].reverse().join``)

Saved a byte thanks to @Kevin Lau!

Array version (60 bytes):

a=>a.map((n,i)=>n?a[z-i+[...a,0].indexOf(0,i)]:(z=i,0),z=-1)


答:
Retina, 25 24

```<code>O^$#`[^0](?=(.*?0)*)
$#1
</code>```

Try it online

Saved 1 byte thanks to Martin!

Sort the nonzero digits by the number of zeros that follow the digit, in reverse order.

See Martin's solution for a clever use of per-line mode to get a shorter program!

Title: Reverse positive runs

Body:
Retina, 25 24

O^$#`[^0](?=(.*?0)*)
$#1

Try it online

Saved 1 byte thanks to Martin!

Sort the nonzero digits by the number of zeros that follow the digit, in reverse order.

See Martin's solution for a clever use of per-line mode to get a shorter program!


答:
Pyth - 17 bytes

```<code>*_lQsm*FlBc/QdlQ{
</code>```

Try it online here.

Title: Compute the histogram entropy estimation of a string

Body:
Write a program or function that estimates the Shannon entropy of a given string.

If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability of that character occuring in the string, then our Shannon entropy estimate for that string is given by:

For the estimation in this challenge we assume that the probability of a character occurring in a string is simply the number of times it occurs divided by the total number of characters.

Your answer must be accurate to at least 3 digits after the period.

Test cases:

```<code>"This is a test.", 45.094
"00001111", 8.000
"cwmfjordbankglyphsvextquiz", 122.211
"             ", 0.0
</code>```

Body:
Pyth - 17 bytes

*_lQsm*FlBc/QdlQ{

Try it online here.


答:
Retina, 15 bytes

```<code>S`0
O%^$`.

¶
0
</code>```

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

Explanation

```<code>S`0
</code>```

Split the input around 0s that is, put each (possibly empty) run of non-zero digits on its own line.

```<code>O%^$`.

</code>```

This reverses each line, by:

Applying the stage to each line individually with %.

Matching each character individually with ..

Sorting it by the result of the substitution ($) with the empty string (the empty second line). I.e. it doesn't sort at all, since all sort values are identical.

Then reverses the order of the sorted characters.

Finally:

```<code>¶
0
</code>```

Turn the linefeeds back into 0s.

Title: Reverse positive runs

Body:
Input

Your input is a list of single-digit numbers in any reasonable format, including a string of digits.
The input will not be empty.

Output

Your output shall be the input list, but with each maximal run of nonzero digits being reversed.

Example

Consider the input

```<code>95883007414830
<--->  <---->
</code>```

where the nonzero runs have been marked with arrows.
Reversing each of these runs, we obtain the output

```<code>38859003841470
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

This challenge is related, but much more complex, since it includes additional string processing.

Test cases

```<code>4 -> 4
00 -> 00
123 -> 321
0010 -> 0010
12000345 -> 21000543
18161604 -> 61618104
95883007414830 -> 38859003841470
010230456078912 -> 010320654021987
357509902003550 -> 575309902005530
2492882377675046 -> 5767732882942064
03026302053000357099 -> 03036202035000753099
</code>```

Leaderboard

Here's a Stack Snippet to generate a leaderboard and list of winners by language.
To make sure your answer shows up, start it with a header of the form

```<code>## Language, N bytes
</code>```

You can keep old scores in the header by using the strikethrough tags: <s>57</s> will appear as <s>57</s>.

/* Configuration */

var QUESTION_ID = 78510; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 32014; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (! /<a/.test(lang)) lang = '' + lang + '';
    lang = jQuery(lang).text().toLowerCase();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.uniq > b.uniq) return 1;
    if (a.uniq < b.uniq) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Retina, 15 bytes

S`0
O%^$`.

¶
0

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

Explanation

S`0

Split the input around 0s that is, put each (possibly empty) run of non-zero digits on its own line.

O%^$`.

This reverses each line, by:

Applying the stage to each line individually with %.

Matching each character individually with ..

Sorting it by the result of the substitution ($) with the empty string (the empty second line). I.e. it doesn't sort at all, since all sort values are identical.

Then reverses the order of the sorted characters.

Finally:

¶
0

Turn the linefeeds back into 0s.


答:
Julia 0.4, 22 bytes

```<code>s->s$reverse(s)⊆""
</code>```

The string contains the control characters EOT (4) and NAK (21). Input must be in form of a character array.

This approach XORs the characters of the input with the corresponding characters in the reversed input. For valid pairings, this results in the characters EOT or NAK. Testing for inclusion in the string of those characters produces the desired Boolean.

Try it online!

Title: Watson-Crick palindromes

Body:
Problem

Create a function that can determine whether or not an arbitrary DNA string is a Watson-Crick palindrome. The function will take a DNA string and output a true  value if the string is a Watson-Crick palindrome and a false value if it is not. (True and False can also be represented as 1 and 0, respectively.)

The DNA string may either be in all uppercase or all lowercase depending on your preference.

Also, the DNA string will not be empty.

Explanation

A DNA string is a Watson-Crick palindrome when the complement of its reverse is equal to itself.

Given a DNA string, first reverse it, and then complement each character according to the DNA bases (A ↔ T and C ↔ G). If the original string is equal to the complemented-reverse string, it is a Watson-Crick palindrome.

For more, see this question. It is a different challenge where you must find the longest substring of a DNA string where that substring is a Watson-Crick palindrome.

Goal

This is code-golf and the shortest code wins.

Test Cases

The format is <input> = <output>.

```<code>ATCGCGAT = true
AGT = false
GTGACGTCAC = true
GCAGTGA = false
GCGC = true
AACTGCGTTTAC = false
ACTG = false
</code>```

Body:
Julia 0.4, 22 bytes

s->s$reverse(s)⊆""

The string contains the control characters EOT (4) and NAK (21). Input must be in form of a character array.

This approach XORs the characters of the input with the corresponding characters in the reversed input. For valid pairings, this results in the characters EOT or NAK. Testing for inclusion in the string of those characters produces the desired Boolean.

Try it online!


答:
Haskell, 10 bytes

```<code>f n=[1..n]
</code>```

Usage example: f 4-> [1,2,3,4].

Title: Count up folks!

Body:
Introduction

It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.

This is not the same thing. That one is a (closed) not well-explained challenge.

This is not the same thing. That one is about counting up indefinitely.

Challenge

Write a program or function that prints every integer from 1 to n inclusive.

Rules

You can get n any way.

You can assume that n will always be a positive integer.

You can get n in any base, but you should always output in decimal.

Output must be separated by any character (or pattern) not in 0123456789. Non-decimal leading or trailing characters are allowed (for example when using arrays such as [1, 2, 3, 4, 5, 6]).

Standard loopholes are denied.

We want to find the shortest approach in each language, not the shortest language, so I will not accept any answer.

You must update your answer(s) after this edit, answers posted before the last edit must comply with the change rule about standard loopholes (I didn't want to deny them, but I didn't want to make the community roar, so I denied them).

You can use any post-dating language version (or language). You cannot use any language or language version made just for this challenge.

Bonuses

20%

Your program must be able to count at least up to 18446744073709551615 (2^64-1). For example, if a new datatype is the only way to support big integers, you must construct it. If your language does not have any way to support huge integers up to 2^64-1, the upper limit of that particular language must be supported instead.

EDIT: I've changed the limit from 2^64 to 2^64-1 to allow more answers.

EDIT: I made the 2^64-1 rule a bonus, since there has not been much interest in this challenge. If your answer supports 2^64-1, you can now edit it to include the bonus. Also, you can post an answer not supporting it, if it is shorter.

Body:
Haskell, 10 bytes

f n=[1..n]

Usage example: f 4-> [1,2,3,4].


答:
JavaScript (ES6), <s>77</s> <s>76</s> <s>63</s> <s>59</s> 58 Bytes

```<code>n=>{for(s=a=b=0;s!=n;console.log(s=[a]+b))a+=!(b=++b%1e9)}
</code>```

Takes input n as a string, should support up to 9007199254740991999999999

Explained:

```<code>n=>{ //create function, takes n as input
    for( //setup for loop
        s=a=b=0; //init s, a, and b to 0
        s!=n; //before each cycle check if s!=n
        console.log(s=[a]+b) //after each cycle concat a and b into to s and print
    )
        a+=!(b=++b%1e9) //During each cycle set b to (b+1)mod 1e9, if b == 0 and increment a
} //Wrap it all up
</code>```

Title: Count up folks!

Body:
JavaScript (ES6), <s>77</s> <s>76</s> <s>63</s> <s>59</s> 58 Bytes

n=>{for(s=a=b=0;s!=n;console.log(s=[a]+b))a+=!(b=++b%1e9)}

Takes input n as a string, should support up to 9007199254740991999999999

Explained:

n=>{ //create function, takes n as input
    for( //setup for loop
        s=a=b=0; //init s, a, and b to 0
        s!=n; //before each cycle check if s!=n
        console.log(s=[a]+b) //after each cycle concat a and b into to s and print
    )
        a+=!(b=++b%1e9) //During each cycle set b to (b+1)mod 1e9, if b == 0 and increment a
} //Wrap it all up


答:
Jolf, 26 bytes

```<code>_*liuΜGμiEd*γ/l miLeHlimzγ
</code>```

Try it here! (Note that the test suite function is borked.)

Explanation

```<code>_*liuΜGμiEd*γ/l miLeHlimzγ
       μi                   unique members of i
      G  E                  split on ""
     Μ    d                 map over function
               _miLeH       match i with regex escaped member
             /l      li     divide length of (^) by length of i
            γ               γ = (^)
           *           mzγ  (^) * log_2(γ)
 *li                        (^) * length of i
_                           negate
</code>```

Body:
Jolf, 26 bytes

_*liuΜGμiEd*γ/l miLeHlimzγ

Try it here! (Note that the test suite function is borked.)

Explanation

_*liuΜGμiEd*γ/l miLeHlimzγ
       μi                   unique members of i
      G  E                  split on ""
     Μ    d                 map over function
               _miLeH       match i with regex escaped member
             /l      li     divide length of (^) by length of i
            γ               γ = (^)
           *           mzγ  (^) * log_2(γ)
 *li                        (^) * length of i
_                           negate


答:
Jelly, 5 bytes

```<code>ṣ0Uj0
</code>```

Try it online!

Title: Reverse positive runs

Body:
Jelly, 5 bytes

ṣ0Uj0

Try it online!


答:
Clojure/ClojureScript, 44 chars

```<code>#(flatten(map reverse(partition-by pos? %)))
</code>```

Same solution as others, just more verbose thanks to long function names.  Wasn't going to post it because of that, but it beats some other answers so why not?

Works on any sequence type.  In ClojureScript, this also works on strings since strings are processable as lists of characters, which are really just 1-length strings, which coerce to numbers for things like pos?.

Title: Reverse positive runs

Body:
Clojure/ClojureScript, 44 chars

#(flatten(map reverse(partition-by pos? %)))

Same solution as others, just more verbose thanks to long function names.  Wasn't going to post it because of that, but it beats some other answers so why not?

Works on any sequence type.  In ClojureScript, this also works on strings since strings are processable as lists of characters, which are really just 1-length strings, which coerce to numbers for things like pos?.


答:
05AB1E, 8 bytes, Cracked

Output:

```<code>a(3) = 2
a(4) = 7
</code>```

Code:

```<code>___s_r__
</code>```

_ (underscore) indicates an obfuscated character

Try it online

Original Code:

```<code>ÑDgs`rG^
</code>```

Which is the sequence A178910 (Binary XOR of divisors of n.)

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:
05AB1E, 8 bytes, Cracked

Output:

a(3) = 2
a(4) = 7

Code:

___s_r__

_ (underscore) indicates an obfuscated character

Try it online

Original Code:

ÑDgs`rG^

Which is the sequence A178910 (Binary XOR of divisors of n.)


答:
05AB1E, 3 bytes, Cracked

Output:

```<code>a(3) = 2
a(4) = 6
</code>```

Code:

```<code>___
</code>```

_ (underscore) indicates an obfuscated character

Try it online

Original Code:

```<code>D;^
</code>```

Which is the sequence A003188 (Decimal equivalent of Gray code for n)

Body:
05AB1E, 3 bytes, Cracked

Output:

a(3) = 2
a(4) = 6

Code:

___

_ (underscore) indicates an obfuscated character

Try it online

Original Code:

D;^

Which is the sequence A003188 (Decimal equivalent of Gray code for n)


答:
Haskell, 46 bytes

```<code>import Data.Lists
(reverse=<<).split(oneOf"0")
</code>```

Usage example: (reverse=<<).split(oneOf"0") $ "0123004500678090"-> "0321005400876090".

Sadly the split function requires the expensive import. Split the input list at every 0, e.g. split(oneOf"0") "0120030" -> ["","0","12","0","","0","3","0",""], reverse each chunk and concatenate into a single string.

Title: Reverse positive runs

Body:
Haskell, 46 bytes

import Data.Lists
(reverse=<<).split(oneOf"0")

Usage example: (reverse=<<).split(oneOf"0") $ "0123004500678090"-> "0321005400876090".

Sadly the split function requires the expensive import. Split the input list at every 0, e.g. split(oneOf"0") "0120030" -> ["","0","12","0","","0","3","0",""], reverse each chunk and concatenate into a single string.


答:
Python, <s>58</s> 50 bytes

```<code>lambda x:"0".join([n[::-1] for n in x.split("0")])
</code>```

Takes in a string x and splits on the zeros and reverses each element in the split and adds a zero and returns the this minus last zero.

Title: Reverse positive runs

Body:
Python, <s>58</s> 50 bytes

lambda x:"0".join([n[::-1] for n in x.split("0")])

Takes in a string x and splits on the zeros and reverses each element in the split and adds a zero and returns the this minus last zero.


答:
MATL, 17 bytes

```<code>S4#Y'ts/tZl*sGn_*
</code>```

Try it online!

Body:
MATL, 17 bytes

S4#Y'ts/tZl*sGn_*

Try it online!


答:
J - 27 bytes

```<code>9!:37[0 _ _ _
(,~<:@{.)^:<:
</code>```

Usage

```<code>   (,~<:@{.)^:<: 20x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
</code>```

Explanation

This avoids using the built-in i. to generate a range.

First, J will truncate output if it's too long, so we disable that by setting the values to infinity _

```<code>9!:37[0 _ _ _
</code>```

Second, the input has to be given as an extended integer, which can be done by marking it with a suffix of x.

The actual function is only 13 bytes, the change in settings another 13 bytes, and the newline between them is a byte, so 13 + 1 + 13 = 27.

```<code>(,~<:@{.)^:<:
           <:    - Decrement the input
         ^:      - Repeat the given verb that many times, nesting its calls
      {.         - Take the head of the input
   <:            - Decrement it
 ,~              - Prepend it to the input
</code>```

Title: Count up folks!

Body:
J - 27 bytes

9!:37[0 _ _ _
(,~<:@{.)^:<:

Usage

   (,~<:@{.)^:<: 20x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Explanation

This avoids using the built-in i. to generate a range.

First, J will truncate output if it's too long, so we disable that by setting the values to infinity _

9!:37[0 _ _ _

Second, the input has to be given as an extended integer, which can be done by marking it with a suffix of x.

The actual function is only 13 bytes, the change in settings another 13 bytes, and the newline between them is a byte, so 13 + 1 + 13 = 27.

(,~<:@{.)^:<:
           <:    - Decrement the input
         ^:      - Repeat the given verb that many times, nesting its calls
      {.         - Take the head of the input
   <:            - Decrement it
 ,~              - Prepend it to the input


答:
Perl 5, 52 bytes

A subroutine:

```<code>{$_=pop;y/0/ /;map$i.=reverse,split/\b/;$i=~y/ /0/r}
</code>```

Title: Reverse positive runs

Body:
Perl 5, 52 bytes

A subroutine:

{$_=pop;y/0/ /;map$i.=reverse,split/\b/;$i=~y/ /0/r}


答:
Python 3.3+, <s>95</s> <s>91</s> <s>89</s> 85 bytes

Simple solution. Version 3.3 is required to use math.log2.

import math
def f(s):C=s.count;return-sum(C(x)*math.log2(C(x)/len(s))for x in set(s))
```

Try it online

Body:
Write a program or function that estimates the Shannon entropy of a given string.

If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability of that character occuring in the string, then our Shannon entropy estimate for that string is given by:

For the estimation in this challenge we assume that the probability of a character occurring in a string is simply the number of times it occurs divided by the total number of characters.

Your answer must be accurate to at least 3 digits after the period.

Test cases:

```<code>"This is a test.", 45.094
"00001111", 8.000
"cwmfjordbankglyphsvextquiz", 122.211
"             ", 0.0
</code>```

Body:
Python 3.3+, <s>95</s> <s>91</s> <s>89</s> 85 bytes

Simple solution. Version 3.3 is required to use math.log2.

import math
def f(s):C=s.count;return-sum(C(x)*math.log2(C(x)/len(s))for x in set(s))

Try it online


答:
Ruby, <s>18</s> 12 bytes

```<code>->n{p *1..n}
</code>```

-3 bytes from  Not that Charles, and -3 more from daniero

Title: Count up folks!

Body:
Ruby, <s>18</s> 12 bytes

->n{p *1..n}

-3 bytes from  Not that Charles, and -3 more from daniero


答:
Joe - 2 or 6

While you can use the inclusive variant of the range function..

```<code>1R
</code>```

..that's boring! Let's instead take the cumulative sum (\/+) of a table of ones of shape n (1~T).

```<code>\/+1~T
</code>```

Title: Count up folks!

Body:
Joe - 2 or 6

While you can use the inclusive variant of the range function..

1R

..that's boring! Let's instead take the cumulative sum (\/+) of a table of ones of shape n (1~T).

\/+1~T


答:
J - <s>18</s> <s>16</s> 14 bytes

```<code>1#.2^.#%1#.=/~
</code>```

Shortened using the idea in Dennis' method.

Usage

```<code>   f =: 1#.2^.#%1#.=/~
   f 'This is a test.'
45.0936
   f '00001111'
8
   f 'cwmfjordbankglyphsvextquiz'
122.211
   f '             '
0
</code>```

Explanation

```<code>1#.2^.#%1#.=/~  Input: string S
           =/~  Create a table testing for equality
        1#.     Convert each row from a list of base 1 digits to decimal
                This is equivalent to taking the sum and forms a list of tallies
      #         Get the length of S
       %        Divide the length by each tally
   2^.          Log base 2 of each
1#.             "Sum" those values and return
</code>```

Body:
J - <s>18</s> <s>16</s> 14 bytes

1#.2^.#%1#.=/~

Shortened using the idea in Dennis' method.

Usage

   f =: 1#.2^.#%1#.=/~
   f 'This is a test.'
45.0936
   f '00001111'
8
   f 'cwmfjordbankglyphsvextquiz'
122.211
   f '             '
0

Explanation

1#.2^.#%1#.=/~  Input: string S
           =/~  Create a table testing for equality
        1#.     Convert each row from a list of base 1 digits to decimal
                This is equivalent to taking the sum and forms a list of tallies
      #         Get the length of S
       %        Divide the length by each tally
   2^.          Log base 2 of each
1#.             "Sum" those values and return


答:
Haskell, 45 bytes

r%(0:t)=r++0:[]%t
r%(h:t)=(h:r)%t
r%_=r
([]%)
```

<p>Recursively accumulates the reversed chunk so far in <code>r</code>, prepending it when a <code>0</code> is reached. When the remaining string is empty, it also discharges <code>r</code>.</p>

<p>The first two repeat some code, but I didn't find a shorter way to combine them (45 and 47 bytes):</p>

<pre class="lang-haskell prettyprint-override"><code>r%(h:t)|h<1=r++h:[]%t|1>0=(h:r)%t
r%_=r
([]%)

r%l|0:t<-l=r++0:[]%t|h:t<-l=(h:r)%t
r%_=r
([]%)
</code>```

Title: Reverse positive runs

Body:
Input

Your input is a list of single-digit numbers in any reasonable format, including a string of digits.
The input will not be empty.

Output

Your output shall be the input list, but with each maximal run of nonzero digits being reversed.

Example

Consider the input

```<code>95883007414830
<--->  <---->
</code>```

where the nonzero runs have been marked with arrows.
Reversing each of these runs, we obtain the output

```<code>38859003841470
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

This challenge is related, but much more complex, since it includes additional string processing.

Test cases

```<code>4 -> 4
00 -> 00
123 -> 321
0010 -> 0010
12000345 -> 21000543
18161604 -> 61618104
95883007414830 -> 38859003841470
010230456078912 -> 010320654021987
357509902003550 -> 575309902005530
2492882377675046 -> 5767732882942064
03026302053000357099 -> 03036202035000753099
</code>```

Leaderboard

Here's a Stack Snippet to generate a leaderboard and list of winners by language.
To make sure your answer shows up, start it with a header of the form

```<code>## Language, N bytes
</code>```

You can keep old scores in the header by using the strikethrough tags: <s>57</s> will appear as <s>57</s>.

/* Configuration */

var QUESTION_ID = 78510; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 32014; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (! /<a/.test(lang)) lang = '' + lang + '';
    lang = jQuery(lang).text().toLowerCase();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.uniq > b.uniq) return 1;
    if (a.uniq < b.uniq) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Haskell, 45 bytes

r%(0:t)=r++0:[]%t
r%(h:t)=(h:r)%t
r%_=r
([]%)

Recursively accumulates the reversed chunk so far in r, prepending it when a 0 is reached. When the remaining string is empty, it also discharges r.

The first two repeat some code, but I didn't find a shorter way to combine them (45 and 47 bytes):

r%(h:t)|h<1=r++h:[]%t|1>0=(h:r)%t
r%_=r
([]%)

r%l|0:t<-l=r++0:[]%t|h:t<-l=(h:r)%t
r%_=r
([]%)


Title: Reverse positive runs

Body:
Factor, 35 bytes

Beating Pyfon and Clojure, booyah!

[ "0"split [ reverse ] map "0"join ]

This anonymous function is a literal translation of this Python answer.

It's quite simple, just split the string on zeroes, reverse every element of the resulting array, and join all the elements (including zero-length strings) with "0".

Here's an example of it running on all test cases:

IN: scratchpad auto-use {
        "4"
        "00"
        "123"
        "0010"
        "12000345"
        "18161604"
        "95883007414830"
        "010230456078912"
        "357509902003550"
        "2492882377675046"
        "03026302053000357099"
        }
        [
          "0" split [ reverse ] map "0" join
        ]
        map .

{
    "4"
    "00"
    "321"
    "0010"
    "21000543"
    "61618104"
    "38859003841470"
    "010320654021987"
    "575309902005530"
    "5767732882942064"
    "03036202035000753099"
}

"00120" -> { "" "" "12" "" } -> { "" "" "21" "" } -> "00210"