答:
S.I.L.O.S 265

The (non competing) code better input format is at the bottom, feel free to try it online!

```<code>def : lbl
loadLine :
a = 256
:a
:s
x = get a
z = x
z - 32
z |
if z u
a + 1
GOTO s
:u
if x c
GOTO e
:c
b = x
b + 512
c = get b
c + 1
set b c
a + 1
if x a
:e
a = 512
b = 768
l = 10
:Z
j = a
j - b
if j z
z = get a
c = a
c - 512
:3
if z C
printChar l
a + 1
GOTO Z
:C
printChar c
z - 1
GOTO 3
:z
</code>```

Input for the above is a series of command line arguments representing ascii values, terminated with a zero.Try it online!.

For a more reasonable method of input we must up the byte count (and use features that were nonexistent before the writing of this challenge).

For 291 bytes we get the following code.

```<code>\
def : lbl
loadLine :
a = 256
:a
:s
x = get a
z = x
z - 32
z |
if z u
a + 1
GOTO s
:u
if x c
GOTO e
:c
b = x
b + 512
c = get b
c + 1
set b c
a + 1
if x a
:e
a = 512
b = 768
l = 10
:Z
j = a
j - b
if j z
z = get a
c = a
c - 512
:3
if z C
printChar l
a + 1
GOTO Z
:C
printChar c
z - 1
GOTO 3
:z
</code>```

Feel free to test this version online!. The backslash is unnecessary but is there to show the important leading line feed.

Title: Exploded view of a string

Body:
Don't you love those exploded-view diagrams  in which a machine or object is taken apart into its smallest pieces?

Let's do that to a string!

The challenge

Write a program or function that

inputs a string containing only printable ASCII characters;

dissects the string into groups of non-space equal characters (the "pieces" of the string);

outputs those groups in any convenient format, with some separator between groups.

For example, given the string

```<code>Ah, abracadabra!
</code>```

the output would be the following groups:

```
!
,
A
aaaaa
bb
c
d
h
rr
```

Each group in the output contains equal characters, with spaces removed. A newline has been used as separator between groups. More about allowed formats below.

Rules

The input should be a string or an array of chars. It will only contain printable ASCII chars (the inclusive range from space to tilde). If your language does not support that, you can take the input in the form of numbers representing ASCII codes.

You can assume that the input contains at least one non-space character.

The output should consist of characters (even if the input is by means of ASCII codes). There has to be an unambiguous separator between groups, different than any non-space character that may appear in the input.

If the output is via function return, it may also be an array or strings, or an array of arrays of chars, or similar structure. In that case the structure provides the necessary separation.

A separator between characters of each group is optional. If there is one, the same rule applies: it can't be a non-space character that may appear in the input. Also, it can't be the same separator as used between groups.

Other than that, the format is flexible. Here are some examples:

The groups may be strings separated by newlines, as shown above.

The groups may be separated by any non-ASCII character, such as  ¬. The output for the above input would be the string:

```<code>!¬,¬A¬aaaaa¬bb¬c¬d¬h¬rr
</code>```

The groups may be separated by n>1 spaces (even if n is variable), with chars between each group separated by a single space:

```<code>!  ,    A   a a a a a    b b  c       d   h  r r
</code>```

The output may also be an array or list of strings returned by a function:

```<code>['!', 'A', 'aaaaa', 'bb', 'c', 'd', 'h', 'rr']
</code>```

Or an array of char arrays:

```<code>[['!'], ['A'], ['a', 'a', 'a', 'a', 'a'], ['b', 'b'], ['c'], ['d'], ['h'], ['r', 'r']]
</code>```

Examples of formats that are not allowed, according to the rules:

A comma can't be used as separator (!,,,A,a,a,a,a,a,b,b,c,d,h,r,r), because the input may contain commas.

It's not accepted to drop the separator between groups (!,Aaaaaabbcdhrr) or to use the same separator between groups and within groups (! , A a a a a a b b c d h r r).

The groups may appear in any order in the output. For example: alphabetical order (as in the examples above), order of first appearance in the string, ... The order need not be consistent or even deterministic.

Note that the input cannot contain newline characters, and A and a are different characters (grouping is case-sentitive).

Shortest code in bytes wins.

Test cases

In each test case, first line is input, and the remaining lines are the output, with each group in a different line.

Test case 1:

```
Ah, abracadabra!
!
,
A
aaaaa
bb
c
d
h
rr
```

Test case 2:

```
\o/\o/\o/
///
\\\
ooo
```

Test case 3:

```
A man, a plan, a canal: Panama!
!
,,
:
A
P
aaaaaaaaa
c
ll
mm
nnnn
p
```

Test case 4:

```
"Show me how you do that trick, the one that makes me scream" she said
""
,
S
aaaaa
cc
dd
eeeeeee
hhhhhh
ii
kk
mmmm
n
ooooo
rr
ssss
tttttt
u
ww
y
```

Body:
S.I.L.O.S 265

The (non competing) code better input format is at the bottom, feel free to <a href="http://silos.tryitonline.net/#code=CmRlZiA6IGxibApsb2FkTGluZSA6CmEgPSAyNTYKOmEKOnMKeCA9IGdldCBhCnogPSB4CnogLSAzMgp6IHwKaWYgeiB1CmEgKyAxCkdPVE8gcwo6dQppZiB4IGMKR09UTyBlCjpjCmIgPSB4CmIgKyA1MTIKYyA9IGdldCBiCmMgKyAxCnNldCBiIGMKYSArIDEKaWYgeCBhCjplCmEgPSA1MTIKYiA9IDc2OApsID0gMTAKOloKaiA9IGEKaiAtIGIKaWYgaiB6CnogPSBnZXQgYQpjID0gYQpjIC0gNTEyCjozCmlmIHogQwpwcmludENoYXIgbAphICsgMQpHT1RPIFoKOkMKcHJpbnRDaGFyIGMKeiAtIDEKR09UTyAzCjp6&input=&args=VGhpcyBpcyB0ZXN0IGlucHV0IHdpdGhvdXQgYW55IG5ld2xpbmVzLiBBQUFBQUEgQkJCQkIgVGhlIHF1aWNrIEJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cgMTIzNDU2Nzg5MCE" rel="nofollow">try it online!

def : lbl
loadLine :
a = 256
:a
:s
x = get a
z = x
z - 32
z |
if z u
a + 1
GOTO s
:u
if x c
GOTO e
:c
b = x
b + 512
c = get b
c + 1
set b c
a + 1
if x a
:e
a = 512
b = 768
l = 10
:Z
j = a
j - b
if j z
z = get a
c = a
c - 512
:3
if z C
printChar l
a + 1
GOTO Z
:C
printChar c
z - 1
GOTO 3
:z

Input for the above is a series of command line arguments representing ascii values, terminated with a zero.Try it online!.

For a more reasonable method of input we must up the byte count (and use features that were nonexistent before the writing of this challenge).

For 291 bytes we get the following code.

\
def : lbl
loadLine :
a = 256
:a
:s
x = get a
z = x
z - 32
z |
if z u
a + 1
GOTO s
:u
if x c
GOTO e
:c
b = x
b + 512
c = get b
c + 1
set b c
a + 1
if x a
:e
a = 512
b = 768
l = 10
:Z
j = a
j - b
if j z
z = get a
c = a
c - 512
:3
if z C
printChar l
a + 1
GOTO Z
:C
printChar c
z - 1
GOTO 3
:z

Feel free to <a href="http://silos.tryitonline.net/#code=CmRlZiA6IGxibApsb2FkTGluZSA6CmEgPSAyNTYKOmEKOnMKeCA9IGdldCBhCnogPSB4CnogLSAzMgp6IHwKaWYgeiB1CmEgKyAxCkdPVE8gcwo6dQppZiB4IGMKR09UTyBlCjpjCmIgPSB4CmIgKyA1MTIKYyA9IGdldCBiCmMgKyAxCnNldCBiIGMKYSArIDEKaWYgeCBhCjplCmEgPSA1MTIKYiA9IDc2OApsID0gMTAKOloKaiA9IGEKaiAtIGIKaWYgaiB6CnogPSBnZXQgYQpjID0gYQpjIC0gNTEyCjozCmlmIHogQwpwcmludENoYXIgbAphICsgMQpHT1RPIFoKOkMKcHJpbnRDaGFyIGMKeiAtIDEKR09UTyAzCjp6&input=&args=VGhpcyBpcyB0ZXN0IGlucHV0IHdpdGhvdXQgYW55IG5ld2xpbmVzLiBBQUFBQUEgQkJCQkIgVGhlIHF1aWNrIEJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cgMTIzNDU2Nzg5MCE" rel="nofollow">test this version online!. The backslash is unnecessary but is there to show the important leading line feed.


问:
Calculate the correlation coefficient
Given a series of numbers for events X and Y, calculate Pearson's correlation coefficient. The probability of each event is equal, so expected values can be calculated by simply summing each series and dividing by the number of trials.

Input

```<code>1   6.86
2   5.92
3   6.08
4   8.34
5   8.7
6   8.16
7   8.22
8   7.68
9   12.04
10  8.6
11  10.96
</code>```

Output

```<code>0.769
</code>```

Shortest code wins. Input can be by stdin or arg. Output will be by stdout.

Edit: Builtin functions should not be allowed (ie calculated expected value, variance, deviation, etc) to allow more diversity in solutions. However, feel free to demonstrate a language that is well suited for the task using builtins (for exhibition).

Based on David's idea for input for Mathematica (86 char using builtin mean)

```<code>m=Mean;x=d[[All,1]];y=d[[All,2]];(m@(x*y)-m@x*m@y)/Sqrt[(m@(x^2)-m@x^2)(m@(y^2)-m@y^2)]

m = Mean;
x = d[[All,1]];
y = d[[All,2]];
(m@(x*y) - m@x*m@y)/((m@(x^2) - m@x^2)(m@(y^2) - m@y^2))^.5
</code>```

Skirting by using our own mean (101 char)

```<code>m=Total[#]/Length[#]&;x=d[[All,1]];y=d[[All,2]];(m@(x*y)-m@x*m@y)/((m@(x^2)-m@x^2)(m@(y^2)-m@y^2))^.5

m = Total[#]/Length[#]&;
x = d[[All,1]];
y = d[[All,2]];
(m@(x*y)-m@x*m@y)/((m@(x^2)-m@x^2)(m@(y^2)-m@y^2))^.5
</code>```

答:
PHP 144 bytes

```<code><?
for(;fscanf(STDIN,'%f%f',$$n,${-$n});$f+=${-$n++})$e+=$$n;
for(;$$i;$z+=$$i*$a=${-$i++}-=$f/$n,$y+=$a*$a)$x+=$$i*$$i-=$e/$n;
echo$z/sqrt($x*$y);
</code>```

Takes the input from STDIN, in the format provided in the original post. Result:

0.76909044055492

Using the vector dot product:

where  are the input vectors  adjusted downwards by  and  respectively.

Perl 112 bytes

```<code>/ /,$e+=$`,$f+=$',@v=($',@v)for@u=<>;
$x+=($_-=$e/$.)*$_,$y+=($;=$f/$.-pop@v)*$;,$z-=$_*$;for@u;
print$z/sqrt$x*$y
</code>```

0.76909044055492

Same alg, different language. In both cases, new lines have been added for 'readability', and are not required. The only notable difference in length is the first line: the parsing of input.

ContentLicense: CC BY-SA 3.0

Title: Calculate the correlation coefficient

Body:
PHP 144 bytes

<?
for(;fscanf(STDIN,'%f%f',$$n,${-$n});$f+=${-$n++})$e+=$$n;
for(;$$i;$z+=$$i*$a=${-$i++}-=$f/$n,$y+=$a*$a)$x+=$$i*$$i-=$e/$n;
echo$z/sqrt($x*$y);

Takes the input from STDIN, in the format provided in the original post. Result:

0.76909044055492

Using the vector dot product:

where  are the input vectors  adjusted downwards by  and  respectively.

Perl 112 bytes

/ /,$e+=$`,$f+=$',@v=($',@v)for@u=<>;
$x+=($_-=$e/$.)*$_,$y+=($;=$f/$.-pop@v)*$;,$z-=$_*$;for@u;
print$z/sqrt$x*$y

0.76909044055492

Same alg, different language. In both cases, new lines have been added for 'readability', and are not required. The only notable difference in length is the first line: the parsing of input.


问:
No strings (or numbers) attached
If you like this, consider participating in:

The Official Dyalog APL 2016 Year Game

The monthly Dyalog APL 2017 Code Golf Challenge

Make 12 snippets/expressions, in the same language, that result in the numbers 0 through 10, and 42 respectively, but without writing any literal numeric, string, or character data.

Build-in data, like PI() and ALPHABET(), are fine, and so are e.g. CJam's U, X, Y, Z, and A constants, and Processing's BLEND, CHORD, CENTER, BREAK, and  LINES.

Every snippet must be able to stand on its own, i.e. they may not be interdependent. However, inside a single snippet, you may assign a variable and use it freely, as long as you refer to it directly by name, and not through a string containing its name.

All the snippets must be valid on the submitter’s computer at the time of submission (as reported by SE), but may not rely on unusual local conditions like number of files in a directory, the exact date or time, or specific input from the user.

Examples of valid snippets

3: INT(LOG10(YEAR(TODAY())))   because it remains true in the foreseeable future

4: CUBICROOT(LEN(CHARACTERSET()))   because a 256 letter character set is very common

8: SQRT(SYSTEMTYPE())   because 64-bit systems are very common

Examples of invalid snippets

5: LEN(USERNAME())   because most people do not use “Admin” as login :-)

9: LOG10(SYSTEMMEMORY())   because it only works on systems with exactly 1 GB of memory

42: CODE("*")   because it contains a string/character literal

The result of each snippet must result in an actual number (value, int, float, etc.) that can be used for further calculations using the same language as the snippet, i.e not a text string representing that number.

Only character based languages allowed.

Score is total byte count of all the 12 snippets combined. Newlines separating the snippets are not counted in.

Note that the above rules may prevent some languages from participating, even if they are Turing complete.

FAQ

Q Can the programs accept any input?

A Yes, but you may not just ask for input and enter the relevant number.

Q Are physical digits (non-data) digits allowed?

A Yes, e.g. LOG10().

Q Do Symbols in Ruby count as literals?

A Yes.

Q Does score include newlines between each snippet?

A No.

Q Is TI-BASIC "character based" enough to be valid?

A Yes.

Q Do false and true count as number literals?

A No, they are acceptable.

Q Can we use a number literal to call a function if that's the only way and the number doesn't influence the output of the function?

A Yes, if that is the normal way to write code in your language.

Q My language assumes there is a [something] at the start of each program/expression. Must I include it, or should my snippets just work if placed in the middle of a program/expression?

A They should just work in the middle of a program/expression.

Q What about regex literals?

A Forbidden, except for languages that only do regexes.

Q Is one piece of code that could print all the specified numbers acceptable?

A No, they have to be separate and mutually independent.

Q May I assume a boilerplate like int main() {}... or equivalent?

A Yes.

Q What output datatypes are allowed?

A Any numeric datatype, like int, float, etc.

Q Do I need to print the result of each snippet?

A No, making the result available for subsequent use is enough.

Q Are pre-set variables allowed?

A Yes, and they become reset (if changed) for every snippet.

Q Are π and e considered number literals?

A No, you may use them.

Q May I return 4 and 2 in different cells for 42?

A No, they must be connected as one number.

Q Bytes or characters?

A Bytes, but you may choose any desired codepage.

Q May constant functions and preset variables like J's 9:, Actually's 9, and Pretzel's 9 be used?

A Yes, if the vocabulary is finite (19 for J, 10 for Actually and Pretzel).

答:
Haskell, <s>212 210 198 196 190 187</s> 134 bytes

Edit: After reading in the FAQ that using pi is allowed, throwing everything away and doing it all using pionly saves a lot of bytes.

```<code>pi-pi                     -- 0.0,  5 bytes
pi/pi                     -- 1.0,  5 bytes
succ$pi/pi                -- 2.0, 10 bytes
floor pi                  --   3,  8 bytes
ceiling pi                --   4, 10 bytes
succ.ceiling$pi           --   5, 15 bytes
floor$pi+pi               --   6, 11 bytes
ceiling$pi+pi             --   7, 13 bytes
pred.floor$pi*pi          --   8, 16 bytes
floor$pi*pi               --   9, 11 bytes
round$pi*pi               --  10, 11 bytes
floor$pi**pi+pi+pi        --  42, 18 bytes
</code>```

However, I still like the old approach more as using a number to generate other numbers feels a bit like cheating.

```<code>sum[]                     --  0,  5 bytes
length[LT]                --  1, 10 bytes
fromEnum GT               --  2, 11 bytes
length[LT ..]             --  3, 13 bytes
length$show[()]           --  4, 15 bytes
length.show$False         --  5, 17 bytes
length$show[True]         --  6, 17 bytes
length.show$Left()        --  7, 18 bytes
length.show$Right()       --  8, 19 bytes
length$show[Just[]]       --  9, 19 bytes
length$show[LT ..]        -- 10, 18 bytes
fromEnum.succ.last$show() -- 42, 25 bytes
</code>```

LT,EQ and GT are the values of the Ordering Type. As Ordering is an instance of Enum, fromEnum GT yields 2 and [LT ..] creates the list [LT,EQ,GT]. show converts all instances of the Show type class to strings.

Bonus:

42 in 42 bytes: length.show$Just$[LT ..]>>[EQ,GT]>>[GT,LT]

How long is nothing? length Nothing

Saved 3 bytes thanks to nimi and 3 bytes thanks to xnor.

Title: No strings (or numbers) attached

Body:
Haskell, <s>212 210 198 196 190 187</s> 134 bytes

Edit: After reading in the FAQ that using pi is allowed, throwing everything away and doing it all using pionly saves a lot of bytes.

pi-pi                     -- 0.0,  5 bytes
pi/pi                     -- 1.0,  5 bytes
succ$pi/pi                -- 2.0, 10 bytes
floor pi                  --   3,  8 bytes
ceiling pi                --   4, 10 bytes
succ.ceiling$pi           --   5, 15 bytes
floor$pi+pi               --   6, 11 bytes
ceiling$pi+pi             --   7, 13 bytes
pred.floor$pi*pi          --   8, 16 bytes
floor$pi*pi               --   9, 11 bytes
round$pi*pi               --  10, 11 bytes
floor$pi**pi+pi+pi        --  42, 18 bytes

However, I still like the old approach more as using a number to generate other numbers feels a bit like cheating.

sum[]                     --  0,  5 bytes
length[LT]                --  1, 10 bytes
fromEnum GT               --  2, 11 bytes
length[LT ..]             --  3, 13 bytes
length$show[()]           --  4, 15 bytes
length.show$False         --  5, 17 bytes
length$show[True]         --  6, 17 bytes
length.show$Left()        --  7, 18 bytes
length.show$Right()       --  8, 19 bytes
length$show[Just[]]       --  9, 19 bytes
length$show[LT ..]        -- 10, 18 bytes
fromEnum.succ.last$show() -- 42, 25 bytes

LT,EQ and GT are the values of the Ordering Type. As Ordering is an instance of Enum, fromEnum GT yields 2 and [LT ..] creates the list [LT,EQ,GT]. show converts all instances of the Show type class to strings.

Bonus:

42 in 42 bytes: length.show$Just$[LT ..]>>[EQ,GT]>>[GT,LT]

How long is nothing? length Nothing

Saved 3 bytes thanks to nimi and 3 bytes thanks to xnor.


问:
Highlight the Bounding Box, Part I: Cartesian Grid
You're given a rectangular grid of the characters . and #, like this:

```<code>..........
..#.......
....#..#..
...#......
..........
</code>```

Your task is to fill the entire axis-aligned bounding box of the # with further #:

```<code>..........
..######..
..######..
..######..
..........
</code>```

The axis-aligned bounding box is the smallest rectangle which contains all the #.

Want more? Try Part II!

Rules

You may use any two distinct printable ASCII characters (0x20 to 0x7E, inclusive), in place of # and .. I'll continue referring to them as # and . for the remainder of the specification though.

Input and output may either be a single linefeed-separated string or a list of strings (one for each line), but the format has to be consistent.

You may assume that the input contains at least one # and all lines are the same length.

You may write a program or a function and use any of the our standard methods of receiving input and providing output.

You may use any programming language, but note that these loopholes are forbidden by default.

This is code-golf, so the shortest valid answer – measured in bytes – wins.

Test Cases

Each test case has input and output next to each other.

```<code>#    #

...    ...
#..    #..
...    ...

...    ...
#..    ###
..#    ###

.#.    ###
#..    ###
..#    ###

.....    .....
.#.#.    .###.
.....    .....

...    ...
.#.    .#.
...    .#.
.#.    .#.
...    ...

..........    ..........
..........    ..........
....#.....    ....#.....
..........    ..........

..........    ..........
..........    ..........
....#.....    ...##.....
...#......    ...##.....

..........    ..........
..#.......    ..###.....
....#.....    ..###.....
...#......    ..###.....

..........    ..........
..#.......    ..######..
....#..#..    ..######..
...#......    ..######..

.........#    ..########
..#.......    ..########
....#..#..    ..########
...#......    ..########
</code>```

答:
Perl 6, 62 bytes

```<code>{.[.grep(/a/,:k).minmax;$_».grep('a',:k).flat.minmax]='a'xx*}
</code>```

An anonymous routine that can be passed an array of arrays of characters (representing the matrix) as argument, and modifies it in-place so that the calling scope has the modified array afterwards.

Uses a instead of # as the "on" character. The "off" character can be anything, it doesn't care.

Body:
Perl 6, 62 bytes

{.[.grep(/a/,:k).minmax;$_».grep('a',:k).flat.minmax]='a'xx*}

An anonymous routine that can be passed an array of arrays of characters (representing the matrix) as argument, and modifies it in-place so that the calling scope has the modified array afterwards.

Uses a instead of # as the "on" character. The "off" character can be anything, it doesn't care.


答:
Perl6 (<s>117</s> 112) no state

```<code>e-e
e/e
e.floor
e.round
pi.ceiling
floor e+e
tau.floor
tau.ceiling
floor pi*e
floor pi*pi
round pi*pi
tau.floor*tau.ceiling
</code>```

Title: No strings (or numbers) attached

Body:
If you like this, consider participating in:

The Official Dyalog APL 2016 Year Game

The monthly Dyalog APL 2017 Code Golf Challenge

Make 12 snippets/expressions, in the same language, that result in the numbers 0 through 10, and 42 respectively, but without writing any literal numeric, string, or character data.

Build-in data, like PI() and ALPHABET(), are fine, and so are e.g. CJam's U, X, Y, Z, and A constants, and Processing's BLEND, CHORD, CENTER, BREAK, and  LINES.

Every snippet must be able to stand on its own, i.e. they may not be interdependent. However, inside a single snippet, you may assign a variable and use it freely, as long as you refer to it directly by name, and not through a string containing its name.

All the snippets must be valid on the submitter’s computer at the time of submission (as reported by SE), but may not rely on unusual local conditions like number of files in a directory, the exact date or time, or specific input from the user.

Examples of valid snippets

3: INT(LOG10(YEAR(TODAY())))   because it remains true in the foreseeable future

4: CUBICROOT(LEN(CHARACTERSET()))   because a 256 letter character set is very common

8: SQRT(SYSTEMTYPE())   because 64-bit systems are very common

Examples of invalid snippets

5: LEN(USERNAME())   because most people do not use “Admin” as login :-)

9: LOG10(SYSTEMMEMORY())   because it only works on systems with exactly 1 GB of memory

42: CODE("*")   because it contains a string/character literal

The result of each snippet must result in an actual number (value, int, float, etc.) that can be used for further calculations using the same language as the snippet, i.e not a text string representing that number.

Only character based languages allowed.

Score is total byte count of all the 12 snippets combined. Newlines separating the snippets are not counted in.

Note that the above rules may prevent some languages from participating, even if they are Turing complete.

FAQ

Q Can the programs accept any input?

A Yes, but you may not just ask for input and enter the relevant number.

Q Are physical digits (non-data) digits allowed?

A Yes, e.g. LOG10().

Q Do Symbols in Ruby count as literals?

A Yes.

Q Does score include newlines between each snippet?

A No.

Q Is TI-BASIC "character based" enough to be valid?

A Yes.

Q Do false and true count as number literals?

A No, they are acceptable.

Q Can we use a number literal to call a function if that's the only way and the number doesn't influence the output of the function?

A Yes, if that is the normal way to write code in your language.

Q My language assumes there is a [something] at the start of each program/expression. Must I include it, or should my snippets just work if placed in the middle of a program/expression?

A They should just work in the middle of a program/expression.

Q What about regex literals?

A Forbidden, except for languages that only do regexes.

Q Is one piece of code that could print all the specified numbers acceptable?

A No, they have to be separate and mutually independent.

Q May I assume a boilerplate like int main() {}... or equivalent?

A Yes.

Q What output datatypes are allowed?

A Any numeric datatype, like int, float, etc.

Q Do I need to print the result of each snippet?

A No, making the result available for subsequent use is enough.

Q Are pre-set variables allowed?

A Yes, and they become reset (if changed) for every snippet.

Q Are π and e considered number literals?

A No, you may use them.

Q May I return 4 and 2 in different cells for 42?

A No, they must be connected as one number.

Q Bytes or characters?

A Bytes, but you may choose any desired codepage.

Q May constant functions and preset variables like J's 9:, Actually's 9, and Pretzel's 9 be used?

A Yes, if the vocabulary is finite (19 for J, 10 for Actually and Pretzel).

Body:
Perl6 (<s>117</s> 112) no state

e-e
e/e
e.floor
e.round
pi.ceiling
floor e+e
tau.floor
tau.ceiling
floor pi*e
floor pi*pi
round pi*pi
tau.floor*tau.ceiling


问:
Enterprise Quality Code Prime Sieve

Enterprise Quality Code!

TL;DR

Answers will consist of a full program (of length < 30k) prints the the first N Prime numbers (as a base 10 representation without leading zeros unless the chosen language only supports unary or other based output) separated by newlines (optional trailing linefeed).

You may post cracks at any time, but you must wait one hour after posting each initial bowled submission

Leading or trailing whitespace is not acceptable (except for the trailing newline)

An answer's score is the number of bytes in the answer. A user's score is the total number of bytes of all uncracked answers.

An answer gets cracked when another user posts an answer (in the same language) which is a permutation of any subset of the characters used in the original answer.

The user with the highest score will receive an accepted tick mark on his /her highest scoring post (although it doesnt really matter which specific post gets the tick)

The Inspiration for this challenge

At Pretty Good consultants there is a focus on writing "quality" verbose code that is sufficiently engineered. Your boss has decided to test you on your skills.

Consider the set of all programming languages in existence before the posting of this challenge. For this challenge there will technically be one individual "winner" in each language, however the boss will give a <s>promotion</s> accepted tick mark to only one answer based on your score.

Detailed Spec

The goal of this challenge is to receive an integer N strictly smaller than 2^8-1 and print the first N prime numbers (in less than 24 hours) separated by your platforms choice of new line (a trailing newline is optional). OEIS sequence A000040 in as many bytes as possible in as many languages as possible. However, note that others vying for the promotion will try to "help" you by golfing down your score. (Please note that your prime generation function should theoretically work for integer N inputs strictly smaller than 2^16-1 given enough time, the bounds for N have been reduced after realizing how slow some interpreters are (namely mine) hardcoding the list of primes is strictly forbidden)

Sample output for an input 11

```
2
3
5
7
11
13
17
19
23
29
31
```

How to participate

Pick any language X, but please avoid selecting a language which is just another version or derivative of another answer.
If there is no existing answer in language X than you will write a program (which must fit into a single post I.E it must be less than 30k characters) that solves this challenge.
The length in bytes of the source (in any reasonable preexisting textual encoding) will be added to your score. You must avoid using any unnecessary characters for reasons that will soon become apparent.

If language X already has been used to answer this question, then you must answer using any permutation of any proper subset of the characters used in the shortest answer (I.E take the shortest X answer and remove some (>=1) characters and optionally rearrange the resulting code). The previous holder of the shortest X answer will lose all of the bytes provided by his answer from his score, and the number of bytes of your submission will now be added to your score. The number of bytes golfed off gets "lost" forever.

Rules for Languages

You may only crack a submission by posting an answer in the same language (and version), but you are barred from posting an answer in language X if there exists a submission in a sufficiently similar language Y. Please do not abuse this rule posting an answer in a sufficiently similar language will receive disqualification.

Below is a leader board which removes answers with "cracked" (with any case) in their header.

var QUESTION_ID=90593,OVERRIDE_USER=46918;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 a-r});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<>]+>)^(?:(?!cracked)\i.)*[^\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

```

答:
C#, 27573 bytes - cracked!

Cracks Jonathan Allan's answer by 18 characters, namely: 00ijjfff++==;;;;().

static void Main(){int n=int.Parse(System.Console.ReadLine()),v=30*"
    ... 27387 '[' characters ...
".Length,c=0,p=0,f,j;while(c<n){j=f=0;while(++j<v)if(p%j==0)f++;f--;if(--f==0){System.Console.WriteLine(p);c++;}p++;}}
```

Test it on ideone!

The characters are saved as follows:

j=0;j++;f=0; is rearranged to j=f=0;j++, giving 0; (2 saved)

j++;while(j<v){if(p%j==0)f++;j++;} is rearranged to while(++j<v)if(p%j==0)f++;, taking both the j++s into the while statement, making it one statement, which allow me to remove the {}. This step gives me j;j++; (6 + 2 = 8 saved), leaving the {} for later use.

The two sequential  if(f==0) statements are merged with the remaining {}, giving a full if(f==0) (8 + 8 = 16 saved).

f--;if(f==0) is changed to if(--f==0), giving the last f; (2 + 16 = 18 saved).

Title: Enterprise Quality Code Prime Sieve

Body:
C#, 27573 bytes - cracked!

Cracks Jonathan Allan's answer by 18 characters, namely: 00ijjfff++==;;;;().

static void Main(){int n=int.Parse(System.Console.ReadLine()),v=30*"
    ... 27387 '[' characters ...
".Length,c=0,p=0,f,j;while(c<n){j=f=0;while(++j<v)if(p%j==0)f++;f--;if(--f==0){System.Console.WriteLine(p);c++;}p++;}}

Test it on ideone!

The characters are saved as follows:

j=0;j++;f=0; is rearranged to j=f=0;j++, giving 0; (2 saved)

j++;while(j<v){if(p%j==0)f++;j++;} is rearranged to while(++j<v)if(p%j==0)f++;, taking both the j++s into the while statement, making it one statement, which allow me to remove the {}. This step gives me j;j++; (6 + 2 = 8 saved), leaving the {} for later use.

The two sequential  if(f==0) statements are merged with the remaining {}, giving a full if(f==0) (8 + 8 = 16 saved).

f--;if(f==0) is changed to if(--f==0), giving the last f; (2 + 16 = 18 saved).

ContentLicense: CC BY-SA 4.0


Title: Variable Prime "Twins"

Body:
I am 2/3 twins with my brother, i.e. born on the same day of the same month but twelve years later. When I was 5, he was 17, both primes; the last pair of ages we can reasonably count on is [71, 83] with both of us being alive and able to celebrate this coincidental jubilee.

Task

Create a code that

takes two integers as input: the difference between the counter and the "twin" as a positive integer k (well yes, I'm the younger) and the upper bound as a positive integer u (runtime consideration)

and gives output as an array or list of all i numbers lower than or equal u for which both i and i+k are primes. The output does not need to be sorted.

Test Cases

```<code>12, 1000 -> [5, 7, 11, 17, 19, 29, 31, 41, 47, 59, 61, 67, 71, 89, 97, 101, 127, 137, 139, 151, 167, 179, 181, 199, 211, 227, 229, 239, 251, 257, 269, 271, 281, 337, 347, 367, 389, 397, 409, 419, 421, 431, 449, 467, 479, 487, 491, 509, 557, 587, 601, 607, 619, 631, 641, 647, 661, 727, 739, 757, 761, 797, 809, 811, 827, 907, 929, 941, 971, 997]
2, 999 -> [3, 5, 11, 17, 29, 41, 59, 71, 101, 107, 137, 149, 179, 191, 197, 227, 239, 269, 281, 311, 347, 419, 431, 461, 521, 569, 599, 617, 641, 659, 809, 821, 827, 857, 881]
3, 1500 -> [2]
30, 1500 -> [7, 11, 13, 17, 23, 29, 31, 37, 41, 43, 53, 59, 67, 71, 73, 79, 83, 97, 101, 107, 109, 127, 137, 149, 151, 163, 167, 181, 193, 197, 199, 211, 227, 233, 239, 241, 251, 263, 277, 281, 283, 307, 317, 337, 349, 353, 359, 367, 379, 389, 401, 409, 419, 431, 433, 449, 457, 461, 479, 491, 541, 547, 557, 563, 569, 571, 577, 587, 601, 613, 617, 631, 643, 647, 653, 661, 709, 727, 739, 743, 757, 797, 809, 823, 827, 829, 853, 857, 877, 881, 907, 911, 937, 941, 947, 953, 967, 983, 991, 1009, 1019, 1021, 1031, 1033, 1039, 1061, 1063, 1087, 1093, 1123, 1151, 1163, 1171, 1187, 1193, 1201, 1229, 1249, 1259, 1277, 1289, 1291, 1297, 1399, 1409, 1423, 1429, 1451, 1453, 1459, 1481, 1493]
</code>```

Edit

Since I failed to specify the upper bound, both inclusive and exclusive solutions are welcome.

Edit No. 2

The challenge ends on 1st September, one week from the start.

Looks like we have a winner but in case of a tie popularity is the tie-breaker; in this case the "second" will be compensated via bounty.

Body:
Javascript (ES6), <s>90</s> <s>83</s> <s>80</s> 75 bytes

(k,u)=>(r=n=>n++<u+k?r(P[P.every(i=>n%i)*n]=n):P.filter(n=>P[n+k]))(1,P=[])

Example:

let F =
(k,u)=>(r=n=>n++<u+k?r(P[P.every(i=>n%i)*n]=n):P.filter(n=>P[n+k]))(1,P=[])

console.log(F(2, 999))


问:
Non-palindromic numbers
A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2).  These numbers are listed on OEIS

For example, the number 19 in base 2,3,4,5,6,...17 is: 10011,201,103,34,31,...12.  None of these representations is palindromic, so the number is strictly non-palindromic.

For this challenge, you need to return a truthy value if the number is non-palindromic, otherwise a falsy value.

You may assume the number passed to you is greater than or equal to 0.

Your program should work for values up to your languages' integer size.

Test cases:

Truthy:

```<code>0
1
2
3
4
6
11
19
47
53
79
103
389
997
1459
</code>```

Falsy:

```<code>5
7
8
9
10
13
16
43
48
61
62
101
113
211
1361
</code>```

This is a code-golf, so make your answers as short as possible!

答:
Perl6, <s>110</s> <s>72</s> 65

```<code>my &f={?all(map {{.reverse ne$_}(@(.polymod: $^a xx*))},2..$_-2)}
</code>```

Couldn't use base since that's broken for any base above 36.

Previous attempts

```<code>my &a={$^a??flat($a%$^b,a($a div$b,$b))!!()};my &f=-> $n {?all(map {.reverse ne$_ given @(a($n,$_))},2..$n-2)}
my &f=->\n {?all(map {.reverse ne$_ given @(n.polymod: $_ xx*)},2..n-2)}
</code>```

Title: Non-palindromic numbers

Body:
Perl6, <s>110</s> <s>72</s> 65

my &f={?all(map {{.reverse ne$_}(@(.polymod: $^a xx*))},2..$_-2)}

Couldn't use base since that's broken for any base above 36.

Previous attempts

my &a={$^a??flat($a%$^b,a($a div$b,$b))!!()};my &f=-> $n {?all(map {.reverse ne$_ given @(a($n,$_))},2..$n-2)}
my &f=->\n {?all(map {.reverse ne$_ given @(n.polymod: $_ xx*)},2..n-2)}


答:
Pyth, <s>12</s> 10 bytes

Saved two bytes with Dennis' trick.

```<code>>3sm_IjQdS
</code>```

Try it online!

Explanation:

```<code>         S (Q)   Get all the bases we need by building a list from 1 to Q
   m               For all bases d in the bases list:
      jQd           cast Q to base d as a list
    _I              and check to see if the list is palindromic (invariant on reversal)
                  Compile all the results back into a list
  s                Sum the results (a shorter form of any), gives 3 or more for palindromics
                    (2 is the usual because of bases 1 and Q-1)
>3                 And verify that the sum is greater than three to get non-palindromics
</code>```

Title: Non-palindromic numbers

Body:
A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2).  These numbers are listed on OEIS

For example, the number 19 in base 2,3,4,5,6,...17 is: 10011,201,103,34,31,...12.  None of these representations is palindromic, so the number is strictly non-palindromic.

For this challenge, you need to return a truthy value if the number is non-palindromic, otherwise a falsy value.

You may assume the number passed to you is greater than or equal to 0.

Your program should work for values up to your languages' integer size.

Test cases:

Truthy:

```<code>0
1
2
3
4
6
11
19
47
53
79
103
389
997
1459
</code>```

Falsy:

```<code>5
7
8
9
10
13
16
43
48
61
62
101
113
211
1361
</code>```

This is a code-golf, so make your answers as short as possible!

Body:
Pyth, <s>12</s> 10 bytes

Saved two bytes with Dennis' trick.

>3sm_IjQdS

Try it online!

Explanation:

         S (Q)   Get all the bases we need by building a list from 1 to Q
   m               For all bases d in the bases list:
      jQd           cast Q to base d as a list
    _I              and check to see if the list is palindromic (invariant on reversal)
                  Compile all the results back into a list
  s                Sum the results (a shorter form of any), gives 3 or more for palindromics
                    (2 is the usual because of bases 1 and Q-1)
>3                 And verify that the sum is greater than three to get non-palindromics


问:
Creating a Crossed Square

Creating a Crossed Square

You are to take input of an integer of one or more and output a square made of any printable character of your choice with a diagonal cross through the centre.

The general idea is for the output to be a hollow square that has a diagonal cross through it.:

```<code>Input: 7
Output:
*******
*#   #*
* # # *
*  #  *
* # # *
*#   #*
*******
</code>```

In the above example the '*'s represent the outer box and the '#'s represent the diagonal cross.

Note that the above example uses two different characters so that it is easier to see what the output looks like, your program should use one character only.

Input

An integer of 1 or more, it is guaranteed to be odd.

Output

A square that is made up of a character of your choice with a cross through the middle.

The cross must be diagonal

The square may be output via the function or written to output

Trailing newlines are okay

Can output as a graphic, diagram or image if you wish too

Examples

```<code>Input: 1
Output:
*

Input: 3
Output:
***
***
***

Input: 5
Output:
*****
** **
* * *
** **
*****

Input: 7
Output:
*******
**   **
* * * *
*  *  *
* * * *
**   **
*******
</code>```

Specs

Functions or full programs are allowed

You can get input by your preferred means

Standard loopholes are disallowed

Programs must work without any additional statements i.e. usings in C#, they must be included in the entry

You can output from a function or print the result

This is code golf so the shortest solution wins.

答:
Python 2, 83 bytes

i=n=input()
while i:l=['* '[1<i<n]]*n;i-=1;l[0]=l[~0]=l[i]=l[~i]='*';print`l`[2::5]
```

Modifies a list of the row's characters to put a * into the first, last, i'th, and i'th-to-last place. The first and last row start as all *, and the rest as all spaces. Works for evens too. A lambda expression is probably shorter than modification, but I like this method.

Title: Creating a Crossed Square

Body:
Python 2, 83 bytes

i=n=input()
while i:l=['* '[1<i<n]]*n;i-=1;l[0]=l[~0]=l[i]=l[~i]='*';print`l`[2::5]

Modifies a list of the row's characters to put a * into the first, last, i'th, and i'th-to-last place. The first and last row start as all *, and the rest as all spaces. Works for evens too. A lambda expression is probably shorter than modification, but I like this method.


答:
MATLAB/Octave

For the purpose of demonstrating built-ins only:

```<code>octave:1> corr(X,Y)
ans =  0.76909
octave:2>
</code>```

Title: Calculate the correlation coefficient

Body:
Given a series of numbers for events X and Y, calculate Pearson's correlation coefficient. The probability of each event is equal, so expected values can be calculated by simply summing each series and dividing by the number of trials.

Input

```<code>1   6.86
2   5.92
3   6.08
4   8.34
5   8.7
6   8.16
7   8.22
8   7.68
9   12.04
10  8.6
11  10.96
</code>```

Output

```<code>0.769
</code>```

Shortest code wins. Input can be by stdin or arg. Output will be by stdout.

Edit: Builtin functions should not be allowed (ie calculated expected value, variance, deviation, etc) to allow more diversity in solutions. However, feel free to demonstrate a language that is well suited for the task using builtins (for exhibition).

Based on David's idea for input for Mathematica (86 char using builtin mean)

```<code>m=Mean;x=d[[All,1]];y=d[[All,2]];(m@(x*y)-m@x*m@y)/Sqrt[(m@(x^2)-m@x^2)(m@(y^2)-m@y^2)]

m = Mean;
x = d[[All,1]];
y = d[[All,2]];
(m@(x*y) - m@x*m@y)/((m@(x^2) - m@x^2)(m@(y^2) - m@y^2))^.5
</code>```

Skirting by using our own mean (101 char)

```<code>m=Total[#]/Length[#]&;x=d[[All,1]];y=d[[All,2]];(m@(x*y)-m@x*m@y)/((m@(x^2)-m@x^2)(m@(y^2)-m@y^2))^.5

m = Total[#]/Length[#]&;
x = d[[All,1]];
y = d[[All,2]];
(m@(x*y)-m@x*m@y)/((m@(x^2)-m@x^2)(m@(y^2)-m@y^2))^.5
</code>```

Body:
MATLAB/Octave

For the purpose of demonstrating built-ins only:

octave:1> corr(X,Y)
ans =  0.76909
octave:2>


答:
JavaScript (ES6), 83 bytes

f=(n,i=n-2,g=n=>ni<2||`${a=g(n)}`!=a.reverse()&&f(n,i-1)```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type=number oninput=o.textContent=f(this.value);><pre id=o></code>```

Title: Non-palindromic numbers

Body:
JavaScript (ES6), 83 bytes

f=(n,i=n-2,g=n=>n<i?[n]:[...g(n/i|0),n%i])=>i<2||`${a=g(n)}`!=a.reverse()&&f(n,i-1)

<input type=number oninput=o.textContent=f(this.value);><pre id=o>


答:
Python 2, 65 bytes

i=n=2**input()/2
while i:print bin((n>i>1or~-n)|n|i|n/i)[2:];i/=2
```
<p>Uses Jonathan Allan's idea of outputting binary numbers like:</p>
```11111
11011
10101
11011
11111
```

The rows are created with bit arithmetic and displayed in binary. Each part it or'ed into the rest. The part are are produced by powers of 2 n (fixed) and i (falling) via

Left side 1

Right side n

Diagonals i and n/i

Top and bottom by n-1 when i==1 or i==n.

Actually, (1) and (4) are combined by producing 1 when 1<i<n and n-1 otherwise.

Title: Creating a Crossed Square

Body:
Creating a Crossed Square

You are to take input of an integer of one or more and output a square made of any printable character of your choice with a diagonal cross through the centre.

The general idea is for the output to be a hollow square that has a diagonal cross through it.:

```<code>Input: 7
Output:
*******
*#   #*
* # # *
*  #  *
* # # *
*#   #*
*******
</code>```

In the above example the '*'s represent the outer box and the '#'s represent the diagonal cross.

Note that the above example uses two different characters so that it is easier to see what the output looks like, your program should use one character only.

Input

An integer of 1 or more, it is guaranteed to be odd.

Output

A square that is made up of a character of your choice with a cross through the middle.

The cross must be diagonal

The square may be output via the function or written to output

Trailing newlines are okay

Can output as a graphic, diagram or image if you wish too

Examples

```<code>Input: 1
Output:
*

Input: 3
Output:
***
***
***

Input: 5
Output:
*****
** **
* * *
** **
*****

Input: 7
Output:
*******
**   **
* * * *
*  *  *
* * * *
**   **
*******
</code>```

Specs

Functions or full programs are allowed

You can get input by your preferred means

Standard loopholes are disallowed

Programs must work without any additional statements i.e. usings in C#, they must be included in the entry

You can output from a function or print the result

This is code golf so the shortest solution wins.

Body:
Python 2, 65 bytes

i=n=2**input()/2
while i:print bin((n>i>1or~-n)|n|i|n/i)[2:];i/=2

Uses Jonathan Allan's idea of outputting binary numbers like:

11111
11011
10101
11011
11111

The rows are created with bit arithmetic and displayed in binary. Each part it or'ed into the rest. The part are are produced by powers of 2 n (fixed) and i (falling) via

Left side 1

Right side n

Diagonals i and n/i

Top and bottom by n-1 when i==1 or i==n.

Actually, (1) and (4) are combined by producing 1 when 1<i<n and n-1 otherwise.


答:
05AB1E, <s>40</s> <s>38</s> 24 bytes

```<code>¾
X
Y
XÌ
Y·
T;
T;>
T;Ì
TÍ
T<
T
žwT+
</code>```

Push counter_variable

Push 1

Push 2

Push 1+2

Push 2*2

Push 10/2

Push (10/2)+1

Push (10/2)+2

Push 10-2

Push 10-1

Push 10

Push 32, 10, add

Title: No strings (or numbers) attached

Body:
05AB1E, <s>40</s> <s>38</s> 24 bytes

¾
X
Y
XÌ
Y·
T;
T;>
T;Ì
TÍ
T<
T
žwT+

Push counter_variable

Push 1

Push 2

Push 1+2

Push 2*2

Push 10/2

Push (10/2)+1

Push (10/2)+2

Push 10-2

Push 10-1

Push 10

Push 32, 10, add


问:
Smallest palindrome divisible by the input
Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by N.

The palindrome (i.e. the output) must not need a leading zero to be a palindrome, e.g. 080 is not the valid answer for 16.

The input will never be a multiple of 10, because of the previous reason.

Your program may take as much time as necessary, even if in practice it would be way too long to output the answer.

Inputs and outputs

You may take the input through STDIN, as a function argument, or anything similar.

You may print the output to STDOUT, return it from a function, or anything similar.

Inputs and outputs must be in the decimal base.

Test cases

```<code>N        Output
1        1
2        2
16       272
17       272
42       252
111      111
302      87278
1234     28382
</code>```

Scoring

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

答:
Perl 6, 35 bytes

->\N{first {$_%%N&&$_==.flip},N..*}
```

<pre class="lang-perl6 prettyprint-override"><code>->\N{first {$_==.flip},(N,N*2...*)}
</code>```

->\N{(N,N*2...*).first:{$_==.flip}}
```

<h2>Explanation:</h2>

<pre class="lang-perl6 prettyprint-override"><code>-> \N {
  # from a list of all multiples of the input
  # ( deduced sequence )
  ( N, N * 2 ... * )

  # find the first
  .first:

  # that is a palindrome
  { $_ == .flip }
}
</code>```

Body:
Perl 6, 35 bytes

->\N{first {$_%%N&&$_==.flip},N..*}

->\N{first {$_==.flip},(N,N*2...*)}

->\N{(N,N*2...*).first:{$_==.flip}}

Explanation:

-> \N {
  # from a list of all multiples of the input
  # ( deduced sequence )
  ( N, N * 2 ... * )

  # find the first
  .first:

  # that is a palindrome
  { $_ == .flip }
}


答:
Jelly, 12 bytes

```<code>¹µ+³ßµDU⁼Dµ?
</code>```

Try it online!

Explanation:

This link takes 1 argument. The µs split it into 4 parts. Starting from the last and moving left:

```<code>           ? The three parts in front of this are the if, else, and
             condition of a ternary expression.
      DU⁼D  This condition takes a number n as an argument. It converts
            n to an array of decimal digits, reverses that array, and
            then compares the reversed array to the decimalization of
            n (ie is n palindromic in decimal?)
  +³ß  This is the else. It adds the original input argument to n
       and then repeats the link with the new value of n.
¹  This is the if. It returns the value passed to it.
</code>```

Title: Smallest palindrome divisible by the input

Body:
Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by N.

The palindrome (i.e. the output) must not need a leading zero to be a palindrome, e.g. 080 is not the valid answer for 16.

The input will never be a multiple of 10, because of the previous reason.

Your program may take as much time as necessary, even if in practice it would be way too long to output the answer.

Inputs and outputs

You may take the input through STDIN, as a function argument, or anything similar.

You may print the output to STDOUT, return it from a function, or anything similar.

Inputs and outputs must be in the decimal base.

Test cases

```<code>N        Output
1        1
2        2
16       272
17       272
42       252
111      111
302      87278
1234     28382
</code>```

Scoring

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

Body:
Jelly, 12 bytes

¹µ+³ßµDU⁼Dµ?

Try it online!

Explanation:

This link takes 1 argument. The µs split it into 4 parts. Starting from the last and moving left:

           ? The three parts in front of this are the if, else, and
             condition of a ternary expression.
      DU⁼D  This condition takes a number n as an argument. It converts
            n to an array of decimal digits, reverses that array, and
            then compares the reversed array to the decimalization of
            n (ie is n palindromic in decimal?)
  +³ß  This is the else. It adds the original input argument to n
       and then repeats the link with the new value of n.
¹  This is the if. It returns the value passed to it.


答:
Perl 6, <s> 39 </s> 37 bytes

->\k,\u{grep {($_&$_+k).is-prime},2..u}
```

<pre class="lang-perl6 prettyprint-override"><code>->\k,\u{grep {($_&$_+k).is-prime},^u}
</code>```

Explanation:

-> \k, \u {

  # find all the values
  grep

  # where
  {
    # ｢all｣ junction of the two values
    ( $_   &   $_ + k ) # ｢ all( $_, $_ + k ) ｣

    # autothread a method call against the junction
    .is-prime
  },

  # from the values up to (and excluding) ｢u｣
  ^ u # short for ｢ 0 ..^ u ｣
  # for inclusive use ｢ 2 .. u ｣

}
```

Title: Variable Prime "Twins"

Body:
Perl 6, <s> 39 </s> 37 bytes

->\k,\u{grep {($_&$_+k).is-prime},2..u}

->\k,\u{grep {($_&$_+k).is-prime},^u}

Explanation:

-> \k, \u {

  # find all the values
  grep

  # where
  {
    # ｢all｣ junction of the two values
    ( $_   &   $_ + k ) # ｢ all( $_, $_ + k ) ｣

    # autothread a method call against the junction
    .is-prime
  },

  # from the values up to (and excluding) ｢u｣
  ^ u # short for ｢ 0 ..^ u ｣
  # for inclusive use ｢ 2 .. u ｣

}


问:
The Letter A without A
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.

Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+0061 or unicode U+0041. Other character encodings that aren't Unicode are allowed, but either way, the resulting output of your code must be the latin letter "A", and not any lookalikes or homoglyphs)

You must not use any of the below characters in your code, regardless of the character encoding that you pick:

"A", whether uppercase or lowercase.

"U", whether lowercase or uppercase.

X, whether uppercase or lowercase.

+

&

#

0

1

4

5

6

7

9

Cheating, loopholes, etc, are not allowed.

Since this is code-golf, the shortest solution, in bytes, that follows all the rules, is the winner.

Validity Checker

This Stack Snippet checks to make sure your code doesn't use the restricted characters. It might not work properly for some character encodings.

var t = prompt("Input your code.");

if (/[AaUuXx+&#0145679]/.test(t)) {
  alert("Contains a disallowed character!");
} else {
  alert("No disallowed characters");
}```
</div>
</div>
</p>

<p><em>This Stack Snippet that makes sure you don't have a disallowed character is also available on JSFiddle.</em></p>

<h3>Leaderboard</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=90349,OVERRIDE_USER=58717;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="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});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;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>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;</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}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

答:
Game Maker Language, 26 bytes

So lucky that the command is chr() instead of char()...

```<code>get_string('',chr(33*3-2))
</code>```

Basically, we have to get chr(65) or chr(97) to get A or a. Also, I had to use get_string to show the output since return, show_message, show_question, etc. all contained restricted characters.

Title: The Letter A without A

Body:
Game Maker Language, 26 bytes

So lucky that the command is chr() instead of char()...

get_string('',chr(33*3-2))

Basically, we have to get chr(65) or chr(97) to get A or a. Also, I had to use get_string to show the output since return, show_message, show_question, etc. all contained restricted characters.


问:
Exploded view of a string
Don't you love those exploded-view diagrams  in which a machine or object is taken apart into its smallest pieces?

Let's do that to a string!

The challenge

Write a program or function that

inputs a string containing only printable ASCII characters;

dissects the string into groups of non-space equal characters (the "pieces" of the string);

outputs those groups in any convenient format, with some separator between groups.

For example, given the string

```<code>Ah, abracadabra!
</code>```

the output would be the following groups:

```
!
,
A
aaaaa
bb
c
d
h
rr
```

Each group in the output contains equal characters, with spaces removed. A newline has been used as separator between groups. More about allowed formats below.

Rules

The input should be a string or an array of chars. It will only contain printable ASCII chars (the inclusive range from space to tilde). If your language does not support that, you can take the input in the form of numbers representing ASCII codes.

You can assume that the input contains at least one non-space character.

The output should consist of characters (even if the input is by means of ASCII codes). There has to be an unambiguous separator between groups, different than any non-space character that may appear in the input.

If the output is via function return, it may also be an array or strings, or an array of arrays of chars, or similar structure. In that case the structure provides the necessary separation.

A separator between characters of each group is optional. If there is one, the same rule applies: it can't be a non-space character that may appear in the input. Also, it can't be the same separator as used between groups.

Other than that, the format is flexible. Here are some examples:

The groups may be strings separated by newlines, as shown above.

The groups may be separated by any non-ASCII character, such as  ¬. The output for the above input would be the string:

```<code>!¬,¬A¬aaaaa¬bb¬c¬d¬h¬rr
</code>```

The groups may be separated by n>1 spaces (even if n is variable), with chars between each group separated by a single space:

```<code>!  ,    A   a a a a a    b b  c       d   h  r r
</code>```

The output may also be an array or list of strings returned by a function:

```<code>['!', 'A', 'aaaaa', 'bb', 'c', 'd', 'h', 'rr']
</code>```

Or an array of char arrays:

```<code>[['!'], ['A'], ['a', 'a', 'a', 'a', 'a'], ['b', 'b'], ['c'], ['d'], ['h'], ['r', 'r']]
</code>```

Examples of formats that are not allowed, according to the rules:

A comma can't be used as separator (!,,,A,a,a,a,a,a,b,b,c,d,h,r,r), because the input may contain commas.

It's not accepted to drop the separator between groups (!,Aaaaaabbcdhrr) or to use the same separator between groups and within groups (! , A a a a a a b b c d h r r).

The groups may appear in any order in the output. For example: alphabetical order (as in the examples above), order of first appearance in the string, ... The order need not be consistent or even deterministic.

Note that the input cannot contain newline characters, and A and a are different characters (grouping is case-sentitive).

Shortest code in bytes wins.

Test cases

In each test case, first line is input, and the remaining lines are the output, with each group in a different line.

Test case 1:

```
Ah, abracadabra!
!
,
A
aaaaa
bb
c
d
h
rr
```

Test case 2:

```
\o/\o/\o/
///
\\\
ooo
```

Test case 3:

```
A man, a plan, a canal: Panama!
!
,,
:
A
P
aaaaaaaaa
c
ll
mm
nnnn
p
```

Test case 4:

```
"Show me how you do that trick, the one that makes me scream" she said
""
,
S
aaaaa
cc
dd
eeeeeee
hhhhhh
ii
kk
mmmm
n
ooooo
rr
ssss
tttttt
u
ww
y
```

答:
ARM machine code on Linux, 60 bytes

Hex Dump:

```<code>b590 4c0d f810 2b01 b11a 58a3 3301 50a3 e7f8 6222 2704 2001 f1ad 0101 2201 237f 5ce5 b135 700b df00 3d01 d8fc 250a 700d df00 3b01 d8f4 bd90 000200bc
</code>```

This function basically creates an array of size 128, and whenever it reads a character from the input string it increment's the value at that characters position. Then it goes back through the array and prints each character array[character] times.

Ungolfed Assembly (GNU syntax):

```<code>.syntax unified
.bss @bss is zero-initialized data (doesn't impact code size)
countArray:
    .skip 128 @countArray[x] is the number of occurances of x

.text
.global expStr
.thumb_func
expstr:
    @Input: r0 - a NUL-terminated string.
    @Output: Groups of characters to STDOUT
    push {r4,r7,lr}
    ldr r4,=countArray @Load countArray into r4
    readLoop:
        ldrb r2,[r0],#1 @r2=*r0++
        cbz r2,endReadLoop @If r2==NUL, break
        ldr r3,[r4,r2] @r3=r4[r2]
        adds r3,r3,#1 @r3+=1
        str r3,[r4,r2] @r4[r2]=r3
        b readLoop @while (true)
    endReadLoop:
    @Now countArray[x] is the number of occurances of x.
    @Also, r2 is zero
    str r2,[r4,#' ] @'<character> means the value of <character>
    @What that just did was set the number of spaces found to zero.
    movs r7,#4 @4 is the system call for write
    movs r0,#1 @1 is stdout
    sub r1,sp,#1 @Allocate 1 byte on the stack
    @Also r1 is the char* used for write
    movs r2,#1 @We will print 1 character at a time
    movs r3,#127 @Loop through all the characters
    writeLoop:
        ldrb r5,[r4,r3] @r5=countArray[r3]
        cbz r5,endCharacterLoop @If we're not printing anything, go past the loop
        strb r3,[r1] @We're going to print byte r3, so we store it at *r0
        characterLoop:
            swi #0 @Make system call
            @Return value of write is number of characters printed in r0
            @Since we're printing one character, it should just return 1, which
            @means r0 didn't change.
            subs r5,r5,#1
            bhi characterLoop
        @If we're here then we're done printing our group of characters
        @Thus we just need to print a newline.
        movs r5,#10 @r5='\n' (reusing r5 since we're done using it as a loop counter
        strb r5,[r1]
        swi #0 @Print the character

        endCharacterLoop:
        subs r3,r3,#1
        bhi writeLoop @while (--r3)
    pop {r4,r7,pc}
.ltorg @Store constants here
</code>```

Testing script (also assembly):

```<code>.global _start
_start:
    ldr r0,[sp,#8] @Read argv[1]
    bl expstr @Call function
    movs r7,#1 @1 is the system call for exit
    swi #0 @Make system call
</code>```

Title: Exploded view of a string

Body:
ARM machine code on Linux, 60 bytes

Hex Dump:

b590 4c0d f810 2b01 b11a 58a3 3301 50a3 e7f8 6222 2704 2001 f1ad 0101 2201 237f 5ce5 b135 700b df00 3d01 d8fc 250a 700d df00 3b01 d8f4 bd90 000200bc

This function basically creates an array of size 128, and whenever it reads a character from the input string it increment's the value at that characters position. Then it goes back through the array and prints each character array[character] times.

Ungolfed Assembly (GNU syntax):

.syntax unified
.bss @bss is zero-initialized data (doesn't impact code size)
countArray:
    .skip 128 @countArray[x] is the number of occurances of x

.text
.global expStr
.thumb_func
expstr:
    @Input: r0 - a NUL-terminated string.
    @Output: Groups of characters to STDOUT
    push {r4,r7,lr}
    ldr r4,=countArray @Load countArray into r4
    readLoop:
        ldrb r2,[r0],#1 @r2=*r0++
        cbz r2,endReadLoop @If r2==NUL, break
        ldr r3,[r4,r2] @r3=r4[r2]
        adds r3,r3,#1 @r3+=1
        str r3,[r4,r2] @r4[r2]=r3
        b readLoop @while (true)
    endReadLoop:
    @Now countArray[x] is the number of occurances of x.
    @Also, r2 is zero
    str r2,[r4,#' ] @'<character> means the value of <character>
    @What that just did was set the number of spaces found to zero.
    movs r7,#4 @4 is the system call for write
    movs r0,#1 @1 is stdout
    sub r1,sp,#1 @Allocate 1 byte on the stack
    @Also r1 is the char* used for write
    movs r2,#1 @We will print 1 character at a time
    movs r3,#127 @Loop through all the characters
    writeLoop:
        ldrb r5,[r4,r3] @r5=countArray[r3]
        cbz r5,endCharacterLoop @If we're not printing anything, go past the loop
        strb r3,[r1] @We're going to print byte r3, so we store it at *r0
        characterLoop:
            swi #0 @Make system call
            @Return value of write is number of characters printed in r0
            @Since we're printing one character, it should just return 1, which
            @means r0 didn't change.
            subs r5,r5,#1
            bhi characterLoop
        @If we're here then we're done printing our group of characters
        @Thus we just need to print a newline.
        movs r5,#10 @r5='\n' (reusing r5 since we're done using it as a loop counter
        strb r5,[r1]
        swi #0 @Print the character

        endCharacterLoop:
        subs r3,r3,#1
        bhi writeLoop @while (--r3)
    pop {r4,r7,pc}
.ltorg @Store constants here

Testing script (also assembly):

.global _start
_start:
    ldr r0,[sp,#8] @Read argv[1]
    bl expstr @Call function
    movs r7,#1 @1 is the system call for exit
    swi #0 @Make system call


问:
Implement a Truth-Machine
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

Gets a number (either 0 or 1) from STDIN.

If that number is 0, print out 0 and terminate.

If that number is 1, print out 1 forever.

Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

take input from STDIN or an acceptable alternative

If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program

must output to STDOUT or an acceptable alternative

If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.

when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory

the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Perl 6, 28 bytes

```<code>{.say;.say while $_}(+slurp)
</code>```

Title: Implement a Truth-Machine

Body:
Perl 6, 28 bytes

{.say;.say while $_}(+slurp)


答:
J, <s>30</s> 27 bytes

```<code>([:+/*%*&(+/)&.:*:)&(-+/%#)
</code>```

This time as a function taking two arguments. Uses the vector formula for calculating it.

Usage

```<code>   f =: ([:+/*%*&(+/)&.:*:)&(-+/%#)
   (1 2 3 4 5 6 7 8 9 10 11) f (6.86 5.92 6.08 8.34 8.7 8.16 8.22 7.68 12.04 8.6 10.96)
0.76909
</code>```

Explanation

Takes two lists a and b as separate arguments.

```<code>([:+/*%*&(+/)&.:*:)&(-+/%#)  Input: a on LHS, b on RHS
                   &(     )  For a and b
                         #     Get the count
                      +/       Reduce using addition to get the sum
                        %      Divide the sum by the count to get the average
                     -         Subtract the initial value from the average
                             Now a and b have both been shifted by their average
                             For both a and b
                *:             Square each value
         (+/)&.:               Reduce the values using addition to get the sum
                               Apply in the inverse of squaring to take the square root
                               of the sum to get the norm
       *&                    Multiply norm(a) by norm(b)
     *                       Multiply a and b elementwise
      %                      Divide a*b by norm(a)*norm(b) elementwise
 [:+/                        Reduce using addition to the sum which is the
                             correlation coefficient and return it
</code>```

Title: Calculate the correlation coefficient

Body:
J, <s>30</s> 27 bytes

([:+/*%*&(+/)&.:*:)&(-+/%#)

This time as a function taking two arguments. Uses the vector formula for calculating it.

Usage

   f =: ([:+/*%*&(+/)&.:*:)&(-+/%#)
   (1 2 3 4 5 6 7 8 9 10 11) f (6.86 5.92 6.08 8.34 8.7 8.16 8.22 7.68 12.04 8.6 10.96)
0.76909

Explanation

Takes two lists a and b as separate arguments.

([:+/*%*&(+/)&.:*:)&(-+/%#)  Input: a on LHS, b on RHS
                   &(     )  For a and b
                         #     Get the count
                      +/       Reduce using addition to get the sum
                        %      Divide the sum by the count to get the average
                     -         Subtract the initial value from the average
                             Now a and b have both been shifted by their average
                             For both a and b
                *:             Square each value
         (+/)&.:               Reduce the values using addition to get the sum
                               Apply in the inverse of squaring to take the square root
                               of the sum to get the norm
       *&                    Multiply norm(a) by norm(b)
     *                       Multiply a and b elementwise
      %                      Divide a*b by norm(a)*norm(b) elementwise
 [:+/                        Reduce using addition to the sum which is the
                             correlation coefficient and return it


问:
Golf you a quine for great good!
Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(index){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}
function commentUrl(index,answers){return"https://api.stackexchange.com/2.2/answers/"+answers.join(';')+"/comments?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}
function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){answers.push.apply(answers,data.items);answers_hash=[];answer_ids=[];data.items.forEach(function(a){a.comments=[];var id=+a.share_link.match(/\d+/);answer_ids.push(id);answers_hash[id]=a});if(!data.has_more)more_answers=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){data.items.forEach(function(c){if(c.owner.user_id===OVERRIDE_USER)
answers_hash[c.post_id].comments.push(c)});if(data.has_more)getComments();else if(more_answers)getAnswers();else process()}})}
getAnswers();var SCORE_REG=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();var OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(a){return a.owner.display_name}
function process(){var valid=[];answers.forEach(function(a){var body=a.body;a.comments.forEach(function(c){if(OVERRIDE_REG.test(c.body))
body='
'+c.body.replace(OVERRIDE_REG,'')+'
'});var match=body.match(SCORE_REG);if(match)
valid.push({user:getAuthorName(a),size:+match[2],language:match[1],link:a.share_link,})});valid.sort(function(a,b){var aB=a.size,bB=b.size;return aB-bB});var languages={};var place=1;var lastSize=null;var lastPlace=1;valid.forEach(function(a){if(a.size!=lastSize)
lastPlace=place;lastSize=a.size;++place;var answer=jQuery("#answer-template").html();answer=answer.replace("{{PLACE}}",lastPlace+".").replace("{{NAME}}",a.user).replace("{{LANGUAGE}}",a.language).replace("{{SIZE}}",a.size).replace("{{LINK}}",a.link);answer=jQuery(answer);jQuery("#answers").append(answer);var lang=a.language;lang=jQuery(''+a.language+'').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)return-1;return 0});for(var i=0;i<langs.length;++i)
{var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

  <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654">

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
Perl 6, 36

```<code>printf |(q<printf |(q<%s>xx 2)>xx 2)
</code>```

Based on the Perl 5 quine.

Title: Golf you a quine for great good!

Body:
Perl 6, 36

printf |(q<printf |(q<%s>xx 2)>xx 2)

Based on the Perl 5 quine.


答:
Mathematica, <s>58</s> 43 bytes

```<code>!Or@@Table[#==#~IntegerReverse~i,{i,2,#-2}]&
</code>```

TIL that #~IntegerReverse~i reverses the digits of the input when written in base i.

Title: Non-palindromic numbers

Body:
A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2).  These numbers are listed on OEIS

For example, the number 19 in base 2,3,4,5,6,...17 is: 10011,201,103,34,31,...12.  None of these representations is palindromic, so the number is strictly non-palindromic.

For this challenge, you need to return a truthy value if the number is non-palindromic, otherwise a falsy value.

You may assume the number passed to you is greater than or equal to 0.

Your program should work for values up to your languages' integer size.

Test cases:

Truthy:

```<code>0
1
2
3
4
6
11
19
47
53
79
103
389
997
1459
</code>```

Falsy:

```<code>5
7
8
9
10
13
16
43
48
61
62
101
113
211
1361
</code>```

This is a code-golf, so make your answers as short as possible!

Body:
Mathematica, <s>58</s> 43 bytes

!Or@@Table[#==#~IntegerReverse~i,{i,2,#-2}]&

TIL that #~IntegerReverse~i reverses the digits of the input when written in base i.


答:
C, 82 bytes

p(n,a,b,c,r){c=0;for(b=1;++b<n-2;c+=r==n)for(a=n,r=0;a>0;a/=b)r=r*b+a%b;return!c;}
```

<p>Ideone it!</p>

<h2>Explanation</h2>

<p>This code reverses <code>n</code> in base <code>b</code> and stores in <code>r</code>:</p>

<pre class="lang-c prettyprint-override"><code>for(a=n,r=0;a>0;a/=b)r=r*b+a%b;
</code>```

The outer loop counts the number of bases from 2 to n-1 in which n is a palindrome.

If n is non-palindromic, the count would be 1 (n must be a palindrome in base n-1).

Title: Non-palindromic numbers

Body:
C, 82 bytes

p(n,a,b,c,r){c=0;for(b=1;++b<n-2;c+=r==n)for(a=n,r=0;a>0;a/=b)r=r*b+a%b;return!c;}

Ideone it!

Explanation

This code reverses n in base b and stores in r:

for(a=n,r=0;a>0;a/=b)r=r*b+a%b;

The outer loop counts the number of bases from 2 to n-1 in which n is a palindrome.

If n is non-palindromic, the count would be 1 (n must be a palindrome in base n-1).


答:
Jelly, 9 bytes

```<code>bRµ⁼"US<3
</code>```

Try it online! or verify all test cases.

How it works

```<code>bRµ⁼"US<3  Main link. Argument: n

 R         Range; yield [1, ..., n].
b          Convert n to all bases between 1 and n, yielding a 2D array A>
  µ        Begin a new, monadic chain. Argument: A
     U     Upend; reverse the 1D arrays in A.
   ⁼"      Zipwith equal; yield 1 for each array that matches its inverse.
      S    Sum; add the resulting Booleans.
           If n > 1, the sum will be 2 if n is strictly non-palindromic (it is only
           a palindrome in bases 1 and n - 1), and greater than 2 otherwise.
           For 0 and 1, the sum will be 0 (sum of the empty array) and 1 (only a
           palindrome in base 1); both are less than 2.
       <3  Compare the sum with 3, yielding the desired Boolean.
</code>```

Title: Non-palindromic numbers

Body:
Jelly, 9 bytes

bRµ⁼"US<3

Try it online! or verify all test cases.

How it works

bRµ⁼"US<3  Main link. Argument: n

 R         Range; yield [1, ..., n].
b          Convert n to all bases between 1 and n, yielding a 2D array A>
  µ        Begin a new, monadic chain. Argument: A
     U     Upend; reverse the 1D arrays in A.
   ⁼"      Zipwith equal; yield 1 for each array that matches its inverse.
      S    Sum; add the resulting Booleans.
           If n > 1, the sum will be 2 if n is strictly non-palindromic (it is only
           a palindrome in bases 1 and n - 1), and greater than 2 otherwise.
           For 0 and 1, the sum will be 0 (sum of the empty array) and 1 (only a
           palindrome in base 1); both are less than 2.
       <3  Compare the sum with 3, yielding the desired Boolean.


问:
Sylvester's sequence
Sylvester's sequence, OEIS A000058, is an integer sequence defined as follows:

Each member is the product of all previous members plus one.  The first member of the sequence is 2.

Task

Create a program to calculate the nth term of Sylvester's Sequence.  Standard input, output and loopholes apply.

Standard sequence rules apply.

This is code-golf, so the goal is to minimize the size of your source code as measured in bytes.

Test Cases

You may use either zero or one indexing. (Here I use zero indexing)

```<code>>>0
2
>>1
3
>>2
7
>>3
43
>>4
1807
</code>```

答:
Jelly, 7 bytes

```<code>²_’
2Ç¡
</code>```

Try it online!

Uses this relationship provided in the sequence instead: a(n+1) = a(n)^2 - a(n) + 1

Explanation

```<code>2Ç¡   Main chain, argument in input

2     Start with 2
  ¡   Repeat as many times as the input:
 Ç        the helper link.

²_’   Helper link, argument: z
²     z²
  ’   z - 1
 _    subtraction, yielding z² - (z-1) = z² - z + 1
</code>```

Title: Sylvester's sequence

Body:
Jelly, 7 bytes

²_’
2Ç¡

Try it online!

Uses this relationship provided in the sequence instead: a(n+1) = a(n)^2 - a(n) + 1

Explanation

2Ç¡   Main chain, argument in input

2     Start with 2
  ¡   Repeat as many times as the input:
 Ç        the helper link.

²_’   Helper link, argument: z
²     z²
  ’   z - 1
 _    subtraction, yielding z² - (z-1) = z² - z + 1


答:
Cheddar, 26 bytes

```<code>n g->n?g(n-=1)**2-g(n)+1:2
</code>```

Try it online!

Pretty idiomatic.

Explanation

```<code>n g ->    // Input n, g is this function
  n ?     // if n is > 1
    g(n-=1)**2-g(n)+1   // Do equation specified in OEIS
  : 2     // if n == 0 return 2
</code>```

Title: Sylvester's sequence

Body:
Sylvester's sequence, OEIS A000058, is an integer sequence defined as follows:

Each member is the product of all previous members plus one.  The first member of the sequence is 2.

Task

Create a program to calculate the nth term of Sylvester's Sequence.  Standard input, output and loopholes apply.

Standard sequence rules apply.

This is code-golf, so the goal is to minimize the size of your source code as measured in bytes.

Test Cases

You may use either zero or one indexing. (Here I use zero indexing)

```<code>>>0
2
>>1
3
>>2
7
>>3
43
>>4
1807
</code>```

Body:
Cheddar, 26 bytes

n g->n?g(n-=1)**2-g(n)+1:2

Try it online!

Pretty idiomatic.

Explanation

n g ->    // Input n, g is this function
  n ?     // if n is > 1
    g(n-=1)**2-g(n)+1   // Do equation specified in OEIS
  : 2     // if n == 0 return 2


答:
Python 2, <s>87</s> <s>73</s> <s>64</s> <s>60</s> 51 bytes

<s>14</s> <s>23</s> 25 bytes saved thanks to Leaky Nun

9 bytes saved thanks to  Specter Terrasbane

Here's my go at my own challenge.

```<code>f=lambda x:reduce(int.__mul__,[1]+map(f,range(x)))+1
</code>```

Title: Sylvester's sequence

Body:
Python 2, <s>87</s> <s>73</s> <s>64</s> <s>60</s> 51 bytes

<s>14</s> <s>23</s> 25 bytes saved thanks to Leaky Nun

9 bytes saved thanks to  Specter Terrasbane

Here's my go at my own challenge.

f=lambda x:reduce(int.__mul__,[1]+map(f,range(x)))+1


答:
Perl 6, 39 bytes

```<code>my &f={first {.flip==$_},($_,2*$_...*)}
</code>```

(33 not including the my &f=)

Body:
Perl 6, 39 bytes

my &f={first {.flip==$_},($_,2*$_...*)}

(33 not including the my &f=)


答:
Brain-Flak, <s>158</s> 154 bytes

Leaky Nun has me beat here

```<code>({}<(()())>){({}[()]<<>(())<>([]){{}<>({}<<>(({}<>))><>)<>({<({}[()])><>({})<>}{})<>{}([])}{}<>({}())([]){{}({}<>)<>([])}{}<>>)}{}([][()]){{}{}([][()])}{}
</code>```

Try it Online!

Explanation

Put a two under the input a(0)

```<code>({}<(()())>)
</code>```

While the input is greater than zero subtract one from the input and...

```<code>{
({}[()]
</code>```

Silently...

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

Put one on the other stack to act as a catalyst for multiplication
     <>(())<>

While the stack is non-empty

```<code> ([])
 {
  {}
</code>```

Move the top of the list over and copy

```<code>  <>({}<<>(({}<>))><>)
</code>```

Multiply the catalyst by the copy

```<code>  <>({<({}[()])><>({})<>}{})<>{}
  ([])
 }
 {}
</code>```

Add one

```<code> <>({}())
</code>```

Move the sequence back to the proper stack

```<code> ([])
 {
 {}
 ({}<>)<>
 ([])
 }
 {}
 <>
>)
}{}
</code>```

Remove all but the bottom item (i.e. the last number created)

```<code>([][()])
{
{}
{}
([][()])
}
{}
</code>```

Title: Sylvester's sequence

Body:
Brain-Flak, <s>158</s> 154 bytes

Leaky Nun has me beat here

({}<(()())>){({}[()]<<>(())<>([]){{}<>({}<<>(({}<>))><>)<>({<({}[()])><>({})<>}{})<>{}([])}{}<>({}())([]){{}({}<>)<>([])}{}<>>)}{}([][()]){{}{}([][()])}{}

Try it Online!

Explanation

Put a two under the input a(0)

({}<(()())>)

While the input is greater than zero subtract one from the input and...

{
({}[()]

Silently...

<

Put one on the other stack to act as a catalyst for multiplication
     <>(())<>

While the stack is non-empty

 ([])
 {
  {}

Move the top of the list over and copy

  <>({}<<>(({}<>))><>)

Multiply the catalyst by the copy

  <>({<({}[()])><>({})<>}{})<>{}
  ([])
 }
 {}

Add one

 <>({}())

Move the sequence back to the proper stack

 ([])
 {
 {}
 ({}<>)<>
 ([])
 }
 {}
 <>
>)
}{}

Remove all but the bottom item (i.e. the last number created)

([][()])
{
{}
{}
([][()])
}
{}


问:
Russian Roulette
Write a program which plays Russian Roulette!

If the program is started,

there should be a 5 in 6 chance of it ending normally after printing "I survived!"

there should be a 1 in 6 chance of the program crashing. (segmentation fault, etc.)

No input, and no other outputs are allowed.

The randomness must be fair: it must have a uniform probability distribution. This means an uninitialized variable (or a RNG without seed) MOD 6 will not be sufficient.

If the solution works with only one dedicated operating system / platform, you will receive a 6 byte penalty to the score.

Shortest code wins, not sooner than 10 days after first valid answer.

答:
GolfScript, 21 chars

```<code>,6rand/;'I survived!'
</code>```

Like most of the answers, this one has a one in six chance of crashing with a ZeroDivisionError.  The shortest solution I could manage without using division by zero is 23 chars:

```<code>5,6rand=+;'I survived!'
</code>```

which has a 1/6 chance of crashing with undefined method `+' for nil:NilClass (NoMethodError).

(Ps. While developing this, I found what might be a bug in the GolfScript interpreter: code like 0,1> appears to leave a nil value on the stack, which will later crash the program if you try to do anything with that value except pop it off and throw it away with ;.  Unfortunately, the fact that I do need to use the value somehow to trigger a crash means that even exploiting this bug didn't help me get below 23 chars.)

Title: Russian Roulette

Body:
GolfScript, 21 chars

,6rand/;'I survived!'

Like most of the answers, this one has a one in six chance of crashing with a ZeroDivisionError.  The shortest solution I could manage without using division by zero is 23 chars:

5,6rand=+;'I survived!'

which has a 1/6 chance of crashing with undefined method `+' for nil:NilClass (NoMethodError).

(Ps. While developing this, I found what might be a bug in the GolfScript interpreter: code like 0,1> appears to leave a nil value on the stack, which will later crash the program if you try to do anything with that value except pop it off and throw it away with ;.  Unfortunately, the fact that I do need to use the value somehow to trigger a crash means that even exploiting this bug didn't help me get below 23 chars.)


答:
Python, <s>38</s> 36 bytes

2 bytes thanks to Dennis.

f=lambda n:0**n*2or~-f(n-1)*f(n-1)+1
```

Ideone it!

Uses this relationship modified from that provided in the sequence instead:

a(n+1) = a(n) * (a(n) - 1) + 1

Explanation

0**n*2 returns 2 when n=0 and 0 otherwise, because 0**0 is defined to be 1 in Python.

Title: Sylvester's sequence

Body:
Python, <s>38</s> 36 bytes

2 bytes thanks to Dennis.

f=lambda n:0**n*2or~-f(n-1)*f(n-1)+1

Ideone it!

Uses this relationship modified from that provided in the sequence instead:

a(n+1) = a(n) * (a(n) - 1) + 1

Explanation

0**n*2 returns 2 when n=0 and 0 otherwise, because 0**0 is defined to be 1 in Python.


问:
Make a (somewhat) self-referential string
You want to make a string where the (1-indexed) character at index n is n. When n is less than 10, this is easy: "123456789". When n is 12, for example, it becomes impossible, since numbers greater than 9 (in base 10) take up more than one character. We can compromise by dividing the string into two-character substrings: "020406081012". Now the index of the end of each substring n is n.

This can be generalized for any d-digit number. Here's an explanation for the "0991021" part of the string for a three-digit number:

```<code>Index:     ... * 97  98  99*100 101 102*103 ...
               *           *           *
               *---+---+---*---+---+---*---+
Character: ... * 0 | 9 | 9 * 1 | 0 | 2 * 1 | ...
               *---+---+---*---+---+---*---+
</code>```

If you haven't figured it out yet, you are to write a program/function that takes a string or integer and output its self-referential string as specified above. You can also output an array of single-digit numbers, chars, or single-character strings.

The given integer will always be positive and divisible by its length (e.g. 126 is divisible by 3; 4928 is divisible by 4). Your program should theoretically work for an arbitrarily large input, but you can assume it is smaller than your language's maximum integer and/or string length.

Some observations if you still don't get it: The length of the output will always be the input itself, and the numbers that appear in the output will be divisible by the number of digits in the input.

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

Test cases

```<code>1    => 1
9    => 123456789
10   => 0204060810
105  => 003006009012015018021024027030033036039042045048051054057060063066069072075078081084087090093096099102105
1004 => 00040008001200160020002400280032003600400044004800520056006000640068007200760080008400880092009601000104010801120116012001240128013201360140014401480152015601600164016801720176018001840188019201960200020402080212021602200224022802320236024002440248025202560260026402680272027602800284028802920296030003040308031203160320032403280332033603400344034803520356036003640368037203760380038403880392039604000404040804120416042004240428043204360440044404480452045604600464046804720476048004840488049204960500050405080512051605200524052805320536054005440548055205560560056405680572057605800584058805920596060006040608061206160620062406280632063606400644064806520656066006640668067206760680068406880692069607000704070807120716072007240728073207360740074407480752075607600764076807720776078007840788079207960800080408080812081608200824082808320836084008440848085208560860086408680872087608800884088808920896090009040908091209160920092409280932093609400944094809520956096009640968097209760980098409880992099610001004
</code>```

Body:
Perl 6, <s>69</s> <s>59</s> 46 bytes

{my \a=.chars;(a,2*a...$_).fmt("%0"~a~"s","")}


答:
C, 46 bytes

s(n,p,r){for(p=r=2;n-->0;p*=r)r=p+1;return r;}
```

Ideone it!

Uses p as the temporary storage of the product.

Basically, I defined two sequences p(n) and r(n), where r(n)=p(n-1)+1 and p(n)=p(n-1)*r(n).

r(n) is the required sequence.

Title: Sylvester's sequence

Body:
C, 46 bytes

s(n,p,r){for(p=r=2;n-->0;p*=r)r=p+1;return r;}

Ideone it!

Uses p as the temporary storage of the product.

Basically, I defined two sequences p(n) and r(n), where r(n)=p(n-1)+1 and p(n)=p(n-1)*r(n).

r(n) is the required sequence.


Title: Sylvester's sequence

Body:
Perl 6, 24 bytes

{(2,{1+[*] @_}...*)[$_]}

{(2,{1+.²-$_}...*)[$_]}

Explanation

# bare block with implicit parameter ｢$_｣
{
  (
    # You can replace 2 with 1 here
    # so that it uses 1 based indexing
    # rather than 0 based
    2,

    # bare block with implicit parameter ｢@_｣
    {
      1 +

      # reduce the input of this inner block with ｢&infix:<*>｣
      # ( the input is all of them generated when using a slurpy @ var )
      [*] @_

      # that is the same as:
      # ｢@_.reduce: &infix:<*>｣
    }

    # keep calling that to generate more values until:
    ...

    # forever
    *

  # get the value as indexed by the input
  )[ $_ ]
}

Usage:

my &code = {(2,{1+[*] @_}...*)[$_]}

say code 0; # 2
say code 1; # 3
say code 2; # 7
say code 3; # 43
say code 4; # 1807

# you can even give it a range
say code 4..7;
# (1807 3263443 10650056950807 113423713055421844361000443)

say code 8;
# 12864938683278671740537145998360961546653259485195807
say code 9;
# 165506647324519964198468195444439180017513152706377497841851388766535868639572406808911988131737645185443
say code 10;
# 27392450308603031423410234291674686281194364367580914627947367941608692026226993634332118404582438634929548737283992369758487974306317730580753883429460344956410077034761330476016739454649828385541500213920807

my $start = now;
# how many digits are there in the 20th value
say chars code 20;
# 213441

my $finish = now;
# how long did it take to generate the values up to 20
say $finish - $start, ' seconds';
# 49.7069076 seconds


答:
Java 7, <s>46</s> 42 bytes

```<code>int f(int n){return--n<0?2:f(n)*~-f(n)+1;}
</code>```

Uses 0-indexing with the usual formula. I swapped n*n-n for n*(n-1) though, since Java doesn't have a handy power operator, and the f() calls were getting long.

Title: Sylvester's sequence

Body:
Java 7, <s>46</s> 42 bytes

int f(int n){return--n<0?2:f(n)*~-f(n)+1;}

Uses 0-indexing with the usual formula. I swapped n*n-n for n*(n-1) though, since Java doesn't have a handy power operator, and the f() calls were getting long.


答:
Perl6, 49 bytes

```<code>my &f={my @c=2;@c.push: 1+[*] @c for ^$_;@c[*-1]}
</code>```

Ungolfed:

```<code>sub f($n) {
  my @sylvester = 2; # declare an array to store the previous
                     # values of the sequence
  # insert S(1) ... S(n) (n iterations)
  @sylvester.push(1 + [*] @sylvester) for 0..^$n;
  return @sylvester[* - 1]; # return last element
}
</code>```

Title: Sylvester's sequence

Body:
Perl6, 49 bytes

my &f={my @c=2;@c.push: 1+[*] @c for ^$_;@c[*-1]}

Ungolfed:

sub f($n) {
  my @sylvester = 2; # declare an array to store the previous
                     # values of the sequence
  # insert S(1) ... S(n) (n iterations)
  @sylvester.push(1 + [*] @sylvester) for 0..^$n;
  return @sylvester[* - 1]; # return last element
}