答:
Mumps, 223 Bytes

This is using InterSystems Cache Mumps -- it allows braces around loops which make it handy for nested loops in a single line.

```<code>S X="09121415141209060403040609",R="097679",L="037973",S=-14 F Y=1:1:13 S S=S+2 F C=1:1:7 S F=$E(X,Y*2-1,Y*2),(M,T)="",$P(T," ",21)="" F A=1:1:$E(L,C){S M=M_"m"} S $E(T,$E(R,C))=M S:C=$S(Y<8:Y,1:Y-S) $E(T,F,F+2)="^o^" W T,!
</code>```

Could probably be golfed more, and I may play with that when I have more time. Add another 9 bytes, and it'll be animated [[ due to the addition of the 'H 1 W # ' --> that halts for a second and clears the screen:

```<code>S X="09121415141209060403040609",R="097679",L="037973",S=-14 F Y=1:1:13 S S=S+2 H 1 W # F C=1:1:7 S F=$E(X,Y*2-1,Y*2),(M,T)="",$P(T," ",21)="" F A=1:1:$E(L,C){S M=M_"m"} S $E(T,$E(R,C))=M S:C=$S(Y<8:Y,1:Y-S) $E(T,F,F+2)="^o^" W T,!
</code>```

Here's an ungolfed / explained version (of the animation version), with the correct 'do' statements and dot loops:

```<code> S X="09121415141209060403040609"
 S R="097679",L="037973",S=-14              ; Initialize Variablex
 F Y=1:1:13 D                               ; Set up our main loop of 13 cels
 . S S=S+2                                  ; set up secondary counter, for start char.
 . H 1                                      ; halt for 1 second
 . W #                                      ; clear screen
 . F C=1:1:7 D                              ; set up our per-line loop
 . . S F=$E(X,Y*2-1,Y*2)                    ; set F to 2-digit "start of bat"
 . . S (M,T)=""                             ; set our "builder" lines to empty strings
 . . S $P(T," ",21)=""                      ; then reset our main 'line string' to 21 spaces.
 . . F A=1:1:$E(L,C){S M=M_"m"}             ; make our 'moon' text.
 . . S $E(T,$E(R,C))=M                      ; and insert our 'moon' into the empty line
 . . S:C=$S(Y<8:Y,1:Y-S) $E(T,F,F+2)="^o^"  ; find the start character for our 'bat' and insert.
 . . W T,!                                  ; and write the line and a CR/LF.
</code>```

I tried to do the "compress then Base-64 encode" jazz just to see what would happen, but the encoded string ended up a little longer than the program itself! That, and Cache's system calls for the compression and base64 encoding are quite long... for example, here's the system call to decode base64:
$System.Encryption.Base64Decode(STRING)

That method would 'bloat' the program to over 300 characters, I think...

Body:
Background

Here is a Halloween related challenge.

As you may have seen from my last challenge I quite like what I term as ascii art animations, that is not just draw a pattern but draw a pattern that progresses. This idea came to me after I was asked a couple of years ago to liven up a (rather dull) presentation by making random ascii bats fly across the screen on Halloween. Needless to say I duly obliged (I was being paid for it) but it made me think that there is more to life than random bats. Inspired by this I would like to propose this challenge.

Challenge

Make a bat fly around the moon.

Here is a bat:

```<code>^o^
</code>```

Here is the moon:

```<code>     mmm
   mmmmmmm
  mmmmmmmmm
   mmmmmmm
     mmm
</code>```

You must show every stage of the bats flight (see output).

Input

None

Output

```<code>      ^o^
      mmm
    mmmmmmm
   mmmmmmmmm
    mmmmmmm
      mmm

      mmm^o^
    mmmmmmm
   mmmmmmmmm
    mmmmmmm
      mmm

      mmm
    mmmmmmm^o^
   mmmmmmmmm
    mmmmmmm
      mmm

      mmm
    mmmmmmm
   mmmmmmmmm^o^
    mmmmmmm
      mmm

      mmm
    mmmmmmm
   mmmmmmmmm
    mmmmmmm^o^
      mmm

      mmm
    mmmmmmm
   mmmmmmmmm
    mmmmmmm
      mmm^o^

      mmm
    mmmmmmm
   mmmmmmmmm
    mmmmmmm
      mmm
      ^o^

      mmm
    mmmmmmm
   mmmmmmmmm
    mmmmmmm
   ^o^mmm

      mmm
    mmmmmmm
   mmmmmmmmm
 ^o^mmmmmmm
      mmm

      mmm
    mmmmmmm
^o^mmmmmmmmm
    mmmmmmm
      mmm

      mmm
 ^o^mmmmmmm
   mmmmmmmmm
    mmmmmmm
      mmm

   ^o^mmm
    mmmmmmm
   mmmmmmmmm
    mmmmmmm
      mmm

      ^o^
      mmm
    mmmmmmm
   mmmmmmmmm
    mmmmmmm
      mmm
</code>```

Rules

No reading from external files or websites

You may submit a full program or a function

Extra spaces and/or newlines are fine by me

Standard loopholes banned as usual

The bat must finish back at the top of the moon

Please feel free to clear the screen between frames if you wish however this is not a requirement. Output as shown above is fine

As this is code golf, the winner will be the answer with the lowest byte count although any answer is welcome

Sample

Reference implementation in totally ungolfed Python 2 (620 bytes but just to prove that it can be done. May golf it later).

```<code>b='^o^'
m=['                     ',
'         mmm         ',
'       mmmmmmm       ',
'      mmmmmmmmm      ',
'       mmmmmmm       ',
'         mmm         ',
'                     ']
p=[(9,12),(12,15),(14,17),(15,18),(14,17),(12,15),(9,12),(6,9),(4,7),(3,6),(4,7),(6,9),(9,12)]
d=0
for z in range(7):
    x=map(str,m[z])
    c="".join(x[:p[z][0]]) + b + "".join(x[p[z][1]:])+"\n"
    print "\n".join(m[:z]) + "\n" + c+"\n".join(m[z+1:])
for z in range(6)[::-1]:
    x=map(str,m[z])
    c="".join(x[:p[z+6][0]]) + b + "".join(x[p[z+6][1]:])+"\n"
    print "\n".join(m[:z]) + "\n" + c+"\n".join(m[z+1:])
</code>```

Result

Although @Jonathan obviously wins on byte count with Jelly, I am going to mark the Brainfuck answer from @Oyarsa as the accepted answer purely because I think that anyone who can actually do something like this in such a crazy language deserves +15 rep no matter how many bytes it takes. This is not because I have any problem with golfing languages. See my answer to a question regarding this on meta if you have any doubts. Many thanks and respect to all who contributed in whatever language.

Body:
Mumps, 223 Bytes

This is using InterSystems Cache Mumps -- it allows braces around loops which make it handy for nested loops in a single line.

S X="09121415141209060403040609",R="097679",L="037973",S=-14 F Y=1:1:13 S S=S+2 F C=1:1:7 S F=$E(X,Y*2-1,Y*2),(M,T)="",$P(T," ",21)="" F A=1:1:$E(L,C){S M=M_"m"} S $E(T,$E(R,C))=M S:C=$S(Y<8:Y,1:Y-S) $E(T,F,F+2)="^o^" W T,!

Could probably be golfed more, and I may play with that when I have more time. Add another 9 bytes, and it'll be animated [[ due to the addition of the 'H 1 W # ' --> that halts for a second and clears the screen:

S X="09121415141209060403040609",R="097679",L="037973",S=-14 F Y=1:1:13 S S=S+2 H 1 W # F C=1:1:7 S F=$E(X,Y*2-1,Y*2),(M,T)="",$P(T," ",21)="" F A=1:1:$E(L,C){S M=M_"m"} S $E(T,$E(R,C))=M S:C=$S(Y<8:Y,1:Y-S) $E(T,F,F+2)="^o^" W T,!

Here's an ungolfed / explained version (of the animation version), with the correct 'do' statements and dot loops:

 S X="09121415141209060403040609"
 S R="097679",L="037973",S=-14              ; Initialize Variablex
 F Y=1:1:13 D                               ; Set up our main loop of 13 cels
 . S S=S+2                                  ; set up secondary counter, for start char.
 . H 1                                      ; halt for 1 second
 . W #                                      ; clear screen
 . F C=1:1:7 D                              ; set up our per-line loop
 . . S F=$E(X,Y*2-1,Y*2)                    ; set F to 2-digit "start of bat"
 . . S (M,T)=""                             ; set our "builder" lines to empty strings
 . . S $P(T," ",21)=""                      ; then reset our main 'line string' to 21 spaces.
 . . F A=1:1:$E(L,C){S M=M_"m"}             ; make our 'moon' text.
 . . S $E(T,$E(R,C))=M                      ; and insert our 'moon' into the empty line
 . . S:C=$S(Y<8:Y,1:Y-S) $E(T,F,F+2)="^o^"  ; find the start character for our 'bat' and insert.
 . . W T,!                                  ; and write the line and a CR/LF.

I tried to do the "compress then Base-64 encode" jazz just to see what would happen, but the encoded string ended up a little longer than the program itself! That, and Cache's system calls for the compression and base64 encoding are quite long... for example, here's the system call to decode base64:
$System.Encryption.Base64Decode(STRING)

That method would 'bloat' the program to over 300 characters, I think...


问:
N(e(s(t))) a string
To "function nest" a string, you must:

Treat the first character as a function, and the following characters as the arguments to that function. For example, if the input string was Hello, then the first step would be:

```<code>H(ello)
</code>```

Then, repeat this same step for every substring. So we get:

```<code>H(ello)
H(e(llo))
H(e(l(lo)))
H(e(l(l(o))))
</code>```

Your task is to write a program or function that "function nests" a string. For example, if the input string was Hello world!, then you should output:

```<code>H(e(l(l(o( (w(o(r(l(d(!)))))))))))
</code>```

The input will only ever contain printable ASCII, and you may take the input and the output in any reasonable format. For example, STDIN/STDOUT, function arguments and return value, reading and writing to a file, etc.

For simplicity's sake, you may also assume the input will not contain parentheses, and will not be empty.

```<code>Input:
Nest a string
Output:
N(e(s(t( (a( (s(t(r(i(n(g))))))))))))

Input:
foobar
Output:
f(o(o(b(a(r)))))

Input:
1234567890
Output:
1(2(3(4(5(6(7(8(9(0)))))))))

Input:
code-golf
Output:
c(o(d(e(-(g(o(l(f))))))))

Input:
a
Output:
a

Input:
42
Output:
4(2)
</code>```

As usual, all of our default rules and loopholes apply, and the shortest answer scored in bytes wins!

答:
Bash / sed, 74 bytes

y=$(echo $1|sed "s/./\0(/g");z=$(echo $1|sed "s/./)/g");echo ${y%?}${z%?}
```

Puts a parenthesis after each characters in y.

Puts a parenthesis for each characters in z.

Print x and z truncated of one character.

To test, put this code into a file, and run the shell script with any arguments.

ContentLicense: CC BY-SA 3.0

Title: N(e(s(t))) a string

Body:
Bash / sed, 74 bytes

y=$(echo $1|sed "s/./\0(/g");z=$(echo $1|sed "s/./)/g");echo ${y%?}${z%?}

Puts a parenthesis after each characters in y.

Puts a parenthesis for each characters in z.

Print x and z truncated of one character.

To test, put this code into a file, and run the shell script with any arguments.


问:
Draw an asterisk triangle
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

Input:

A positive integer n >= 1.

Output:

n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

Test case (n=5):

```<code>    *
    **
    ***
    ****
    *****
</code>```

This is code-golf, so shortest answer in bytes wins.

答:
Python 3, 196 Bytes

```<code>import contextlib as b,io;q=io.StringIO()
with b.redirect_stdout(q):import this
n=int(input());c=q.getvalue()[655];print(''.join([''.join([c for z in range(n)][:i+1])+'\n' for i in range(n)]))
</code>```

This is probably counted as a cheat, but it uses the asterisk character in the import this string rather than explicitly writing an asterisk in the program code. It also doesn't use any asterisk multiplication operators. It temporarily rerouts stdout so as not to print the Zen of Python when run.

ContentLicense: CC BY-SA 4.0

Title: Draw an asterisk triangle

Body:
Python 3, 196 Bytes

import contextlib as b,io;q=io.StringIO()
with b.redirect_stdout(q):import this
n=int(input());c=q.getvalue()[655];print(''.join([''.join([c for z in range(n)][:i+1])+'\n' for i in range(n)]))

This is probably counted as a cheat, but it uses the asterisk character in the import this string rather than explicitly writing an asterisk in the program code. It also doesn't use any asterisk multiplication operators. It temporarily rerouts stdout so as not to print the Zen of Python when run.


问:
Compute the Eulerian number
The Eulerian number A(n, m) is the number of permutations of [1, 2, ..., n] in which exactly m elements are greater than the previous element. These are also called rises. For example, if n = 3, there are 3! = 6 permutations of [1, 2, 3]

```<code>1 2 3
 < <  2 elements are greater than the previous

1 3 2
 < >  1 ...

2 1 3
 > <  1 ...

2 3 1
 < >  1 ...

3 1 2
 > <  1 ...

3 2 1
 > >  0 ...
</code>```

So the outputs for A(3, m) for m in [0, 1, 2, 3] will be

```<code>A(3, 0) = 1
A(3, 1) = 4
A(3, 2) = 1
A(3, 3) = 0
</code>```

Also, this is the OEIS sequence A173018.

Rules

This is code-golf so the shortest code wins.

The input n will be a nonnegative integer and m will be a integer in the range [0, 1, ..., n].

Test Cases

```<code>n   m   A(n, m)
0   0   1
1   0   1
1   1   0
2   0   1
2   1   1
2   2   0
3   0   1
3   1   4
3   2   1
3   3   0
4   0   1
4   1   11
4   2   11
4   3   1
4   4   0
5   1   26
7   4   1191
9   5   88234
10  5   1310354
10  7   47840
10  10  0
12  2   478271
15  6   311387598411
17  1   131054
20  16  1026509354985
42  42  0
</code>```

答:
MATL, 10 bytes

```<code>:Y@!d0>s=s
</code>```

Try it online!

Explanation

Consider as an example inputs n=3, m=1. You can place a % symbol to comment out the code from that point onwards and thus see the intermediate results. For example, the link shows the stack after the first step.

```<code>:      % Input n implicitly. Push [1 2 ... n]
       % STACK: [1 2 ... n]
Y@     % Matrix of all permutations, one on each row
       % STACK: [1 2 3; 1 3 2; 2 1 3; 2 3 1; 3 1 2; 3 2 1]
!      % Transpose
       % STACK: [1 1 2 2 3 3; 2 3 1 3 1 2; 3 2 3 1 2 1]
d      % Consecutive differences along each column
       % STACK: [1 2 -1 1 -2 -1; 1 -1 2 -2 1 -1]
0>     % True for positive entries
       % STACK: [1 1 0 1 0 0; 1 0 1 0 1 0]
s      % Sum of each column
       % STACK: [2 1 1 1 1 0]
=      % Input m implicitly. Test each entry for equality with m
       % STACK: [0 1 1 1 1 0]
s      % Sum. Implicitly display
       % STACK: 4
</code>```

Title: Compute the Eulerian number

Body:
MATL, 10 bytes

:Y@!d0>s=s

Try it online!

Explanation

Consider as an example inputs n=3, m=1. You can place a % symbol to comment out the code from that point onwards and thus see the intermediate results. For example, the link shows the stack after the first step.

:      % Input n implicitly. Push [1 2 ... n]
       % STACK: [1 2 ... n]
Y@     % Matrix of all permutations, one on each row
       % STACK: [1 2 3; 1 3 2; 2 1 3; 2 3 1; 3 1 2; 3 2 1]
!      % Transpose
       % STACK: [1 1 2 2 3 3; 2 3 1 3 1 2; 3 2 3 1 2 1]
d      % Consecutive differences along each column
       % STACK: [1 2 -1 1 -2 -1; 1 -1 2 -2 1 -1]
0>     % True for positive entries
       % STACK: [1 1 0 1 0 0; 1 0 1 0 1 0]
s      % Sum of each column
       % STACK: [2 1 1 1 1 0]
=      % Input m implicitly. Test each entry for equality with m
       % STACK: [0 1 1 1 1 0]
s      % Sum. Implicitly display
       % STACK: 4


问:
Take a ride on the Reading, If you pass Go, collect $200

Monopoly Board

For this code-golf challenge we will be building the board game Monopoly.

Rules:

Take no input.

Output a 11x11 board where each ASCII character forming the board is the first letter of each space of the U.S. version of the Monopoly board.

The characters must be separated by spaces.

Go should start in the bottom right.

The exact string to produce is

```<code>F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G
</code>```

Note that from bottom right to bottom left the squares are as follows:

```<code>G --> Go
M --> Mediterranean Avenue
C --> Community Chest
B --> Baltic Avenue
I --> Income Tax
...
J --> Jail
</code>```

Edit
Wow! you guys sure liked this one! :)

答:
Batch, 171 bytes

```<code>@echo F K C I I B A V W M G
@set s=NPTNCCSPPSVCSPELSB
:l
@echo %s:~0,1%                   %s:~1,1%
@set s=%s:~2%
@if not "%s%"=="" goto l
@echo J C V C O R I B C M G
</code>```

Body:
Batch, 171 bytes

@echo F K C I I B A V W M G
@set s=NPTNCCSPPSVCSPELSB
:l
@echo %s:~0,1%                   %s:~1,1%
@set s=%s:~2%
@if not "%s%"=="" goto l
@echo J C V C O R I B C M G


答:
V, <s>75, 62</s>, 59 bytes

```<code>iFKCIIBAVWMG
NPTNCCSPPSVCSPELSB
JCVCORIBCMG-ò9á lli
òÍ./&
</code>```

Try it online!

Since this codel contains non-ASCII characters, here is a hexdump:

```<code>0000000: 6946 4b43 4949 4241 5657 4d47 0a4e 5054  iFKCIIBAVWMG.NPT
0000010: 4e43 4353 5050 5356 4353 5045 4c53 420a  NCCSPPSVCSPELSB.
0000020: 4a43 5643 4f52 4942 434d 471b 2df2 39e1  JCVCORIBCMG.-.9.
0000030: 206c 6c69 0af2 cd2e 2f26 20               lli..../&
</code>```

Explanation. First, we enter the following text:

```<code>FKCIIBAVWMG
NPTNCCSPPSVCSPELSB
JCVCORIBCMG
</code>```

Then, we <esc> back to normal mode. At this point, the cursor is on the third line on the last G. Conveniently, there is a command to put us on the first column of the line right above the cursor. That command is -. Then, once we end up on the second line (on the N), we run the following loop:

```<code>ò9á lli
ò
</code>```

Explanation:

```<code>ò           " Recursively:
 9á         "   Append 9 spaces
    ll      "   Move to the right twice. This will fail on the last time because there isn't a space to move into
      i     "   Enter a newline
ò           " End
</code>```

Now, the buffer looks like this:

```<code>FKCIIBAVWMG
N         P
T         N
C         C
S         P
P         S
V         C
S         P
E         L
S         B
JCVCORIBCMG
</code>```

Now we use a compressed regex to replace each character with that character and a space. That's the Í./& part. This translates to the following vim regex:

```<code>:%s/./& /g
</code>```

Which means:

```<code>:%          " On any line
  s/        " Substitute
    ./      " Any character with
      & /   " That same character and a space
         g  " Allow for multiple substitutions on the same line
</code>```

Title: Take a ride on the Reading, If you pass Go, collect $200

Body:
Monopoly Board

For this code-golf challenge we will be building the board game Monopoly.

Rules:

Take no input.

Output a 11x11 board where each ASCII character forming the board is the first letter of each space of the U.S. version of the Monopoly board.

The characters must be separated by spaces.

Go should start in the bottom right.

The exact string to produce is

```<code>F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G
</code>```

Note that from bottom right to bottom left the squares are as follows:

```<code>G --> Go
M --> Mediterranean Avenue
C --> Community Chest
B --> Baltic Avenue
I --> Income Tax
...
J --> Jail
</code>```

Edit
Wow! you guys sure liked this one! :)

Body:
V, <s>75, 62</s>, 59 bytes

iFKCIIBAVWMG
NPTNCCSPPSVCSPELSB
JCVCORIBCMG-ò9á lli
òÍ./&

Try it online!

Since this codel contains non-ASCII characters, here is a hexdump:

0000000: 6946 4b43 4949 4241 5657 4d47 0a4e 5054  iFKCIIBAVWMG.NPT
0000010: 4e43 4353 5050 5356 4353 5045 4c53 420a  NCCSPPSVCSPELSB.
0000020: 4a43 5643 4f52 4942 434d 471b 2df2 39e1  JCVCORIBCMG.-.9.
0000030: 206c 6c69 0af2 cd2e 2f26 20               lli..../&

Explanation. First, we enter the following text:

FKCIIBAVWMG
NPTNCCSPPSVCSPELSB
JCVCORIBCMG

Then, we <esc> back to normal mode. At this point, the cursor is on the third line on the last G. Conveniently, there is a command to put us on the first column of the line right above the cursor. That command is -. Then, once we end up on the second line (on the N), we run the following loop:

ò9á lli
ò

Explanation:

ò           " Recursively:
 9á         "   Append 9 spaces
    ll      "   Move to the right twice. This will fail on the last time because there isn't a space to move into
      i     "   Enter a newline
ò           " End

Now, the buffer looks like this:

FKCIIBAVWMG
N         P
T         N
C         C
S         P
P         S
V         C
S         P
E         L
S         B
JCVCORIBCMG

Now we use a compressed regex to replace each character with that character and a space. That's the Í./& part. This translates to the following vim regex:

:%s/./& /g

Which means:

:%          " On any line
  s/        " Substitute
    ./      " Any character with
      & /   " That same character and a space
         g  " Allow for multiple substitutions on the same line


答:
MATLAB / Octave, 40 bytes

```<code>@(n,m)sum(sum(diff((perms(1:n))')>0)==m)
</code>```

This is a port of my MATL answer, in the form of an anonymous function. Call it as ans(7,4).

Try it at Ideone.

Title: Compute the Eulerian number

Body:
The Eulerian number A(n, m) is the number of permutations of [1, 2, ..., n] in which exactly m elements are greater than the previous element. These are also called rises. For example, if n = 3, there are 3! = 6 permutations of [1, 2, 3]

```<code>1 2 3
 < <  2 elements are greater than the previous

1 3 2
 < >  1 ...

2 1 3
 > <  1 ...

2 3 1
 < >  1 ...

3 1 2
 > <  1 ...

3 2 1
 > >  0 ...
</code>```

So the outputs for A(3, m) for m in [0, 1, 2, 3] will be

```<code>A(3, 0) = 1
A(3, 1) = 4
A(3, 2) = 1
A(3, 3) = 0
</code>```

Also, this is the OEIS sequence A173018.

Rules

This is code-golf so the shortest code wins.

The input n will be a nonnegative integer and m will be a integer in the range [0, 1, ..., n].

Test Cases

```<code>n   m   A(n, m)
0   0   1
1   0   1
1   1   0
2   0   1
2   1   1
2   2   0
3   0   1
3   1   4
3   2   1
3   3   0
4   0   1
4   1   11
4   2   11
4   3   1
4   4   0
5   1   26
7   4   1191
9   5   88234
10  5   1310354
10  7   47840
10  10  0
12  2   478271
15  6   311387598411
17  1   131054
20  16  1026509354985
42  42  0
</code>```

Body:
MATLAB / Octave, 40 bytes

@(n,m)sum(sum(diff((perms(1:n))')>0)==m)

This is a port of my MATL answer, in the form of an anonymous function. Call it as ans(7,4).

Try it at Ideone.


问:
Sieve of Eratosthenes, Step by Step
Given a number N, draw a left aligned NxN board of numbers, leaving 1 blank (as a space) (I will show diagrams with N=5)

```<code>   2  3  4  5
6  7  8  9  10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
</code>```

Your job is to construct the Sieve of Eratosthenes, step by step. First, start with 2. It's prime, so leave it there, and replace all other numbers divisible by 2 with the proper number of spaces.

```<code>   2  3     5
   7     9
11    13    15
   17    19
21    23    25
</code>```

Next, go to the next unprinted number (3 in this case) and do the same.

```<code>   2  3     5
   7
11    13
   17    19
      23    25
</code>```

And so on, until you reach N.

You need to first print the complete grid, and every time you go to a new number, print the board with the multiples removed. Make sure you print a blank line in between!

Examples

Text in parenthesis () are just for reference, you don't need to print it

N = 2:

```<code>  2 (complete grid)
3 4

  2 (remove multiples of 2)
3
</code>```

N = 3:

```<code>  2 3 (complete grid)
4 5 6
7 8 9

  2 3 (remove multiples of 2)
  5
7   9

  2 3 (remove multiples of 3)
  5
7
</code>```

Remember, this is code-golf, so the code with the smallest number of bytes wins.

答:
Perl, <s>250</s> <s>243</s> <s>231</s> <s>202</s> 157 bytes

```<code>$n=<>;@a=0..($e=$n*$n);$a[1]=$";for$p(1..$n){next if!$a[$p];for(1..$e){$a[$_]=""if!($p~~[(1,$_)]||$_%$p);printf"%-*s",1+length$e,$a[$_];say""if!($_%$n)}say}
</code>```

Test the current golf online! (be sure to run as perl -M5.010 main.pl)

The two literal newlines each save 1 byte in place of \n.

Sample output (input of 7):

```<code>   2  3  4  5  6  7
8  9  10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35
36 37 38 39 40 41 42
43 44 45 46 47 48 49

   2  3     5     7
   9     11    13
15    17    19    21
   23    25    27
29    31    33    35
   37    39    41
43    45    47    49

   2  3     5     7
         11    13
      17    19
   23    25
29    31          35
   37          41
43          47    49

   2  3     5     7
         11    13
      17    19
   23
29    31
   37          41
43          47    49

   2  3     5     7
         11    13
      17    19
   23
29    31
   37          41
43          47
</code>```

I'm positive I didn't golf it very well, so when I get home I'll take another look at it to see just how much I can shave off.

Edit 1: -7 bytes (changing "print sprintf" to the obvious "printf")

Edit 2: Saved 12 bytes by using $d explicitly in the one place it was called instead of creating a separate variable, by combining some declarations, and by eliminating one of my conditions for the next statement inside the first foreach loop by adding a space somewhere else.
An additional 29 bytes were golfed out by reworking two for loops into a single loop, eliminating two variable declarations, and turning unless statements into if-not statements.  Declaring my$e=$n*$n; then replacing the three instances of $n*$n with $e (allowing me to drop a paren for one of them) turned out to yield ±0 bytes, but I kept it in anyway.

Edit 3: Thanks to @Dada, another 40 bytes were golfed out (variable declarations, 'foreach' becoming 'for', implicit $_ in several locations, and cutting down on the printf statement size).  An additional 1 byte was shaved off by turning if!($c%$p||$c==$p||$p==1) into if!($p~~[(1,$_)]||$_%$p).  Unfortunately, the [] around the array is necessary, because the smartmatch operator ~~ is still experimental and doesn't seem to work properly on actual arrays, but does work on references to them instead.  4 more bytes were removed by removing two semicolons and an empty set of quotation marks after the last say.

Title: Sieve of Eratosthenes, Step by Step

Body:
Perl, <s>250</s> <s>243</s> <s>231</s> <s>202</s> 157 bytes

$n=<>;@a=0..($e=$n*$n);$a[1]=$";for$p(1..$n){next if!$a[$p];for(1..$e){$a[$_]=""if!($p~~[(1,$_)]||$_%$p);printf"%-*s",1+length$e,$a[$_];say""if!($_%$n)}say}

Test the current golf online! (be sure to run as perl -M5.010 main.pl)

The two literal newlines each save 1 byte in place of \n.

Sample output (input of 7):

   2  3  4  5  6  7
8  9  10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35
36 37 38 39 40 41 42
43 44 45 46 47 48 49

   2  3     5     7
   9     11    13
15    17    19    21
   23    25    27
29    31    33    35
   37    39    41
43    45    47    49

   2  3     5     7
         11    13
      17    19
   23    25
29    31          35
   37          41
43          47    49

   2  3     5     7
         11    13
      17    19
   23
29    31
   37          41
43          47    49

   2  3     5     7
         11    13
      17    19
   23
29    31
   37          41
43          47

I'm positive I didn't golf it very well, so when I get home I'll take another look at it to see just how much I can shave off.

Edit 1: -7 bytes (changing "print sprintf" to the obvious "printf")

Edit 2: Saved 12 bytes by using $d explicitly in the one place it was called instead of creating a separate variable, by combining some declarations, and by eliminating one of my conditions for the next statement inside the first foreach loop by adding a space somewhere else.
An additional 29 bytes were golfed out by reworking two for loops into a single loop, eliminating two variable declarations, and turning unless statements into if-not statements.  Declaring my$e=$n*$n; then replacing the three instances of $n*$n with $e (allowing me to drop a paren for one of them) turned out to yield ±0 bytes, but I kept it in anyway.

Edit 3: Thanks to @Dada, another 40 bytes were golfed out (variable declarations, 'foreach' becoming 'for', implicit $_ in several locations, and cutting down on the printf statement size).  An additional 1 byte was shaved off by turning if!($c%$p||$c==$p||$p==1) into if!($p~~[(1,$_)]||$_%$p).  Unfortunately, the [] around the array is necessary, because the smartmatch operator ~~ is still experimental and doesn't seem to work properly on actual arrays, but does work on references to them instead.  4 more bytes were removed by removing two semicolons and an empty set of quotation marks after the last say.


答:
PHP, 155 Bytes

```<code>for(;$d++<$n=$argv[1];$x&$a[$d]<1?:print"\n".chunk_split(join($a),$n*$l))for($i=$d*$x=$d>1;$n**2>=$i+=$d;)$a[$i]=str_pad($x|$i<2?"":$i,$l=strlen($n**2)+1);
</code>```

@Crypto -3 Bytes Thank You
@Titus -6 Bytes Thank You

Try it

First time that I use print in a after loop condition

Breakdown

```<code>for(;$d++<$n=$argv[1];
$x&$a[$d]<1?:print"\n".chunk_split(join($a),$n*$l))
#after loop print the grid if $d = 1 or is prime
for($i=$d*$x=$d>1;$n**2>=$i+=$d;)
$a[$i]=str_pad($x|$i<2?"":$i,$l=strlen($n**2)+1);
#fills the array at first run and replace positions with space in the next runs
</code>```

Previous Version 174 Bytes

```<code>for(;$d++<=$n=$argv[1];!($d<2||$a[$d]>0)?:print chunk_split(join($a),$n*$l)."\n")for($i=$d<2?1:2*$d;$i<=$m=$n**2;$i+=$d)$a[$i]=str_pad($d<2?($i<2?"":$i):" ",$l=strlen($m)+1);
</code>```

Title: Sieve of Eratosthenes, Step by Step

Body:
Given a number N, draw a left aligned NxN board of numbers, leaving 1 blank (as a space) (I will show diagrams with N=5)

```<code>   2  3  4  5
6  7  8  9  10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
</code>```

Your job is to construct the Sieve of Eratosthenes, step by step. First, start with 2. It's prime, so leave it there, and replace all other numbers divisible by 2 with the proper number of spaces.

```<code>   2  3     5
   7     9
11    13    15
   17    19
21    23    25
</code>```

Next, go to the next unprinted number (3 in this case) and do the same.

```<code>   2  3     5
   7
11    13
   17    19
      23    25
</code>```

And so on, until you reach N.

You need to first print the complete grid, and every time you go to a new number, print the board with the multiples removed. Make sure you print a blank line in between!

Examples

Text in parenthesis () are just for reference, you don't need to print it

N = 2:

```<code>  2 (complete grid)
3 4

  2 (remove multiples of 2)
3
</code>```

N = 3:

```<code>  2 3 (complete grid)
4 5 6
7 8 9

  2 3 (remove multiples of 2)
  5
7   9

  2 3 (remove multiples of 3)
  5
7
</code>```

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Body:
PHP, 155 Bytes

for(;$d++<$n=$argv[1];$x&$a[$d]<1?:print"\n".chunk_split(join($a),$n*$l))for($i=$d*$x=$d>1;$n**2>=$i+=$d;)$a[$i]=str_pad($x|$i<2?"":$i,$l=strlen($n**2)+1);

@Crypto -3 Bytes Thank You
@Titus -6 Bytes Thank You

Try it

First time that I use print in a after loop condition

Breakdown

for(;$d++<$n=$argv[1];
$x&$a[$d]<1?:print"\n".chunk_split(join($a),$n*$l))
#after loop print the grid if $d = 1 or is prime
for($i=$d*$x=$d>1;$n**2>=$i+=$d;)
$a[$i]=str_pad($x|$i<2?"":$i,$l=strlen($n**2)+1);
#fills the array at first run and replace positions with space in the next runs

Previous Version 174 Bytes

for(;$d++<=$n=$argv[1];!($d<2||$a[$d]>0)?:print chunk_split(join($a),$n*$l)."\n")for($i=$d<2?1:2*$d;$i<=$m=$n**2;$i+=$d)$a[$i]=str_pad($d<2?($i<2?"":$i):" ",$l=strlen($m)+1);


答:
Ruby, 92

Full program, prints to stdout using $> <<

```<code>40.times{|i|$><<"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"[i]+(i%29>9?[$/,' '*19][i%2]:' ')}
</code>```

There are 40 total letters to plot. Letters 10 to 28 alternate between being followed by a newline or ' '*19. The earlier and later letters are separated by single spaces.

Body:
Ruby, 92

Full program, prints to stdout using $> <<

40.times{|i|$><<"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"[i]+(i%29>9?[$/,' '*19][i%2]:' ')}

There are 40 total letters to plot. Letters 10 to 28 alternate between being followed by a newline or ' '*19. The earlier and later letters are separated by single spaces.


答:
C, <s>171</s> 156 Bytes

```<code>i,j;char*b="FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG ";f(){for(i=1;*b;j=i%21==0?putchar(*b++),puts(""),i++,*b++:i<21||i>210?i&1?*b++:32:32,putchar(j),i++);}
</code>```

Outputs a trailing newline character as well...  Could probably be golfed down a bit more.

Body:
C, <s>171</s> 156 Bytes

i,j;char*b="FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG ";f(){for(i=1;*b;j=i%21==0?putchar(*b++),puts(""),i++,*b++:i<21||i>210?i&1?*b++:32:32,putchar(j),i++);}

Outputs a trailing newline character as well...  Could probably be golfed down a bit more.


问:
Spaced-out numbers
Given a list of N non-negative integers, output those numbers with each left-padded by spaces to a length of N. (Alternatively, return a character/string list.) You may assume that N is greater than or equal to the number of digits of the largest number in the list. Trailing spaces are allowed in the output.

You may also take a string containing these numbers, but N is not the length of the string, but rather the number of elements in the list; also, you may take a list of strings e.g. ["1", "2", "3"].

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

Test cases

```<code>input => 'output'
0 => '0'
1 => '1'
2 3 => ' 2 3'
2 10 => ' 210'
4 5 6 => '  4  5  6'
17 19 20 => ' 17 19 20'
7 8 9 10 => '   7   8   9  10'
100 200 300 0 => ' 100 200 300   0'
1000 400 30 7 => '1000 400  30   7'
1 33 333 7777 => '   1  33 3337777'
0 0 0 0 0 0 => '     0     0     0     0     0     0'
</code>```

答:
J, 4 bytes

```<code>":~#
</code>```

Try it online!

Unary function taking the list of numbers on the right as an array and returning the padded string.

Here it is in use at the REPL. Note that input lines are indented three spaces.

```<code>   f=: ":~#
   f 2 3
 2 3
   f 2 10
 210
   f 1111 222 33 4
1111 222  33   4
</code>```

Title: Spaced-out numbers

Body:
J, 4 bytes

":~#

Try it online!

Unary function taking the list of numbers on the right as an array and returning the padded string.

Here it is in use at the REPL. Note that input lines are indented three spaces.

   f=: ":~#
   f 2 3
 2 3
   f 2 10
 210
   f 1111 222 33 4
1111 222  33   4


答:
GNU sed, <s>37</s> <s>35</s> 31 bytes (30 +1 for -r argument)

Pure linux sed solution

```<code>:;s/([^(])([^()].*)$/\1(\2)/;t
</code>```

Naming the subsitution :; then calling it recursively with t

Making 2 regex groups:

First group is first char of two consecutive characters which are not parenthesis

Second group is the second consecutive character and the rest of the string until end of line

Add parenthesis around the second group \1 ( \2 )

Edit: Thanks to @manatwork for helping removing 4 characters!

Online tester

Title: N(e(s(t))) a string

Body:
To "function nest" a string, you must:

Treat the first character as a function, and the following characters as the arguments to that function. For example, if the input string was Hello, then the first step would be:

```<code>H(ello)
</code>```

Then, repeat this same step for every substring. So we get:

```<code>H(ello)
H(e(llo))
H(e(l(lo)))
H(e(l(l(o))))
</code>```

Your task is to write a program or function that "function nests" a string. For example, if the input string was Hello world!, then you should output:

```<code>H(e(l(l(o( (w(o(r(l(d(!)))))))))))
</code>```

The input will only ever contain printable ASCII, and you may take the input and the output in any reasonable format. For example, STDIN/STDOUT, function arguments and return value, reading and writing to a file, etc.

For simplicity's sake, you may also assume the input will not contain parentheses, and will not be empty.

```<code>Input:
Nest a string
Output:
N(e(s(t( (a( (s(t(r(i(n(g))))))))))))

Input:
foobar
Output:
f(o(o(b(a(r)))))

Input:
1234567890
Output:
1(2(3(4(5(6(7(8(9(0)))))))))

Input:
code-golf
Output:
c(o(d(e(-(g(o(l(f))))))))

Input:
a
Output:
a

Input:
42
Output:
4(2)
</code>```

As usual, all of our default rules and loopholes apply, and the shortest answer scored in bytes wins!

Body:
GNU sed, <s>37</s> <s>35</s> 31 bytes (30 +1 for -r argument)

Pure linux sed solution

:;s/([^(])([^()].*)$/\1(\2)/;t

Naming the subsitution :; then calling it recursively with t

Making 2 regex groups:

First group is first char of two consecutive characters which are not parenthesis

Second group is the second consecutive character and the rest of the string until end of line

Add parenthesis around the second group \1 ( \2 )

Edit: Thanks to @manatwork for helping removing 4 characters!

Online tester


答:
Groovy, <s>201</s> <s>195</s> 191 Bytes

```<code>{n->a=(1..n*n).toArray();y={a.collect{(it?"$it":"").padRight((""+n*n).size())}.collate(n).each{println it.join(" ")}};a[0]=0;y(a);(2..n).each{b->(b+1..n*n).each{if(it%b==0){a[it-1]=0}};y(a)}}
</code>```

This is an absolute cluster... The left-align murdered my byte count. But hey, it works. Here's the output for 4:

```<code>   2  3  4
5  6  7  8
9  10 11 12
13 14 15 16

   2  3
5     7
9     11
13    15

   2  3
5     7
      11
13

   2  3
5     7
      11
13
</code>```

Ungolfed:

```<code>{
    n->
    a = (1..n*n).toArray();                           // Create initial array.
    y = {                                             // Createa  printing utility closure.
        a.collect {                                   // Create an array collection of...
            (it ? "$it":"").padRight((""+n*n).size()) // If 0, store "", else store number & right pad it.
        }.collate(n).each{                            // Collate by n (break into nxn grid).
            println it.join(" ")                      // print each separated by spaces.
        }
    };
    a[0]=0;                                           // Remove first element.
    y(a);                                             // Print initial status.
    (2..n).each{                                      // From 2 to n...
        b->
        (b+1..n*n).each{                              // From current number + 1 to end of grid...
            if(it%b==0){                              // If current grid position is divisible...
                a[it-1]=0                             // Replace with 0.
            }
        }
        y(a)                                          // Print it.
    }
}
</code>```

Title: Sieve of Eratosthenes, Step by Step

Body:
Groovy, <s>201</s> <s>195</s> 191 Bytes

{n->a=(1..n*n).toArray();y={a.collect{(it?"$it":"").padRight((""+n*n).size())}.collate(n).each{println it.join(" ")}};a[0]=0;y(a);(2..n).each{b->(b+1..n*n).each{if(it%b==0){a[it-1]=0}};y(a)}}

This is an absolute cluster... The left-align murdered my byte count. But hey, it works. Here's the output for 4:

   2  3  4
5  6  7  8
9  10 11 12
13 14 15 16

   2  3
5     7
9     11
13    15

   2  3
5     7
      11
13

   2  3
5     7
      11
13

Ungolfed:

{
    n->
    a = (1..n*n).toArray();                           // Create initial array.
    y = {                                             // Createa  printing utility closure.
        a.collect {                                   // Create an array collection of...
            (it ? "$it":"").padRight((""+n*n).size()) // If 0, store "", else store number & right pad it.
        }.collate(n).each{                            // Collate by n (break into nxn grid).
            println it.join(" ")                      // print each separated by spaces.
        }
    };
    a[0]=0;                                           // Remove first element.
    y(a);                                             // Print initial status.
    (2..n).each{                                      // From 2 to n...
        b->
        (b+1..n*n).each{                              // From current number + 1 to end of grid...
            if(it%b==0){                              // If current grid position is divisible...
                a[it-1]=0                             // Replace with 0.
            }
        }
        y(a)                                          // Print it.
    }
}


Title: Sieve of Eratosthenes, Step by Step

Body:
J, 125 bytes

p=:3 :'}."1,./('' '',.>)"1|:(-%:#y)]\((a:"_)`(<@":)@.*)"+y'
3 :'p@>~.|.(]*](*@|~+.=)({[:I.*){])&.>/\.(<"+i.-y),<]`>:@.*i.*:y'

This is explicit, not tacit J, but there should be a way to golf it tacitly.

Usage

   p =: 3 :'}."1,./('' '',.>)"1|:(-%:#y)]\((a:"_)`(<@":)@.*)"+y'
   f =: 3 :'p@>~.|.(]*](*@|~+.=)({[:I.*){])&.>/\.(<"+i.-y),<]`>:@.*i.*:y'
   f 2
  2
3 4

  2
3
   f 3
  2 3
4 5 6
7 8 9

  2 3
  5
7   9

  2 3
  5
7
   f 4
   2  3  4
5  6  7  8
9  10 11 12
13 14 15 16

   2  3
5     7
9     11
13    15

   2  3
5     7
      11
13
   f 5
   2  3  4  5
6  7  8  9  10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

   2  3     5
   7     9
11    13    15
   17    19
21    23    25

   2  3     5
   7
11    13
   17    19
      23    25

   2  3     5
   7
11    13
   17    19
      23


答:
Python 2, <s>199 202</s> 201 bytes

+3 bytes (I wasn't stopping early)

-1 byte thanks to @Oliver (missed a space)

def f(n,p={()}):
 m=n*n;g=['']+[[i,''][any(i>n and i%n<1for n in p)]for i in range(2,m+1)];x=min(set(g)-p);i=0
 while i<m+n:print' '.join('%%%ds'%-len(`m`)%v for v in g[i:i+n]);i+=n
 if x<=n:f(n,p|{x})
```

repl.it

Title: Sieve of Eratosthenes, Step by Step

Body:
Python 2, <s>199 202</s> 201 bytes

+3 bytes (I wasn't stopping early)

-1 byte thanks to @Oliver (missed a space)

def f(n,p={()}):
 m=n*n;g=['']+[[i,''][any(i>n and i%n<1for n in p)]for i in range(2,m+1)];x=min(set(g)-p);i=0
 while i<m+n:print' '.join('%%%ds'%-len(`m`)%v for v in g[i:i+n]);i+=n
 if x<=n:f(n,p|{x})

repl.it


答:
GameMaker Language, 148 bytes

I know it's pretty basic, but I don't think this can be beat in GML...

```<code>a="                   "return"F K C I I B A V W M G #N"+a+"P#T"+a+"N#C"+a+"C#S"+a+"P#P"+a+"S#V"+a+"C#S"+a+"P#E"+a+"L#S"+a+"B#J C V C O R I B C M G "
</code>```

Body:
GameMaker Language, 148 bytes

I know it's pretty basic, but I don't think this can be beat in GML...

a="                   "return"F K C I I B A V W M G #N"+a+"P#T"+a+"N#C"+a+"C#S"+a+"P#P"+a+"S#V"+a+"C#S"+a+"P#E"+a+"L#S"+a+"B#J C V C O R I B C M G "


Body:
J, <s>77</s> 73 bytes

' FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG'{~_22}.\,0,.(*+/\),0=*/~5-|i:5

Note that 43 bytes, over half the total, are used just for the string ' FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG'.

Explanation

First, make a list

   |i:5
5 4 3 2 1 0 1 2 3 4 5
   5-|i:5
0 1 2 3 4 5 4 3 2 1 0

Then make its times table

   */~5-|i:5
0 0  0  0  0  0  0  0  0 0 0
0 1  2  3  4  5  4  3  2 1 0
0 2  4  6  8 10  8  6  4 2 0
0 3  6  9 12 15 12  9  6 3 0
0 4  8 12 16 20 16 12  8 4 0
0 5 10 15 20 25 20 15 10 5 0
0 4  8 12 16 20 16 12  8 4 0
0 3  6  9 12 15 12  9  6 3 0
0 2  4  6  8 10  8  6  4 2 0
0 1  2  3  4  5  4  3  2 1 0
0 0  0  0  0  0  0  0  0 0 0

Then test for equality with zero

   0=*/~5-|i:5
1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1

Flatten it, find the cumulative sums, and multiply elementwise

   ,0=*/~5-|i:5
1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
   +/\,0=*/~5-|i:5
1 2 3 4 5 6 7 8 9 10 11 12 12 12 12 12 12 12 12 12 12 13 14 14 14 14 14 14 14 14 14 14 15 16 16 16 16 16 16 16 16 16 16 17 18 18 18 18 18 18 18 18 18 18 19 20 20 20 20 20 20 20 20 20 20 21 22 22 22 22 22 22 22 22 22 22 23 24 24 24 24 24 24 24 24 24 24 25 26 26 26 26 26 26 26 26 26 26 27 28 28 28 28 28 28 28 28 28 28 29 30 31 32 33 34 35 36 37 38 39 40
   (*+/\),0=*/~5-|i:5
1 2 3 4 5 6 7 8 9 10 11 12 0 0 0 0 0 0 0 0 0 13 14 0 0 0 0 0 0 0 0 0 15 16 0 0 0 0 0 0 0 0 0 17 18 0 0 0 0 0 0 0 0 0 19 20 0 0 0 0 0 0 0 0 0 21 22 0 0 0 0 0 0 0 0 0 23 24 0 0 0 0 0 0 0 0 0 25 26 0 0 0 0 0 0 0 0 0 27 28 0 0 0 0 0 0 0 0 0 29 30 31 32 33 34 35 36 37 38 39 40

Then join with zeros, split it into sublists of length 22, drop the head of each sublist, and use the values as indices in the string ' FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG'

   ' FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG'{~_22}.\,0,.(*+/\),0=*/~5-|i:5
F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G


答:
Pyth, 10 characters

```<code>+j\(Q*\)tl
</code>```

Try it online!

Joins the input on (, and appends length - 1 closing parens afterwards.

Title: N(e(s(t))) a string

Body:
Pyth, 10 characters

+j\(Q*\)tl

Try it online!

Joins the input on (, and appends length - 1 closing parens afterwards.


答:
Python 2, 89 bytes

l='%s '*11+'\n'
print(l+'%s%20s\n'*9+l)%tuple("FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG")
```

<p>Creates the template </p>

```? ? ? ? ? ? ? ? ? ? ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
? ? ? ? ? ? ? ? ? ? ?
```

to substitute in letters via string formatting. The template uses two types of lines:

The outer line l of 11 copies of letter-plus-space, then a newline. It's also used for the first and last line. It has a trailing space.

The inner line of a character, then a character preceded by 19 characters of padding spaces, then a newline. It's copied 9 times for the center lines.

Python 3.5 can save a byte with tuple unpacking (*'...',).

Body:
Monopoly Board

For this code-golf challenge we will be building the board game Monopoly.

Rules:

Take no input.

Output a 11x11 board where each ASCII character forming the board is the first letter of each space of the U.S. version of the Monopoly board.

The characters must be separated by spaces.

Go should start in the bottom right.

The exact string to produce is

```<code>F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G
</code>```

Note that from bottom right to bottom left the squares are as follows:

```<code>G --> Go
M --> Mediterranean Avenue
C --> Community Chest
B --> Baltic Avenue
I --> Income Tax
...
J --> Jail
</code>```

Edit
Wow! you guys sure liked this one! :)

Body:
Python 2, 89 bytes

l='%s '*11+'\n'
print(l+'%s%20s\n'*9+l)%tuple("FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG")

Creates the template

? ? ? ? ? ? ? ? ? ? ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
?                   ?
? ? ? ? ? ? ? ? ? ? ?

to substitute in letters via string formatting. The template uses two types of lines:

The outer line l of 11 copies of letter-plus-space, then a newline. It's also used for the first and last line. It has a trailing space.

The inner line of a character, then a character preceded by 19 characters of padding spaces, then a newline. It's copied 9 times for the center lines.

Python 3.5 can save a byte with tuple unpacking (*'...',).


问:
Add two numbers
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Wise, 12 bytes (non-competing)

Mistah Figgins has me beat here

```<code>[:??:?^?&<]|
</code>```

I just made this language so I thought I would try the basics.

Try it online

Explanation

```<code>[   ...   ]      #Loop until our carry is zero
 :               #Duplicate the top
  ??             #Roll the top two to the bottom
    :            #Duplicate the top
     ?           #Roll to the bottom
</code>```

At this point we have n m m n on the stack

```<code>      ^          #Xor n and m
       ?         #Roll that to the bottom
        &        #And n and m to create the carry over
         <       #Bitshift to the left
           |     #Remove the extra zero with an or
</code>```

Title: Add two numbers

Body:
Wise, 12 bytes (non-competing)

Mistah Figgins has me beat here

[:??:?^?&<]|

I just made this language so I thought I would try the basics.

Try it online

Explanation

[   ...   ]      #Loop until our carry is zero
 :               #Duplicate the top
  ??             #Roll the top two to the bottom
    :            #Duplicate the top
     ?           #Roll to the bottom

At this point we have n m m n on the stack

      ^          #Xor n and m
       ?         #Roll that to the bottom
        &        #And n and m to create the carry over
         <       #Bitshift to the left
           |     #Remove the extra zero with an or


答:
Jolf, 72 bytes

```<code>Ζ0ρ,ahtht"111"'.d?=H♣Q♣+."FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"wΖhζ♣
</code>```

Replace all ♣ with \x05, or try it here!

```<code>Ζ0ρ,ahtht"111"'.d?=H♣Q♣+."..."wΖhζ♣
Ζ0                                   ζ = 0
   ,ahtht"111"                       a box of width&height 11, with borders "1"
  ρ           '.d                    replace each char in that string with...
                 ?=H♣                 is it a space?
                     Q♣                if so, return two spaces.
                                      otherwise
                        ."..."         get the Nth member of this string
                              wΖhζ      where N = (++ζ) - 1
                       +          ♣      and add a space to the end
</code>```

This gives the desired string.

Body:
Jolf, 72 bytes

Ζ0ρ,ahtht"111"'.d?=H♣Q♣+."FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"wΖhζ♣

Replace all ♣ with \x05, or try it here!

Ζ0ρ,ahtht"111"'.d?=H♣Q♣+."..."wΖhζ♣
Ζ0                                   ζ = 0
   ,ahtht"111"                       a box of width&height 11, with borders "1"
  ρ           '.d                    replace each char in that string with...
                 ?=H♣                 is it a space?
                     Q♣                if so, return two spaces.
                                      otherwise
                        ."..."         get the Nth member of this string
                              wΖhζ      where N = (++ζ) - 1
                       +          ♣      and add a space to the end

This gives the desired string.


答:
Actually, 74 bytes

```<code>"%s"9⌐α' j;"%s%20s"9α'
j(k'
j"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"#@%
</code>```

Try it online!

This program works off of the same basic principle as xnor's Python 2 answer.

Explanation (newlines replaced with \n for clarity):

```<code>"%s"9⌐α' j                                       ' '.join(["%s"]*11)
;                                                duplicate
"%s%20s"9α'\nj                                   '\n'.join(["%s%20s"]*9)
(                                                move bottom of stack to top
k'\nj                                            '\n'.join(stack)
"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"#@%                    %tuple(longstring)
</code>```

Body:
Actually, 74 bytes

"%s"9⌐α' j;"%s%20s"9α'
j(k'
j"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"#@%

Try it online!

This program works off of the same basic principle as xnor's Python 2 answer.

Explanation (newlines replaced with \n for clarity):

"%s"9⌐α' j                                       ' '.join(["%s"]*11)
;                                                duplicate
"%s%20s"9α'\nj                                   '\n'.join(["%s%20s"]*9)
(                                                move bottom of stack to top
k'\nj                                            '\n'.join(stack)
"FKCIIBAVWMGNPTNCCSPPSVCSPELSBJCVCORIBCMG"#@%                    %tuple(longstring)


答:
Charcoal, 66 bytes

```<code>Ｂ²¹¦¹¹F K C I I B A V W M GPNCPSCPLBG M C B I R O C V C JSESVPSCTN
</code>```

Try it online!

Box(21, 11, 'F K C I I B A V W M GPNCPSCPLBG M C B I R O C V C JSESVPSCTN').

Noncompeting, 36 bytes

Body:
Charcoal, 66 bytes

Ｂ²¹¦¹¹F K C I I B A V W M GPNCPSCPLBG M C B I R O C V C JSESVPSCTN

<a href="http://charcoal.tryitonline.net/#code=77yiwrLCucKmwrnCuUYgSyBDIEkgSSBCIEEgViBXIE0gR1BOQ1BTQ1BMQkcgTSBDIEIgSSBSIE8gQyBWIEMgSlNFU1ZQU0NUTg&input=&args=LW8+RiBLIEMgSSBJIEIgQSBWIFcgTSBHCk4gICAgICAgICAgICAgICAgICAgUApUICAgICAgICAgICAgICAgICAgIE4KQyAgICAgICAgICAgICAgICAgICBDClMgICAgICAgICAgICAgICAgICAgUApQICAgICAgICAgICAgICAgICAgIFMKViAgICAgICAgICAgICAgICAgICBDClMgICAgICAgICAgICAgICAgICAgUApFICAgICAgICAgICAgICAgICAgIEwKUyAgICAgICAgICAgICAgICAgICBCCkogQyBWIEMgTyBSIEkgQiBDIE0gRw" rel="nofollow">Try it online!

Box(21, 11, 'F K C I I B A V W M GPNCPSCPLBG M C B I R O C V C JSESVPSCTN').

<a href="http://charcoal.tryitonline.net/#code=Qm94KDExLCAxMSwgJ0ZLQ0lJQkFWV01HUE5DUFNDUExCR01DQklST0NWQ0pTRVNWUFNDVE4nKTsgRXh0ZW5kKDEpOw&input=&args=LXNs+LXY+LW8+RiBLIEMgSSBJIEIgQSBWIFcgTSBHCk4gICAgICAgICAgICAgICAgICAgUApUICAgICAgICAgICAgICAgICAgIE4KQyAgICAgICAgICAgICAgICAgICBDClMgICAgICAgICAgICAgICAgICAgUApQICAgICAgICAgICAgICAgICAgIFMKViAgICAgICAgICAgICAgICAgICBDClMgICAgICAgICAgICAgICAgICAgUApFICAgICAgICAgICAgICAgICAgIEwKUyAgICAgICAgICAgICAgICAgICBCCkogQyBWIEMgTyBSIEkgQiBDIE0gRw" rel="nofollow">Noncompeting, 36 bytes


答:
Jelly, 34 bytes

```<code>Ṿ€“1“ ”ys³G
>®i©1ḍoṛ®¦
²R;1©ÇÐĿÑ€Y
</code>```

Try it online!

How it works

```<code>²R;1©ÇÐĿÑ€Y  Main link. Argument: n (integer)

²            Yield n².
 R           Range; yield [1, ..., n²].
   1©        Yield 1 and copy it to the register.
  ;          Append 1 to the range.
             This is the initial state. Let's call it S.
     ÇÐĿ     Call the second helper link until the results are no longer unique.
             This returns all unique results as an array.
        Ṅ€   Call the first helper link on each result.
          Y  Join, separating by linefeeds.

>®i©1ḍoṛ®¦   Second helper link. Argument: S (state)

>®           Compare all integers in S with the value in the register.
  i 1        Find the first index of 1 (i.e., the first number that is greater
             than the register.
   ©         Copy the index to the register. Let's call the index p.
     ḍ       Test all numbers in S for divisibility by p. This yield 1 for
             multiples of p, 0 otherwise.
      o      Logical OR; replace 0's with the corresponding values of S.
       ṛ®¦   Replace the 0 at index p with the corresponding element of S (p).
             For the purposes of the explanation, S is now the updated state.

Ṿ€“1“ ”ys³G  First helper link. Argument: A (array)

Ṿ€           Uneval each; convert all integers in A into strings.
  “1“ ”y     Replace each string "1" with the string " ".
        s³   Split into chunks of length n (command-line argument).
          G  Grid; separate row items by spaces (left-padding since the row items
             are strings), the rows themselves by linefeeds.
</code>```

Title: Sieve of Eratosthenes, Step by Step

Body:
Given a number N, draw a left aligned NxN board of numbers, leaving 1 blank (as a space) (I will show diagrams with N=5)

```<code>   2  3  4  5
6  7  8  9  10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
</code>```

Your job is to construct the Sieve of Eratosthenes, step by step. First, start with 2. It's prime, so leave it there, and replace all other numbers divisible by 2 with the proper number of spaces.

```<code>   2  3     5
   7     9
11    13    15
   17    19
21    23    25
</code>```

Next, go to the next unprinted number (3 in this case) and do the same.

```<code>   2  3     5
   7
11    13
   17    19
      23    25
</code>```

And so on, until you reach N.

You need to first print the complete grid, and every time you go to a new number, print the board with the multiples removed. Make sure you print a blank line in between!

Examples

Text in parenthesis () are just for reference, you don't need to print it

N = 2:

```<code>  2 (complete grid)
3 4

  2 (remove multiples of 2)
3
</code>```

N = 3:

```<code>  2 3 (complete grid)
4 5 6
7 8 9

  2 3 (remove multiples of 2)
  5
7   9

  2 3 (remove multiples of 3)
  5
7
</code>```

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Body:
Jelly, 34 bytes

Ṿ€“1“ ”ys³G
>®i©1ḍoṛ®¦
²R;1©ÇÐĿÑ€Y

Try it online!

How it works

²R;1©ÇÐĿÑ€Y  Main link. Argument: n (integer)

²            Yield n².
 R           Range; yield [1, ..., n²].
   1©        Yield 1 and copy it to the register.
  ;          Append 1 to the range.
             This is the initial state. Let's call it S.
     ÇÐĿ     Call the second helper link until the results are no longer unique.
             This returns all unique results as an array.
        Ṅ€   Call the first helper link on each result.
          Y  Join, separating by linefeeds.

>®i©1ḍoṛ®¦   Second helper link. Argument: S (state)

>®           Compare all integers in S with the value in the register.
  i 1        Find the first index of 1 (i.e., the first number that is greater
             than the register.
   ©         Copy the index to the register. Let's call the index p.
     ḍ       Test all numbers in S for divisibility by p. This yield 1 for
             multiples of p, 0 otherwise.
      o      Logical OR; replace 0's with the corresponding values of S.
       ṛ®¦   Replace the 0 at index p with the corresponding element of S (p).
             For the purposes of the explanation, S is now the updated state.

Ṿ€“1“ ”ys³G  First helper link. Argument: A (array)

Ṿ€           Uneval each; convert all integers in A into strings.
  “1“ ”y     Replace each string "1" with the string " ".
        s³   Split into chunks of length n (command-line argument).
          G  Grid; separate row items by spaces (left-padding since the row items
             are strings), the rows themselves by linefeeds.


答:
Turtlèd, 72 bytes

```<code>"K C I I B A V W M G">"GPNCPSCPLBG">"G M C B I R O C V C J">"JSESVPSCTNF
</code>```

Try it online

> rotates turtle, "foo" writes strings on grid. last " was elidable

Body:
Turtlèd, 72 bytes

"K C I I B A V W M G">"GPNCPSCPLBG">"G M C B I R O C V C J">"JSESVPSCTNF

Try it online

> rotates turtle, "foo" writes strings on grid. last " was elidable


问:
Tips for golfing in Jelly
Jelly is a tacit, golf-oriented programming language by our very own Dennis. It’s popping up in answers here more and more often, beating other golf-y languages like Pyth and CJam, both by using its own code page and its powerful chain system to succinctly express programs.

Let’s collect some useful tips for golfing in Jelly. (As always, one tip per answer, please!)

答:
Abuse string bugs

Credits go to Adnan for taking advantage of this first in Write a program to elasticize strings.

Jelly is supposed to get character arithmetic one day, but until that happens, we can take advantage of the fact that Python overloads most arithmetic operators and that Jelly does no type checking.

For example

```<code>“abcd”Ḥ
</code>```

isn't supposed to do anything useful right now, but since Ḥ (unhalve) is implemented as

lambda z: z * 2
```

<p>and arithmetic atoms vectorize at depth <strong>0</strong> (i.e., they operate on numbers or characters), the above Jelly code yields</p>

```['aa', 'bb', 'cc', 'dd']
```

Careful that this produces actual Python strings (a type Jelly isn't supposed to have), so this won't be usable in all situations.

Likewise, +/ can be useful to concatenate strings, with the same caveats.

Title: Tips for golfing in Jelly

Body:
Abuse string bugs

Credits go to Adnan for taking advantage of this first in Write a program to elasticize strings.

Jelly is supposed to get character arithmetic one day, but until that happens, we can take advantage of the fact that Python overloads most arithmetic operators and that Jelly does no type checking.

For example

“abcd”Ḥ

isn't supposed to do anything useful right now, but since Ḥ (unhalve) is implemented as

lambda z: z * 2

and arithmetic atoms vectorize at depth 0 (i.e., they operate on numbers or characters), the above Jelly code yields

['aa', 'bb', 'cc', 'dd']

Careful that this produces actual Python strings (a type Jelly isn't supposed to have), so this won't be usable in all situations.

Likewise, +/ can be useful to concatenate strings, with the same caveats.


答:
Mathematica, 133 bytes

```<code>Grid[#,Alignment->Left]~Print~"
"&/@FoldList[#/.(##|1&@@(2~r~i#2)->Null)&,(r=Range)[i=#^2]~Partition~#/.Rule[1,],Prime@r@PrimePi@#];&
</code>```

Title: Sieve of Eratosthenes, Step by Step

Body:
Mathematica, 133 bytes

Grid[#,Alignment->Left]~Print~"
"&/@FoldList[#/.(##|1&@@(2~r~i#2)->Null)&,(r=Range)[i=#^2]~Partition~#/.Rule[1,],Prime@r@PrimePi@#];&


问:
Exploded Suffixes
Given an ASCII string, output the exploded suffixes of it. For example, if the string was abcde, there are 5 suffixes, ordered longest to shortest:

```<code>abcde
bcde
cde
de
e
</code>```

Each suffix is then exploded, meaning each character is copied as many times as its one-indexed location in that suffix. For example, exploding the suffixes of abcde,

```<code>abcde
12345
abbcccddddeeeee

bcde
1234
bccdddeeee

cde
123
cddeee

de
12
dee

e
1
e
</code>```

Altogether, the exploded suffixes of abcde are

```<code>abbcccddddeeeee
bccdddeeee
cddeee
dee
e
</code>```

Rules

This is code-golf so the shortest code wins.

The input will consist of the printable ASCII characters. (This excludes newlines but includes spaces.)

The output will have each string on a separate line.

Trailing spaces are allowed on each line and there may be an extra newline at the end.

Test Cases

```<code>''

'a'
a

'bc'
bcc
c

'xyz'
xyyzzz
yzz
z

'code-golf'
coodddeeee-----ggggggooooooollllllllfffffffff
oddeee----gggggoooooolllllllffffffff
dee---ggggooooollllllfffffff
e--gggoooolllllffffff
-ggooollllfffff
goolllffff
ollfff
lff
f

's p a c e'
s  ppp    aaaaa      ccccccc        eeeeeeeee
 pp   aaaa     cccccc       eeeeeeee
p  aaa    ccccc      eeeeeee
 aa   cccc     eeeeee
a  ccc    eeeee
 cc   eeee
c  eee
 ee
e
</code>```

答:
C, 186 Bytes

```<code>#include <string.h>
#define S strlen
p(char* s){char *t=s;char u[999]="";for(int i=0;i<S(s);i++){for(int j=i+1;j>0;j--){sprintf(u+S(u),"%c",*t);}t++;}printf("%s\n",u);if(S(s)>1)p(s+1);}
</code>```

This probably can be shortened quite a bit, but I just wanted to try it. It's my second try at golf, so give me any pointers (*lol) you can. It takes a string as a parameter and does the exploding from there. u is used as a buffer that stores the exploded string.

Ungolfed:

```<code>#include <string.h>
#define S strlen
p(char* s){
    char *t=s;
    char u[999]="";
    for(int i=0;i<S(s);i++){
        for(int j=i+1;j>0;j--){
            sprintf(u+S(u),"%c",*t);
        }
        t++;
    }
    printf("%s\n",u);
    if(S(s)>1)p(s+1);
}
</code>```

Title: Exploded Suffixes

Body:
C, 186 Bytes

#include <string.h>
#define S strlen
p(char* s){char *t=s;char u[999]="";for(int i=0;i<S(s);i++){for(int j=i+1;j>0;j--){sprintf(u+S(u),"%c",*t);}t++;}printf("%s\n",u);if(S(s)>1)p(s+1);}

This probably can be shortened quite a bit, but I just wanted to try it. It's my second try at golf, so give me any pointers (*lol) you can. It takes a string as a parameter and does the exploding from there. u is used as a buffer that stores the exploded string.

Ungolfed:

#include <string.h>
#define S strlen
p(char* s){
    char *t=s;
    char u[999]="";
    for(int i=0;i<S(s);i++){
        for(int j=i+1;j>0;j--){
            sprintf(u+S(u),"%c",*t);
        }
        t++;
    }
    printf("%s\n",u);
    if(S(s)>1)p(s+1);
}


答:
Python, 53 bytes

t=lambda n,k:n and(n-k)*t(n-1,k-1)-~k*t(n-1,k)or k==0
```

Recursion from OEIS. Outputs Boolean True as 1 when n==k.

Title: Compute the Eulerian number

Body:
The Eulerian number A(n, m) is the number of permutations of [1, 2, ..., n] in which exactly m elements are greater than the previous element. These are also called rises. For example, if n = 3, there are 3! = 6 permutations of [1, 2, 3]

```<code>1 2 3
 < <  2 elements are greater than the previous

1 3 2
 < >  1 ...

2 1 3
 > <  1 ...

2 3 1
 < >  1 ...

3 1 2
 > <  1 ...

3 2 1
 > >  0 ...
</code>```

So the outputs for A(3, m) for m in [0, 1, 2, 3] will be

```<code>A(3, 0) = 1
A(3, 1) = 4
A(3, 2) = 1
A(3, 3) = 0
</code>```

Also, this is the OEIS sequence A173018.

Rules

This is code-golf so the shortest code wins.

The input n will be a nonnegative integer and m will be a integer in the range [0, 1, ..., n].

Test Cases

```<code>n   m   A(n, m)
0   0   1
1   0   1
1   1   0
2   0   1
2   1   1
2   2   0
3   0   1
3   1   4
3   2   1
3   3   0
4   0   1
4   1   11
4   2   11
4   3   1
4   4   0
5   1   26
7   4   1191
9   5   88234
10  5   1310354
10  7   47840
10  10  0
12  2   478271
15  6   311387598411
17  1   131054
20  16  1026509354985
42  42  0
</code>```

Body:
Python, 53 bytes

t=lambda n,k:n and(n-k)*t(n-1,k-1)-~k*t(n-1,k)or k==0

Recursion from OEIS. Outputs Boolean True as 1 when n==k.


问:
Find the Centroid of a Polygon
From Wikipedia:

The centroid of a non-self-intersecting closed polygon
  defined by n vertices (x0,y0),
  (x1,y1), ...,
  (xn−1,yn−1) is the point (Cx,
  Cy), where

and where A is the polygon's signed area,

In these formulas, the vertices are assumed to be numbered in order of
  their occurrence along the polygon's perimeter. Furthermore, the
  vertex ( xn, yn ) is assumed to be the same as
  ( x0, y0 ), meaning i + 1 on the last case
  must loop around to i = 0. Note that if the points are numbered in
  clockwise order the area A, computed as above, will have a negative
  sign; but the centroid coordinates will be correct even in this case.

Given a list of vertices in order (either clockwise, or counter-clockwise), find the centroid of the non-self-intersecting closed polygon represented by the vertices.

If it helps, you may assume input to be only CW, or only CCW. Say so in your answer if you require this.

The coordinates are not required to be integers, and may contain negative numbers.

Input will always be valid and contain at least three vertices.

Inputs only need to be handled that fit in your language's native floating point data type.

You may assume that input numbers will always contain a decimal point.

You may assume that input integers end in . or .0.

You may use complex numbers for input.

Output should be accurate to the nearest thousandth.

Examples

```<code>[(0.,0.), (1.,0.), (1.,1.), (0.,1.)]        -> (0.5, 0.5)
[(-15.21,0.8), (10.1,-0.3), (-0.07,23.55)]  -> -1.727 8.017
[(-39.00,-55.94), (-56.08,-4.73), (-72.64,12.12), (-31.04,53.58), (-30.36,28.29), (17.96,59.17), (0.00,0.00), (10.00,0.00), (20.00,0.00), (148.63,114.32), (8.06,-41.04), (-41.25,34.43)]   -> 5.80104769975, 15.0673812762
</code>```

Too see each polygon on a coordinate plane, paste the coordinates without the square brackets in the "Edit" menu of this page.

I confirmed my results using this Polygon Centroid Point Calculator, which is awful. I couldn't find one that you can input all vertices at once, or that didn't try to erase your - sign when you type it first. I'll post my Python solution for your use after people have had a chance to answer.

答:
Actually, <s>45</s> <s>40</s> 39 bytes

This uses an algorithm similar to miles' Jelly answer. There is a shorter way to calculate determinants using a dot product, but there's currently a bug with Actually's dot product where it won't work with lists  of floats. Golfing suggestions welcome. Try it online!

```<code>;\Z♂#;`i¥`M@`i│N@F*)F@N*-`M;Σ3*)♀*┬♂Σ♀/
</code>```

Ungolfing

```<code>         Implicit input pts.
;\       Duplicate pts, rotate right.
Z        Zip rot_pts and pts together.
♂#       Convert the iterables inside the zip to lists
         (currently necessary due to a bug with duplicate)
;        Duplicate the zip.
`...`M   Get the sum each pair of points in the zip.
  i        Flatten the pair to the stack.
  ¥        Pairwise add the two coordinate vectors.
@        Swap with the other zip.
`...`M   Get the determinants of the zip.
  i│       Flatten to stack and duplicate entire stack.
           Stack: [a,b], [c,d], [a,b], [c,d]
  N@F*)    Push b*c and move it to BOS.
  F@N*     Push a*d.
  -        Get a*d-b*c.
;Σ3*)    Push 3 * sum(determinants) and move it to BOS.
♀*       Vector multiply the determinants and the sums.
┬        Transpose the coordinate pairs in the vector.
♂Σ       Sum the x's, then the y's.
♀/       Divide the x and y of this last coordinate pair by 3*sum(determinants).
         Implicit return.
</code>```

A shorter, non-competitive version

This is another 24-byte version that uses complex numbers. It's non-competitive because it relies on bug fixes that postdate this challenge. Try it online!

```<code>;\│¥)Z`iá*╫@X`M;Σ3*)♀*Σ/
</code>```

Ungolfing

```<code>         Implicit input a list of complex numbers, pts.
;\       Duplicate pts, rotate right.
│        Duplicate stack. Stack: rot_pts, pts, rot_pts, pts.
¥)       Pairwise sum the two lists of points together and rotate to BOS.
Z        Zip rot_pts and pts together.
`...`M   Map the following function over the zipped points to get our determinants.
  i        Flatten the list of [a+b*i, c+d*i].
  á        Push the complex conjugate of a+bi, i.e. a-b*i.
  *        Multiply a-b*i by c+d*i, getting (a*c+b*d)+(a*d-b*c)*i.
           Our determinant is the imaginary part of this result.
  ╫@X      Push Re(z), Im(z) to the stack, and immediately discard Re(z).
           This map returns a list of these determinants.
;        Duplicate list_determinants.
Σ3*)     Push 3 * sum(list_determinants) and rotate that to BOS.
♀*Σ      Pairwise multiply the sums of pairs of points and the determinants and sum.
/        Divide that sum by 3*sum(list_determinants).
         Implicit return.
</code>```

Title: Find the Centroid of a Polygon

Body:
Actually, <s>45</s> <s>40</s> 39 bytes

This uses an algorithm similar to miles' Jelly answer. There is a shorter way to calculate determinants using a dot product, but there's currently a bug with Actually's dot product where it won't work with lists  of floats. Golfing suggestions welcome. Try it online!

;\Z♂#;`i¥`M@`i│N@F*)F@N*-`M;Σ3*)♀*┬♂Σ♀/

Ungolfing

         Implicit input pts.
;\       Duplicate pts, rotate right.
Z        Zip rot_pts and pts together.
♂#       Convert the iterables inside the zip to lists
         (currently necessary due to a bug with duplicate)
;        Duplicate the zip.
`...`M   Get the sum each pair of points in the zip.
  i        Flatten the pair to the stack.
  ¥        Pairwise add the two coordinate vectors.
@        Swap with the other zip.
`...`M   Get the determinants of the zip.
  i│       Flatten to stack and duplicate entire stack.
           Stack: [a,b], [c,d], [a,b], [c,d]
  N@F*)    Push b*c and move it to BOS.
  F@N*     Push a*d.
  -        Get a*d-b*c.
;Σ3*)    Push 3 * sum(determinants) and move it to BOS.
♀*       Vector multiply the determinants and the sums.
┬        Transpose the coordinate pairs in the vector.
♂Σ       Sum the x's, then the y's.
♀/       Divide the x and y of this last coordinate pair by 3*sum(determinants).
         Implicit return.

A shorter, non-competitive version

This is another 24-byte version that uses complex numbers. It's non-competitive because it relies on bug fixes that postdate this challenge. Try it online!

;\│¥)Z`iá*╫@X`M;Σ3*)♀*Σ/

Ungolfing

         Implicit input a list of complex numbers, pts.
;\       Duplicate pts, rotate right.
│        Duplicate stack. Stack: rot_pts, pts, rot_pts, pts.
¥)       Pairwise sum the two lists of points together and rotate to BOS.
Z        Zip rot_pts and pts together.
`...`M   Map the following function over the zipped points to get our determinants.
  i        Flatten the list of [a+b*i, c+d*i].
  á        Push the complex conjugate of a+bi, i.e. a-b*i.
  *        Multiply a-b*i by c+d*i, getting (a*c+b*d)+(a*d-b*c)*i.
           Our determinant is the imaginary part of this result.
  ╫@X      Push Re(z), Im(z) to the stack, and immediately discard Re(z).
           This map returns a list of these determinants.
;        Duplicate list_determinants.
Σ3*)     Push 3 * sum(list_determinants) and rotate that to BOS.
♀*Σ      Pairwise multiply the sums of pairs of points and the determinants and sum.
/        Divide that sum by 3*sum(list_determinants).
         Implicit return.


答:
Acc!!, 150 bytes

Expects input on stdin, terminated with a tab character.

```<code>N
Count c while _/128^c-9 {
_+N*128^(c+1)
}
Count i while _-9 {
Count j while _/128^j-9 {
Count k while j+1-k {
Write _/128^j%128
}
}
Write 10
_/128
}
</code>```

Explanation

This is actually a pretty good task for Acc!!, since it only requires reading a string and iterating over it with some nested loops. We read the string into the accumulator, treating it as a sequence of base-128 digits, with the first character on the low-order end. After the opening Count c loop, the accumulator value can be conceptualized like this (using xyz as example input):

```<code>128^   3  2  1  0
     tab  z  y  x
</code>```

(The actual accumulator value for this example is 9*128^3 + 122*128^2 + 121*128 + 120 = 20888824.)

We can then iterate over the string by iterating over increasing powers of 128. And we can iterate over the suffixes by dividing the accumulator by 128 after each iteration, chopping off a character.

With indentation and comments:

```<code># Initialize the accumulator with the first input character
N
# Loop until most recent input was a tab (ASCII 9)
Count c while _/128^c - 9 {
    # Input another character and add it at the left end (next higher power of 128)
    _ + N * 128^(c+1)
}

# Loop over each suffix, until only the tab is left
Count i while _ - 9 {
    # Loop over powers of 128 until the tab
    Count j while _/128^j - 9 {
        # Loop (j+1) times
        Count k while j + 1 - k {
            # Output the j'th character
            Write _ / 128^j % 128
        }
    }
    # Output a newline
    Write 10
    # Remove a character
    _/128
}
</code>```

Title: Exploded Suffixes

Body:
Given an ASCII string, output the exploded suffixes of it. For example, if the string was abcde, there are 5 suffixes, ordered longest to shortest:

```<code>abcde
bcde
cde
de
e
</code>```

Each suffix is then exploded, meaning each character is copied as many times as its one-indexed location in that suffix. For example, exploding the suffixes of abcde,

```<code>abcde
12345
abbcccddddeeeee

bcde
1234
bccdddeeee

cde
123
cddeee

de
12
dee

e
1
e
</code>```

Altogether, the exploded suffixes of abcde are

```<code>abbcccddddeeeee
bccdddeeee
cddeee
dee
e
</code>```

Rules

This is code-golf so the shortest code wins.

The input will consist of the printable ASCII characters. (This excludes newlines but includes spaces.)

The output will have each string on a separate line.

Trailing spaces are allowed on each line and there may be an extra newline at the end.

Test Cases

```<code>''

'a'
a

'bc'
bcc
c

'xyz'
xyyzzz
yzz
z

'code-golf'
coodddeeee-----ggggggooooooollllllllfffffffff
oddeee----gggggoooooolllllllffffffff
dee---ggggooooollllllfffffff
e--gggoooolllllffffff
-ggooollllfffff
goolllffff
ollfff
lff
f

's p a c e'
s  ppp    aaaaa      ccccccc        eeeeeeeee
 pp   aaaa     cccccc       eeeeeeee
p  aaa    ccccc      eeeeeee
 aa   cccc     eeeeee
a  ccc    eeeee
 cc   eeee
c  eee
 ee
e
</code>```

Body:
Acc!!, 150 bytes

Expects input on stdin, terminated with a tab character.

N
Count c while _/128^c-9 {
_+N*128^(c+1)
}
Count i while _-9 {
Count j while _/128^j-9 {
Count k while j+1-k {
Write _/128^j%128
}
}
Write 10
_/128
}

Explanation

This is actually a pretty good task for Acc!!, since it only requires reading a string and iterating over it with some nested loops. We read the string into the accumulator, treating it as a sequence of base-128 digits, with the first character on the low-order end. After the opening Count c loop, the accumulator value can be conceptualized like this (using xyz as example input):

128^   3  2  1  0
     tab  z  y  x

(The actual accumulator value for this example is 9*128^3 + 122*128^2 + 121*128 + 120 = 20888824.)

We can then iterate over the string by iterating over increasing powers of 128. And we can iterate over the suffixes by dividing the accumulator by 128 after each iteration, chopping off a character.

With indentation and comments:

# Initialize the accumulator with the first input character
N
# Loop until most recent input was a tab (ASCII 9)
Count c while _/128^c - 9 {
    # Input another character and add it at the left end (next higher power of 128)
    _ + N * 128^(c+1)
}

# Loop over each suffix, until only the tab is left
Count i while _ - 9 {
    # Loop over powers of 128 until the tab
    Count j while _/128^j - 9 {
        # Loop (j+1) times
        Count k while j + 1 - k {
            # Output the j'th character
            Write _ / 128^j % 128
        }
    }
    # Output a newline
    Write 10
    # Remove a character
    _/128
}


答:
Python, <s>156</s> 127 bytes

```<code>def f(p):n=len(p);p=p+p[:1];i=s=0;exec'd=(p[i].conjugate()*p[i+1]).imag;s+=d;p[i]=(p[i]+p[i+1])*d;i+=1;'*n;print sum(p[:n])/s/3
</code>```

Ungolfed:

```<code>def f(points):
  n = len(points)
  points = points + [points[0]]
  determinantSum = 0
  for i in range(n):
    determinant = (points[i].conjugate() * points[i+1]).imag
    determinantSum += determinant
    points[i] = (points[i] + points[i+1]) * determinant
  print sum(points[:n]) / determinantSum / 3
</code>```

Ideone it.

This takes each pair of points [x, y] as a complex number x + y*j, and outputs the resulting centroid as a complex number in the same format.

For the pair of points [a, b] and [c, d], the value a*d - b*c which is needed for each pair of points can be computed from the determinant of the matrix

```<code>| a b |
| c d |
</code>```

Using complex arithmetic, the complex values a + b*j and c + d*j can be used as

```<code>conjugate(a + b*j) * (c + d*j)
(a - b*j) * (c + d*j)
(a*c + b*d) + (a*d - b*c)*j
</code>```

Notice that the imaginary part is equivalent to the determinant. Also, using complex values allows the points to be easily summed component-wise in the other operations.

Title: Find the Centroid of a Polygon

Body:
From Wikipedia:

The centroid of a non-self-intersecting closed polygon
  defined by n vertices (x0,y0),
  (x1,y1), ...,
  (xn−1,yn−1) is the point (Cx,
  Cy), where

and where A is the polygon's signed area,

In these formulas, the vertices are assumed to be numbered in order of
  their occurrence along the polygon's perimeter. Furthermore, the
  vertex ( xn, yn ) is assumed to be the same as
  ( x0, y0 ), meaning i + 1 on the last case
  must loop around to i = 0. Note that if the points are numbered in
  clockwise order the area A, computed as above, will have a negative
  sign; but the centroid coordinates will be correct even in this case.

Given a list of vertices in order (either clockwise, or counter-clockwise), find the centroid of the non-self-intersecting closed polygon represented by the vertices.

If it helps, you may assume input to be only CW, or only CCW. Say so in your answer if you require this.

The coordinates are not required to be integers, and may contain negative numbers.

Input will always be valid and contain at least three vertices.

Inputs only need to be handled that fit in your language's native floating point data type.

You may assume that input numbers will always contain a decimal point.

You may assume that input integers end in . or .0.

You may use complex numbers for input.

Output should be accurate to the nearest thousandth.

Examples

```<code>[(0.,0.), (1.,0.), (1.,1.), (0.,1.)]        -> (0.5, 0.5)
[(-15.21,0.8), (10.1,-0.3), (-0.07,23.55)]  -> -1.727 8.017
[(-39.00,-55.94), (-56.08,-4.73), (-72.64,12.12), (-31.04,53.58), (-30.36,28.29), (17.96,59.17), (0.00,0.00), (10.00,0.00), (20.00,0.00), (148.63,114.32), (8.06,-41.04), (-41.25,34.43)]   -> 5.80104769975, 15.0673812762
</code>```

Too see each polygon on a coordinate plane, paste the coordinates without the square brackets in the "Edit" menu of this page.

I confirmed my results using this Polygon Centroid Point Calculator, which is awful. I couldn't find one that you can input all vertices at once, or that didn't try to erase your - sign when you type it first. I'll post my Python solution for your use after people have had a chance to answer.

Body:
Python, <s>156</s> 127 bytes

def f(p):n=len(p);p=p+p[:1];i=s=0;exec'd=(p[i].conjugate()*p[i+1]).imag;s+=d;p[i]=(p[i]+p[i+1])*d;i+=1;'*n;print sum(p[:n])/s/3

Ungolfed:

def f(points):
  n = len(points)
  points = points + [points[0]]
  determinantSum = 0
  for i in range(n):
    determinant = (points[i].conjugate() * points[i+1]).imag
    determinantSum += determinant
    points[i] = (points[i] + points[i+1]) * determinant
  print sum(points[:n]) / determinantSum / 3

Ideone it.

This takes each pair of points [x, y] as a complex number x + y*j, and outputs the resulting centroid as a complex number in the same format.

For the pair of points [a, b] and [c, d], the value a*d - b*c which is needed for each pair of points can be computed from the determinant of the matrix

| a b |
| c d |

Using complex arithmetic, the complex values a + b*j and c + d*j can be used as

conjugate(a + b*j) * (c + d*j)
(a - b*j) * (c + d*j)
(a*c + b*d) + (a*d - b*c)*j

Notice that the imaginary part is equivalent to the determinant. Also, using complex values allows the points to be easily summed component-wise in the other operations.


答:
Pip, 64 bytes

63 bytes of code, +1 for -S flag.

```<code>.*"NTCSPVSES".sX19.^"PNCPSCPLB"PE^"FKCIIBAVWMG"AE^"JCVCORIBCMG"
</code>```

Try it online!

Explanation

Operators used:

. (binary) concatenates (operates item-wise on lists).

X (binary) string-multiplies. (s is a variable preinitialized to " ".)

^ (unary) splits a string into a list of characters.

.* is another way to split a string into characters. It consists of unary ., which is a no-op on strings, paired with the * meta-operator, which maps a unary operator to each item in its (iterable) operand. Using .*"..." lets us save a byte over (^"...")--the parentheses would be required because . is higher precedence than ^.

PE prepends an element to a list. AE appends an element to a list.

With that background, here's the code step by step:

```<code>.*"NTCSPVSES"

['N 'T 'C 'S 'P 'V 'S 'E 'S]

.sX19

["N                   "
 "T                   "
 "C                   "
 "S                   "
 "P                   "
 "V                   "
 "S                   "
 "E                   "
 "S                   "]

.^"PNCPSCPLB"

["N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"]

PE^"FKCIIBAVWMG"

[['F 'K 'C 'I 'I 'B 'A 'V 'W 'M 'G]
 "N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"]

AE^"JCVCORIBCMG"

[['F 'K 'C 'I 'I 'B 'A 'V 'W 'M 'G]
 "N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"
 ['J 'C 'V 'C 'O 'R 'I 'B 'C 'M 'G]]
</code>```

When this result is autoprinted, the -S flag joins the sublists on spaces and the main list on newlines, giving the desired output.

Body:
Monopoly Board

For this code-golf challenge we will be building the board game Monopoly.

Rules:

Take no input.

Output a 11x11 board where each ASCII character forming the board is the first letter of each space of the U.S. version of the Monopoly board.

The characters must be separated by spaces.

Go should start in the bottom right.

The exact string to produce is

```<code>F K C I I B A V W M G
N                   P
T                   N
C                   C
S                   P
P                   S
V                   C
S                   P
E                   L
S                   B
J C V C O R I B C M G
</code>```

Note that from bottom right to bottom left the squares are as follows:

```<code>G --> Go
M --> Mediterranean Avenue
C --> Community Chest
B --> Baltic Avenue
I --> Income Tax
...
J --> Jail
</code>```

Edit
Wow! you guys sure liked this one! :)

Body:
Pip, 64 bytes

63 bytes of code, +1 for -S flag.

.*"NTCSPVSES".sX19.^"PNCPSCPLB"PE^"FKCIIBAVWMG"AE^"JCVCORIBCMG"

Try it online!

Explanation

Operators used:

. (binary) concatenates (operates item-wise on lists).

X (binary) string-multiplies. (s is a variable preinitialized to " ".)

^ (unary) splits a string into a list of characters.

.* is another way to split a string into characters. It consists of unary ., which is a no-op on strings, paired with the * meta-operator, which maps a unary operator to each item in its (iterable) operand. Using .*"..." lets us save a byte over (^"...")--the parentheses would be required because . is higher precedence than ^.

PE prepends an element to a list. AE appends an element to a list.

With that background, here's the code step by step:

.*"NTCSPVSES"

['N 'T 'C 'S 'P 'V 'S 'E 'S]

.sX19

["N                   "
 "T                   "
 "C                   "
 "S                   "
 "P                   "
 "V                   "
 "S                   "
 "E                   "
 "S                   "]

.^"PNCPSCPLB"

["N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"]

PE^"FKCIIBAVWMG"

[['F 'K 'C 'I 'I 'B 'A 'V 'W 'M 'G]
 "N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"]

AE^"JCVCORIBCMG"

[['F 'K 'C 'I 'I 'B 'A 'V 'W 'M 'G]
 "N                   P"
 "T                   N"
 "C                   C"
 "S                   P"
 "P                   S"
 "V                   C"
 "S                   P"
 "E                   L"
 "S                   B"
 ['J 'C 'V 'C 'O 'R 'I 'B 'C 'M 'G]]

When this result is autoprinted, the -S flag joins the sublists on spaces and the main list on newlines, giving the desired output.


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

答:
S.I.L.O.S, 37 bytes (Cracked.)

Code:

```<code>readIO
#=#
#+#
#*#
#*#
#+#
printInt i
</code>```

#s are the hidden characters.

Output:

```<code>a(0) = 1
a(4) = 41
a(9) = 181
</code>```

Body:
S.I.L.O.S, 37 bytes (Cracked.)

Code:

readIO
#=#
#+#
#*#
#*#
#+#
printInt i

#s are the hidden characters.

Output:

a(0) = 1
a(4) = 41
a(9) = 181


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

答:
S.I.L.O.S, betseg, A001844

```<code>readIO
a=i
a+1
i*2
i*a
i+1
printInt i
</code>```

Try it online!

Body:
S.I.L.O.S, betseg, A001844

readIO
a=i
a+1
i*2
i*a
i+1
printInt i

Try it online!


答:
Perl, <s>115</s> <s>114</s> <s>113</s> 112 bytes

Includes +1 for -a

Run with input number on STDIN:

```<code>perl -M5.010 sieving.pl <<< 7
</code>```

sieving.pl:

```<code>#!/usr/bin/perl -a
$_*=$_;$a.="$_"x$|++|$"x"@+".($_%"@F"?$":$/)for/\d+/..$_;*_=a;s^^$$_++||say;$.++;s//$&%$.|$&==$.?$&:$&&$_/eg^eg
</code>```

Needs a recent enough perl so that -a implies -n. If your perl is too old add a -n option.

Prints a trailing newline which is allowed.

Title: Sieve of Eratosthenes, Step by Step

Body:
Given a number N, draw a left aligned NxN board of numbers, leaving 1 blank (as a space) (I will show diagrams with N=5)

```<code>   2  3  4  5
6  7  8  9  10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
</code>```

Your job is to construct the Sieve of Eratosthenes, step by step. First, start with 2. It's prime, so leave it there, and replace all other numbers divisible by 2 with the proper number of spaces.

```<code>   2  3     5
   7     9
11    13    15
   17    19
21    23    25
</code>```

Next, go to the next unprinted number (3 in this case) and do the same.

```<code>   2  3     5
   7
11    13
   17    19
      23    25
</code>```

And so on, until you reach N.

You need to first print the complete grid, and every time you go to a new number, print the board with the multiples removed. Make sure you print a blank line in between!

Examples

Text in parenthesis () are just for reference, you don't need to print it

N = 2:

```<code>  2 (complete grid)
3 4

  2 (remove multiples of 2)
3
</code>```

N = 3:

```<code>  2 3 (complete grid)
4 5 6
7 8 9

  2 3 (remove multiples of 2)
  5
7   9

  2 3 (remove multiples of 3)
  5
7
</code>```

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Body:
Perl, <s>115</s> <s>114</s> <s>113</s> 112 bytes

Includes +1 for -a

Run with input number on STDIN:

perl -M5.010 sieving.pl <<< 7

sieving.pl:

#!/usr/bin/perl -a
$_*=$_;$a.="$_"x$|++|$"x"@+".($_%"@F"?$":$/)for/\d+/..$_;*_=a;s^^$$_++||say;$.++;s//$&%$.|$&==$.?$&:$&&$_/eg^eg

Needs a recent enough perl so that -a implies -n. If your perl is too old add a -n option.

Prints a trailing newline which is allowed.


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

答:
R, 67 bytes

```<code>l=length(i<-strsplit(readline(),"")[[1]]);-sum(log2(l/table(i)[i]))
</code>```

Explanation

Take input from stdin and split it into a list of characters. (This clunky syntax is why string golf challenges are so tough in R...)

```<code>         i<-strsplit(readline(),"")[[1]])
</code>```

This assignment is hidden inside of a length command, so we get two assignments for the price of one. We have i, the list of characters, and l, its length.

```<code>l=length(i<-strsplit(readline(),"")[[1]]);
</code>```

Now we calculate the entropy. R has a nice function table which returns the counts of all unique values. For input This is a test, table(i) returns

```<code>> table(i)
i
  . a e h i s t T
3 1 1 1 1 2 3 2 1
</code>```

This is indexed by characters, which is nice, as we can then use i as an index to get the count of each character, like so:

```<code>> table(i)[i]
i
T h i s   i s   a   t e s t .
1 1 2 3 3 2 3 3 1 3 2 1 3 2 1
</code>```

The rest of the code is then a simple implementation of the entropy formula, flipped around a little.

```<code>                                           -sum(log2(l/table(i)[i]))
</code>```

Body:
R, 67 bytes

l=length(i<-strsplit(readline(),"")[[1]]);-sum(log2(l/table(i)[i]))

Explanation

Take input from stdin and split it into a list of characters. (This clunky syntax is why string golf challenges are so tough in R...)

         i<-strsplit(readline(),"")[[1]])

This assignment is hidden inside of a length command, so we get two assignments for the price of one. We have i, the list of characters, and l, its length.

l=length(i<-strsplit(readline(),"")[[1]]);

Now we calculate the entropy. R has a nice function table which returns the counts of all unique values. For input This is a test, table(i) returns

> table(i)
i
  . a e h i s t T
3 1 1 1 1 2 3 2 1

This is indexed by characters, which is nice, as we can then use i as an index to get the count of each character, like so:

> table(i)[i]
i
T h i s   i s   a   t e s t .
1 1 2 3 3 2 3 3 1 3 2 1 3 2 1

The rest of the code is then a simple implementation of the entropy formula, flipped around a little.

                                           -sum(log2(l/table(i)[i]))