答:
05AB1E, 5 bytes, cracked

```<code>##s##
</code>```

# indicates a hidden character.

Output:

```<code>a(4) = 8
a(6) = 144
</code>```

The sequence starts at a(1).

The original code was exactly as in @Adnan's answer to robbers' thread.

Body:
05AB1E, 5 bytes, cracked

##s##

# indicates a hidden character.

Output:

a(4) = 8
a(6) = 144

The sequence starts at a(1).

The original code was exactly as in @Adnan's answer to robbers' thread.


问:
Greatest Common Divisor
Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible.

You may write a program or function, taking input and returning output via any of our accepted standard methods (including STDIN/STDOUT, function parameters/return values, command-line arguments, etc.).

Input will be two non-negative integers. You should be able to handle either the full range supported by your language's default integer type, or the range [0,255], whichever is greater. You are guaranteed that at least one of the inputs will be non-zero.

You are not allowed to use built-ins that compute either the GCD or the LCM (least common multiple).

Standard code-golf rules apply.

Test Cases

```<code>0 2     => 2
6 0     => 6
30 42   => 6
15 14   => 1
7 7     => 7
69 25   => 1
21 12   => 3
169 123 => 1
20 142  => 2
101 202 => 101
</code>```

答:
Scheme, 44 bytes

```<code>(define(f a b)(if(= b 0)a(f b(modulo a b))))
</code>```

Scheme is the future of code-golf. :)

ContentLicense: CC BY-SA 3.0

Title: Greatest Common Divisor

Body:
Scheme, 44 bytes

(define(f a b)(if(= b 0)a(f b(modulo a b))))

Scheme is the future of code-golf. :)


答:
RETURN, 16 bytes

```<code>[$[\¤÷%G][\]?]=G
</code>```

Try it here.

Recursive operator implementation of Euclid's algorithm. Leaves result on top of stack. Usage:

```<code>[$[\¤÷%G][\]?]=G21 12G
</code>```

Explanation

```<code>[            ]=G  Define operator G
 $                Check if b is truthy
  [     ][ ]?     Conditional
   \¤               If so, create pattern [b a b] on stack
     ÷%             Mod top 2 items
       G            Recurse
          \         Otherwise, swap top 2 items
</code>```

Title: Greatest Common Divisor

Body:
Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible.

You may write a program or function, taking input and returning output via any of our accepted standard methods (including STDIN/STDOUT, function parameters/return values, command-line arguments, etc.).

Input will be two non-negative integers. You should be able to handle either the full range supported by your language's default integer type, or the range [0,255], whichever is greater. You are guaranteed that at least one of the inputs will be non-zero.

You are not allowed to use built-ins that compute either the GCD or the LCM (least common multiple).

Standard code-golf rules apply.

Test Cases

```<code>0 2     => 2
6 0     => 6
30 42   => 6
15 14   => 1
7 7     => 7
69 25   => 1
21 12   => 3
169 123 => 1
20 142  => 2
101 202 => 101
</code>```

Body:
RETURN, 16 bytes

[$[\¤÷%G][\]?]=G

Try it here.

Recursive operator implementation of Euclid's algorithm. Leaves result on top of stack. Usage:

[$[\¤÷%G][\]?]=G21 12G

Explanation

[            ]=G  Define operator G
 $                Check if b is truthy
  [     ][ ]?     Conditional
   \¤               If so, create pattern [b a b] on stack
     ÷%             Mod top 2 items
       G            Recurse
          \         Otherwise, swap top 2 items


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

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

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

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

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

The submission should be formatted like this:

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

Code:

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

Output

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

Optional explanation and comments.

答:
JavaScript (ES6), 119 bytes, Cᴏɴᴏʀ O'Bʀɪᴇɴ, A178501

x=>(n="=>[[["|x|"##r(###f#n###;##")|n?Math.pow("#<1##].c####t.##pl##[####nc#"|10,"y([###(###(#]###)"|x-1|``):0|`#h####`
```

I'm sure the actual code generates a trickier sequence than this, but with just the two outputs, this OEIS sequence is simple and matches them.

Without all the ignored characters, the algorithm is just x=>x?Math.pow(10,x-1):0.

Body:
JavaScript (ES6), 119 bytes, Cᴏɴᴏʀ O'Bʀɪᴇɴ, A178501

x=>(n="=>[[["|x|"##r(###f#n###;##")|n?Math.pow("#<1##].c####t.##pl##[####nc#"|10,"y([###(###(#]###)"|x-1|``):0|`#h####`

I'm sure the actual code generates a trickier sequence than this, but with just the two outputs, this OEIS sequence is simple and matches them.

Without all the ignored characters, the algorithm is just x=>x?Math.pow(10,x-1):0.


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

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

The cop's task

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

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

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

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

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

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

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

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

For example, if my program is:

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

Then I would hide these characters as I want:

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

The robber's task

is obviously to find the original source code.

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

Tips for the cops

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

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

Your score is the number of bytes in your code.

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

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

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

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

Lua, 98 bytes

Output:

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

Code (# marks unrevealed characters):

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

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

Body:
J, 8 bytes, cracked

# marks unrevealed characters

(##-#)#.

(Online interpreter here.)

Output:

No, I'm not hiding anything by using a long sample. If the input is 0, it outputs 0, if the input is between 1 and 29, it outputs 1.

The outputs for the negative inputs do not match with the actual sequence.

   (##-#)#.0
0
   (##-#)#.1
1
   (##-#)#.2
1
   (##-#)#.3
1
   (##-#)#.4
1
   (##-#)#.5
1
   (##-#)#.6
1
   (##-#)#.7
1
   (##-#)#.8
1
   (##-#)#.9
1
   (##-#)#.10
1
   (##-#)#.11
1
   (##-#)#.12
1
   (##-#)#.13
1
   (##-#)#.14
1
   (##-#)#.15
1
   (##-#)#.16
1
   (##-#)#.17
1
   (##-#)#.18
1
   (##-#)#.19
1
   (##-#)#.20
1
   (##-#)#.21
1
   (##-#)#.22
1
   (##-#)#.23
1
   (##-#)#.24
1
   (##-#)#.25
1
   (##-#)#.26
1
   (##-#)#.27
1
   (##-#)#.28
1
   (##-#)#.29
1


答:
05AB1E, 5 bytes, Luis Mendo, A051696

Code:

```<code>Ðms!¿
</code>```

Explanation:

```<code>Ð      # Triplicate input.
 m     # Power function, which calculates input ** input.
  s    # Swap two top elements of the stack.
   !   # Calculate the factorial of input.
    ¿  # Compute the greatest common divisor of the top two elements.
</code>```

So, basically this calculates gcd(n!, nn), which is A051696.

Try it online!.

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

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

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

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

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

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

The submission should be formatted like this:

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

Code:

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

Output

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

Optional explanation and comments.

Body:
05AB1E, 5 bytes, Luis Mendo, A051696

Code:

Ðms!¿

Explanation:

Ð      # Triplicate input.
 m     # Power function, which calculates input ** input.
  s    # Swap two top elements of the stack.
   !   # Calculate the factorial of input.
    ¿  # Compute the greatest common divisor of the top two elements.

So, basically this calculates gcd(n!, nn), which is A051696.

Try it online!.


答:
PHP, 18 bytes, cracked

Here's a very short one, at least in terms of PHP. I wonder if it survives <s>this Sunday</s> the next thirty minutes.

Output

```<code>a(0) = -1
a(1) =  0
</code>```

Source

```<code>____$____[1]+_+_0;
#### ####    # #
</code>```

Notes

It's a full program, not a function.

Reads the input from command line.

Does not contain any PHP opening tag.

Cracked

The sequence was A023443:

a(n) = n - 1

Here's my original source code, which is slightly different to the robber's:

 echo$argv[1]+-+!0;

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

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

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

The cop's task

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

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

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

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

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

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

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

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

For example, if my program is:

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

Then I would hide these characters as I want:

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

The robber's task

is obviously to find the original source code.

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

Tips for the cops

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

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

Your score is the number of bytes in your code.

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

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

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

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

Lua, 98 bytes

Output:

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

Code (# marks unrevealed characters):

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

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

Body:
PHP, 18 bytes, cracked

Here's a very short one, at least in terms of PHP. I wonder if it survives <s>this Sunday</s> the next thirty minutes.

Output

a(0) = -1
a(1) =  0

Source

____$____[1]+_+_0;
#### ####    # #

Notes

It's a full program, not a function.

Reads the input from command line.

Does not contain any PHP opening tag.

Cracked

The sequence was A023443:

a(n) = n - 1

Here's my original source code, which is slightly different to the robber's:

 echo$argv[1]+-+!0;


答:
PHP, 18 bytes, insertusernamehere, A023443

Code:

```<code>echo$argv[1]+0+~0;
</code>```

Output:

```<code>a(0) = -1
a(1) = 0
</code>```

Body:
PHP, 18 bytes, insertusernamehere, A023443

Code:

echo$argv[1]+0+~0;

Output:

a(0) = -1
a(1) = 0


答:
Labyrinth, 18 bytes

```<code>?}
:
)"%{!
( =
}:{
</code>```

Terminates with an error, but the error message goes to STDERR.

Try it online!

This doesn't feel quite optimal yet, but I'm not seeing a way to compress the loop below 3x3 at this point.

Explanation

This uses the Euclidean algorithm.

First, there's a linear bit to read input and get into the main loop. The instruction pointer (IP) starts in the top left corner, going east.

```<code>?    Read first integer from STDIN and push onto main stack.
}    Move the integer over to the auxiliary stack.
     The IP now hits a dead end so it turns around.
?    Read the second integer.
     The IP hits a corner and follows the bend, so it goes south.
:    Duplicate the second integer.
)    Increment.
     The IP is now at a junction. The top of the stack is guaranteed to be
     positive, so the IP turns left, to go east.
"    No-op.
%    Modulo. Since `n % (n+1) == n`, we end up with the second input on the stack.
</code>```

We now enter a sort of while-do loop which computes the Euclidean algorithm. The tops of the stacks contain a and b (on top of an implicit infinite amount of zeros, but we won't need those). We'll represent the stacks side to side, growing towards each other:

```<code>    Main     Auxiliary
[ ... 0 a  |  b 0 ... ]
</code>```

The loop terminates once a is zero. A loop iteration works as follows:

```<code>=    Swap a and b.           [ ... 0 b  |  a 0 ... ]
{    Pull a from aux.        [ ... 0 b a  |  0 ... ]
:    Duplicate.              [ ... 0 b a a  |  0 ... ]
}    Move a to aux.          [ ... 0 b a  |  a 0 ... ]
()   Increment, decrement, together a no-op.
%    Modulo.                 [ ... 0 (b%a)  |  a 0 ... ]
</code>```

You can see, we've replaced a and b with b%a and a respectively.

Finally, once b%a is zero, the IP keeps moving east and executes:

```<code>{    Pull the non-zero value, i.e. the GCD, over from aux.
!    Print it.
     The IP hits a dead end and turns around.
{    Pull a zero from aux.
%    Attempt modulo. This fails due to division by 0 and the program terminates.
</code>```

Title: Greatest Common Divisor

Body:
Labyrinth, 18 bytes

?}
:
)"%{!
( =
}:{

Terminates with an error, but the error message goes to STDERR.

Try it online!

This doesn't feel quite optimal yet, but I'm not seeing a way to compress the loop below 3x3 at this point.

Explanation

This uses the Euclidean algorithm.

First, there's a linear bit to read input and get into the main loop. The instruction pointer (IP) starts in the top left corner, going east.

?    Read first integer from STDIN and push onto main stack.
}    Move the integer over to the auxiliary stack.
     The IP now hits a dead end so it turns around.
?    Read the second integer.
     The IP hits a corner and follows the bend, so it goes south.
:    Duplicate the second integer.
)    Increment.
     The IP is now at a junction. The top of the stack is guaranteed to be
     positive, so the IP turns left, to go east.
"    No-op.
%    Modulo. Since `n % (n+1) == n`, we end up with the second input on the stack.

We now enter a sort of while-do loop which computes the Euclidean algorithm. The tops of the stacks contain a and b (on top of an implicit infinite amount of zeros, but we won't need those). We'll represent the stacks side to side, growing towards each other:

    Main     Auxiliary
[ ... 0 a  |  b 0 ... ]

The loop terminates once a is zero. A loop iteration works as follows:

=    Swap a and b.           [ ... 0 b  |  a 0 ... ]
{    Pull a from aux.        [ ... 0 b a  |  0 ... ]
:    Duplicate.              [ ... 0 b a a  |  0 ... ]
}    Move a to aux.          [ ... 0 b a  |  a 0 ... ]
()   Increment, decrement, together a no-op.
%    Modulo.                 [ ... 0 (b%a)  |  a 0 ... ]

You can see, we've replaced a and b with b%a and a respectively.

Finally, once b%a is zero, the IP keeps moving east and executes:

{    Pull the non-zero value, i.e. the GCD, over from aux.
!    Print it.
     The IP hits a dead end and turns around.
{    Pull a zero from aux.
%    Attempt modulo. This fails due to division by 0 and the program terminates.


答:
J, 8 bytes, Kenny Lau, A057427

Code:

```<code>(-%- )\.
</code>```

Output:

```<code>a(0) = 0
a(1..29) = 1
</code>```

I don't think this is intended. And I don't know why J had this behavior. But it works.

Body:
J, 8 bytes, Kenny Lau, A057427

Code:

(-%- )\.

Output:

a(0) = 0
a(1..29) = 1

I don't think this is intended. And I don't know why J had this behavior. But it works.


答:
Hexagony, 17 bytes

```<code>?'?>}!@<\=%)>{\.(
</code>```

Unfolded:

```<code>  ? ' ?
 > } ! @
< \ = % )
 > { \ .
  ( . .
</code>```

Try it online!

Fitting it into side-length 3 was a breeze. Shaving off those two bytes at the end wasn't... I'm also not convinced it's optimal, but I'm sure I think it's close.

Explanation

Another Euclidean algorithm implementation.

The program uses three memory edges, which I'll call A, B and C, with the memory pointer (MP) starting out as shown:

Here is the control flow diagram:

Control flow starts on the grey path with a short linear bit for input:

```<code>?    Read first integer into memory edge A.
'    Move MP backwards onto edge B.
?    Read second integer into B.
</code>```

Note that the code now wraps around the edges to the < in the left corner. This < acts as a branch. If the current edge is zero (i.e. the Euclidean algorithm terminates), the IP is deflected to the left and takes the red path. Otherwise, an iteration of the Euclidean algorithm is computed on the green path.

We'll first consider the green path. Note that > and \ all acts as mirrors which simply deflect the instruction pointer. Also note that control flow wraps around the edges three times, once from the bottom to the top, once from the right corner to the bottom row and finally from the bottom right corner to the left corner to re-check the condition. Also note that . are no-ops.

That leaves the following linear code for a single iteration:

```<code>{    Move MP forward onto edge C.
'}   Move to A and back to C. Taken together this is a no-op.
=    Reverse the direction of the MP so that it now points at A and B.
%    Compute A % B and store it in C.
)(   Increment, decrement. Taken together this is a no-op, but it's
     necessary to ensure that IP wraps to the bottom row instead of
     the top row.
</code>```

Now we're back where we started, except that the three edges have changed their roles cyclically (the original C now takes the role of B and the original B the role of A...). In effect, we've relpaced inputs A and B with B and A % B, respectively.

Once A % B (on edge C) is zero, the GCD can be found on edge B. Again the > just deflects the IP, so on the red path we execute:

```<code>}    Move MP to edge B.
!    Print its value as an integer.
@    Terminate the program.
</code>```

Title: Greatest Common Divisor

Body:
Hexagony, 17 bytes

?'?>}!@<\=%)>{\.(

Unfolded:

  ? ' ?
 > } ! @
< \ = % )
 > { \ .
  ( . .

Try it online!

Fitting it into side-length 3 was a breeze. Shaving off those two bytes at the end wasn't... I'm also not convinced it's optimal, but I'm sure I think it's close.

Explanation

Another Euclidean algorithm implementation.

The program uses three memory edges, which I'll call A, B and C, with the memory pointer (MP) starting out as shown:

Here is the control flow diagram:

Control flow starts on the grey path with a short linear bit for input:

?    Read first integer into memory edge A.
'    Move MP backwards onto edge B.
?    Read second integer into B.

Note that the code now wraps around the edges to the < in the left corner. This < acts as a branch. If the current edge is zero (i.e. the Euclidean algorithm terminates), the IP is deflected to the left and takes the red path. Otherwise, an iteration of the Euclidean algorithm is computed on the green path.

We'll first consider the green path. Note that > and \ all acts as mirrors which simply deflect the instruction pointer. Also note that control flow wraps around the edges three times, once from the bottom to the top, once from the right corner to the bottom row and finally from the bottom right corner to the left corner to re-check the condition. Also note that . are no-ops.

That leaves the following linear code for a single iteration:

{    Move MP forward onto edge C.
'}   Move to A and back to C. Taken together this is a no-op.
=    Reverse the direction of the MP so that it now points at A and B.
%    Compute A % B and store it in C.
)(   Increment, decrement. Taken together this is a no-op, but it's
     necessary to ensure that IP wraps to the bottom row instead of
     the top row.

Now we're back where we started, except that the three edges have changed their roles cyclically (the original C now takes the role of B and the original B the role of A...). In effect, we've relpaced inputs A and B with B and A % B, respectively.

Once A % B (on edge C) is zero, the GCD can be found on edge B. Again the > just deflects the IP, so on the red path we execute:

}    Move MP to edge B.
!    Print its value as an integer.
@    Terminate the program.


Body:
J, 8 bytes (Cracked)

# marks unrevealed characters

(#1-#)#.

The output:

No, I'm not hiding anything by using a long sample. If the input is 0, it outputs 0, if the input is between 1 and 29, it outputs 1.

The outputs for the negative inputs do not match with the actual sequence.

   (#1-#)#.0
0
   (#1-#)#.1
1
   (#1-#)#.2
1
   (#1-#)#.3
1
   (#1-#)#.4
1
   (#1-#)#.5
1
   (#1-#)#.6
1
   (#1-#)#.7
1
   (#1-#)#.8
1
   (#1-#)#.9
1
   (#1-#)#.10
1
   (#1-#)#.11
1
   (#1-#)#.12
1
   (#1-#)#.13
1
   (#1-#)#.14
1
   (#1-#)#.15
1
   (#1-#)#.16
1
   (#1-#)#.17
1
   (#1-#)#.18
1
   (#1-#)#.19
1
   (#1-#)#.20
1
   (#1-#)#.21
1
   (#1-#)#.22
1
   (#1-#)#.23
1
   (#1-#)#.24
1
   (#1-#)#.25
1
   (#1-#)#.26
1
   (#1-#)#.27
1
   (#1-#)#.28
1
   (#1-#)#.29
1


答:
JavaScript (ES7), 10 bytes, Cracked

Output

```<code>f(0) -> 1
f(1) -> -1
</code>```

Code

```<code>t=>~t##**#
</code>```

Test it in Firefox nightly. The code is an anonymous function. This will probably be easy since there's only three characters hidden, but at least it's short! :P

My original code was:

 t=>~top**t

but after brute-forcing my own code for a solution, I soon realised

 t=>~t.x**t (where x can be any variable name character)

could also be used. This works because

 in the original ES7 exponentiation operator spec, the operator had lower precedence than unary operators (unlike conventional mathematics and most other languages). ~ performs a bitwise NOT on t.x (undefined) or top (Object) which casts them to a 32-bit signed integer (uncastables like these become 0) before doing the NOT (so 0 becomes -1). I looked into further into this, and very recently, the spec has changed to disallow ambiguous references like this (not good for future golfing D: ), however most ES7 engines haven't updated to the latest version of the spec yet.

Body:
JavaScript (ES7), 10 bytes, Cracked

Output

f(0) -> 1
f(1) -> -1

Code

t=>~t##**#

Test it in Firefox nightly. The code is an anonymous function. This will probably be easy since there's only three characters hidden, but at least it's short! :P

My original code was:

 t=>~top**t

but after brute-forcing my own code for a solution, I soon realised

 t=>~t.x**t (where x can be any variable name character)

could also be used. This works because

 in the original ES7 exponentiation operator spec, the operator had lower precedence than unary operators (unlike conventional mathematics and most other languages). ~ performs a bitwise NOT on t.x (undefined) or top (Object) which casts them to a 32-bit signed integer (uncastables like these become 0) before doing the NOT (so 0 becomes -1). I looked into further into this, and very recently, the spec has changed to disallow ambiguous references like this (not good for future golfing D: ), however most ES7 engines haven't updated to the latest version of the spec yet.


问:
"Stair-ify" a string
You must write a program or function that creates a "stair-ified" string. Here is how you "stair-ify" a string:

For each character in the string:

If the character is an upper or lowercase vowel, not including 'y', output it then move the rest of the string up a column.

If the character is a space or a tab, output it then move the rest of the string down a colum.

If the character is neither, output it normally.

IO can be in any reasonable format. The input will not contain any newlines. If you want, you can remove any trailing whitespace.

If you choose to return the string, rather than printing it, please also include a short program that will print your string so that it can be visualized. This is not mandatory, nor will it go towards your byte-count. This is just a convenience for users who don't understand golf or esolangs (like me) to be able to verify output or tinker with the code.

Sample IO:

Output for "bcdef ghijkl":

```<code>    f    jkl
bcde  ghi
</code>```

Output for "Programming Puzzles And Code-Golf":

```<code>                               lf
                            -Go
                  s  nd   de
         ng   zzle  A   Co
      mmi   Pu
   gra
Pro
</code>```

Output for "Abcdefghijklmnopqrstuvwxyz":

```<code>                     vwxyz
               pqrstu
         jklmno
     fghi
 bcde
A
</code>```

As usual, this is code-golf, so shortest answer in bytes wins.

答:
C, <s> 173 </s> <s> 160 </s> <s> 156 </s> 155 bytes

Edit: Borrowed idea of using strchr from @mIllIbyte to shave off 13 bytes

Edit2: Streamlined the min/max comparisons, -4 bytes

Edit3: c can have any value to begin with -> into main(c) instead, -1 byte

Edit4: Added ungolf/explanation

```<code>p,l,j,m;main(c){char b[99],*s=gets(b);for(;j<m+2;p?putchar(c?l?32:c:10):l<j?j=l:l>m?m=l:0,l-=c?(c&=223)&&c-9?!!strchr("AEIOU",c):-1:(p=s=b,l+j++))c=*s++;}
</code>```

Ungolfed and explained:

```<code>/* declare and initialize these variables to int and 0 */
p,l,j,m;

/* declares main, but also int c */
main(c)
{

  /* we can handle strings of length 98 (+1 for string-terminating 0) */
  /* we declare and initialize s to point to the beginning of the input
     string for the first pass through the for loop */
  char b[99],*s=gets(b);

  /* the for-loop actually contains nested loops, where the inner loops
     behave differently depending on the outer loop parameter p as follows:
     p attains the values false (0) and true (non-null pointer), in this order.

     p == false:
      the inner loop has the parameter s and passes through all the characters
      in the string until the string is exhausted (*s == 0). l is the vertical
      position of the current character relative to the first character
      (l = 0), smaller number = higher up. The purpose here is simply to find
      the range of vertical positions [j, m] present in the string. The
      commands in execution order are:

      -- loop over s --

      // test does not do anything since j <= m by design
      1. j < m+2

      // puts current char in c and increments string counter
      2. c = *s++

      // ensures that j (m) equals the min (max) of the vertical positions (l)
         encountered so far. At first step j = l = m = 0.
      3. l<j?j=l:l>m?m=l:0

      // c != 0, this updates the vertical position for the next character
      // c = SPC or C = TAB -> lower (l increases by 1)
      // c = "aeiouAEIOU" -> higher (l decreases by 1)
      4a. l-=(c&=223)&&c-9?!!strchr("AEIOU",c):-1

      -- loop over s ends --

      // c == 0, this resets the string pointer s and puts p = true, and
      //         thereby initiates the next phase of the algorithm
      //         see rest of the explanation at p == true)
      4b. p=s=b

    p == true:
     now there are two inner loops. The outer of these has the parameter j,
     which ranges from the smallest vertical position+1 (the value of j after
     the p == false pass) to the largest vertical position+1 (m+2 after the
     p == true pass). The innermost loop has the parameter s and passes through
     all characters in the string until the string is exhausted (*s == 0) just
     as in the p == false inner loop. Here l is now the vertical position
     relative to the current position j-1, so that l == 0 when a character is
     at the current level. Such characters are printed as is, whereas
     characters at other levels are replaced by space. The end-of-string
     marker 0 outputs a newline. The commands in execution order are:

      -- loop over j --

      // at first step increments j to point to be one more than the
      // current vertical position. At other steps moves the current position
      // (j-1) one vertical position downwards. Also, at all steps, this
      // biases the vertical position counter l to be zero at the current
      // vertical position (j-1)
      1. l=-j++

      // compare j to stopping criteria, exit if j > m+1
      2. j < m+2

       -- loop over s --

       // puts current char in c and increments string counter
       3. c = *s++

       // outputs character as follows:
       // c == 0 (end of string), output newline
       // c != 0 (middle of string)
       //  l == 0 (character at current vertcial position), output c
       //  l != 0 (character not at current vertical position), output space
       4. putchar(c?l?32:c:10)

       // c != 0, this updates the vertical position for the next character
       // c = SPC or C = TAB -> lower (l increases by 1)
       // c = "aeiouAEIOU" -> higher (l decreases by 1)
       5a. l-=(c&=223)&&c-9?!!strchr("AEIOU",c):-1

       -- loop over s ends --

      // c == 0, this resets the string pointer s for next loop over s
      //         algorithm (see rest of the explanation at p == true)
      5b. p=s=b

     -- loop over j ends --
  */

  for(;
      j<m+2;
      p?putchar(c?l?32:c:10):
    l<j?j=l:l>m?m=l:0,
      l-=c?(c&=223)&&c-9?!!strchr("AEIOU",c):-1:
       (p=s=b,l+j++))
    c=*s++;
}
</code>```

Title: "Stair-ify" a string

Body:
C, <s> 173 </s> <s> 160 </s> <s> 156 </s> 155 bytes

Edit: Borrowed idea of using strchr from @mIllIbyte to shave off 13 bytes

Edit2: Streamlined the min/max comparisons, -4 bytes

Edit3: c can have any value to begin with -> into main(c) instead, -1 byte

Edit4: Added ungolf/explanation

p,l,j,m;main(c){char b[99],*s=gets(b);for(;j<m+2;p?putchar(c?l?32:c:10):l<j?j=l:l>m?m=l:0,l-=c?(c&=223)&&c-9?!!strchr("AEIOU",c):-1:(p=s=b,l+j++))c=*s++;}

Ungolfed and explained:

/* declare and initialize these variables to int and 0 */
p,l,j,m;

/* declares main, but also int c */
main(c)
{

  /* we can handle strings of length 98 (+1 for string-terminating 0) */
  /* we declare and initialize s to point to the beginning of the input
     string for the first pass through the for loop */
  char b[99],*s=gets(b);

  /* the for-loop actually contains nested loops, where the inner loops
     behave differently depending on the outer loop parameter p as follows:
     p attains the values false (0) and true (non-null pointer), in this order.

     p == false:
      the inner loop has the parameter s and passes through all the characters
      in the string until the string is exhausted (*s == 0). l is the vertical
      position of the current character relative to the first character
      (l = 0), smaller number = higher up. The purpose here is simply to find
      the range of vertical positions [j, m] present in the string. The
      commands in execution order are:

      -- loop over s --

      // test does not do anything since j <= m by design
      1. j < m+2

      // puts current char in c and increments string counter
      2. c = *s++

      // ensures that j (m) equals the min (max) of the vertical positions (l)
         encountered so far. At first step j = l = m = 0.
      3. l<j?j=l:l>m?m=l:0

      // c != 0, this updates the vertical position for the next character
      // c = SPC or C = TAB -> lower (l increases by 1)
      // c = "aeiouAEIOU" -> higher (l decreases by 1)
      4a. l-=(c&=223)&&c-9?!!strchr("AEIOU",c):-1

      -- loop over s ends --

      // c == 0, this resets the string pointer s and puts p = true, and
      //         thereby initiates the next phase of the algorithm
      //         see rest of the explanation at p == true)
      4b. p=s=b

    p == true:
     now there are two inner loops. The outer of these has the parameter j,
     which ranges from the smallest vertical position+1 (the value of j after
     the p == false pass) to the largest vertical position+1 (m+2 after the
     p == true pass). The innermost loop has the parameter s and passes through
     all characters in the string until the string is exhausted (*s == 0) just
     as in the p == false inner loop. Here l is now the vertical position
     relative to the current position j-1, so that l == 0 when a character is
     at the current level. Such characters are printed as is, whereas
     characters at other levels are replaced by space. The end-of-string
     marker 0 outputs a newline. The commands in execution order are:

      -- loop over j --

      // at first step increments j to point to be one more than the
      // current vertical position. At other steps moves the current position
      // (j-1) one vertical position downwards. Also, at all steps, this
      // biases the vertical position counter l to be zero at the current
      // vertical position (j-1)
      1. l=-j++

      // compare j to stopping criteria, exit if j > m+1
      2. j < m+2

       -- loop over s --

       // puts current char in c and increments string counter
       3. c = *s++

       // outputs character as follows:
       // c == 0 (end of string), output newline
       // c != 0 (middle of string)
       //  l == 0 (character at current vertcial position), output c
       //  l != 0 (character not at current vertical position), output space
       4. putchar(c?l?32:c:10)

       // c != 0, this updates the vertical position for the next character
       // c = SPC or C = TAB -> lower (l increases by 1)
       // c = "aeiouAEIOU" -> higher (l decreases by 1)
       5a. l-=(c&=223)&&c-9?!!strchr("AEIOU",c):-1

       -- loop over s ends --

      // c == 0, this resets the string pointer s for next loop over s
      //         algorithm (see rest of the explanation at p == true)
      5b. p=s=b

     -- loop over j ends --
  */

  for(;
      j<m+2;
      p?putchar(c?l?32:c:10):
    l<j?j=l:l>m?m=l:0,
      l-=c?(c&=223)&&c-9?!!strchr("AEIOU",c):-1:
       (p=s=b,l+j++))
    c=*s++;
}


答:
Haskell (within ANSI terminal), 75 bytes

```<code>("\27[2J"++).(h=<<)
h ' '="\27[B "
h c|elem c"aeiouAEIOU"=c:"\27[A"
h c=[c]
</code>```

Usage example: putStr $ ("\27[2J"++).(h=<<) $ "bcdef ghijkl"

This uses ANSI escape codes to move the cursor up and down.

Title: "Stair-ify" a string

Body:
You must write a program or function that creates a "stair-ified" string. Here is how you "stair-ify" a string:

For each character in the string:

If the character is an upper or lowercase vowel, not including 'y', output it then move the rest of the string up a column.

If the character is a space or a tab, output it then move the rest of the string down a colum.

If the character is neither, output it normally.

IO can be in any reasonable format. The input will not contain any newlines. If you want, you can remove any trailing whitespace.

If you choose to return the string, rather than printing it, please also include a short program that will print your string so that it can be visualized. This is not mandatory, nor will it go towards your byte-count. This is just a convenience for users who don't understand golf or esolangs (like me) to be able to verify output or tinker with the code.

Sample IO:

Output for "bcdef ghijkl":

```<code>    f    jkl
bcde  ghi
</code>```

Output for "Programming Puzzles And Code-Golf":

```<code>                               lf
                            -Go
                  s  nd   de
         ng   zzle  A   Co
      mmi   Pu
   gra
Pro
</code>```

Output for "Abcdefghijklmnopqrstuvwxyz":

```<code>                     vwxyz
               pqrstu
         jklmno
     fghi
 bcde
A
</code>```

As usual, this is code-golf, so shortest answer in bytes wins.

Body:
Haskell (within ANSI terminal), 75 bytes

("\27[2J"++).(h=<<)
h ' '="\27[B "
h c|elem c"aeiouAEIOU"=c:"\27[A"
h c=[c]

Usage example: putStr $ ("\27[2J"++).(h=<<) $ "bcdef ghijkl"

This uses ANSI escape codes to move the cursor up and down.


问:
Running length of the movie in a human readable format
Whenever I search for the running length of a movie in IMDb, it is displayed in minutes. Immediately I would try to convert it into hour(s) and minute(s). It would be better if we could automate this.

Input:

```<code>150 min
</code>```

Output:

```<code>2 hours 30 minutes
</code>```

Input:

```<code>90 min
</code>```

Output:

```<code>1 hour 30 minutes
</code>```

Input:

```<code>61 min
</code>```

Output:

```<code>1 hour 1 minute
</code>```

Input:

```<code>60 min
</code>```

Output:

```<code>1 hour 0 minute or 1 hour 0 minutes
</code>```

Following are the conditions:

Input and Output should be in this exact format.

Input minutes will between 0 and 240.

Your answer can accept command line arguments or read input from the
user or a function.

Output should not be enclosed within quotes.

Output must be printed, not returned.

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Result:

Its a tie between CJam and Pyth. Accepting CJam's answer as it was submitted before Pyth's 35 bytes code. However, please continue encouraging new submissions.

Body:
Pyke, 31 bytes, noncompeting

dchE60.D]~U1 3:],FDJRh1N\s*+)_J

Try it here!

Explanation:

dchE                            -     eval(input().split(" ")[0])
    60.D]                       -    [divmod(^, 60)]
               ],               -   zip(*[^,V])
         ~U1 3:                 -    ["minute", "hour"]
                 F          )   -  for _ in ^:
                     h1N        -     _[0] != 1
                        \s*     -    "s"*^
                           +    -    V+^
                   J            -     " ".join(_)
                             _J - " ".join(^[::-1])


问:
Fibonacci function or sequence
The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it.  The first two numbers in the sequence are both 1. Here are the first few terms:

```<code>1 1 2 3 5 8 13 21 34 55 89 ...
</code>```

Write the shortest code that either:

Generates the Fibonacci sequence without end.

Given n calculates the nth term of the sequence. (Either 1 or zero indexed)

You may use standard forms of input and output.

(I gave both options in case one is easier to do in your chosen language than the other.)

For the function that takes an n, a reasonably large return value (the largest Fibonacci number that fits your computer's normal word size, at a minimum) has to be supported.

Leaderboard

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  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(''+lang+'').text();

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

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

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) 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;
  display: block !important;
}

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Fuzzy Octo Guacamole, 11 bytes

```<code>01(!aZrZo;)
</code>```

This takes the infinite route.

Explanation:

01 pushes 0 and then 1 to the stack.

( starts a infinite loop.

! sets the register, saving the value on the top of the stack and storing it.  It doesn't pop though.

a adds the 2 values.

ZrZ reverses the stack, pushes the register contents, and reverses again.  This pushes the stored number to the bottom of the stack.

o; peeks and prints.

) ends the infinite loop.

Then the whole things starts again from the (.

As a a side note, this is quite fast to hit the max long size possible in Python.  The last number it prints is 12200160415121876738, and it repeats that forever.

ContentLicense: CC BY-SA 4.0

Title: Fibonacci function or sequence

Body:
Fuzzy Octo Guacamole, 11 bytes

01(!aZrZo;)

This takes the infinite route.

Explanation:

01 pushes 0 and then 1 to the stack.

( starts a infinite loop.

! sets the register, saving the value on the top of the stack and storing it.  It doesn't pop though.

a adds the 2 values.

ZrZ reverses the stack, pushes the register contents, and reverses again.  This pushes the stored number to the bottom of the stack.

o; peeks and prints.

) ends the infinite loop.

Then the whole things starts again from the (.

As a a side note, this is quite fast to hit the max long size possible in Python.  The last number it prints is 12200160415121876738, and it repeats that forever.


问:
Draw a spiral in a box

This geometric spiral looks complicated, but it's fairly simple to draw; take the following box:

Draw a straight line between the corner of the box and some set distance above the next corner counter-clockwise.

Continue this pattern inward, always staying that set distance away from the corner of the next line. Here's a few more lines in.

As you can see, as the pattern continues, the spiral approaches the center and the boxes you draw begin to rotate. Note that the distance remains constant, regardless of angle.

The Challenge

The Inspiration (and also thanks to the wonderful person who introduced me to this concept <3)

Given a numerical (possibly fractional) input from 1 to 25, write an image to disk that uses this pattern or display the output on the screen, where the distance from each corner is the distance of one initial side of the box divided by the input. Continue the pattern inward until the distance from the corner specified is longer than the length of the next side.

Rules

You may not use built-ins for this spiral creation, but you may use image processing builtins.

If you write to disk, you must output an image in any of .jpg, .gif, .tiff, .pbm, .ppm, and .png.

The initial side length must be at least 500 pixels.

The initial corner may be whichever you choose.

As always, the Standard Loopholes are disallowed.

答:
Shoes (Ruby) 163 bytes

Shoes is a ruby-based GUI toolkit.

```<code>Shoes.app{n=ask('').to_f
r=s=5E2
a=[0,s*i="i".to_c,s*i+s,s,0]
(q=a[-3]-a[-4]
r=q.abs/s*n
a<<a[-4]+q/r)while r>1
1.upto(a.size-1){|j|line *(a[j-1].rect+a[j].rect)}}
</code>```

Ungolfed

```<code>Shoes.app{
  n=ask('').to_f                 #Open a dialog box with no message, get n from user
  r=s=5E2                        #Initialize s to sidelength=500. r can be initialized to any vale, we use the same one for convenience.
  a=[0,s*i="i".to_c,s*i+s,s,0]   #intialize array a with 5 points needed to draw a square, in complex number format (first point=0 is duplicated.)

  (
    q=a[-3]-a[-4]                #find the vector from point plotted 4 before to the following point (plotted 3 before)
    r=q.abs/s*n                  #r is the scale factor
    a<<a[-4]+q/r                 #add a new point derived from a[-4] by moving toward a[-3] by a distance s/n
  )while r>1                     #break loop when length of line is less than s/n

  1.upto(a.size-1){|j|           #for all points except 1st and last one
    line *(a[j-1].rect+a[j].rect)#take the two complex numbers correspondimg to the current and previous point,
  }                              #convert to 2-element arrays (rectangular coordinates
}                                #combine to make a 4-element array, use * to splat into 4 parameters, and draw using the line method.
</code>```

Outputs n=4 and n=25

Note that the shape always ends in a triangle, which collapses further to a line. Replacing size-1 with size makes no difference to the appearance of the output and would save 2 bytes, but I left it in for theoretical correctness.

Output n=300

Inspired by a comment by OP, the higher numbers do look great!

Title: Draw a spiral in a box

Body:
Shoes (Ruby) 163 bytes

Shoes is a ruby-based GUI toolkit.

Shoes.app{n=ask('').to_f
r=s=5E2
a=[0,s*i="i".to_c,s*i+s,s,0]
(q=a[-3]-a[-4]
r=q.abs/s*n
a<<a[-4]+q/r)while r>1
1.upto(a.size-1){|j|line *(a[j-1].rect+a[j].rect)}}

Ungolfed

Shoes.app{
  n=ask('').to_f                 #Open a dialog box with no message, get n from user
  r=s=5E2                        #Initialize s to sidelength=500. r can be initialized to any vale, we use the same one for convenience.
  a=[0,s*i="i".to_c,s*i+s,s,0]   #intialize array a with 5 points needed to draw a square, in complex number format (first point=0 is duplicated.)

  (
    q=a[-3]-a[-4]                #find the vector from point plotted 4 before to the following point (plotted 3 before)
    r=q.abs/s*n                  #r is the scale factor
    a<<a[-4]+q/r                 #add a new point derived from a[-4] by moving toward a[-3] by a distance s/n
  )while r>1                     #break loop when length of line is less than s/n

  1.upto(a.size-1){|j|           #for all points except 1st and last one
    line *(a[j-1].rect+a[j].rect)#take the two complex numbers correspondimg to the current and previous point,
  }                              #convert to 2-element arrays (rectangular coordinates
}                                #combine to make a 4-element array, use * to splat into 4 parameters, and draw using the line method.

Outputs n=4 and n=25

Note that the shape always ends in a triangle, which collapses further to a line. Replacing size-1 with size makes no difference to the appearance of the output and would save 2 bytes, but I left it in for theoretical correctness.

Output n=300

Inspired by a comment by OP, the higher numbers do look great!


答:
SWIFT, 55 bytes, Cracked

```<code>func M(n:Int)->Int{
return(n*****) ?M(**n****):n***;
}
</code>```

* marks a hidden character

Output:

```<code>M(30) -> 91
M(60) -> 91
M(90) -> 91
M(120)-> 110
M(150)-> 140
</code>```

Function accepts 0

Body:
SWIFT, 55 bytes, Cracked

func M(n:Int)->Int{
return(n*****) ?M(**n****):n***;
}

* marks a hidden character

Output:

M(30) -> 91
M(60) -> 91
M(90) -> 91
M(120)-> 110
M(150)-> 140

Function accepts 0


答:
PHP, 137 bytes, cracked

This is my final sequence. You should be feeling lucky when trying this one.

Output

```<code>a(3)  =   7
a(7)  =  21
a(23) =  99
</code>```

Source

```<code>for(___range___303_______________________array_merge____)for(__________________________________________)unset________;echo___$argv[1]-1_;
    ###     ###   #######################           ####     ##########################################      ########     ###          #
</code>```

Notes

This sequence starts at 1.

The program works up to the last number given bei OEIS, but can easily be adjusted to go to any other value as well.

It's a full program, not a function.

Reads the input from command line (obviously).

Does not contain any PHP opening tag.

Cracked

The wording "feeling lucky" and the value 303 in the source were hints to the sequence A000959:

Lucky numbers

This is my original source, which is slightly different to the robber's:

 for($n=range(1,303);$j<count($n);++$j,$n=array_merge($n))for($i=($x=$j?$n[$j]:2)-1;isset($n[$i]);$i+=$x)unset($n[$i]);echo$n[$argv[1]-1];

Body:
PHP, 137 bytes, cracked

This is my final sequence. You should be feeling lucky when trying this one.

Output

a(3)  =   7
a(7)  =  21
a(23) =  99

Source

for(___range___303_______________________array_merge____)for(__________________________________________)unset________;echo___$argv[1]-1_;
    ###     ###   #######################           ####     ##########################################      ########     ###          #

Notes

This sequence starts at 1.

The program works up to the last number given bei OEIS, but can easily be adjusted to go to any other value as well.

It's a full program, not a function.

Reads the input from command line (obviously).

Does not contain any PHP opening tag.

Cracked

The wording "feeling lucky" and the value 303 in the source were hints to the sequence A000959:

Lucky numbers

This is my original source, which is slightly different to the robber's:

 for($n=range(1,303);$j<count($n);++$j,$n=array_merge($n))for($i=($x=$j?$n[$j]:2)-1;isset($n[$i]);$i+=$x)unset($n[$i]);echo$n[$argv[1]-1];


问:
Find the last position in a matrix walking like a spiral
This question will be deleted soon, do not read/answer it

Introduction

Given one matrix A x A and a number of movements N.

You will need to walk like a spiral starting in (1; 1):

right while possible, then

down while possible, then

left while possible, then

up while possible, repeat until got N.

Challenge

You can only take as input the numbers A and N.

You must output the final (row; column) after walking N steps in the conditions explained above. You can not invert the output order.

You can use indexes starting with zero as well. Just state it in your answer.

Program or function allowed.

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

Sample

For input (A = 8; N = 54).

The output should be (5; 6).

Another samples

```<code>input: A=8, N=64
output: [5, 4]
</code>```

```<code>input: A=15, N=14
output: [1, 14]
</code>```

```<code>input: A=26, N=400
output: [22, 9]
</code>```

```<code>input: A=1073741824, N=1152921504603393520
output: [536871276, 536869983]
</code>```

Restrictions

1 <= A <= 230

1 <= N <= (A2 OR the below higher number supported in your language).

And, if you want a generic formula.

答:
MATL, 24 bytes

This works in release 16.0.0 of the language, which predates the challenge.

```<code>2^Q6Y3GYLG2\?!P!}P]-=2#f
</code>```

Output is 1-based, as in the examples.

A^2 and N are limited to 2^53 as per the language's default data type (double). In addition, since the whole matrix is being generated, memory will limit A to significantly lower values.

Try it online! (In the online version I have changed the order of G and 6Y3 so it works in the new 16.1.0 release)

Explanation

This uses MATL's builtin for generating an outward spiral. To make it inward, a subtraction and a reversal are needed. The direction of reversal depends on whether A is odd or even.

```<code>2^Q     % take input A implicitly. Compute A^2+1
6Y3GYL  % outward spiral of side length A
G2\     % is A odd?
?       % if so
  !P!   %   flip matrix horizontally
}       % else
  P     %   flip matrix vertically
]       % end if
-       % compute A^2+1 minus the matrix element-wise, so (1,1) contains 1
=       % take input N implicitly. Set matrix entry that contains that value to true
2#f     % row and column index of that true value
</code>```

Body:
MATL, 24 bytes

This works in release 16.0.0 of the language, which predates the challenge.

2^Q6Y3GYLG2\?!P!}P]-=2#f

Output is 1-based, as in the examples.

A^2 and N are limited to 2^53 as per the language's default data type (double). In addition, since the whole matrix is being generated, memory will limit A to significantly lower values.

Try it online! (In the online version I have changed the order of G and 6Y3 so it works in the new 16.1.0 release)

Explanation

This uses MATL's builtin for generating an outward spiral. To make it inward, a subtraction and a reversal are needed. The direction of reversal depends on whether A is odd or even.

2^Q     % take input A implicitly. Compute A^2+1
6Y3GYL  % outward spiral of side length A
G2\     % is A odd?
?       % if so
  !P!   %   flip matrix horizontally
}       % else
  P     %   flip matrix vertically
]       % end if
-       % compute A^2+1 minus the matrix element-wise, so (1,1) contains 1
=       % take input N implicitly. Set matrix entry that contains that value to true
2#f     % row and column index of that true value


答:
Pyth, 70 bytes, Cracked

```<code>DhbI|qb"#"qb"#"R!1Iqb"#"#####+""s####2###;##lY+Q1Ih+""Z#####)=Z+Z1;@YQ
</code>```

# are the hidden characters

Has been cracked, so here is the versionn without hidden chars :

```<code>DhbI|qb"4"qb"0"R!1Iqb"1"R!0Rh+""sm^sd2cb1;W<lY+Q1Ih+""Z=Y+YZ)=Z+Z1;@YQ
</code>```

Sample outputs :

```<code>a(2) -> 10
a(4) -> 19
</code>```

<s>Good luck to find this on OEIS, I personally failed to find it from those examples (even tho the sequence is quite easy to spot.)</s>

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

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

The cop's task

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

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

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

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

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

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

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

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

For example, if my program is:

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

Then I would hide these characters as I want:

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

The robber's task

is obviously to find the original source code.

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

Tips for the cops

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

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

Your score is the number of bytes in your code.

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

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

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

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

Lua, 98 bytes

Output:

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

Code (# marks unrevealed characters):

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

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

Body:
Pyth, 70 bytes, Cracked

DhbI|qb"#"qb"#"R!1Iqb"#"#####+""s####2###;##lY+Q1Ih+""Z#####)=Z+Z1;@YQ

# are the hidden characters

Has been cracked, so here is the versionn without hidden chars :

DhbI|qb"4"qb"0"R!1Iqb"1"R!0Rh+""sm^sd2cb1;W<lY+Q1Ih+""Z=Y+YZ)=Z+Z1;@YQ

Sample outputs :

a(2) -> 10
a(4) -> 19

<s>Good luck to find this on OEIS, I personally failed to find it from those examples (even tho the sequence is quite easy to spot.)</s>


答:
Pyth, 70 bytes, FliiFe, A070650

Code (with obfuscated version below):

```<code>DhbI|qb"#"qb"#"R!1Iqb"#";=^Q6+""s ]%Q27  ;.qlY+Q1Ih+""Z##;.q)=Z+Z1;@YQ
DhbI|qb"#"qb"#"R!1Iqb"#"#####+""s####2###;##lY+Q1Ih+""Z#####)=Z+Z1;@YQ (obfuscated)
</code>```

This basically does:

```<code>=^Q6%Q27
</code>```

It calculates a(n) = n6 % 27, which is A070650. Explanation:

```<code>=^Q6       # Assign Q to Q ** 6
    %Q27   # Compute Q % 27
           # Implicit output
</code>```

Try it here

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

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

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

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

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

The submission should be formatted like this:

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

Code:

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

Output

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

Optional explanation and comments.

Body:
Pyth, 70 bytes, FliiFe, A070650

Code (with obfuscated version below):

DhbI|qb"#"qb"#"R!1Iqb"#";=^Q6+""s ]%Q27  ;.qlY+Q1Ih+""Z##;.q)=Z+Z1;@YQ
DhbI|qb"#"qb"#"R!1Iqb"#"#####+""s####2###;##lY+Q1Ih+""Z#####)=Z+Z1;@YQ (obfuscated)

This basically does:

=^Q6%Q27

It calculates a(n) = n6 % 27, which is A070650. Explanation:

=^Q6       # Assign Q to Q ** 6
    %Q27   # Compute Q % 27
           # Implicit output

Try it here


答:
Octave (34 bytes) by Stewie Griffin

The sequence is A066911.

```<code>@(m)(mod(m,u=1:m  )&isprime(u))*u'
</code>```

Body:
Octave (34 bytes) by Stewie Griffin

The sequence is A066911.

@(m)(mod(m,u=1:m  )&isprime(u))*u'


问:
Draw an indexed fractal

Introduction

In this challenge, a 2×2 matrix is indexed like this:

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

We define a family of fractal-like patterns F(L), where L is a length-n list of these indices and F(L) has size 2n-1 × 2n-1.

If L == [], then F(L) is the 1×1 pattern #.

If L != [], then F(L) is constructed as follows. Let P be the pattern obtained from L with first element removed. Take four grids of size 2n-1-1 × 2n-1-1 filled with periods ., and replace the grid indexed by L[0] with the pattern P. Then, glue the grids together using one layer of hashes # between them. Here are diagrams for the four cases:

```<code>L[0]==0  L[0]==1  L[0]==2  L[0]==3
   #...  ...#     ...#...  ...#...
[P]#...  ...#[P]  ...#...  ...#...
   #...  ...#     ...#...  ...#...
#######  #######  #######  #######
...#...  ...#...     #...  ...#
...#...  ...#...  [P]#...  ...#[P]
...#...  ...#...     #...  ...#
</code>```

Example

Consider the input L = [2,0].
We begin with the 1×1 grid #, and traverse L from the right.
The rightmost element is 0, so we take four copies of the 1×1 grid ., replace the first one by #, and glue them together with hashes.
This results in the 3×3 grid

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

The next element is 2, so we take four copies of the 3×3 grid of .s, and replace the third one with the above grid.
The four grids are

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

and gluing them together with #s results in the 7×7 grid

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

This is our final output.

Input

Your input is a list L of the indices 0, 1, 2, 3.
You can take it as a list of integers, or a string of digits.
Note that it may be empty, and it may contain duplicates.
The length of L is at most 5.

Output

Your output is the pattern F(L) as a newline-delimited string.

Rules and scoring

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

Test cases

```<code>[]
#

[0]
##.
###
.#.

[3]
.#.
###
.##

[2,0]
...#...
...#...
...#...
#######
##.#...
####...
.#.#...

[1,1]
...#.##
...####
...#.#.
#######
...#...
...#...
...#...

[1,2,0]
.......#...#...
.......#...#...
.......#...#...
.......########
.......###.#...
.......#####...
.......#.#.#...
###############
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......

[3,3,1]
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
###############
.......#...#...
.......#...#...
.......#...#...
.......########
.......#...#.##
.......#...####
.......#...#.#.

[0,1,2,3]
.......#...#...#...............
.......#...#...#...............
.......#...#...#...............
.......#########...............
.......#.#.#...#...............
.......#####...#...............
.......#.###...#...............
################...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
###############################
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............

[0,0,1,2,3]
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#########...............#...............................
.......#.#.#...#...............#...............................
.......#####...#...............#...............................
.......#.###...#...............#...............................
################...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
################################...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
###############################################################
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
</code>```

答:
CJam, <s>59</s> <s>47</s> <s>43</s> <s>41</s> 40 bytes

Thanks to Sp3000 for saving 1 byte.

```<code>Sal~W%{_Bff|a4*I@t2/{zSf*z}:F%F}fI3ff+N*
</code>```

Test it here.

Explanation

Slightly outdated. Will fix later.

All the dimension reorderings of 4D lists are making me dizzy...

This code implements the specification very literally, using the iterative algorithm from the example section instead of its recursive definition.. One major golfing trick is that I'm using spaces instead of # during the computation and only replace them with # at the end, which simplifies the code in one place and allows me to use S instead of '# or "#" in several.

```<code>Sa       e# Push [" "], i.e. a 1x1 grid containing only a space as the
         e# initial fractal.
l~       e# Read and evaluate input.
W%       e# Reverse the list.
{        e# For each list element, assigning the element to variable I...
  _      e#   Duplicate the grid.
  Eff|   e#   Map (OR 14) over each character in the grid, turning spaces into
         e#   periods and leaving periods unchanged.
  a4*    e#   Create an array with four copies of this cleared grid.
  I@t    e#   Replace the Ith element in this list with the previous grid.
  2/     e#   Split this array into a 2x2 grid of subgrids...
         e#   Now it's getting a bit weird... we've got 4 dimensions now, which are:
         e#    - Rows of the 2x2 meta-grid.
         e#    - Cells in each row of the 2x2 meta-grid (i.e. subgrids).
         e#    - Rows of each subgrid.
         e#    - Characters in each row of each subgrid.
  :z     e#   Transpose each outer row, i.e. swap dimensions 2 and 3.
         e#   We've now got in each row of the meta-grid, a list of pairs of
         e#   corresponding rows of the subgrids.
  Sff*   e#   Join those pairs of rows with a single space each. We're now down
         e#   to three dimensions:
         e#    - Rows of the 2x2 meta-grid.
         e#    - Rows of each 1x2 block of the meta-grid.
         e#    - Characters in each row of those blocks.
  :z     e#   Transpose the blocks, i.e. turn the 1x2 blocks into a list of
         e#   columns of their characters.
  z      e#   Transpose the outer grid, i.e. turn it into a list of pairs of
         e#   corresponding columns in the two 1x2 blocks.
  Sf*    e#   Join each pair of columns with a single space. We've now got the
         e#   new grid we're looking for, but it's a list of columns, i.e. transposed.
  z      e#   Fix that by transposing the entire grid once more.
}I
N*       e# Join the rows of the grid with linefeeds.
S'#er    e# Replace all spaces with #.
</code>```

Title: Draw an indexed fractal

Body:
CJam, <s>59</s> <s>47</s> <s>43</s> <s>41</s> 40 bytes

Thanks to Sp3000 for saving 1 byte.

Sal~W%{_Bff|a4*I@t2/{zSf*z}:F%F}fI3ff+N*

Test it here.

Explanation

Slightly outdated. Will fix later.

All the dimension reorderings of 4D lists are making me dizzy...

This code implements the specification very literally, using the iterative algorithm from the example section instead of its recursive definition.. One major golfing trick is that I'm using spaces instead of # during the computation and only replace them with # at the end, which simplifies the code in one place and allows me to use S instead of '# or "#" in several.

Sa       e# Push [" "], i.e. a 1x1 grid containing only a space as the
         e# initial fractal.
l~       e# Read and evaluate input.
W%       e# Reverse the list.
{        e# For each list element, assigning the element to variable I...
  _      e#   Duplicate the grid.
  Eff|   e#   Map (OR 14) over each character in the grid, turning spaces into
         e#   periods and leaving periods unchanged.
  a4*    e#   Create an array with four copies of this cleared grid.
  I@t    e#   Replace the Ith element in this list with the previous grid.
  2/     e#   Split this array into a 2x2 grid of subgrids...
         e#   Now it's getting a bit weird... we've got 4 dimensions now, which are:
         e#    - Rows of the 2x2 meta-grid.
         e#    - Cells in each row of the 2x2 meta-grid (i.e. subgrids).
         e#    - Rows of each subgrid.
         e#    - Characters in each row of each subgrid.
  :z     e#   Transpose each outer row, i.e. swap dimensions 2 and 3.
         e#   We've now got in each row of the meta-grid, a list of pairs of
         e#   corresponding rows of the subgrids.
  Sff*   e#   Join those pairs of rows with a single space each. We're now down
         e#   to three dimensions:
         e#    - Rows of the 2x2 meta-grid.
         e#    - Rows of each 1x2 block of the meta-grid.
         e#    - Characters in each row of those blocks.
  :z     e#   Transpose the blocks, i.e. turn the 1x2 blocks into a list of
         e#   columns of their characters.
  z      e#   Transpose the outer grid, i.e. turn it into a list of pairs of
         e#   corresponding columns in the two 1x2 blocks.
  Sf*    e#   Join each pair of columns with a single space. We've now got the
         e#   new grid we're looking for, but it's a list of columns, i.e. transposed.
  z      e#   Fix that by transposing the entire grid once more.
}I
N*       e# Join the rows of the grid with linefeeds.
S'#er    e# Replace all spaces with #.


答:
Python 3, 108 bytes (Cracked)

Warning (and hint): my implementation is dreadfully slow...

```<code>>>> a(0)
0
>>> a(4)
2
>>> a(16)
8
>>> a(20)
42
</code>```

a(0) is the first element of the series exactly as defined in OEIS.
# is used to hide chars.

def a(n):
 ###n####0######n#0
 f=a#######
 return f #f#####a###### f ####a(##f###i#i###a####n##else a#######
```

Body:
Python 3, 108 bytes (Cracked)

Warning (and hint): my implementation is dreadfully slow...

>>> a(0)
0
>>> a(4)
2
>>> a(16)
8
>>> a(20)
42

a(0) is the first element of the series exactly as defined in OEIS.
# is used to hide chars.

def a(n):
 ###n####0######n#0
 f=a#######
 return f #f#####a###### f ####a(##f###i#i###a####n##else a#######


答:
J, 8 bytes, Kenny Lau, A057427

Code:

```<code>(>1-*)<.
</code>```

Output:

```<code>a(0) = 0
a(i) = 1 for 0 < i < 30
</code>```

The sequence is simply signum(n).
The program computes floor(n) > 1 - signum(floor(n)), which is signum(n) for non-negative integers n.

Body:
J, 8 bytes, Kenny Lau, A057427

Code:

(>1-*)<.

Output:

a(0) = 0
a(i) = 1 for 0 < i < 30

The sequence is simply signum(n).
The program computes floor(n) > 1 - signum(floor(n)), which is signum(n) for non-negative integers n.


Body:
Python, 108, CAD97, A005132

def a(n):
 if n == 0: return 0
 f=a(n-1)-n
 return f if f>0 and not f in(a(i)for i in range(n))else a(n-1)+n

Obfuscated code :

def a(n):
 ###n####0######n#0
 f=a#######
 return f #f#####a###### f ####a(##f###i#i###a####n##else a#######

Outputs:

>>> a(0)
0
>>> a(4)
2
>>> a(16)
8
>>> a(20)
42


答:
05AB1E, 28  bytes (Cracked)

```<code>#D>D>D>D>*##*#D<*#+*#n#n#**#
</code>```

a(1) = 1

a(2) = 8

a(3) = 42

Behaviour for zero is unspecified.

Cracked:

```<code> DD>D>D>D>****rD<*6+*6n2n5**/
</code>```

There is no need for an explanation I think as the crack was almost 100% spot on. The only difference is I used r to reverse stack instead of swapping top two elements.

Body:
05AB1E, 28  bytes (Cracked)

#D>D>D>D>*##*#D<*#+*#n#n#**#

a(1) = 1

a(2) = 8

a(3) = 42

Behaviour for zero is unspecified.

Cracked:

 DD>D>D>D>****rD<*6+*6n2n5**/

There is no need for an explanation I think as the crack was almost 100% spot on. The only difference is I used r to reverse stack instead of swapping top two elements.


Title: Draw a spiral in a box

Body:
This geometric spiral looks complicated, but it's fairly simple to draw; take the following box:

Draw a straight line between the corner of the box and some set distance above the next corner counter-clockwise.

Continue this pattern inward, always staying that set distance away from the corner of the next line. Here's a few more lines in.

As you can see, as the pattern continues, the spiral approaches the center and the boxes you draw begin to rotate. Note that the distance remains constant, regardless of angle.

The Challenge

The Inspiration (and also thanks to the wonderful person who introduced me to this concept <3)

Given a numerical (possibly fractional) input from 1 to 25, write an image to disk that uses this pattern or display the output on the screen, where the distance from each corner is the distance of one initial side of the box divided by the input. Continue the pattern inward until the distance from the corner specified is longer than the length of the next side.

Rules

You may not use built-ins for this spiral creation, but you may use image processing builtins.

If you write to disk, you must output an image in any of .jpg, .gif, .tiff, .pbm, .ppm, and .png.

The initial side length must be at least 500 pixels.

The initial corner may be whichever you choose.

As always, the Standard Loopholes are disallowed.

Body:
Java, <s>1056</s> <s>1005</s> <s>985</s> <s>948</s> <s>522</s> <s>508</s> <s>507</s> <s>504</s> <s>502</s> <s>501</s> <s>493</s> <s>492</s> <s>488</s> <s>474</s> <s>465</s> 458 bytes

import java.awt.*;interface G{static void main(String[]a){new Frame(){int s=499,o=s,e,i,x,y;{o/=new Float(a[0]);add(new Component(){public void paint(Graphics g){g.drawRect(0,0,s,s);int[]p={s,s,s,0,0,0,0,s};for(double d=s,t;d>o;t=o/d,i=e*2,x=(int)((1-t)*p[i]+t*p[(2+i)%8]+.5),y=(int)((1-t)*p[1+i]+t*p[(3+i)%8]+.5),g.drawLine(p[(6+i)%8],p[(7+i)%8],x,y),p[i]=x,p[1+i]=y,e=++e%4,i=e*2,x=p[(2+i)%8]-p[i],y=p[(3+i)%8]-p[1+i],d=Math.sqrt(x*x+y*y));}});show();}};}}

Thanks to CoolestVeto and ECS for yet other ways to reduce size. :-)


答:
T-SQL, 147 Bytes

SQL Fiddle

MS SQL Server 2014 Schema Setup:

```<code>CREATE PROC G @ INT,@B INT,@C INT OUT AS BEGIN IF @<@B EXEC G @B,@,@C OUT ELSE IF @B>0 BEGIN SELECT @=@%@B EXEC G @B,@,@C OUT END ELSE SET @C=@ END
</code>```

Testing:

Use something like this to generate each set of results:

```<code>DECLARE @A INT,@B INT,@EXP INT,@RES INT
  SELECT @A=0,@B=2,@EXP=2
  EXEC G @A,@B,@RES OUT
  SELECT @A A,@B B,@EXP EXPECTED,@RES RESULT
</code>```

Results:

```<code>|  A  |  B  | EXPECTED | RESULT |
|-----|-----|----------|--------|
|   0 |   2 |        2 |      2 |
|   6 |   0 |        6 |      6 |
|  30 |  42 |        6 |      6 |
|  15 |  14 |        1 |      1 |
|   7 |   7 |        7 |      7 |
|  69 |  25 |        1 |      1 |
|  21 |  12 |        3 |      3 |
|  20 | 142 |        2 |      2 |
| 101 | 202 |      101 |    101 |
</code>```

Title: Greatest Common Divisor

Body:
Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible.

You may write a program or function, taking input and returning output via any of our accepted standard methods (including STDIN/STDOUT, function parameters/return values, command-line arguments, etc.).

Input will be two non-negative integers. You should be able to handle either the full range supported by your language's default integer type, or the range [0,255], whichever is greater. You are guaranteed that at least one of the inputs will be non-zero.

You are not allowed to use built-ins that compute either the GCD or the LCM (least common multiple).

Standard code-golf rules apply.

Test Cases

```<code>0 2     => 2
6 0     => 6
30 42   => 6
15 14   => 1
7 7     => 7
69 25   => 1
21 12   => 3
169 123 => 1
20 142  => 2
101 202 => 101
</code>```

Body:
T-SQL, 147 Bytes

SQL Fiddle

MS SQL Server 2014 Schema Setup:

CREATE PROC G @ INT,@B INT,@C INT OUT AS BEGIN IF @<@B EXEC G @B,@,@C OUT ELSE IF @B>0 BEGIN SELECT @=@%@B EXEC G @B,@,@C OUT END ELSE SET @C=@ END

Testing:

Use something like this to generate each set of results:

DECLARE @A INT,@B INT,@EXP INT,@RES INT
  SELECT @A=0,@B=2,@EXP=2
  EXEC G @A,@B,@RES OUT
  SELECT @A A,@B B,@EXP EXPECTED,@RES RESULT

Results:

|  A  |  B  | EXPECTED | RESULT |
|-----|-----|----------|--------|
|   0 |   2 |        2 |      2 |
|   6 |   0 |        6 |      6 |
|  30 |  42 |        6 |      6 |
|  15 |  14 |        1 |      1 |
|   7 |   7 |        7 |      7 |
|  69 |  25 |        1 |      1 |
|  21 |  12 |        3 |      3 |
|  20 | 142 |        2 |      2 |
| 101 | 202 |      101 |    101 |


答:
JavaScript (ES6), <s>171</s> 152 bytes

```<code>([d,...a],h=`#`,r=`replace`)=>d<4?(s=f(a)[r](/.+/g,s=>(t=s[r](/./g,`.`),d&1?t+h+s:s+h+t)),t=s[r](/.+/g,w=t+h+t),w=`
${w[r](/./g,h)}
`,d&2?t+w+s:s+w+t):h
</code>```

Takes the result of the recursive call, then replaces each line with itself plus a hash plus a string of dots of the same length, in reverse order if necessary, then from that partial result creates a string of dots except for the newlines and central column of hashes, and also a string of hashes with surrounding newlines, then joins those three strings together in the appropriate order.

Title: Draw an indexed fractal

Body:
Introduction

In this challenge, a 2×2 matrix is indexed like this:

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

We define a family of fractal-like patterns F(L), where L is a length-n list of these indices and F(L) has size 2n-1 × 2n-1.

If L == [], then F(L) is the 1×1 pattern #.

If L != [], then F(L) is constructed as follows. Let P be the pattern obtained from L with first element removed. Take four grids of size 2n-1-1 × 2n-1-1 filled with periods ., and replace the grid indexed by L[0] with the pattern P. Then, glue the grids together using one layer of hashes # between them. Here are diagrams for the four cases:

```<code>L[0]==0  L[0]==1  L[0]==2  L[0]==3
   #...  ...#     ...#...  ...#...
[P]#...  ...#[P]  ...#...  ...#...
   #...  ...#     ...#...  ...#...
#######  #######  #######  #######
...#...  ...#...     #...  ...#
...#...  ...#...  [P]#...  ...#[P]
...#...  ...#...     #...  ...#
</code>```

Example

Consider the input L = [2,0].
We begin with the 1×1 grid #, and traverse L from the right.
The rightmost element is 0, so we take four copies of the 1×1 grid ., replace the first one by #, and glue them together with hashes.
This results in the 3×3 grid

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

The next element is 2, so we take four copies of the 3×3 grid of .s, and replace the third one with the above grid.
The four grids are

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

and gluing them together with #s results in the 7×7 grid

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

This is our final output.

Input

Your input is a list L of the indices 0, 1, 2, 3.
You can take it as a list of integers, or a string of digits.
Note that it may be empty, and it may contain duplicates.
The length of L is at most 5.

Output

Your output is the pattern F(L) as a newline-delimited string.

Rules and scoring

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

Test cases

```<code>[]
#

[0]
##.
###
.#.

[3]
.#.
###
.##

[2,0]
...#...
...#...
...#...
#######
##.#...
####...
.#.#...

[1,1]
...#.##
...####
...#.#.
#######
...#...
...#...
...#...

[1,2,0]
.......#...#...
.......#...#...
.......#...#...
.......########
.......###.#...
.......#####...
.......#.#.#...
###############
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......

[3,3,1]
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
###############
.......#...#...
.......#...#...
.......#...#...
.......########
.......#...#.##
.......#...####
.......#...#.#.

[0,1,2,3]
.......#...#...#...............
.......#...#...#...............
.......#...#...#...............
.......#########...............
.......#.#.#...#...............
.......#####...#...............
.......#.###...#...............
################...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
###############################
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............

[0,0,1,2,3]
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#########...............#...............................
.......#.#.#...#...............#...............................
.......#####...#...............#...............................
.......#.###...#...............#...............................
################...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
################################...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
###############################################################
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
</code>```

Body:
JavaScript (ES6), <s>171</s> 152 bytes

([d,...a],h=`#`,r=`replace`)=>d<4?(s=f(a)[r](/.+/g,s=>(t=s[r](/./g,`.`),d&1?t+h+s:s+h+t)),t=s[r](/.+/g,w=t+h+t),w=`
${w[r](/./g,h)}
`,d&2?t+w+s:s+w+t):h

Takes the result of the recursive call, then replaces each line with itself plus a hash plus a string of dots of the same length, in reverse order if necessary, then from that partial result creates a string of dots except for the newlines and central column of hashes, and also a string of hashes with surrounding newlines, then joins those three strings together in the appropriate order.


答:
Oracle SQL 11.2, 108 Bytes

```<code>CREATE PROCEDURE G(A INT,B INT,C OUT INT)AS BEGIN IF A>0 THEN G(LEAST(A,B),ABS(A-B),C);ELSE C:=B;END IF;END;
</code>```

Testing:

```<code>CREATE FUNCTION testHelper(A INT,B INT) RETURN INT
AS
  C INT;
BEGIN
  G(A,B,C);
  RETURN C;
END;
/

WITH tests( A, B, Expected ) AS (
  SELECT   0,  2,  2 FROM DUAL UNION ALL
  SELECT   6,  0,  6 FROM DUAL UNION ALL
  SELECT  30, 42,  6 FROM DUAL UNION ALL
  SELECT  15, 14,  1 FROM DUAL UNION ALL
  SELECT   7,  7,  7 FROM DUAL UNION ALL
  SELECT  69, 25,  1 FROM DUAL UNION ALL
  SELECT  21, 12,  3 FROM DUAL UNION ALL
  SELECT 169,123,  1 FROM DUAL UNION ALL
  SELECT  20,142,  2 FROM DUAL UNION ALL
  SELECT 101,202,101 FROM DUAL
)
SELECT t.*,testHelper(A,B) AS "RESULT"
FROM   tests t;
</code>```

Output:

```<code>         A          B   EXPECTED     RESULT
---------- ---------- ---------- ----------
         0          2          2          2
         6          0          6          6
        30         42          6          6
        15         14          1          1
         7          7          7          7
        69         25          1          1
        21         12          3          3
       169        123          1          1
        20        142          2          2
       101        202        101        101
</code>```

Title: Greatest Common Divisor

Body:
Oracle SQL 11.2, 108 Bytes

CREATE PROCEDURE G(A INT,B INT,C OUT INT)AS BEGIN IF A>0 THEN G(LEAST(A,B),ABS(A-B),C);ELSE C:=B;END IF;END;

Testing:

CREATE FUNCTION testHelper(A INT,B INT) RETURN INT
AS
  C INT;
BEGIN
  G(A,B,C);
  RETURN C;
END;
/

WITH tests( A, B, Expected ) AS (
  SELECT   0,  2,  2 FROM DUAL UNION ALL
  SELECT   6,  0,  6 FROM DUAL UNION ALL
  SELECT  30, 42,  6 FROM DUAL UNION ALL
  SELECT  15, 14,  1 FROM DUAL UNION ALL
  SELECT   7,  7,  7 FROM DUAL UNION ALL
  SELECT  69, 25,  1 FROM DUAL UNION ALL
  SELECT  21, 12,  3 FROM DUAL UNION ALL
  SELECT 169,123,  1 FROM DUAL UNION ALL
  SELECT  20,142,  2 FROM DUAL UNION ALL
  SELECT 101,202,101 FROM DUAL
)
SELECT t.*,testHelper(A,B) AS "RESULT"
FROM   tests t;

Output:

         A          B   EXPECTED     RESULT
---------- ---------- ---------- ----------
         0          2          2          2
         6          0          6          6
        30         42          6          6
        15         14          1          1
         7          7          7          7
        69         25          1          1
        21         12          3          3
       169        123          1          1
        20        142          2          2
       101        202        101        101