问:
A game of atomic proportions
Your task make a bot that plays Atomas, with the highest score.

How the game works:

The gameboard starts with a ring of 6 "atoms", with numbers ranging from 1 to 3. You can "play" an atom between two atoms, or on another atom, depending on the atom itself.

You can either have a normal atom, or a special atom.

The normal atom:

You can play a normal atom between any two available atoms on the board.

You start off with atoms in the range 1 to 3, but the range increases by 1 once every 40 moves (so after 40 moves, the range becomes 2 to 4).

If there are atoms on the board that are lower than the range, it has a 1 / no. of atoms of that number on the board chance of spawning.

Let's say you have a 2 to play, and the board looks like this:

```<code>   1 1 2 1
</code>```

Let's place the 2 to the right of the 1.

The board now becomes:

```<code>   1 1 2 1 2
</code>```

Note: the board wraps around, so the 1 on the far left is actually next to the 2 on the far right. This will be important later.

There are 4 types of "special" atoms, and they are:

The + atom:

This atom is played between two atoms. It has a 1 in 5 chance of spawning.

If the atoms on both sides of the + atom are the same, fusion occurs. Here's how it works:

```<code>The two atoms fuse together to create an atom one higher.
(So, two 3 atoms fuse together to form one 4 atom.)
While the atoms on both sides of the fused atom are equal:
    If the atoms on the side >= the fused atom:
        The new fused atom = the old fused atom's value + 2.
    If the atoms on the side < the fused atom:
        The new fused atom = the old fused atom's value + 1.
</code>```

Example:

```<code>   1 1 3 2 2 3  (the 1 on the left-hand side "wraps back"
                 to the 3 on the right-hand side)

Let's use the + on the two 2's in the middle.

-> 1 1 3 3 3    (the two 2's fused together to make a 3)
-> 1 1 5        (the two 3's fused with the 3, and because 3 >= 3,
                 the new fused atom = 3 + 2 = 5)
-> 6            (the two 1's fused with the 5, since the board wraps,
                 and because 1 < 5, the new fused atom = 5 + 1 = 6)

Because the atoms on the sides of the 6 don't exist, fusion stops,
and the board is now [6].
</code>```

If the atoms on both sides of the + atom are different, then the + stays on the board.

Example:

```<code>   1 3 2 3 1 1

Let's use the + on the 2 and 3 in the middle.

-> 1 3 2 + 3 1 1 (2 != 3, so the + stays on the board)
</code>```

The - atom:

This atom is played on another atom. It has a 1 in 10 chance of spawning.

The - atom removes an atom from the board, and gives you a choice to either:

play the removed atom next round, or

turn it into a + atom to play next round.

Example:

```<code>   1 3 2 3 1 1

Let's use the - on the left-hand 2.

-> 1 3 3 1 1    (the 2 is now removed from the board)

Let's turn it into a +, and place it in between the 3's.

-> 1 4 1 1      (the two 3's fused together to make a 4)
-> 5 1          (the two 1's fused with the 4, and because 1 < 4,
                 the new fused atom = 4 + 1 = 5)
</code>```

The black + atom (B):

This atom is played between 2 atoms. It has a 1 in 80 chance of spawning, and only spawns once your score > 750.

This atom is basically the same as the + atom, except that it fuses any two atoms together, even +'s. From then on, it follows the + rule (it only fuses atoms together if the atoms on both sides of the fused atom are equal).

The fused atom as a result of the black + is equal to:

the higher number atom in the fusion + 3

4 if the two fused atoms are +'s

Example:

```<code>   1 3 2 1 3 1

Let's use the black + on the 2 and 1 in the middle.

-> 1 3 5 3 1    (the 2 and 1 fused together to make a 2 + 3 = 5)
-> 1 6 1        (+ rule)
-> 7            (+ rule)
</code>```

Another example:

```<code>   2 + + 2

Let's use the black + on the two +'s.

-> 2 4 2        (the two +'s fused together to make a 4)
-> 5            (+ rule)
</code>```

The clone atom (C):

This atom is played on another atom. It has a 1 in 60 chance of spawning, and only spawns once your score > 1500.

The clone atom allows you to choose an atom, and play it next round.

Example:

```<code>   1 1 2 1

Let's use the clone on the 2, and place it to the right of the 1.

-> 1 1 2 1 2
</code>```

Here is my build of the game, in Python 2:

import random
import subprocess

logs='atoms.log'
atom_range = [1, 3]
board = []
score = 0
move_number = 0
carry_over = " "
previous_moves = []

specials = ["+", "-", "B", "C"]

def plus_process(user_input):
    global board, score, previous_moves, matches
    previous_moves = []
    matches = 0

    def score_calc(atom):
        global score, matches
        if matches == 0:
            score += int(round((1.5 * atom) + 1.25, 0))
        else:
            if atom < final_atom:
                outer = final_atom - 1
            else:
                outer = atom
            score += ((-final_atom + outer + 3) * matches) - final_atom + (3 * outer) + 3
        matches += 1

    if len(board) < 1 or user_input == "":
        board.append("+")
        return None
    board_start = board[:int(user_input) + 1]
    board_end = board[int(user_input) + 1:]
    final_atom = 0
    while len(board_start) > 0 and len(board_end) > 0:
        if board_start[-1] == board_end[0] and board_end[0] != "+":
            if final_atom == 0:
                final_atom = board_end[0] + 1
            elif board_end[0] >= final_atom:
                final_atom += 2
            else:
                final_atom += 1
            score_calc(board_end[0])
            board_start = board_start[:-1]
            board_end = board_end[1:]
        else:
            break
    if len(board_start) == 0:
        while len(board_end) > 1:
            if board_end[0] == board_end[-1] and board_end[0] != "+":
                if final_atom == 0:
                    final_atom = board_end[0]
                elif board_end[0] >= final_atom:
                    final_atom += 2
                else:
                    final_atom += 1
                score_calc(board_end[0])
                board_end = board_end[1:-1]
            else:
                break
    if len(board_end) == 0:
        while len(board_start) > 1:
            if board_start[0] == board_start[-1] and board_start[0] != "+":
                if board_start[0] >= final_atom:
                    final_atom += 2
                else:
                    final_atom += 1
                score_calc(board_start[0])
                board_start = board_start[1:-1]
            else:
                break
    if matches == 0:
        board = board_start + ["+"] + board_end
    else:
        board = board_start + [final_atom] + board_end
        for a in range(len(board) - 1):
            if board[a] == "+":
                if board[(a + 1) % len(board)] == board[a - 1]:
                    board = board[:a - 1] + board[a:]
                    plus_process(a)
                    break

def minus_process(user_input, minus_check):
    global carry_over, board
    carry_atom = board[int(user_input)]
    if user_input == len(board) - 1:
        board = board[:-1]
    else:
        board = board[:int(user_input)] + board[int(user_input) + 1:]
    if minus_check == "y":
        carry_over = "+"
    elif minus_check == "n":
        carry_over = str(carry_atom)

def black_plus_process(user_input):
    global board
    if board[int(user_input)] == "+":
        if board[int(user_input) + 1] == "+":
            inter_atom = 4
        else:
            inter_atom = board[int(user_input) + 1] + 2
    else:
        if board[int(user_input)] + 1 == "+":
            inter_atom = board[int(user_input)] + 2
        else:
            inter_list = [board[int(user_input)], board[int(user_input) + 1]]
            inter_atom = (inter_list.sort())[1] + 2
    board = board[int(user_input) - 1:] + [inter_atom] * 2 + board[int(user_input) + 1:]
    plus_process(int(user_input) - 1)

def clone_process(user_input):
    global carry_over
    carry_over = str(board[int(user_input)])

def regular_process(atom,user_input):
    global board
    if user_input == "":
        board.append(random.randint(atom_range[0], atom_range[1]))
    else:
        board = board[:int(user_input) + 1] + [int(atom)] + board[int(user_input) + 1:]

def gen_specials():
    special = random.randint(1, 240)
    if special <= 48:
        return "+"
    elif special <= 60 and len(board) > 0:
        return "-"
    elif special <= 64 and len(board) > 0 and score >= 750:
        return "B"
    elif special <= 67 and len(board) > 0 and score >= 1500:
        return "C"
    else:
        small_atoms = []
        for atom in board:
            if atom not in specials and atom < atom_range[0]:
                small_atoms.append(atom)
        small_atom_check = random.randint(1, len(board))
        if small_atom_check <= len(small_atoms):
            return str(small_atoms[small_atom_check - 1])
        else:
            return str(random.randint(atom_range[0], atom_range[1]))

def specials_call(atom, user_input):
    specials_dict = {
        "+": plus_process,
        "-": minus_process,
        "B": black_plus_process,
        "C": clone_process
    }
    if atom in specials_dict.keys():
        if atom == "-":
            minus_process(user_input[0], user_input[1])
        else:
            specials_dict[atom](user_input[0])
    else:
        regular_process(atom,user_input[0])

def init():
    global board, score, move_number, carry_over, previous_moves
    board = []
    score = 0

    for _ in range(6):
        board.append(random.randint(1, 3))

    while len(board) <= 18:
        move_number += 1
        if move_number % 40 == 0:
            atom_range[0] += 1
            atom_range[1] += 1
        if carry_over != " ":
            special_atom = carry_over
            carry_over = " "
        elif len(previous_moves) >= 5:
            special_atom = "+"
        else:
            special_atom = gen_specials()
        previous_moves.append(special_atom)
        bot_command = "python yourBot.py"
        bot = subprocess.Popen(bot_command.split(),
                               stdout = subprocess.PIPE,
                               stdin = subprocess.PIPE)
        to_send="/".join([
            # str(score),
            # str(move_number),
            str(special_atom),
            " ".join([str(x) for x in board])
        ])
        bot.stdin.write(to_send)
        with open(logs, 'a') as f:f.write(to_send+'\n')
        bot.stdin.close()
        all_user_input = bot.stdout.readline().strip("\n").split(" ")
        specials_call(special_atom, all_user_input)

    print("Game over! Your score is " + str(score))

if __name__ == "__main__":
    for a in range(20):
        with open(logs, 'a') as f:f.write('round '+str(a)+'-'*50+'\n')
        init()
```

<h2>How the bot thing works:</h2>

<h3>Input</h3>

<ul>
<li>Your bot will get 2 inputs: the atom that is currently in play, and the state of the board.</li>
<li>The atom will be like so:

<ul>
<li><code>+</code> for a <code>+</code> atom</li>
<li><code>-</code> for a <code>-</code> atom</li>
<li><code>B</code> for a Black <code>+</code> atom</li>
<li><code>C</code> for a Clone atom</li>
<li><code>{atom}</code> for a normal atom</li>
</ul></li>
<li>The state of the board will be like so:

<ul>
<li><code>atom 0 atom 1 atom 2... atom n</code>, with the atoms separated by spaces (<code>atom n</code> wraps back to <code>atom 1</code>, to simulate a "ring" gameboard)</li>
</ul></li>
<li>These two will be separated by a <code>/</code>.</li>
</ul>

<p>Example inputs:</p>

```1/1 2 2 3   (the atom in play is 1, and the board is [1 2 2 3])
+/1         (the atom in play is +, and the board is [1] on its own)
```

<h3>Output</h3>

<ul>
<li><p>You will output a string, depending on what the atom in play is.</p>

<ul>
<li><p>If the atom is meant to be played between two atoms:</p>

<ul>
<li><p>Output the gap you want to play the atom in. The gaps are like in between each atom, like so:</p>

```   1 1 2 1 2
```0

<p>(<code>gap n</code> indicates you want to place the atom between <code>atom 1</code> and atom <code>n</code>)
So output <code>2</code> if you want to play the atom on <code>gap 2</code>.</p></li>
</ul></li>
<li>If the atom is meant to be played on an atom:

<ul>
<li>Output the atom you want to play it on, so <code>2</code> if you want to play the atom on <code>atom 2</code>.</li>
</ul></li>
<li>If the atom is a <code>-</code>:

<ul>
<li>Output the atom you want to play it on, followed by a space, followed by a <code>y/n</code> choice of turning the atom into a <code>+</code> later, so <code>2, "y"</code> if you want to play the atom on <code>atom 2</code>, and you want to turn it into a <code>+</code>. <strong>Note: this requires 2 inputs, instead of 1.</strong></li>
</ul></li>
</ul></li>
</ul>

<p>Example outputs:</p>

```   1 1 2 1 2
```1

<ul>
<li>To make the bot work, you have to go to the <code>Popen</code> bit (at around the end of the code), and replace it with whatever makes your program run as a Pythonic list (so if your program is <code>derp.java</code>, replace <code>["python", "bot.py"]</code> with <code>["java", "derp.java"]</code>).</li>
</ul>

<h2>Answer-specific Specs:</h2>

<ul>
<li>Place the entire code of your bot into the answer. If it doesn't fit, it doesn't count.</li>
<li>Each user is allowed to have more than 1 bot, however, they should all be in separate answer posts.</li>
<li>Also, give your bot a name.</li>
</ul>

<h2>Scoring:</h2>

<ul>
<li>The bot with the highest score wins.

<ul>
<li>Your bot will be tested for 20 games, and the final score is the average of the 20 games.</li>
</ul></li>
<li>The tie-breaker will be the time of the upload of the answer.</li>
<li><p>So your answer will be formatted like this:</p>

```   1 1 2 1 2
```2

Good luck!

答:
Python, RandomBot, Score = 7.95

Nothing too fancy, just a random bot.

import random

game_input = raw_input().split("/")
current_atom = game_input[0]
board = game_input[1].split(" ")

if current_atom != "-":
    print(random.randint(0, len(board) - 1))
else:
    random_choice = " y" if random.randint(0, 1) == 1 else " n"
    print(str(random.randint(0, len(board) - 1)) + random_choice)
```

Title: A game of atomic proportions


问:
Tips for golfing in Python
What general tips do you have for golfing in Python? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Python (e.g. "remove comments" is not an answer).

Please post one tip per answer.

答:
Use string substitution and exec to deal with long keywords like lambda that are repeated often in your code.

a=lambda b:lambda c:lambda d:lambda e:lambda f:0   # 48 bytes  (plain)
exec"a=`b:`c:`d:`e:`f:0".replace('`','lambda ')    # 47 bytes  (replace)
exec"a=%sb:%sc:%sd:%se:%sf:0"%(('lambda ',)*5)     # 46 bytes  (%)
```
<p>The target string is very often <code>'lambda '</code>, which is 7 bytes long. Suppose your code snippet contains <code>n</code> occurences of <code>'lambda '</code>, and is <code>s</code> bytes long. Then:</p>
<ul>
<li>The <code>plain</code> option is <code>s</code> bytes long.</li>
<li>The <code>replace</code> option is <code>s - 6n + 29</code> bytes long.</li>
<li>The <code>%</code> option is <code>s - 5n + 22 + len(str(n))</code> bytes long.</li>
</ul>
<p>From a plot of <em>bytes saved over <code>plain</code></em> for these three options, we can see that:</p>
<ul>
<li>For <em>n < 5</em> lambdas, you're better off not doing anything fancy at all.</li>
<li>For <em>n = 5</em>, writing <code>exec"..."%(('lambda ',)*5)</code> saves 2 bytes, and is your best option.</li>
<li>For <em>n > 5</em>, writing <code>exec"...".replace('`','lambda ')</code> is your best option.</li>
</ul>
<p><strong>For other cases, you can index the table below:</strong></p>
```          1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 (occurences)
       +---------------------------------------------------------
     3 |  -  -  -  -  -  -  -  -  -  -  -  -  -  -  r  r  r  r  r
     4 |  -  -  -  -  -  -  -  -  -  r  r  r  r  r  r  r  r  r  r
     5 |  -  -  -  -  -  -  -  r  r  r  r  r  r  r  r  r  r  r  r
     6 |  -  -  -  -  -  r  r  r  r  r  r  r  r  r  r  r  r  r  r
     7 |  -  -  -  -  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
     8 |  -  -  -  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
     9 |  -  -  -  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
    10 |  -  -  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
    11 |  -  -  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
    12 |  -  -  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r = replace
    13 |  -  -  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r   % = string %
    14 |  -  %  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r   - = do nothing
    15 |  -  %  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  (length)
```

For example, if the string lambda x,y: (length 11) occurs 3 times in your code, you're better off writing exec"..."%(('lambda x,y:',)*3).

ContentLicense: CC BY-SA 3.0

Title: Tips for golfing in Python

Body:
Use string substitution and exec to deal with long keywords like lambda that are repeated often in your code.

a=lambda b:lambda c:lambda d:lambda e:lambda f:0   # 48 bytes  (plain)
exec"a=`b:`c:`d:`e:`f:0".replace('`','lambda ')    # 47 bytes  (replace)
exec"a=%sb:%sc:%sd:%se:%sf:0"%(('lambda ',)*5)     # 46 bytes  (%)

The target string is very often 'lambda ', which is 7 bytes long. Suppose your code snippet contains n occurences of 'lambda ', and is s bytes long. Then:

The plain option is s bytes long.

The replace option is s - 6n + 29 bytes long.

The % option is s - 5n + 22 + len(str(n)) bytes long.

From a plot of bytes saved over plain for these three options, we can see that:

For n < 5 lambdas, you're better off not doing anything fancy at all.

For n = 5, writing exec"..."%(('lambda ',)*5) saves 2 bytes, and is your best option.

For n > 5, writing exec"...".replace('`','lambda ') is your best option.

For other cases, you can index the table below:

          1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 (occurences)
       +---------------------------------------------------------
     3 |  -  -  -  -  -  -  -  -  -  -  -  -  -  -  r  r  r  r  r
     4 |  -  -  -  -  -  -  -  -  -  r  r  r  r  r  r  r  r  r  r
     5 |  -  -  -  -  -  -  -  r  r  r  r  r  r  r  r  r  r  r  r
     6 |  -  -  -  -  -  r  r  r  r  r  r  r  r  r  r  r  r  r  r
     7 |  -  -  -  -  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
     8 |  -  -  -  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
     9 |  -  -  -  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
    10 |  -  -  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
    11 |  -  -  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
    12 |  -  -  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r = replace
    13 |  -  -  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r   % = string %
    14 |  -  %  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r   - = do nothing
    15 |  -  %  %  %  %  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  (length)

For example, if the string lambda x,y: (length 11) occurs 3 times in your code, you're better off writing exec"..."%(('lambda x,y:',)*3).

ContentLicense: CC BY-SA 4.0


问:
Directories required for creating a folder tree
Say that you have this folder structure on your coumputer:

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

And you want to have these folders:

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

You would need to create four directories, using mkdir for example:

```<code>mkdir /a/b
mkdir /a/c
mkdir /b
mkdir /b/b
</code>```

Write a program that, given existing and required directory structures, will output the directories that need to be created.

Input

First line has two numbers: n, number of existing directories, and m, number of required directories
Next n lines has the list of existing directories
Next m lines has the list of required directories

Example:

```<code>1 3
/a
/a/b
/a/c
/b/b
</code>```

Output

Directories you need to create

Example:

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

答:
Bash, <s>175</s> <s>169</s> <s>168</s> <s>135</s> <s>130</s> 128

Here's one of my worthwhile solutions from SO, then:

WARNING: Be sure to run in an empty directory, as this will wipe out its contents first thing per test.

read t
for((;x++<t;));do
rm -r *
read n m
for((i=n+m;i--;));do
read d
mkdir -p .$d
done
echo Case \#$x: $[`find|wc -l`-n-1]
done
```

ContentLicense: CC BY-SA 2.5


问:
Bit-Reversal Permutations
Your goal is to create a function or a program to reverse the bits in a range of integers given an integer \$n\$. In other words, you want to find the bit-reversal permutation of a range of \$2^n\$ items, zero-indexed. This is also the OEIS sequence A030109. This process is often used in computing Fast Fourier Transforms, such as the in-place Cooley-Tukey algorithm for FFT. There is also a challenge for computing the FFT for sequences where the length is a power of 2.

This process requires you to iterate over the range \$[0, 2^n-1]\$, convert each value to binary and reverse the bits in that value. You will be treating each value as a \$n\$-digit number in base 2 which means reversal will only occur among the last \$n\$ bits.

For example, if \$n = 3\$, the range of integers is [0, 1, 2, 3, 4, 5, 6, 7]. These are

```<code>i  Regular  Bit-Reversed  j
0    000        000       0
1    001        100       4
2    010        010       2
3    011        110       6
4    100        001       1
5    101        101       5
6    110        011       3
7    111        111       7
</code>```

where each index \$i\$ is converted to an index \$j\$ using bit-reversal. This means that the output is [0, 4, 2, 6, 1, 5, 3, 7].

The output for \$n\$ from 0 thru 4 are

```<code>n    Bit-Reversed Permutation
0    [0]
1    [0, 1]
2    [0, 2, 1, 3]
3    [0, 4, 2, 6, 1, 5, 3, 7]
</code>```

You may have noticed a pattern forming. Given \$n\$, you can take the previous sequence for \$n-1\$ and double it. Then concatenate that doubled list to the same double list but incremented by one. To show,

```<code>[0, 2, 1, 3] * 2 = [0, 4, 2, 6]
[0, 4, 2, 6] + 1 = [1, 5, 3, 7]
[0, 4, 2, 6] ⊕ [1, 5, 3, 7] = [0, 4, 2, 6, 1, 5, 3, 7]
</code>```

where \$⊕\$ represents concatenation.

You can use either of the two methods above in order to form your solution. If you know a better way, you are free to use that too. Any method is fine as long as it outputs the correct results.

Rules

This is code-golf so the shortest solution wins.

Builtins that solve this challenge as a whole and builtins that compute the bit-reversal of a value are not allowed. This does not include builtins which perform binary conversion or other bitwise operations.

Your solution must be, at the least, valid for \$n\$ from 0 to 31.

答:
Perl, <s>46</s> 45 bytes

Includes +1 for -p

Give input number on STDIN

```<code>#!/usr/bin/perl -p
map$F[@F]=($_*=2)+1,@F for(@F=0)..$_;$_="@F"
</code>```

Title: Bit-Reversal Permutations

Body:
Perl, <s>46</s> 45 bytes

Includes +1 for -p

Give input number on STDIN

#!/usr/bin/perl -p
map$F[@F]=($_*=2)+1,@F for(@F=0)..$_;$_="@F"


问:
Shuffle Up and Deal!
It is Friday and I am tired, so let's do a quick one! Take no input, however you should output all thirteen different numbered cards in a standard deck of cards. You should output 2 through Ace (Suit agnostic).

Each card has a top that is denoted with a space   and ten _ and another space .

The second row from the top is denoted with a / and ten spaces   and a \

The third row is the same as all the middle-ish rows excepts the character(s) denoting the card value appear two spaces to right (if at the top) or two space to the left (if at the bottom) of the edge.

Each middle-ish row is a simple | and ten spaces   and one more |

Finally the last line is a \ and ten _ and finally a /

If the value is multi-digit the overall width by height of the card should not change. (i.e. the 10 will not make the card's sides wider)

King Example:

```<code> __________
/          \
| K        |
|          |
|          |
|          |
|          |
|          |
|        K |
\__________/
</code>```

9 Example

```<code> __________
/          \
| 9        |
|          |
|          |
|          |
|          |
|          |
|        9 |
\__________/
</code>```

10 Example

```<code> __________
/          \
| 10       |
|          |
|          |
|          |
|          |
|          |
|       10 |
\__________/
</code>```

Output them in order from least to greatest (Aces are high!).

This is code-golf so the shortest code wins.

Have fun and have a fun weekend!

Title: Shuffle Up and Deal!

Body:
V, 87 bytes

i ±_
/± \Ypr|$.Y6P3|r2Lhhr2o\±_/
H8ñy}GP2j6j? _ñ2j$X6jxG"04p/9
rJn.nrQn,nrKn.nrAn.

Try it online!

Since this contains some unprintables, here is a hexdump:

0000000: 6920 b15f 200a 2fb1 205c 1b59 7072 7c24  i ._ ./. \.Ypr|$
0000010: 2e59 3650 337c 7232 4c68 6872 326f 5cb1  .Y6P3|r2Lhhr2o\.
0000020: 5f2f 0a1b 4838 f179 7d47 5032 6a01 366a  _/..H8.y}GP2j.6j
0000030: 013f 205f f132 6a24 5836 6a78 4722 3034  .? _.2j$X6jxG"04
0000040: 702f 390a 724a 6e2e 6e72 516e 2c6e 724b  p/9.rJn.nrQn,nrK
0000050: 6e2e 6e72 416e 2e                        n.nrAn.


问:
Maximal number of regions obtained by joining n points around a circle by straight lines
Let's define f(n) as the maximal number of regions obtained by joining n points around a circle by straight lines. For example, two points would split the circle into two pieces, three into four, like this:

Make sure when you are drawing the lines, you don't have an intersection of more than two lines.

Your task

Given a number n, print f(n).

Test cases:

```<code> n | f(n)
---+-----
 1 |   1
 2 |   2
 3 |   4
 4 |   8
 5 |  16
 6 |  31
 7 |  57
 8 |  99
 9 | 163
</code>```

You can see more here.

Using built-in sequence generators is not allowed.

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

If you guys want the formula, here it is:

答:
Octave, 27 bytes

```<code>@(m)binocdf(4,m-1,.5)*2^m/2
</code>```

This is an anonymous function.

Try it at Ideone.

Explanation

This is based on the OEIS formula a(m) = C(m−1, 4) + C(m−1, 3) + ... + C(m−1, 0), where C are binomial coefficients. The binomial distribution function

for k = 4, n = m−1 and p = 1/2 gives 2m−1a(m).

Body:
Octave, 27 bytes

@(m)binocdf(4,m-1,.5)*2^m/2

This is an anonymous function.

Try it at Ideone.

Explanation

This is based on the OEIS formula a(m) = C(m−1, 4) + C(m−1, 3) + ... + C(m−1, 0), where C are binomial coefficients. The binomial distribution function

for k = 4, n = m−1 and p = 1/2 gives 2m−1a(m).


问:
Find the maximum deviation
This problem is "inspired" from a question that was originally asked on Quora (not for code golfing). I just want to make it a challenge for you guys (and my first problem submission here).

Given an array of integer elements v and an integer d (we assume that d is lower or equal to the array's length), consider all the sequences of d consecutive elements in the array. For each sequence, compute the difference between the maximum and minimum value of the elements in that sequence and name it the deviation.

Your task is to write a program or function that computes the maximum value among all deviations of all the sequences considered above, and return or output that value.

Worked-through Example:

```<code>v: (6,9,4,7,4,1)
d: 3

The sequences of length 3 are:
6,9,4 with deviation 5
9,4,7 with deviation 5
4,7,4 with deviation 3
7,4,1 with deviation 6

Thus the maximal deviation is 6, so the output is 6.
</code>```

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

答:
Haskell, 56 bytes

```<code>_#[]=0
d#l|m<-take d l=max(maximum m-minimum m)$d#tail l
</code>```

Usage example: 3 # [6,9,4,7,4,1] -> 6.

Considering ranges less than d doesn't change the overall maximum, so we can run take d down to the very end of the list (i.e. also include the ranges with the last d-1, d-2, ... 0 elements). The recursion stops with the empty list where we set the deviation to 0.

Title: Find the maximum deviation

Body:
Haskell, 56 bytes

_#[]=0
d#l|m<-take d l=max(maximum m-minimum m)$d#tail l

Usage example: 3 # [6,9,4,7,4,1] -> 6.

Considering ranges less than d doesn't change the overall maximum, so we can run take d down to the very end of the list (i.e. also include the ranges with the last d-1, d-2, ... 0 elements). The recursion stops with the empty list where we set the deviation to 0.


问:
Does the code terminate?
This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An example of what I mean could be the following piece of python code, adapted from an anwser to this cs stackexchange question.

```<code>def is_perfect(n):
    return sum(i for i in range(1, n) if n % i == 0) == n

n = 3
while not is_perfect(n):
    n = n + 2
</code>```

Mathematicians conjecture that there are no odd perfect numbers, but it has never been proven, so no one knows if this piece of code will ever terminate. Can you come up with other pieces of code (perhaps relying on other open problems like the Collatz conjecture, or the twin primes conjecture) that are shorter, but for which it is unknown whether or not they terminate?

Edit: Some people have brought up a good additional rule - The solutions to the question should be deterministic. Although it might be even more interesting if you could find shorter solutions using nondeterminism. In this case, the rule would be to find a snippet for which the probability of termination is unknown.

答:
Pyth, 16 bytes

```<code>f!}1.u@,/G2h*3GG
</code>```

Returns the first value for which the Collatz conjecture does not hold.  As it is unknown whether the conjecture holds for all numbers, it is unknown whether this code will terminate.

Title: Does the code terminate?

Body:
Pyth, 16 bytes

f!}1.u@,/G2h*3GG

Returns the first value for which the Collatz conjecture does not hold.  As it is unknown whether the conjecture holds for all numbers, it is unknown whether this code will terminate.


答:
Perl, <s>50</s> <s>38</s> <s>36</s> <s>34</s> 33 bytes

```<code>$_=196;$_+=$%while($%=reverse)-$_
</code>```

Explanation: 196 is a possible Lychrel number - a number that does not form a palindrome by repeatedly adding its reverse to itself.  The loop continues until $n is equal to its reverse, which is as yet unknown for initial value 196.

```<code>25 + 52 = 77
</code>```

which is not valid.

```<code>96 + 69 = 165
165 + 561 = 726
726 + 627 = 1353
1353 + 3531 = 4884
</code>```

so none of the numbers in this sequence are valid.

Edit: Golfed it down by using an until loop instead of a for loop (somehow).  Also, I had fewer bytes than I thought (I should probably look at my bytecount more carefully in the future).

Edit: Replaced $n with $_ to save 2 bytes for the implied argument in reverse.  I think this is as golfed as this implementation is going to get.

Edit: I was wrong.  Instead of using until($%=reverse)==$_ I can go while the difference is nonzero (i.e. true): while($%=reverse)-$_.

Title: Does the code terminate?

Body:
This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An example of what I mean could be the following piece of python code, adapted from an anwser to this cs stackexchange question.

```<code>def is_perfect(n):
    return sum(i for i in range(1, n) if n % i == 0) == n

n = 3
while not is_perfect(n):
    n = n + 2
</code>```

Mathematicians conjecture that there are no odd perfect numbers, but it has never been proven, so no one knows if this piece of code will ever terminate. Can you come up with other pieces of code (perhaps relying on other open problems like the Collatz conjecture, or the twin primes conjecture) that are shorter, but for which it is unknown whether or not they terminate?

Edit: Some people have brought up a good additional rule - The solutions to the question should be deterministic. Although it might be even more interesting if you could find shorter solutions using nondeterminism. In this case, the rule would be to find a snippet for which the probability of termination is unknown.

Body:
Perl, <s>50</s> <s>38</s> <s>36</s> <s>34</s> 33 bytes

$_=196;$_+=$%while($%=reverse)-$_

Explanation: 196 is a possible Lychrel number - a number that does not form a palindrome by repeatedly adding its reverse to itself.  The loop continues until $n is equal to its reverse, which is as yet unknown for initial value 196.

25 + 52 = 77

which is not valid.

96 + 69 = 165
165 + 561 = 726
726 + 627 = 1353
1353 + 3531 = 4884

so none of the numbers in this sequence are valid.

Edit: Golfed it down by using an until loop instead of a for loop (somehow).  Also, I had fewer bytes than I thought (I should probably look at my bytecount more carefully in the future).

Edit: Replaced $n with $_ to save 2 bytes for the implied argument in reverse.  I think this is as golfed as this implementation is going to get.

Edit: I was wrong.  Instead of using until($%=reverse)==$_ I can go while the difference is nonzero (i.e. true): while($%=reverse)-$_.


答:
Python 2, <s>123</s> <s>98</s> 92 bytes

p=lambda n,k=2:n<=k or n%k*p(n,k+1)
g=lambda n:[p(b)*p(n-b)for b in range(n)]and g(n+2)
g(4)
```

This code will terminate if the Goldbach conjecture does not hold for all even numbers (i.e. if all even numbers can be expressed as the sum of two primes). It has currently been tested for numbers up to 4*10^18.

A huge amount of thanks to @Pietu1998 for shortening my code by a lot!

EDIT: Thanks to @JonathanAllan for shaving 6 bytes off my code!

Title: Does the code terminate?

Body:
Python 2, <s>123</s> <s>98</s> 92 bytes

p=lambda n,k=2:n<=k or n%k*p(n,k+1)
g=lambda n:[p(b)*p(n-b)for b in range(n)]and g(n+2)
g(4)

This code will terminate if the Goldbach conjecture does not hold for all even numbers (i.e. if all even numbers can be expressed as the sum of two primes). It has currently been tested for numbers up to 4*10^18.

A huge amount of thanks to @Pietu1998 for shortening my code by a lot!

EDIT: Thanks to @JonathanAllan for shaving 6 bytes off my code!


答:
MATL, 11 bytes

```<code>`@QEtZq&+=z
</code>```

Terminates iff the Goldbach conjecture is false. That is, the program stops if it finds an even number greater than 2 that cannot be expressed as the sum of two primes.

```<code>`        % Do...while
  @      %   Push iteration index k. Gives 1, 2, 3, ...
  QE     %   Add 1 and multiply by 2. Gives 4, 6, 8, ...
  tZq    %   Duplicate. Push all primes up to current k
  &+     %   Matrix with all pairwise additions of those primes
  =z     %   Number of entries of that matrix that equal k. This is used as loop
         %   condition. That is, the loop continues if this number is nonzero
         % Implicit end
</code>```

Title: Does the code terminate?

Body:
MATL, 11 bytes

`@QEtZq&+=z

Terminates iff the Goldbach conjecture is false. That is, the program stops if it finds an even number greater than 2 that cannot be expressed as the sum of two primes.

`        % Do...while
  @      %   Push iteration index k. Gives 1, 2, 3, ...
  QE     %   Add 1 and multiply by 2. Gives 4, 6, 8, ...
  tZq    %   Duplicate. Push all primes up to current k
  &+     %   Matrix with all pairwise additions of those primes
  =z     %   Number of entries of that matrix that equal k. This is used as loop
         %   condition. That is, the loop continues if this number is nonzero
         % Implicit end


答:
Python 3.5, 110 bytes

u='_'*10
for c in[*range(2,11),*'JQKA']:print(' %s\n/%%11s\n'%u%'\\'+'| %-6s%2s |\n'*7%(c,*' '*12,c)+'\%s/'%u)
```

Prints

The top two lines ' %s\n/%%11s\n'%u%'\\' where u is '_'*10

The middle 7 lines '| %-2s    %2s |\n', each of which has two string formatting slots. The first and last are filled with the card value, and the rest with spaces for no effect

The bottom line '\%s/'%u

Python 3.5's new unpacking features are used in two places. The list of labels [*range(2,11),*'JQKA'] unpacks the numbers and letters into one list. And, the tuple (c,*' '*12,c) unpacks twelve entries of spaces into the center.

Title: Shuffle Up and Deal!

Body:
It is Friday and I am tired, so let's do a quick one! Take no input, however you should output all thirteen different numbered cards in a standard deck of cards. You should output 2 through Ace (Suit agnostic).

Each card has a top that is denoted with a space   and ten _ and another space .

The second row from the top is denoted with a / and ten spaces   and a \

The third row is the same as all the middle-ish rows excepts the character(s) denoting the card value appear two spaces to right (if at the top) or two space to the left (if at the bottom) of the edge.

Each middle-ish row is a simple | and ten spaces   and one more |

Finally the last line is a \ and ten _ and finally a /

If the value is multi-digit the overall width by height of the card should not change. (i.e. the 10 will not make the card's sides wider)

King Example:

```<code> __________
/          \
| K        |
|          |
|          |
|          |
|          |
|          |
|        K |
\__________/
</code>```

9 Example

```<code> __________
/          \
| 9        |
|          |
|          |
|          |
|          |
|          |
|        9 |
\__________/
</code>```

10 Example

```<code> __________
/          \
| 10       |
|          |
|          |
|          |
|          |
|          |
|       10 |
\__________/
</code>```

Output them in order from least to greatest (Aces are high!).

This is code-golf so the shortest code wins.

Have fun and have a fun weekend!

Body:
Python 3.5, 110 bytes

u='_'*10
for c in[*range(2,11),*'JQKA']:print(' %s\n/%%11s\n'%u%'\\'+'| %-6s%2s |\n'*7%(c,*' '*12,c)+'\%s/'%u)

Prints

The top two lines ' %s\n/%%11s\n'%u%'\\' where u is '_'*10

The middle 7 lines '| %-2s    %2s |\n', each of which has two string formatting slots. The first and last are filled with the card value, and the rest with spaces for no effect

The bottom line '\%s/'%u

Python 3.5's new unpacking features are used in two places. The list of labels [*range(2,11),*'JQKA'] unpacks the numbers and letters into one list. And, the tuple (c,*' '*12,c) unpacks twelve entries of spaces into the center.


问:
Goldbach partitions
The Goldbach conjecture states that every even number greater than two can be expressed as the sum of two primes. For example,

```<code>4 = 2 + 2
6 = 3 + 3
8 = 5 + 3
</code>```

However, once we get to 10 something interesting happens. Not only can 10 be written as

```<code>5 + 5
</code>```

but it can also be written as

```<code>7 + 3
</code>```

Since 10 can be expressed as the sum of two primes two ways, we say that the "Goldbach partition" of 10 is 2. Or more generally,

The Goldbach partition of a number is the total number of distinct ways of writing n = p + q where p and q are primes and p >= q

Your challenge is to write a program or function that finds the Goldbach partition of a number. Now, technically the term "Goldbach partition" is used only to refer to even numbers. However, since the odd integer p + 2 can also be expressed as the sum of two primes if p > 2 is prime, we will extend this to all positive integers (A061358).

You may safely assume that your input will always be a positive integer, and you may take input and output in any of our default allowed methods, for example function arguments and return value, STDIN and STDOUT, reading and writing to a file, etc.

The Goldbach partitions of the positive integers up to 100 are:

```<code>0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, 2, 1, 2, 1, 3, 0, 3, 1,
3, 0, 2, 0, 3, 1, 2, 1, 4, 0, 4, 0, 2, 1, 3, 0, 4, 1, 3, 1, 4, 0, 5, 1, 4,
0, 3, 0, 5, 1, 3, 0, 4, 0, 6, 1, 3, 1, 5, 0, 6, 0, 2, 1, 5, 0, 6, 1, 5, 1,
5, 0, 7, 0, 4, 1, 5, 0, 8, 1, 5, 0, 4, 0, 9, 1, 4, 0, 5, 0, 7, 0, 3, 1, 6
</code>```

As usual, standard loopholes apply, and the shortest answer in bytes wins!

答:
MATL, 8 bytes

```<code>tZq&+=Rz
</code>```

Try it online!

Explanation

Consider input 8 as an example

```<code>      % Take input implicitly
t     % Duplicate
      % STACK: 8, 8
Zq    % All primes up to that number
      % STACK: 8, [2 3 5 7]
&+    % Matrix with all pairwise additions
      % STACK: 8, [4  5  7  9
                   5  6  8 10
                   7  8 10 12
                   9 10 12 14]
=     % True for entries that equal the input
      % STACK: [0 0 0 0
                0 0 1 0
                0 1 0 0
                0 0 0 0]
R     % Extract upper triangular part (including diagonal).
      % This removes pairs that are equal up to order
      % STACK: [0 0 0 0
                0 0 1 0
                0 0 0 0
                0 0 0 0]
z     % Number of nonzero entries
      % STACK: 1
      % Display implicitly
</code>```

It's interesting to observe the graph of the sequence, using a slightly modified version of the code:

```<code>:"@       % Input n implicitly. For each k from 1 to n, push k
tZq&+=Rz  % Same code as above. Pushes the result for each k
]v'.'&XG  % End. Concatenate all results into a vector. Plot as dots
</code>```

For input 10000 the result is

You can try it at MATL Online (Refresh the page if the "Run" button doesn't change to "Kill" when pressed). It takes several about 25 seconds to produce the graph for input 3000; inputs above a few thousands will time out.

Title: Goldbach partitions

Body:
MATL, 8 bytes

tZq&+=Rz

Try it online!

Explanation

Consider input 8 as an example

      % Take input implicitly
t     % Duplicate
      % STACK: 8, 8
Zq    % All primes up to that number
      % STACK: 8, [2 3 5 7]
&+    % Matrix with all pairwise additions
      % STACK: 8, [4  5  7  9
                   5  6  8 10
                   7  8 10 12
                   9 10 12 14]
=     % True for entries that equal the input
      % STACK: [0 0 0 0
                0 0 1 0
                0 1 0 0
                0 0 0 0]
R     % Extract upper triangular part (including diagonal).
      % This removes pairs that are equal up to order
      % STACK: [0 0 0 0
                0 0 1 0
                0 0 0 0
                0 0 0 0]
z     % Number of nonzero entries
      % STACK: 1
      % Display implicitly

It's interesting to observe the graph of the sequence, using a slightly modified version of the code:

:"@       % Input n implicitly. For each k from 1 to n, push k
tZq&+=Rz  % Same code as above. Pushes the result for each k
]v'.'&XG  % End. Concatenate all results into a vector. Plot as dots

For input 10000 the result is

You can try it at MATL Online (Refresh the page if the "Run" button doesn't change to "Kill" when pressed). It takes several about 25 seconds to produce the graph for input 3000; inputs above a few thousands will time out.


答:
Jelly, <s>11</s> 9 bytes

```<code>ÆẸ⁺‘ÆPµ6#
</code>```

This will terminate once the sixth Fermat prime is found.

Try it online!

How it works

```<code>ÆẸ⁺‘ÆPµ6#  Main link. No arguments. Implicit argument: 0

      µ6#  Convert the links to the left into a monadic chain and call it with
           arguments k = 0, 1, 2, ... until 6 of them return 1.
ÆẸ         Convert [k] to the integer with that prime exponent factorization, i.e.,
           into 2 ** k.
  ⁺        Repeat.
   ‘       Increment.
           We've now calculated 2 ** 2 ** k + 1.
    ÆP     Test the result for primality.
</code>```

Title: Does the code terminate?

Body:
Jelly, <s>11</s> 9 bytes

ÆẸ⁺‘ÆPµ6#

This will terminate once the sixth Fermat prime is found.

Try it online!

How it works

ÆẸ⁺‘ÆPµ6#  Main link. No arguments. Implicit argument: 0

      µ6#  Convert the links to the left into a monadic chain and call it with
           arguments k = 0, 1, 2, ... until 6 of them return 1.
ÆẸ         Convert [k] to the integer with that prime exponent factorization, i.e.,
           into 2 ** k.
  ⁺        Repeat.
   ‘       Increment.
           We've now calculated 2 ** 2 ** k + 1.
    ÆP     Test the result for primality.


答:
Python 2, 76 bytes

g=lambda n,k=2:n/k/2and all(x%i for x in[k,n-k]for i in range(2,x))+g(n,k+1)
```

<p>Recursively crawls up from <code>k=2</code> to <code>n/2</code>, adding up values where both <code>k</code> and <code>n-k</code> are prime. It would be nice to count <code>n</code> down at the same time instead, but this has a problem that <code>k=0</code> and <code>k=1</code> are falsely called prime:</p>

<pre class="lang-python prettyprint-override"><code>g=lambda n,k=0:n/k and all(x%i for x in[k,n]for i in range(2,x))+g(n-1,k+1)
</code>```

The primality check is trial-division, shortened by checking both k and n-k together. I found this to be shorter than using a Wilson's Theorem generator (79 bytes):

f=lambda n,k=1,P=1,l=[]:n/k and P%k*(n-k in l+P%k*[k])+f(n,k+1,P*k*k,l+P%k*[k])
```

<p>The idea for this one is to keep a list of all primes in the bottom half to be checked by the time we get to the top half, but for the midpoint <code>k=n/2</code>, we haven't had time to add <code>n-k</code> to out list when we get to <code>k</code>. An iterative version gets around this, but is 82 bytes:</p>

<pre class="lang-python prettyprint-override"><code>n=input()
s=P=k=1;l=[]
while k<n:l+=P%k*[k];s+=P%k*(n-k in l);P*=k*k;k+=1
print~-s
</code>```

Title: Goldbach partitions

Body:
The Goldbach conjecture states that every even number greater than two can be expressed as the sum of two primes. For example,

```<code>4 = 2 + 2
6 = 3 + 3
8 = 5 + 3
</code>```

However, once we get to 10 something interesting happens. Not only can 10 be written as

```<code>5 + 5
</code>```

but it can also be written as

```<code>7 + 3
</code>```

Since 10 can be expressed as the sum of two primes two ways, we say that the "Goldbach partition" of 10 is 2. Or more generally,

The Goldbach partition of a number is the total number of distinct ways of writing n = p + q where p and q are primes and p >= q

Your challenge is to write a program or function that finds the Goldbach partition of a number. Now, technically the term "Goldbach partition" is used only to refer to even numbers. However, since the odd integer p + 2 can also be expressed as the sum of two primes if p > 2 is prime, we will extend this to all positive integers (A061358).

You may safely assume that your input will always be a positive integer, and you may take input and output in any of our default allowed methods, for example function arguments and return value, STDIN and STDOUT, reading and writing to a file, etc.

The Goldbach partitions of the positive integers up to 100 are:

```<code>0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, 2, 1, 2, 1, 3, 0, 3, 1,
3, 0, 2, 0, 3, 1, 2, 1, 4, 0, 4, 0, 2, 1, 3, 0, 4, 1, 3, 1, 4, 0, 5, 1, 4,
0, 3, 0, 5, 1, 3, 0, 4, 0, 6, 1, 3, 1, 5, 0, 6, 0, 2, 1, 5, 0, 6, 1, 5, 1,
5, 0, 7, 0, 4, 1, 5, 0, 8, 1, 5, 0, 4, 0, 9, 1, 4, 0, 5, 0, 7, 0, 3, 1, 6
</code>```

As usual, standard loopholes apply, and the shortest answer in bytes wins!

Body:
Python 2, 76 bytes

g=lambda n,k=2:n/k/2and all(x%i for x in[k,n-k]for i in range(2,x))+g(n,k+1)

Recursively crawls up from k=2 to n/2, adding up values where both k and n-k are prime. It would be nice to count n down at the same time instead, but this has a problem that k=0 and k=1 are falsely called prime:

g=lambda n,k=0:n/k and all(x%i for x in[k,n]for i in range(2,x))+g(n-1,k+1)

The primality check is trial-division, shortened by checking both k and n-k together. I found this to be shorter than using a Wilson's Theorem generator (79 bytes):

f=lambda n,k=1,P=1,l=[]:n/k and P%k*(n-k in l+P%k*[k])+f(n,k+1,P*k*k,l+P%k*[k])

The idea for this one is to keep a list of all primes in the bottom half to be checked by the time we get to the top half, but for the midpoint k=n/2, we haven't had time to add n-k to out list when we get to k. An iterative version gets around this, but is 82 bytes:

n=input()
s=P=k=1;l=[]
while k<n:l+=P%k*[k];s+=P%k*(n-k in l);P*=k*k;k+=1
print~-s


Title: Goldbach partitions

Body:
Jelly, 12 bytes

HRð,_@ÆPð×/S

TryItOnline

1-100

How?

HRð,_@ÆPð×/S - Main link: n    e.g. 22
H            - halve
 R           - range          [1,2,3,4,5,6,7,8,9,10,11] (note this will be 1 to n//2)
  ð          - dyadic chain separation
   ,         - pair with
    _@       - n -           [[1,2,3,4,5,6,7,8,9,10,11],[21,20,19,18,17,16,15,14,13,12,11]]
      ÆP     - is prime? (1 if prime 0 if not)
                            [[0,1,1,0,1,0,1,0,0,0,1],[0,0,1,0,1,0,0,0,1,0,1]]
        ð    - dyadic chain separation
         ×/  - reduce with multiplication
                             [0,0,1,0,1,0,0,0,0,0,1]
           S - sum           3


答:
Jelly, 8 bytes

```<code>_ÆRÆPSHĊ
</code>```

Try it online! or verify all test cases.

How it works

```<code>_ÆRÆPSHĊ  Main link. Argument: n (positive integer)

 ÆR       Prime range; yield [2, 3, 5, ..., n].
_         Subtract all primes in this range from n.
   ÆP     Compute the primality of the resulting differences.
          This returns 1 for each prime p such that n - p is also prime.
     S    Compute the sum of the resulting Booleans.
      H   Divide it by 2, since [p, n - p] and [n - p, p] have both been counted.
       Ċ  Ceil; round the resulting quotient up (needed if n = 2p).
</code>```

Title: Goldbach partitions

Body:
Jelly, 8 bytes

_ÆRÆPSHĊ

Try it online! or verify all test cases.

How it works

_ÆRÆPSHĊ  Main link. Argument: n (positive integer)

 ÆR       Prime range; yield [2, 3, 5, ..., n].
_         Subtract all primes in this range from n.
   ÆP     Compute the primality of the resulting differences.
          This returns 1 for each prime p such that n - p is also prime.
     S    Compute the sum of the resulting Booleans.
      H   Divide it by 2, since [p, n - p] and [n - p, p] have both been counted.
       Ċ  Ceil; round the resulting quotient up (needed if n = 2p).


问:
Print the tetration

Tetration, represented as \${}^ba\$, is repeated exponentiation. For example, \${}^32\$ is \$2^{2^2}\$, which is \$16\$.

Given two numbers \$a\$ and \$b\$, print \${}^ba\$.

Test cases

```<code>1 2 -> 1
2 2 -> 4
5 2 -> 3125
3 3 -> 7625597484987
etc.
</code>```

Scientific notation is acceptable.

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

答:
Python, 33 bytes

```<code>lambda a,b:eval('**'.join([a]*b))
</code>```

This evaluates to an unnamed function, that takes the string representation of a number and a number. For example:

```<code>>>> f=lambda a,b:eval('**'.join([a]*b))
>>> f('5',2)
3125
>>>
</code>```

If mixing input formats like this does not count, there is also this 38 byte version:

```<code>lambda a,b:eval('**'.join([str(a)]*b))
</code>```

Title: Print the tetration

Body:
Python, 33 bytes

lambda a,b:eval('**'.join([a]*b))

This evaluates to an unnamed function, that takes the string representation of a number and a number. For example:

>>> f=lambda a,b:eval('**'.join([a]*b))
>>> f('5',2)
3125
>>>

If mixing input formats like this does not count, there is also this 38 byte version:

lambda a,b:eval('**'.join([str(a)]*b))


答:
Haskell, 19 bytes

a%b=iterate(a^)1!!b
```

<p>Iterates exponentiating starting at <code>1</code> to produce the list <code>[1,a,a^a,a^a^a,...]</code>, then take the <code>b</code>'th element.</p>

<p>Same length directly:</p>

<pre class="lang-haskell prettyprint-override"><code>a%0=1;a%b=a^a%(b-1)
</code>```

Point-free is longer:

(!!).(`iterate`1).(^)
```

Title: Print the tetration

Body:
Tetration, represented as \${}^ba\$, is repeated exponentiation. For example, \${}^32\$ is \$2^{2^2}\$, which is \$16\$.

Given two numbers \$a\$ and \$b\$, print \${}^ba\$.

Test cases

```<code>1 2 -> 1
2 2 -> 4
5 2 -> 3125
3 3 -> 7625597484987
etc.
</code>```

Scientific notation is acceptable.

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

Body:
Haskell, 19 bytes

a%b=iterate(a^)1!!b

Iterates exponentiating starting at 1 to produce the list [1,a,a^a,a^a^a,...], then take the b'th element.

Same length directly:

a%0=1;a%b=a^a%(b-1)

Point-free is longer:

(!!).(`iterate`1).(^)


答:
Python, 30 bytes

f=lambda a,b:b<1or a**f(a,b-1)
```

Uses the recursive definition.

Title: Print the tetration

Body:
Python, 30 bytes

f=lambda a,b:b<1or a**f(a,b-1)

Uses the recursive definition.


答:
J, <s>5</s> 4 bytes

```<code>^/@#
</code>```

This is literally the definition of tetration.

Usage

```<code>   f =: ^/@#
   3 f 2
16
   2 f 1
1
   2 f 2
4
   2 f 5
3125
   4 f 2
65536
</code>```

Explanation

```<code>^/@#  Input: b (LHS), a (RHS)
   #  Make b copies of a
^/@   Reduce from right-to-left using exponentation
</code>```

Title: Print the tetration

Body:
J, <s>5</s> 4 bytes

^/@#

This is literally the definition of tetration.

Usage

   f =: ^/@#
   3 f 2
16
   2 f 1
1
   2 f 2
4
   2 f 5
3125
   4 f 2
65536

Explanation

^/@#  Input: b (LHS), a (RHS)
   #  Make b copies of a
^/@   Reduce from right-to-left using exponentation


答:
Perl, 40 bytes

```<code>map{$a=$ARGV[0]**$a}0..$ARGV[1];print$a;
</code>```

Accepts two integers as input to the function and outputs the result

Title: Print the tetration

Body:
Perl, 40 bytes

map{$a=$ARGV[0]**$a}0..$ARGV[1];print$a;

Accepts two integers as input to the function and outputs the result


答:
Element, 11 bytes

```<code>__2:':1[^]`
</code>```

Try it online!

This is just "straightforward" exponentiation in a loop.

```<code>__2:':1[^]`
__              take two values as input (x and y)
  2:'           duplicate y and send one copy to the control stack
     :          make y copies of x
      1         push 1 as the initial value
       [ ]      loop y times
        ^       exponentiate
          `     print result
</code>```

Title: Print the tetration

Body:
Element, 11 bytes

__2:':1[^]`

Try it online!

This is just "straightforward" exponentiation in a loop.

__2:':1[^]`
__              take two values as input (x and y)
  2:'           duplicate y and send one copy to the control stack
     :          make y copies of x
      1         push 1 as the initial value
       [ ]      loop y times
        ^       exponentiate
          `     print result


问:
Generate a random digit!
Your task is to generate a random digit following these steps:

First, generate 10 random digits to make a binary number, 50% 0, and 50% 1:

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

If it is all zeros, generate a new one.

Convert this to decimal:

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

For each digit, write that amount of alternating 0s and 1s (first digit = 1s, second digit = 0s, third digit = 1s, etc.):

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

Convert this to decimal:

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

Take the middle digit (If there is an even number of digits, take the left middle)

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

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

答:
Pyth, <s>23</s> 22 bytes

1 byte thanks to @Jakube (swap r operands).

```<code>ehc2`ir9,R=!ZjOS1023T2
</code>```

Try it online.

First, generate 10 random digits to make a binary number, 50% 0, and 50% 1.

If it is all zeros, generate a new one.

Convert this to decimal.

Generate a number between 1 and 1023. OS1023 in Pyth. Then get its digits: j…T.

For each digit, write that amount of alternating 0s and 1s (first digit = 1s, second digit = 0s, third digit = 1s, etc.).

Pair each digit with an alternating True or False: ,R=!Z. The alternating booleans come from =!Z, or Z = not Z where Z starts as 0. Then run-length decode: r…9.

Convert this to decimal.

Parse integer as binary: i…2.

Take the middle digit (If there is an even number of digits, take the left middle).

Take the string representation: `. Split it in two, with the possible middle character going to the left: c2. Take the first half's last character: eh.

Title: Generate a random digit!

Body:
Pyth, <s>23</s> 22 bytes

1 byte thanks to @Jakube (swap r operands).

ehc2`ir9,R=!ZjOS1023T2

Try it online.

First, generate 10 random digits to make a binary number, 50% 0, and 50% 1.

If it is all zeros, generate a new one.

Convert this to decimal.

Generate a number between 1 and 1023. OS1023 in Pyth. Then get its digits: j…T.

For each digit, write that amount of alternating 0s and 1s (first digit = 1s, second digit = 0s, third digit = 1s, etc.).

Pair each digit with an alternating True or False: ,R=!Z. The alternating booleans come from =!Z, or Z = not Z where Z starts as 0. Then run-length decode: r…9.

Convert this to decimal.

Parse integer as binary: i…2.

Take the middle digit (If there is an even number of digits, take the left middle).

Take the string representation: `. Split it in two, with the possible middle character going to the left: c2. Take the first half's last character: eh.


答:
Jelly, 4 bytes

```<code>x*@/
</code>```

Try it online! or verify all test cases.

How it works

```<code>x*@/  Main link. Arguments: a, b

x     Repeat [a] b times.
 *@/  Reduce the resulting array by exponentation with swapped arguments.
</code>```

Title: Print the tetration

Body:
Jelly, 4 bytes

x*@/

Try it online! or verify all test cases.

How it works

x*@/  Main link. Arguments: a, b

x     Repeat [a] b times.
 *@/  Reduce the resulting array by exponentation with swapped arguments.


答:
Python, 36 bytes

k=n=1
while(n+1)**.5%1+7/k:k+=1;n*=k
```

Uses Brocard's problem:

Is n!+1 a perfect square for any n≥8?

Computes successive factorials and checks whether they are squares and have k>7. Thanks to Dennis for 2 bytes!

This assumes Python continues to have accurate arithmetic for arbitrarily large numbers. In actual implementation, it terminates.

Title: Does the code terminate?

Body:
This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An example of what I mean could be the following piece of python code, adapted from an anwser to this cs stackexchange question.

```<code>def is_perfect(n):
    return sum(i for i in range(1, n) if n % i == 0) == n

n = 3
while not is_perfect(n):
    n = n + 2
</code>```

Mathematicians conjecture that there are no odd perfect numbers, but it has never been proven, so no one knows if this piece of code will ever terminate. Can you come up with other pieces of code (perhaps relying on other open problems like the Collatz conjecture, or the twin primes conjecture) that are shorter, but for which it is unknown whether or not they terminate?

Edit: Some people have brought up a good additional rule - The solutions to the question should be deterministic. Although it might be even more interesting if you could find shorter solutions using nondeterminism. In this case, the rule would be to find a snippet for which the probability of termination is unknown.

Body:
Python, 36 bytes

k=n=1
while(n+1)**.5%1+7/k:k+=1;n*=k

Uses Brocard's problem:

Is n!+1 a perfect square for any n≥8?

Computes successive factorials and checks whether they are squares and have k>7. Thanks to Dennis for 2 bytes!

This assumes Python continues to have accurate arithmetic for arbitrarily large numbers. In actual implementation, it terminates.


答:
Dyalog APL, 3 bytes

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

TryAPL.

Explanation

```<code>*/⍴  Input: b (LHS), a (RHS)
  ⍴  Create b copies of a
*/   Reduce from right-to-left using exponentation
</code>```

Title: Print the tetration

Body:
Dyalog APL, 3 bytes

*/⍴

TryAPL.

Explanation

*/⍴  Input: b (LHS), a (RHS)
  ⍴  Create b copies of a
*/   Reduce from right-to-left using exponentation


答:
JavaScript (ES7), 24 bytes

```<code>f=(a,b)=>b?a**f(a,b-1):1
</code>```

The ES6 version is 33 bytes:

```<code>f=(a,b)=>b?Math.pow(a,f(a,b-1)):1
</code>```

Title: Print the tetration

Body:
JavaScript (ES7), 24 bytes

f=(a,b)=>b?a**f(a,b-1):1

The ES6 version is 33 bytes:

f=(a,b)=>b?Math.pow(a,f(a,b-1)):1


答:
Pyth, 6 bytes

```<code>u^QGE1
</code>```

Try it online.

Explanation

```<code>          (implicit: input a to Q)
     1    Start from 1.
u   E     b times,
 ^GQ      raise the previous number to power a.

</code>```

Title: Print the tetration

Body:
Pyth, 6 bytes

u^QGE1

Try it online.

Explanation

          (implicit: input a to Q)
     1    Start from 1.
u   E     b times,
 ^GQ      raise the previous number to power a.


答:
JavaScript (ES6), <s>77</s> <s>73</s> 70 bytes

Saved 3 bytes thanks to @Arnauld

```<code>f=(n,x=n)=>--x<2||n%x&&f(n,x)
g=(a,b=a>>1)=>b>1?f(b)*f(a-b)+g(a,b-1):0
</code>```

f is a primality-test function; the relevant function is g.

f works by recursively counting down from n-1; the control flow at each stage goes like this:

x<2|| If x < 2, the number is prime; return 1.

n%x&& Otherwise if n mod x = 0, the number is not prime; return n%x.

f(n,x-1) Otherwise, the number may or may not be prime; decrement x and try again.

g works in a similar fashion, though with not so much control flow. It works by multiplying f(b) by f(a-b) for each integer b in the range [2, floor(a/2)], then summing the results. This gives us the number of pairs that sum to a where both numbers in the pair are prime, which is exactly what we want.

Title: Goldbach partitions

Body:
The Goldbach conjecture states that every even number greater than two can be expressed as the sum of two primes. For example,

```<code>4 = 2 + 2
6 = 3 + 3
8 = 5 + 3
</code>```

However, once we get to 10 something interesting happens. Not only can 10 be written as

```<code>5 + 5
</code>```

but it can also be written as

```<code>7 + 3
</code>```

Since 10 can be expressed as the sum of two primes two ways, we say that the "Goldbach partition" of 10 is 2. Or more generally,

The Goldbach partition of a number is the total number of distinct ways of writing n = p + q where p and q are primes and p >= q

Your challenge is to write a program or function that finds the Goldbach partition of a number. Now, technically the term "Goldbach partition" is used only to refer to even numbers. However, since the odd integer p + 2 can also be expressed as the sum of two primes if p > 2 is prime, we will extend this to all positive integers (A061358).

You may safely assume that your input will always be a positive integer, and you may take input and output in any of our default allowed methods, for example function arguments and return value, STDIN and STDOUT, reading and writing to a file, etc.

The Goldbach partitions of the positive integers up to 100 are:

```<code>0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, 2, 1, 2, 1, 3, 0, 3, 1,
3, 0, 2, 0, 3, 1, 2, 1, 4, 0, 4, 0, 2, 1, 3, 0, 4, 1, 3, 1, 4, 0, 5, 1, 4,
0, 3, 0, 5, 1, 3, 0, 4, 0, 6, 1, 3, 1, 5, 0, 6, 0, 2, 1, 5, 0, 6, 1, 5, 1,
5, 0, 7, 0, 4, 1, 5, 0, 8, 1, 5, 0, 4, 0, 9, 1, 4, 0, 5, 0, 7, 0, 3, 1, 6
</code>```

As usual, standard loopholes apply, and the shortest answer in bytes wins!

Body:
JavaScript (ES6), <s>77</s> <s>73</s> 70 bytes

Saved 3 bytes thanks to @Arnauld

f=(n,x=n)=>--x<2||n%x&&f(n,x)
g=(a,b=a>>1)=>b>1?f(b)*f(a-b)+g(a,b-1):0

f is a primality-test function; the relevant function is g.

f works by recursively counting down from n-1; the control flow at each stage goes like this:

x<2|| If x < 2, the number is prime; return 1.

n%x&& Otherwise if n mod x = 0, the number is not prime; return n%x.

f(n,x-1) Otherwise, the number may or may not be prime; decrement x and try again.

g works in a similar fashion, though with not so much control flow. It works by multiplying f(b) by f(a-b) for each integer b in the range [2, floor(a/2)], then summing the results. This gives us the number of pairs that sum to a where both numbers in the pair are prime, which is exactly what we want.


答:
Minkolang 0.15, <s>12</s> 11 bytes

```<code>nnDI1-[;]N.
</code>```

Try it here!

Explanation

```<code>nn             Read two integers from input
  D            Pop top of stack and duplicate next element that many times
   I1-         Push length of stack, minus 1
      [        Pop top of stack and repeat for loop that many times
       ;       Pop b, a and push a^b
        ]      Close for loop
         N.    Output as number and stop.
</code>```

Title: Print the tetration

Body:
Minkolang 0.15, <s>12</s> 11 bytes

nnDI1-[;]N.

Try it here!

Explanation

nn             Read two integers from input
  D            Pop top of stack and duplicate next element that many times
   I1-         Push length of stack, minus 1
      [        Pop top of stack and repeat for loop that many times
       ;       Pop b, a and push a^b
        ]      Close for loop
         N.    Output as number and stop.


答:
Jelly 17 bytes

```<code>⁵Ḷx“ḶƇleJZaEC_‘µX
</code>```

TryItOnline!

How?

The distribution of the first step are [1,1023] with equal likelihood.

Applying the transformation instructed for each of those numbers produces a distribution of:

{0: 178, 1: 144, 2: 108, 3: 101, 4: 74, 5: 90, 6: 97, 7: 69, 8: 67, 9: 95}

```<code>⁵Ḷx“ḶƇleJZaEC_‘µX - Main link: (niladic)
⁵                 - literal 10
 Ḷ                - range -> [0,1,2,3,4,5,6,7,8,9]
   “ḶƇleJZaEC_‘   - code page indexes -> [178,144,108,101,74,90,97,69,67,95]
  x               - repeat - > [178 zeros, 144 ones, 108 twos, ...]
               µ  - monadic chain separation
                X - pick a random element
</code>```

Title: Generate a random digit!

Body:
Your task is to generate a random digit following these steps:

First, generate 10 random digits to make a binary number, 50% 0, and 50% 1:

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

If it is all zeros, generate a new one.

Convert this to decimal:

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

For each digit, write that amount of alternating 0s and 1s (first digit = 1s, second digit = 0s, third digit = 1s, etc.):

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

Convert this to decimal:

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

Take the middle digit (If there is an even number of digits, take the left middle)

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

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

Body:
Jelly 17 bytes

⁵Ḷx“ḶƇleJZaEC_‘µX

TryItOnline!

How?

The distribution of the first step are [1,1023] with equal likelihood.

Applying the transformation instructed for each of those numbers produces a distribution of:

{0: 178, 1: 144, 2: 108, 3: 101, 4: 74, 5: 90, 6: 97, 7: 69, 8: 67, 9: 95}

⁵Ḷx“ḶƇleJZaEC_‘µX - Main link: (niladic)
⁵                 - literal 10
 Ḷ                - range -> [0,1,2,3,4,5,6,7,8,9]
   “ḶƇleJZaEC_‘   - code page indexes -> [178,144,108,101,74,90,97,69,67,95]
  x               - repeat - > [178 zeros, 144 ones, 108 twos, ...]
               µ  - monadic chain separation
                X - pick a random element


问:
A penny saved is a penny

...counted!

You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values.  Your challenge is to output the number of possible combinations of the given array of coin values that would add up to the amount passed to the code.  If it is not possible with the coins named, the program should return 0.

Note on American numismatic terminology:

1-cent coin: penny

5-cent coin: nickel

10-cent coin: dime

25-cent coin: quarter (quarter dollar)

Example 1:

Program is passed:

```<code>12, [1, 5, 10]
</code>```

(12 cents)

Output:

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

There are 4 possible ways of combining the coins named to produce 12 cents:

12 pennies

1 nickel and 7 pennies

2 nickels and 2 pennies

1 dime and 2 pennies

Example 2:

Program is passed:

```<code>26, [1, 5, 10, 25]
</code>```

(26 cents)

Output:

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

There are 13 possible ways of combining the coins named to produce 26 cents:

26 pennies

21 pennies and 1 nickel

16 pennies and 2 nickels

11 pennies and 3 nickels

6 pennies and 4 nickels

1 penny and 5 nickels

16 pennies and 1 dime

6 pennies and 2 dimes

11 pennies, 1 dime, and 1 nickel

6 pennies, 1 dime, and 2 nickels

1 penny, 1 dime, and 3 nickels

1 penny, 2 dimes, and 1 nickel

1 quarter and 1 penny

Example 3:

Program is passed:

```<code>19, [2, 7, 12]
</code>```

Output:

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

There are 2 possible ways of combining the coins named to produce 19 cents:

1 12-cent coin and 1 7-cent coin

1 7-cent coin and 6 2-cent coins

Example 4:

Program is passed:

```<code>13, [2, 8, 25]
</code>```

Output:

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

There are no possible ways of combining the coins named to produce 13 cents.

This has been through the Sandbox.  Standard loopholes apply.  This is code golf, so the answer with the fewest bytes wins.

答:
Racket 275 bytes

```<code>(set! l(flatten(for/list((i l))(for/list((j(floor(/ s i))))i))))(define oll'())(for((i(range 1(add1(floor(/ s(apply min l)))))))
(define ol(combinations l i))(for((j ol))(set! j(sort j >))(when(and(= s(apply + j))(not(ormap(λ(x)(equal? x j))oll)))(set! oll(cons j oll)))))oll
</code>```

Ungolfed:

```<code>(define(f s l)
  (set! l              ; have list contain all possible coins that can be used
        (flatten
         (for/list ((i l))
           (for/list ((j
                       (floor
                        (/ s i))))
             i))))
  (define oll '())                    ; final list of all solutions initialized
  (for ((i (range 1
                  (add1
                   (floor             ; for different sizes of coin-set
                    (/ s
                       (apply min l)))))))
    (define ol (combinations l i))          ; get a list of all combinations
    (for ((j ol))                           ; test each combination
      (set! j (sort j >))
      (when (and
             (= s (apply + j))              ; sum is correct
             (not(ormap                     ; solution is not already in list
                  (lambda(x)
                    (equal? x j))
                  oll)))
        (set! oll (cons j oll))             ; add found solution to final list
        )))
  (reverse oll))
</code>```

Testing:

```<code>(f 4 '[1 2])
(println "-------------")
(f 12 '[1 5 10])
(println "-------------")
(f 19 '[2 7 12])
(println "-------------")
(f 8 '(1 2 3))
</code>```

Output:

```<code>'((2 2) (2 1 1) (1 1 1 1))
"-------------"
'((10 1 1) (5 5 1 1) (5 1 1 1 1 1 1 1) (1 1 1 1 1 1 1 1 1 1 1 1))
"-------------"
'((12 7) (7 2 2 2 2 2 2))
"-------------"
'((3 3 2) (2 2 2 2) (3 2 2 1) (3 3 1 1) (2 2 2 1 1) (3 2 1 1 1) (2 2 1 1 1 1) (3 1 1 1 1 1) (2 1 1 1 1 1 1) (1 1 1 1 1 1 1 1))
</code>```

Following recursive solution has some error:

```<code>(define (f s l)                      ; s is sum needed; l is list of coin-types
  (set! l (sort l >))
  (define oll '())                   ; list of all solution lists
  (let loop ((l l)
             (ol '()))               ; a solution list initialized
    (when (not (null? l))
        (set! ol (cons (first l) ol)))
    (define ols (apply + ol))        ; current sum in solution list
    (cond
      [(null? l) (remove-duplicates oll)]
      [(= ols s) (set! oll (cons ol oll))
                 (loop (rest l) '())
                 ]
      [(> ols s) (loop (rest l) (rest ol))
                 (loop (rest l) '())
                 ]
      [(< ols s) (loop l ol)
                 (loop (rest l) ol)
                 ])))
</code>```

Does not work properly for:

```<code>(f 8 '[1 2 3])
</code>```

Output:

```<code>'((1 1 1 2 3) (1 2 2 3) (1 1 1 1 1 1 1 1) (2 3 3) (1 1 1 1 1 1 2) (1 1 1 1 2 2) (1 1 2 2 2) (2 2 2 2))
</code>```

(1 1 3 3) is possible but does not come in solution list.

Title: A penny saved is a penny

Body:
Racket 275 bytes

(set! l(flatten(for/list((i l))(for/list((j(floor(/ s i))))i))))(define oll'())(for((i(range 1(add1(floor(/ s(apply min l)))))))
(define ol(combinations l i))(for((j ol))(set! j(sort j >))(when(and(= s(apply + j))(not(ormap(λ(x)(equal? x j))oll)))(set! oll(cons j oll)))))oll

Ungolfed:

(define(f s l)
  (set! l              ; have list contain all possible coins that can be used
        (flatten
         (for/list ((i l))
           (for/list ((j
                       (floor
                        (/ s i))))
             i))))
  (define oll '())                    ; final list of all solutions initialized
  (for ((i (range 1
                  (add1
                   (floor             ; for different sizes of coin-set
                    (/ s
                       (apply min l)))))))
    (define ol (combinations l i))          ; get a list of all combinations
    (for ((j ol))                           ; test each combination
      (set! j (sort j >))
      (when (and
             (= s (apply + j))              ; sum is correct
             (not(ormap                     ; solution is not already in list
                  (lambda(x)
                    (equal? x j))
                  oll)))
        (set! oll (cons j oll))             ; add found solution to final list
        )))
  (reverse oll))

Testing:

(f 4 '[1 2])
(println "-------------")
(f 12 '[1 5 10])
(println "-------------")
(f 19 '[2 7 12])
(println "-------------")
(f 8 '(1 2 3))

Output:

'((2 2) (2 1 1) (1 1 1 1))
"-------------"
'((10 1 1) (5 5 1 1) (5 1 1 1 1 1 1 1) (1 1 1 1 1 1 1 1 1 1 1 1))
"-------------"
'((12 7) (7 2 2 2 2 2 2))
"-------------"
'((3 3 2) (2 2 2 2) (3 2 2 1) (3 3 1 1) (2 2 2 1 1) (3 2 1 1 1) (2 2 1 1 1 1) (3 1 1 1 1 1) (2 1 1 1 1 1 1) (1 1 1 1 1 1 1 1))

Following recursive solution has some error:

(define (f s l)                      ; s is sum needed; l is list of coin-types
  (set! l (sort l >))
  (define oll '())                   ; list of all solution lists
  (let loop ((l l)
             (ol '()))               ; a solution list initialized
    (when (not (null? l))
        (set! ol (cons (first l) ol)))
    (define ols (apply + ol))        ; current sum in solution list
    (cond
      [(null? l) (remove-duplicates oll)]
      [(= ols s) (set! oll (cons ol oll))
                 (loop (rest l) '())
                 ]
      [(> ols s) (loop (rest l) (rest ol))
                 (loop (rest l) '())
                 ]
      [(< ols s) (loop l ol)
                 (loop (rest l) ol)
                 ])))

Does not work properly for:

(f 8 '[1 2 3])

Output:

'((1 1 1 2 3) (1 2 2 3) (1 1 1 1 1 1 1 1) (2 3 3) (1 1 1 1 1 1 2) (1 1 1 1 2 2) (1 1 2 2 2) (2 2 2 2))

(1 1 3 3) is possible but does not come in solution list.


答:
Pyth, 10 bytes

```<code>fP_h^2^2T5
</code>```

Uses the conjecture that all Fermat numbers 2^(2^n)+1 are composite for n>4.

```<code>f        5   Find the first number T>=5 for which
   h^2^2T    2^(2^T)+1
 P_          is prime
</code>```

Title: Does the code terminate?

Body:
Pyth, 10 bytes

fP_h^2^2T5

Uses the conjecture that all Fermat numbers 2^(2^n)+1 are composite for n>4.

f        5   Find the first number T>=5 for which
   h^2^2T    2^(2^T)+1
 P_          is prime


答:
dc, <s>35</s> 29 bytes:

```<code>?dsdsa?[ldla^sa1-d1<b]dsbxlap
</code>```

Here is my first complete program in dc.

Title: Print the tetration

Body:
Tetration, represented as \${}^ba\$, is repeated exponentiation. For example, \${}^32\$ is \$2^{2^2}\$, which is \$16\$.

Given two numbers \$a\$ and \$b\$, print \${}^ba\$.

Test cases

```<code>1 2 -> 1
2 2 -> 4
5 2 -> 3125
3 3 -> 7625597484987
etc.
</code>```

Scientific notation is acceptable.

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

Body:
dc, <s>35</s> 29 bytes:

?dsdsa?[ldla^sa1-d1<b]dsbxlap

Here is my first complete program in dc.


答:
Mathematica, 16 bytes

```<code>Power@@Table@##&
</code>```

Explanation

```<code>Table@##
</code>```

Make b copies of a.

```<code>Power@@...
</code>```

Exponentiation.

Title: Print the tetration

Body:
Mathematica, 16 bytes

Power@@Table@##&

Explanation

Table@##

Make b copies of a.

Power@@...

Exponentiation.


答:
Jelly, 7 bytes

```<code>!‘Æ²µ4#
</code>```

Try it online!

Background

This will terminate once it finds a fourth solution to Brocard's problem, i.e. a solution n! + 1 = m² with (n,m) ≠ (4, 5), (5, 11), (7, 71) over the positive integers. The implementation doesn't use floating point arithmetic, so it will only terminate if it does find a fourth solution or if n! can no longer be represented in memory.

Brocard's problem was first used in this answer by @xnor.

How it works

```<code>!‘Æ²µ4#  Main link. No arguments. Implicit argument: 0

    µ4#  Convert the links to the left into a monadic chain and call it with
         arguments k = 0, 1, 2, ... until 4 of them return 1.
!        Factorial; yield k!.
 ‘       Increment; yield k! + 1.
  Æ²     Squareness; return 1 if k! + 1 is a perfect square, 0 if not.
</code>```

Title: Does the code terminate?

Body:
Jelly, 7 bytes

!‘Æ²µ4#

Try it online!

Background

This will terminate once it finds a fourth solution to Brocard's problem, i.e. a solution n! + 1 = m² with (n,m) ≠ (4, 5), (5, 11), (7, 71) over the positive integers. The implementation doesn't use floating point arithmetic, so it will only terminate if it does find a fourth solution or if n! can no longer be represented in memory.

Brocard's problem was first used in this answer by @xnor.

How it works

!‘Æ²µ4#  Main link. No arguments. Implicit argument: 0

    µ4#  Convert the links to the left into a monadic chain and call it with
         arguments k = 0, 1, 2, ... until 4 of them return 1.
!        Factorial; yield k!.
 ‘       Increment; yield k! + 1.
  Æ²     Squareness; return 1 if k! + 1 is a perfect square, 0 if not.


答:
Racket 51 bytes

```<code>(define ans 1)(for((i b))(set! ans(expt a ans)))ans
</code>```

Ungolfed:

```<code>(define (f a b)
  (define ans 1)
  (for((i b))
    (set! ans
          (expt a ans)))
  ans)
</code>```

Testing:

```<code>(f 1 2)
(f 2 2)
(f 5 2)
(f 3 3)
</code>```

Output:

```<code>1
4
3125
7625597484987
</code>```

Title: Print the tetration

Body:
Racket 51 bytes

(define ans 1)(for((i b))(set! ans(expt a ans)))ans

Ungolfed:

(define (f a b)
  (define ans 1)
  (for((i b))
    (set! ans
          (expt a ans)))
  ans)

Testing:

(f 1 2)
(f 2 2)
(f 5 2)
(f 3 3)

Output:

1
4
3125
7625597484987


答:
Brain-Flak, <s>212</s> <s>208</s> 204 bytes

This program uses a multiplication algorithm written by MegaTom and a non-square checker written by 1000000000

Try It Online

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

This program starts at 8 and tests each number to see if n!+1 is a square number.  It exits when it finds one.  This is known as Brocard's Problem and it is an open problem in mathematics.

Title: Does the code terminate?

Body:
This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An example of what I mean could be the following piece of python code, adapted from an anwser to this cs stackexchange question.

```<code>def is_perfect(n):
    return sum(i for i in range(1, n) if n % i == 0) == n

n = 3
while not is_perfect(n):
    n = n + 2
</code>```

Mathematicians conjecture that there are no odd perfect numbers, but it has never been proven, so no one knows if this piece of code will ever terminate. Can you come up with other pieces of code (perhaps relying on other open problems like the Collatz conjecture, or the twin primes conjecture) that are shorter, but for which it is unknown whether or not they terminate?

Edit: Some people have brought up a good additional rule - The solutions to the question should be deterministic. Although it might be even more interesting if you could find shorter solutions using nondeterminism. In this case, the rule would be to find a snippet for which the probability of termination is unknown.

Body:
Brain-Flak, <s>212</s> <s>208</s> 204 bytes

This program uses a multiplication algorithm written by MegaTom and a non-square checker written by 1000000000

Try It Online

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

This program starts at 8 and tests each number to see if n!+1 is a square number.  It exits when it finds one.  This is known as Brocard's Problem and it is an open problem in mathematics.


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

 ```

答:
Turtlèd, <s>68 63</s> <s>53</s> 54 bytes (newlines)

rewrote

```@##'@r,r,r-{ +.r_}r{ +.r_}'#'@r,r,r-{ +.r_}r{ +.r_}'f

```

Try it online!

Explanation

```<code>@#         Set character variable to #. Useful because this cannot occur in string var
  #                        #  Set the string var to...
   '@r,r,r-{ +.r_}r{ +.r_}'   This string (quotes included. coincidental)
                            '@r,r,r            Write out first three chars of program: @##
                                   -{ +.r_}r   Write out the string var, then #, move right
                                            { +.r_} Write out the string var again, write #
                                                   'f   overwrite last # with f
</code>```

Title: Golf you a quine for great good!

Body:
Turtlèd, <s>68 63</s> <s>53</s> 54 bytes (newlines)

rewrote

@##'@r,r,r-{ +.r_}r{ +.r_}'#'@r,r,r-{ +.r_}r{ +.r_}'f

Try it online!

Explanation

@#         Set character variable to #. Useful because this cannot occur in string var
  #                        #  Set the string var to...
   '@r,r,r-{ +.r_}r{ +.r_}'   This string (quotes included. coincidental)
                            '@r,r,r            Write out first three chars of program: @##
                                   -{ +.r_}r   Write out the string var, then #, move right
                                            { +.r_} Write out the string var again, write #
                                                   'f   overwrite last # with f


答:
Racket 219 bytes

```<code>(let*((pl(for/list((i n) #:when(prime? i))i))(ll(combinations(append pl pl)2))(ol'()))(for/list((i ll))(define tl(sort i >))
(when(and(= n(apply + i))(not(ormap(λ(x)(equal? x tl))ol)))(set! ol(cons tl ol))))(length ol))
</code>```

Ungolfed:

```<code>(define(f n)
 (let* ((pl                                   ; create a list of primes till n
          (for/list ((i n) #:when (prime? i))
            i))
         (ll (combinations (append pl pl) 2)) ; get a list of combinations of 2 primes
         (ol '()))                            ; initialize output list
    (for/list ((i ll))                        ; test each combination
      (define tl (sort i >))
      (when (and (= n (apply + i))            ; sum is n
                 (not(ormap (lambda(x)(equal? x tl)) ol))) ; not already in list
        (set! ol (cons tl ol))))              ; if ok, add to list
    (println ol)                              ; print list
    (length ol)))                             ; print length of list
</code>```

Testing:

```<code>(f 10)
(f 100)
</code>```

Output:

```<code>'((5 5) (7 3))
2
'((97 3) (89 11) (83 17) (71 29) (59 41) (53 47))
6
</code>```

Title: Goldbach partitions

Body:
Racket 219 bytes

(let*((pl(for/list((i n) #:when(prime? i))i))(ll(combinations(append pl pl)2))(ol'()))(for/list((i ll))(define tl(sort i >))
(when(and(= n(apply + i))(not(ormap(λ(x)(equal? x tl))ol)))(set! ol(cons tl ol))))(length ol))

Ungolfed:

(define(f n)
 (let* ((pl                                   ; create a list of primes till n
          (for/list ((i n) #:when (prime? i))
            i))
         (ll (combinations (append pl pl) 2)) ; get a list of combinations of 2 primes
         (ol '()))                            ; initialize output list
    (for/list ((i ll))                        ; test each combination
      (define tl (sort i >))
      (when (and (= n (apply + i))            ; sum is n
                 (not(ormap (lambda(x)(equal? x tl)) ol))) ; not already in list
        (set! ol (cons tl ol))))              ; if ok, add to list
    (println ol)                              ; print list
    (length ol)))                             ; print length of list

Testing:

(f 10)
(f 100)

Output:

'((5 5) (7 3))
2
'((97 3) (89 11) (83 17) (71 29) (59 41) (53 47))
6


答:
Actually, 6 bytes

```<code>n`ⁿ)`Y
</code>```

Try it online!

Input is taken as b\na (\n is a newline)

Explanation:

```<code>n`ⁿ)`Y
n       a copies of b
 `ⁿ)`Y  while stack changes between each call (fixed-point combinator):
  ⁿ       pow
   )      move top of stack to bottom (for right-associativity)
</code>```

Title: Print the tetration

Body:
Actually, 6 bytes

n`ⁿ)`Y

Try it online!

Input is taken as b\na (\n is a newline)

Explanation:

n`ⁿ)`Y
n       a copies of b
 `ⁿ)`Y  while stack changes between each call (fixed-point combinator):
  ⁿ       pow
   )      move top of stack to bottom (for right-associativity)


答:
Actually, 11 bytes

```<code>;R`p`░@-♂bΣ
</code>```

Try it online!

Explanation:

```<code>;R`p`░@-♂bΣ
 R`p`░       prime values in [1, n]
;     @-     subtract each value from n
        ♂b   convert each value to boolean
          Σ  sum
</code>```

Title: Goldbach partitions

Body:
The Goldbach conjecture states that every even number greater than two can be expressed as the sum of two primes. For example,

```<code>4 = 2 + 2
6 = 3 + 3
8 = 5 + 3
</code>```

However, once we get to 10 something interesting happens. Not only can 10 be written as

```<code>5 + 5
</code>```

but it can also be written as

```<code>7 + 3
</code>```

Since 10 can be expressed as the sum of two primes two ways, we say that the "Goldbach partition" of 10 is 2. Or more generally,

The Goldbach partition of a number is the total number of distinct ways of writing n = p + q where p and q are primes and p >= q

Your challenge is to write a program or function that finds the Goldbach partition of a number. Now, technically the term "Goldbach partition" is used only to refer to even numbers. However, since the odd integer p + 2 can also be expressed as the sum of two primes if p > 2 is prime, we will extend this to all positive integers (A061358).

You may safely assume that your input will always be a positive integer, and you may take input and output in any of our default allowed methods, for example function arguments and return value, STDIN and STDOUT, reading and writing to a file, etc.

The Goldbach partitions of the positive integers up to 100 are:

```<code>0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, 2, 1, 2, 1, 3, 0, 3, 1,
3, 0, 2, 0, 3, 1, 2, 1, 4, 0, 4, 0, 2, 1, 3, 0, 4, 1, 3, 1, 4, 0, 5, 1, 4,
0, 3, 0, 5, 1, 3, 0, 4, 0, 6, 1, 3, 1, 5, 0, 6, 0, 2, 1, 5, 0, 6, 1, 5, 1,
5, 0, 7, 0, 4, 1, 5, 0, 8, 1, 5, 0, 4, 0, 9, 1, 4, 0, 5, 0, 7, 0, 3, 1, 6
</code>```

As usual, standard loopholes apply, and the shortest answer in bytes wins!

Body:
Actually, 11 bytes

;R`p`░@-♂bΣ

Try it online!

Explanation:

;R`p`░@-♂bΣ
 R`p`░       prime values in [1, n]
;     @-     subtract each value from n
        ♂b   convert each value to boolean
          Σ  sum


答:
Actually, 13 bytes

```<code>╗╜@V`;m@M-`MM
</code>```

Try it online!

-6 bytes from the observation in nimi's Haskell answer, that slices shorter than d don't affect the maximum deviation.

Explanation:

```<code>╗╜@V`;m@M-`MM
╗              store d in register 0
 ╜@            push d, swap so v is on top
   V           push all slices of v whose length is in [1, d]
    `;m@M-`M   map (for each slice):
     ;m@M-       get minimum and maximum, subtract min from max
           M  get maximum of list of deviations
</code>```

Title: Find the maximum deviation

Body:
This problem is "inspired" from a question that was originally asked on Quora (not for code golfing). I just want to make it a challenge for you guys (and my first problem submission here).

Given an array of integer elements v and an integer d (we assume that d is lower or equal to the array's length), consider all the sequences of d consecutive elements in the array. For each sequence, compute the difference between the maximum and minimum value of the elements in that sequence and name it the deviation.

Your task is to write a program or function that computes the maximum value among all deviations of all the sequences considered above, and return or output that value.

Worked-through Example:

```<code>v: (6,9,4,7,4,1)
d: 3

The sequences of length 3 are:
6,9,4 with deviation 5
9,4,7 with deviation 5
4,7,4 with deviation 3
7,4,1 with deviation 6

Thus the maximal deviation is 6, so the output is 6.
</code>```

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

Body:
Actually, 13 bytes

╗╜@V`;m@M-`MM

Try it online!

-6 bytes from the observation in nimi's Haskell answer, that slices shorter than d don't affect the maximum deviation.

Explanation:

╗╜@V`;m@M-`MM
╗              store d in register 0
 ╜@            push d, swap so v is on top
   V           push all slices of v whose length is in [1, d]
    `;m@M-`M   map (for each slice):
     ;m@M-       get minimum and maximum, subtract min from max
           M  get maximum of list of deviations


答:
Python 2, 88 bytes

p=lambda n:all(n%x for x in range(2,n))
s=lambda n:0if p((10223*2**n)+1)else s(n+1)
s(0)
```

This code will terminate if 10223 is a Sierpiński number. 10223 is currently the smallest candidate that may or may not be a Sierpiński number, as of December 2013.

A Sierpiński number is a number k in which all numbers of the form (k * 2^n) + 1 are composite.

Title: Does the code terminate?

Body:
Python 2, 88 bytes

p=lambda n:all(n%x for x in range(2,n))
s=lambda n:0if p((10223*2**n)+1)else s(n+1)
s(0)

This code will terminate if 10223 is a Sierpiński number. 10223 is currently the smallest candidate that may or may not be a Sierpiński number, as of December 2013.

A Sierpiński number is a number k in which all numbers of the form (k * 2^n) + 1 are composite.


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

Monopoly Board

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

Rules:

Take no input.

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

The characters must be separated by spaces.

Go should start in the bottom right.

The exact string to produce is

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

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

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

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

答:
Haskell, <s>128</s> <s>125</s> 114 bytes

```<code>mapM(putStrLn.((:" ")=<<))$"FKCIIBAVWMG":zipWith(\a b->a:"         "++[b])"NTCSPVSES""PNCPSCPLB"++["JCVCORIBCMG"]
</code>```

Try it here

((:" ")=<<) is concatMap (\a -> [a,' ']) - pads by adding a space behind every letter in its input

Body:
Haskell, <s>128</s> <s>125</s> 114 bytes

mapM(putStrLn.((:" ")=<<))$"FKCIIBAVWMG":zipWith(\a b->a:"         "++[b])"NTCSPVSES""PNCPSCPLB"++["JCVCORIBCMG"]

Try it here

((:" ")=<<) is concatMap (\a -> [a,' ']) - pads by adding a space behind every letter in its input