title: First spiral, then diagonal

text:
# Question
Title: First spiral, then diagonal
Given a positive input number \\$n\\$, construct a spiral of numbers from \\$1\\$ to \\$n^2\\$, with \\$1\\$ in the top-left, spiraling inward clockwise. Take the sum of the diagonals (if \\$n\\$ is odd, the middle number \\$n^2\\$ is counted twice) and output that number.

Example for \\$n = 1\\$:

```
1

(1) + (1) = 2

```

Example for \\$n = 2\\$:

```
1 2
4 3

(1+3) + (4+2) = 4 + 6 = 10

```

Example for \\$n = 4\\$:

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

(1+13+15+7) + (10+16+14+4) = 36 + 44 = 80

```

Example of \\$n = 5\\$:

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

(1+17+25+21+9) + (13+23+25+19+5) = 73 + 85 = 158

```

## Further rules and clarifications

* This is OEIS A059924 and there are some closed-form solutions on that page.
* The input and output can be assumed to fit in your language's native integer type.
* The input and output can be given in any convenient format.
* You can choose to either 0-index or 1-index, as I am here in my examples, for your submission. Please state which you're doing.
* Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
* If possible, please include a link to an online testing environment so other people can try out your code!
* Standard loopholes are forbidden.
* This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

# Answer
> 22 votes
# , ~~43~~ 34 bytes

```
function(n)(8*n^3-3*n^2+4*n+3)%/%6

```

Try it online!

The OEIS page lists the following formula for `a(n)`:

```
(16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1)^n)/12

```

However, I skipped right over that to get to the PROG section where the following PARI code is found:

```
floor((16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1^n))/12))

```

Naturally, `+3-3*(-1^n)` is the same as `+6` so we can simplify the linked formula, first by reducing it to

```
(16*n^3-6*n^2+8*n+6)/12 -> (8*n^3-3*n^2+4*n+3)/6

```

and using `%/%`, integer division, rather than `/` to eliminate the need for `floor`.

# Answer
> 5 votes
# Python 2, 30 bytes

Saved some bytes by porting Giuseppe's approach.

```
lambda n:((8*n-3)*n*n+4*n+3)/6

```

Try it online!

# Python 2,  ~~36~~  34 bytes

Saved some *more* bytes thanks to @LeakyNun.

```
lambda n:((8*n-3)*n*n+4*n+n%2*3)/6

```

Try it online!

# Answer
> 3 votes
# Mathematica, 19 bytes

```
((8#-3)#*#+4#+3)/6&

```

Try it online!

Saved some bytes by porting Giuseppe's approach.

# Mathematica, 58 bytes

I always enjoy questions with given answers thanx to oeis (for the nice question and answer)

```
LinearRecurrence[{3,-2,-2,3,-1},{0,2,10,34,80},2#][[#+1]]&

```

# Answer
> 3 votes
# Mathematica, 19 bytes

```
((8#-3)#*#+4#+3)/6&

```

You can run it with the following syntax:

```
((8#-3)#*#+4#+3)/6&[5]

```

Where `5` can be replaced with the input.

You can Try it in the Wolfram Sandbox (Copy-Paste + Evaluate Cells)

# Answer
> 2 votes
# Jelly, ~~11~~ 10 bytes

1 byte thanks to Jonathan Allan.

```
⁽ø\DN2¦ḅ:6

```

Try it online!

# Answer
> 1 votes
# SOGL V0.12, ~~25~~ ~~15~~ 14 bytes

```
8*3-**4.*+3+6÷

```

Try it Here!

Translation of Mr.Xcoder's Python answer which is using Giuseppe's approach. SOGL's not winning anything here :p

# Answer
> 1 votes
# MATL, 21 bytes

```
tt2^Qw6Y3YL-wXytP+*ss

```

Try it online!

# Answer
> 1 votes
# Cubix, 33 bytes

```
I:u8**.../\*3t3n*3t+u@O,6+3+t3*4p

```

Try it online!

cube version:

```
      I : u
      8 * *
      . . .
/ \ * 3 t 3 n * 3 t + u
@ O , 6 + 3 + t 3 * 4 p
. . . . . . . . . . . .
      . . .
      . . .
      . . .

```

Implements the same algorithm as my R answer. I suspect this can be golfed down.

# Answer
> 1 votes
# 05AB1E,  ~~13~~  12 bytes

Uses the same base-conversion technique as Leaky Nun's Jelly submission

<sup>~~Maybe~~ there is a shorter way to create the list of coefficients</sup>

-1 byte thanks to Datboi (use spaces ans wrap to beat compression(!))

```
8 3(4 3)¹β6÷

```

**Try it online!**

### How?

```
8 3(4 3)¹β6÷               stack: []
8            - literal            ['8']
  3          - literal            ['8','3']
   (         - negate             ['8',-3]
    4        - literal            ['8',-3,'4']
      3      - literal            ['8',-3,'4','3']
       )     - wrap               [['8',-3,'4','3']]
        ¹    - 1st input (e.g. 4) [['8',-3,'4','3'], 4]
         β   - base conversion    [483]
          6  - literal six        [483,6]
           ÷ - integer division   [80]
             - print TOS           80

```

---

My 13s...

```
•VŠ•S3(1ǝ¹β6÷

```

```
•2ùë•₂в3-¹β6÷

```

```
•мå•12в3-¹β6÷

```

All using compressions to find the list of coefficients.

# Answer
> 1 votes
# Java 8, 24 bytes

```
n->((8*n-3)*n*n+4*n+3)/6

```

Port of *@Giuseppe*'s R answer.
Note that `/6` floors by default when calculating with integers in Java.

Try it here.

# Answer
> 1 votes
# Excel, ~~35~~ 30 bytes

Saved 5 bytes using Giuseppe's approach.

```
=INT((8*A1^3-3*A1^2+4*A1+3)/6)

```

---

First attempt:

```
=(8*A1^3-3*A1^2+4*A1+3*MOD(A1,2))/6

```

Evolved from a direct implementation of formula from OEIS (37 bytes):

```
=(16*A1^3-6*A1^2+8*A1+3-3*(-1)^A1)/12

```

`+3-3*(-1)^A1` logic can be changed to `6*MOD(A1,2)`.

```
=(16*A1^3-6*A1^2+8*A1+6*MOD(A1,2))/12

```

Does not save bytes, but allows removal of a common factor for 2 bytes.

# Answer
> 0 votes
# Pyth, 17 bytes

```
/+3+*^Q2-*8Q3*4Q6

```

**Try it here.**

# Answer
> 0 votes
# Pyke, 14 bytes

```
8*3-**Q4*+3+6f

```

Try it here!

# Answer
> 0 votes
# 05AB1E, 14 bytes

```
8*3-**4I*+3+6÷

```

Try it online!

# Answer
> 0 votes
# MATL, 12 bytes

```
[DcKI]6/iZQk

```

Try it at **MATL Online!**

### Explanation

Same approach as Giuseppe's answer.

```
[DcKI]   % Push array [8, -3, 4, 3]
6/       % Divide each entry by 6
i        % Push input
ZQ       % Evaluate polynomial
k        % Round down. Implicitly display

```

# Answer
> 0 votes
# Gaia, 14 bytes

```
8×3⁻××@4×+3+6/

```

**Try it online!**

---
Tags: code-golf, number, sequence, number-theory, matrix
---


title: Go away! No-1's Here!

text:
# Question
Title: Go away! No-1's Here!
I was playing around with some numbers and found a sequence that, of course, is on OEIS. It is A005823: ***Numbers whose ternary expansion contains no 1's***. It goes:

> a(2n) = 3\*a(n)+2
>
> a(2n+1) = 3\*a(n+1)
>
> a(1) = 0
>
> a = 0,2,6,8,18,20,24,26,54....

I wrote a CJam program that generates the first *n* of these numbers by converting the index to binary, replacing the 1's with 2's, and converting from ternary to decimal.

I also noticed that any even number can be obtained by taking the sum of two numbers in the sequence (sometimes the number with itself).

**The Challenge:**

Given any non-negative even number as input, output the indices of two numbers in the sequence that sum to it. (Note that sometimes multiple pairs are possible.)

**The Rules:**

* Specify if you're using 0- or 1-indexing.
* If you're outputting as a string, put a delimiter between the two indices.
* You are allowed to output as a complex number.
* If you so desire, you can output every valid pair.
* Code Golf: shortest answer wins

## Test Cases

I use 0-indexing. Here I list every possible output for each input, but you only need to output one.

```
**0:**      [0 0]
**2:**      [1 0]
**4:**      [1 1]
**6:**      [2 0]
**8:**      [2 1]   [3 0]
**10:**     [3 1]
**12:**     [2 2]
**14:**     [3 2]
**16:**     [3 3]
**18:**     [4 0]
**30:**     [6 2]
**32:**     [6 3]   [7 2]
**46:**     [7 5]
**50:**     [7 6]
**120:**    [10 10]
**338:**    [19 18]
**428:**    [30 23] [31 22]
**712:**    [33 27] [35 25] [41 19] [43 17] [49 11] [51 9]  [57 3]  [59 1]
**1016:**   [38 37] [39 36]
```
Thanks to @Luis Mendo for test case help.

Related: Is it within the Cantor set?

# Answer
> 10 votes
# Husk, ~~21~~ ~~14~~ 13 bytes

-7 bytes, thanks to @Neil's JS answer

-1 byte inspired by betaveros's Parradoc answer

Uses 0-indexing

```
mḋTmMo±>ḋ2B3½

```

Try it online!

### Explanation

```
            ½    Half the input
          B3     Convert to Base 3
   m             Map over the list
    Mo±>ḋ2       Function such that: 0 -> [0,0], 1 -> [0,1], 2 -> [1,1]
        ḋ2       Binary 2, [1,0]
    M            For each in that list
     o±>         check if the argument is greater than it
  T              Transpose
mḋ               Convert each from binary

```

### Previous 21 byte Solution

First time I've seen a use for `»`.

```
mḋT»o%2+ȯ?´eḋε%3`-0B3

```

Try it online!

Longer, as I was dealing with carries

# Answer
> 8 votes
## JavaScript (ES6), ~~75~~ 71 bytes

```
f=
n=>[1,0].map(i=>parseInt((n/2).toString(3).replace(/./g,c=>+c+i>>1),2))
```

```
<input type=number min=0 step=2 oninput=o.textContent=this.value%2?``:f(this.value)><pre id=o>
```

Explanation: Dividing input and the elements of A005823 by 2 doesn't alter the problem, however it makes the solution simpler as the ternary representations now only use 0s and 1s and therefore there is no carrying to consider. It also saves a step when converting from the element to its index (each element's ternary is twice the binary of its index). Examples:

```
                 A005823
                  halved
            n in  values A005823
   n n/2  base 3  base 3 indices
   0   0       0   0   0   0   0
   2   1       1   1   0   1   0
   4   2       2   1   1   1   1
   6   3      10  10   0   2   0
   8   4      11  11   0   3   0
  10   5      12  11   1   3   1
  12   6      20  10  10   2   2
  14   7      21  11  10   3   2
  16   8      22  11  11   3   3
  18   9     100 100   0   4   0
  30  15     120 110  10   6   2
  32  16     121 111  10   7   2
  46  23     212 111 101   7   5
  50  25     221 111 110   7   6

```

# Answer
> 6 votes
# Jelly, ~~26, 22~~, 21 bytes

```
ḶBḤḅ3
ÇŒcS=¥Ðf⁸ḢiÐ€ÇT

```

Try it online!

One byte saved thanks to @JonathanAllan!

Explanation:

```
                # Helper link: A005823 to *N* terms
Ḷ               # Lowered range(N)
 B              # Converted to binary
  Ḥ             # Double each digit
   ḅ3           # Converted from base 3 to decimal
                # Main link
Ç               # Last link
 Œc             # All combinations of 2 items (with replacement)
      Ðf        # Remove every combination where this isn't true:
   S=¥          #   The sum of the two items is equal to N
        ⁸Ḣ      # Take the first combination left
          i     # Index of
           Ð€   # Each element of the combination
             Ç  # In the sequence
              T # Return the truthy indices

```

# Answer
> 3 votes
# J, <sub>~~35~~</sub> 32 bytes

```
($#:I.@,)@(=[:+/~3#.+:@#:@i.@>:)

```

Try it online!

0-indexed and input is given monadically. Returns all possible summations to the value (it treats `a b` and `b a` as different possible summations).

Converting from a boolean matrix to indices takes a lot of code...

I'd like to also remove the fork on the left so I don't have to use as many parentheses and `@`-ats, but I can't figure out a good way to do it (my alternate approach doesn't save any bytes).

# Explanation

For purposes of explaining and ungolfing, consider the following components of the main function

```
valid_nums      =. = [: +/~ 3 #. +:@#:@i.@>:
indices_of_ones =. $ #: I.@,

```

**valid\_nums** yields a boolean matrix where the indices are the indices of the summed sequence values. If there's a one at those indices, it means that the two numbers sum to the input value.

**indices\_of\_ones** is a J idiom for giving the coordinates of the ones in an arbitrary rank boolean matrix

The main function is composed quite simply as

```
indices_of_ones@valid_nums

```

### valid\_nums

```
= [: +/~ 3 #. +:@#:@i.@>:  Input is n
                 #:@i.@>:  Binary numbers in range [0,n]
              +:           Doubled
         3 #.              Interpreted as ternary
     +/~                   Addition table with self (sum all possible pairs)
=                          Equate to n

```

### indices\_of\_ones

```
$ #: I.@,
        ,  Ravel matrix into a single list
     I.    Find the indices of ones in that list
  #:       Convert to the base given by
$          The shape of the matrix

```

`,`-ravel works in this case by joining each row to the next.

```
   i.3 3
0 1 2
3 4 5
6 7 8
   , i.3 3
0 1 2 3 4 5 6 7 8

```

We can see that if this were a boolean matrix, the coordinates of ones can be found by interpreting the indices of the raveled matrix as numbers in the base of the shape of that matrix using as many prepositional phrases as possible to help confuse the poor reader.

# Answer
> 3 votes
# Python 2, 51 bytes

```
f=lambda n:[n and(n/2%3>r)+2*f(n/3)[r]for r in 0,1]

```

Try it online!

The task can be done like this:

1. Halve the input
2. Convert to ternary list
3. Split that into two binary lists that sum elementwise to it
4. Convert those lists from binary

We can do the splitting in (3) by converting `0->0,1->1,2->1` for one list and `0->0,1->0,2->1` for the other. That is, by checking is the value is above a threshold of 0 or 1.

The two values can be found by respective recursive functions:

```
p=lambda n:n and(n/2%3>0)+2*p(n/3)
q=lambda n:n and(n/2%3>1)+2*q(n/3)

```

The function `f` combines the two of these in a list comprehension. This makes it inefficient due to exponential branching.

If complex numbers could be output, we could save 10 bytes with:

```
f=lambda n:n and(n%6>1)+n%6/4*1j+2*f(n/3)

```

# Answer
> 3 votes
# MATL, ~~22~~ ~~21~~ ~~19~~ 17 bytes

```
tQ:qBEI_ZA&+=R&fh

```

Output is 1-based. The program produces all solution pairs. Try it online! Or verify all test cases.

### Explanation

```
t      % Implicit input: n. Duplicate
Q:q    % Range [0 1 ... n]
B      % Convert to binary. Gives a matrix where each row corresponds to a number
E      % Multiply each entry by 2
I_ZA   % Convert each row from ternary to a number
&+     % Matrix of all pair-wise additions
=      % Does each entry equal n?
R      % Upper triangular matrix
&f     % Push row and column indices of nonzero entries
h      % Concatenate horizontally. Implicit didsplay

```

# Answer
> 3 votes
# Paradoc (v0.2.10), 11 bytes (CP-1252)

```
½3B2>_B™2Bv

```

Try it online!

Algorithmically it's very much just like Neil's ES6 answer. On a lower level, also strikingly similar to H.PWiz's Husk answer. I am amused that we got to use all three overloadings of `B`.

Takes an integer on the stack, leaves a list of two integers on the stack.

Explanation:

```
½           .. Halve input
 3B         .. Convert to ternary
   2        .. 2, which will get implicitly coerced to [0,1]
    >_      .. Greater than, as a block
      B     .. "Bimap": take the block and map it over the Cartesian
            .. product of the last two lists to get a matrix
       ™    .. Transpose
        2Bv .. Convert each row from binary

```

# Answer
> 2 votes
# Pyth, 37 bytes

0-indexed

Certainly not golfed as well as it could be.

```
KUQJmi:.Bd\1\23KhfqQ+@JeT@JhTsmm,dkKK

```

Try it online!

# Answer
> 2 votes
# Pyth, 29 bytes

This one returns all possible pairs of indices.

```
fqQ+@Kmi:.Bd\1\23QhT@KeT.cUQ2

```

**Try it here.**

# Pyth, 30 bytes

```
hfqQ+@Kmi:.Bd\1\23QhT@KeT.cUQ2

```

**Try it here.**

This returns the pairs of indices as `[LowerIndex, HigherIndex]`.

---

# How does this work?

```
hfqQ+@Kmi:.Bd\1\23QhT@KeT.cUQ2   Full Program. Q means input throughout the whole explanation.

       m          Q               Map over the range [0, Q) with a variable d.
          .Bd                     Convert to binary.
         :   \1\2                 Replace 1 with 2.
        i        3                Convert it from base 3 to integer.
      K                           Assign the mapped range to a variable K.
                         .cUQ2    All possible two-element combinations of the range [0...Q).
    +@             hT@KeT         Sum of the integers on positions in K of the two-element
                                  combination.
 fqQ                              Filter those that equal the input.
h                                 Optional: Head. Take the first element.
                                  Print the result, implicitly.

```

# Answer
> 1 votes
# JavaScript, ~~120~~ 101 bytes

```
n=>[(A=[...Array(n+1)].map(Z=(a,b=a)=>b&&3*Z(b/2|0)+b%2*2))[F='findIndex'](a=>z=~A[F](b=>a+b==n)),~z]

```

Try it online!

0-indexed.
It returns the pair of indices where one index is the smallest possible (for example in the case of `428` it returns `22,31`).

# Answer
> 1 votes
# Python 3, ~~122~~ 120 bytes

-2 bytes thanks to Mr. Xcoder!

0-indexed

```
def f(a):r=range(a);s=[int(bin(x)[2:].replace(*'12'),3)for x in r];return[(i,j)for i in r for j in r if s[i]+s[j]==a][0]

```

Ungolfed:

```
def f(a):
    r=range(a)
    s=[int(bin(x)[2:].replace(*'12'),3)for x in r]
    return[(i,j)for i in r for j in r if s[i]+s[j]==a][0]

```

Try it online!

# Answer
> 1 votes
# Mathematica, 94 bytes

```
(w=#;Position[s,#]&/@#&@@(k=Select)[Tuples[s=k[Range@w,DigitCount[#,3,1]==0&],{2}],Tr@#==w&])&

```

1-indexed

# Answer
> 1 votes
# Brain-Flak, ~~220~~ 166 bytes

-54 bytes by looking up the modulo function on the wiki, allowing some structural changes

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

```

Try it online!

0-indexed.

### Explanation

Like many of the other solutions, this computes the ternary expansion of `n/2` and converts that to two binary numbers.

Step 1: Divide input by 2

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

 {              }     until number becomes zero:
     ({}[()()])       subtract two
( ()<          > {})  push number of iterations

```

Step 2: compute ternary expansion

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

 ({}(<>))<>         {   (({})){({}[()])<>}{} }{}<> ([{}()]{})         modulo (from wiki)
           (()()())                                                   use 3 as base
                     ()<                    >                         evaluate as 1 every time the 3 rolls over
                   (                              <          >[()])   push number of rollovers (function is now division with remainder)
{                                                                  }  repeat until quotient is zero, leaving all remainders on stack

```

Step 3: Convert to solution

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

([]){{}                                                      ([][()])}           repeat while stack height > 1:
                                                                                (loop happens once when initial stack height is 1, but that's fine)
       <>(({}){})                                                                double smaller output number
                 <>(({}){}                                  )                    double larger output number
                          {                              }{}                     if digit in ternary expansion is nonzero:
                           ()<                          >                        add 1 to larger output number
                              ({}[()]){                }                         if digit is 2:
                                       <>({}())<>(<{}>)                          add 1 to smaller output number

```

# Answer
> 0 votes
## JavaScript (ES6), 70 ~~72~~ bytes

```
n=>[6,4].map(x=>parseInt((n/2).toString(3).replace(/./g,d=>x>>d&1),2)) // thanks @Neil
n=>[0,1].map(x=>parseInt((n/2).toString(3).replace(/1|2/g,d=>~-d||x),2))

```

(0-indexed, and apparently nearly the same solution as @Neil even if I hadn't seen his answer)

I started off with getting the index back from a number using the reverse of the process: stringify with base 3, replace every `2` with `1`, parse with base 2.

To get two numbers, and that for every even one, we just half the input - but now, also `1` digits can occur. So we replace it with a `0` in the one number and a `2` in the other number, which does not change the sum of the two, before the replace-and-parse step. Here is what I came up with (doing the two replacements, `1` -\> 0-or-2 and `2` -\> `1` in one step):

```
n=>["001","011"].map(x=>parseInt((n/2).toString(3).replace(/./g,d=>x[d]),2))

```

Of course the two replacement maps (strings) differ only in one index, so we should be able to shorten the array literal by only replacing `1` and `2` with `d == 2 ? 1 : x`. Or `d-1 || x`. Where `-1` does the same as the two unary operators - but they look scarier :-)

Trying to avoid the array literal and the parenthesis around `n/2` I also came up with

```
n=>Array.from(parseInt,(h=n/2,i)=>parseInt(h.toString(3).replace(/1|2/g,d=>~-d||i),2))

```

but it did not turn out fruitful.

# Answer
> 0 votes
# Pyth, 22 bytes

```
J.m}1jb3hQxLJhfqsTQ^J2

```

Try it online: Demonstration

### Explanation:

```
J.m}1jb3hQxLJhfqsTQ^J2
        hQ                input + 1
 .m                       find all values of [0, 1, 2, ..., input], where
     jb3                     value converted to base 3
   }1                        check if it contains the digit 1
                          this boolean ^ is false
J                         store this list in variable J

                   ^J2    every pair of J
              f           filter for pairs with
                sT           sum of pair
               q             equal
                  Q          the input
             h            take the first of these pairs
          xLJ             and find the corresponding indices of J

```

---
Tags: code-golf, sequence, base-conversion
---


title: Maximum Recursion Depth

text:
# Question
Title: Maximum Recursion Depth
Does your language have a maximum recursion depth (MRD)?

Let's say your language has **MRD=500**

Write a code that finds the recursion depth and outputs the **exact value**

For the case above your program (or function) should output **500**

**Code-Golf** Shortest answer wins!

# Answer
# Mathematica, 15 bytes

```
$RecursionLimit

```

¯\\\_(ツ)\_/¯

Try it online!
> 53 votes

# Answer
# Python 3, 40 bytes

```
def f(x=2):
 try:f(x+1)
 except:print(x)

```

Try it online!

Without just reading it from the builtin. We start at 2 instead of 1 because the except clause is run one level before it errors. This is a byte shorter in python 2, of course.
> 21 votes

# Answer
# JavaScript (Babel), ~~35~~ ~~33~~ 29 bytes

```
f=_=>do{try{-~f()}catch(e){}}

```
* 2 bytes saved thanks to Neil.

Try it here, or use the Snippet below to test it with `eval` instead of `do`.

```
console.log((f=_=>eval(`try{-~f()}catch(e){}`))())
```

---

## Japt port, 24 bytes

It's not really worth posting this as a separate solution as it's, essentially, identical.

```
Ox`try\{-~rp()}¯t®(e)\{}

```

Test it

---

## Explanation

JavaScript itself doesn't have a recursion limit per se, rather the limit is imposed by the interpreter (i.e., the browser) - good thing we define languages by their interpreter 'round here! Among other factors, the limit can vary by browser and available memory, which is impacted by the operations being performed. The following Snippet illustrates that last point, using the 5 different versions of this solution I went through. As you can see from the last 2 tests, in Chrome, at least, even the order of operations can make a difference.

```
console.log((f=(i=0)=>eval(`try{f(i+1)}catch(e){i}`))())
console.log((f=i=>eval(`try{f(-~i)}catch(e){i}`))())
console.log((f=(i=0)=>eval(`try{f(++i)}catch(e){i}`))())
console.log((f=_=>eval(`try{-~f()}catch(e){}`))())
console.log((f=_=>eval(`try{f()+1}catch(e){0}`))())
console.log((f=_=>eval(`try{1+f()}catch(e){0}`))())
```

Given that, we therefore don't have the convenience of a constant or method to work with. Instead, we're going to create a function that calls itself continuously before, eventually, crapping out. In it's simplest form that is:

```
f=_=>f()

```

But that's not much use to us for this challenge as it only throws an overflow error with no indication of how many times `f` called itself. We can avoid the error by *`try`ing* to call `f` continuously and `catch`ing when it fails:

```
f=_=>{try{f()}catch(e){}}

```

No error, but still no return value of how many times the function managed to call itself before failing, because the `catch` isn't actually doing anything. Let's try evaluating the `try / catch` statement:

```
f=_=>eval(`try{f()}catch(e){}`)

```

Now we've got a value being returned (and, because this is code golf, saved ourselves a few bytes over using an actual `return`). The value being returned, though, is `undefined`, again because the `catch` isn't doing anything. Luckily for us `-~undefined==1` and `-~n==n+1` so, by popping a `-~` in front of the call to `f`, we've essentially got `-~-~ ... -~-~undefined`, with another `-~` prepended with each call, giving us the number of times `f` was called.

```
f=_=>eval(`try{-~f()}catch(e){}`)

```
> 15 votes

# Answer
# Mathematica (no built-in), 20 bytes

```
#0[#+1];&@1
%[[1,1]]

```

Omitting the `;` will calculate `1+$IterationLimit` (probably because Mathematica tail-optimize the function). Alternatively `0 //. x_ -> x + 1` calculate `ReplaceRepeated`'s default `MaxIteration`, that is, `65536` (which is larger than both value above).

(This is a code snippet which evaluates to the result. However the other Mathematica solution is also)
> 14 votes

# Answer
# J, 8 bytes

```
1+$: ::]

```

Try it online!

So, I don't actually know how to execute a verb without any input and some brief searching (as well as personal intuition) makes it seem like that isn't possible. If it is, please let me know how to do it and I'll either delete or update my answer. It doesn't really make sense for a verb to be given no input, though. In light of this, the function given expects `0`, the default "empty" input for integers. I can probably change it to use the empty array (`0$0`) if you think that's more befitting.

Edit: the OP has allowed the function to take 0.

# Explanation

```
1+$: ::]
     ::]  Assign adverse: if an error occurs, call ] (the identify function)
1+        Add one to
  $:      Recursive call to self

```

This calls itself recursively, adding 1 to the input (0 expected) until it hits a stack error. When it errors, it calls the adverse (`]`-right identity) on the input, which is just 0.

By the way, the space is necessary.
> 10 votes

# Answer
# Python 3, ~~41~~ 32 bytes

```
import sys
sys.getrecursionlimit

```

Try it online!

Saved 9 bytes thanks to @FryAmTheEggman!

### 34 bytes

```
from sys import*
getrecursionlimit

```

### 35 bytes

```
__import__('sys').getrecursionlimit

```

The last 2 are thanks to @totallyhuman
> 9 votes

# Answer
# Java 8, ~~131~~ ~~51~~ ~~48~~ ~~47~~ 43 bytes

```
int d;int c(){try{c();}finally{return++d;}}

```

-80 bytes thanks to *@Nevay*. I tried a method instead of program as well, but made a mistake so ended up with a full program.. Now it's a method.
-3 bytes thanks to *@Neil* by making use of `finally` instead of `catch(Error e)`.
-5 byte thanks to *@Nevay* again.

**Explanation:**

Try it here.

```
int d;                 // Depth-integer `d` on class-level (implicit 0)
int c(){               // Method without parameter and integer return-type
  try{c();}            //  Recursive call
  finally{return++d;}  //  Increase depth-integer `d` and always return it,
                       //   whether a StackOverflowError occurs or not
}                      // End of method

```
> 8 votes

# Answer
# C (gcc, Linux x64), ~~180~~ 133 bytes

*-4 bytes thanks to @scottinet*

```
c;f(){f(++c);}h(){exit(printf("%d",c));}main(){int b[512];f(sigaction(11,(int*[]){h,[17]=1<<27},sigaltstack((int*[]){b,0,2048},0)));}

```

Try it online!

Installs a SIGSEGV (signal 11) handler with an alternate signal stack (minimum size `MINSIGSTKSZ` is 2 KB, flag `SA_ONSTACK` is 0x08000000), then calls a function without arguments and no local variables recursively until the stack overflows. It's interesting that the maximum recursion depth varies across runs, probably due to ASLR.

The maximum recursion depth in C depends on a lot of factors, of course. On a typical 64-bit Linux system the default stack size is 8 MB, and the stack alignment is 16 bytes, so you get a recursion depth of about 512K for simple functions.

Also note that the program above doesn't work with `-O2` because of tail call optimization.
> 8 votes

# Answer
# , ~~32~~ ~~26~~ 18 bytes

*-8 bytes thanks to Sven Hohenstein* : `$` will do partial matching, so we can just use `exp` instead of the full `expressions`.

```
cat(options()$exp)

```

The `options` command can also be used to set the recursion depth, i.e., `options(expressions=500)` for 500.

Try it online!
> 4 votes

# Answer
# Octave, ~~25~~ ~~22~~ 20 bytes

*2 bytes removed thanks to a suggestion by Sanchises*

```
@max_recursion_depth

```

Anonymous function that outputs the value.

Try it online!
> 4 votes

# Answer
# **Octave, 19 bytes**

```
max_recursion_depth

```

Usage:

```
octave:1> max_recursion_depth
ans =  256

```
> 4 votes

# Answer
# zsh, 24 bytes

```
f(){f $[++i];f};set -x;f

```

Try it online! (See under debug)

Or 12 bytes if hardcoded values are allowed (From *GammaFunction*):

```
<<<$FUNCNEST

```

# bash, 24 bytes

```
f(){ f $[++i];};set -x;f

```

Try it online! (See under debug)

# ksh93, 27 bytes

```
f(){ f $(($1+1));};set -x;f

```

Try it online! (See under debug)

# dash, 27 bytes

```
f(){ f $(($1+1));};set -x;f

```

Try it online! (Exceeds tio debug output, run it in your own shell)
> 3 votes

# Answer
# Lua, 52 bytes

```
f=load"b,e=pcall(f,(...or 3)+1)return b and e or..."

```

Try it online!
> 1 votes

# Answer
# q/kdb+, 16 bytes

**Solution:**

```
{@[.z.s;x+1;x]}0

```

**Example:**

```
/ solution
q){@[.z.s;x+1;x]}0
2000

/ without apply (try/catch)
q){.z.s x+1}0
'stack
@
{.z.s x+1}
2001

```

**Explanation:**

Try to recurse, increase x by one each time, if error, return x.

```
{@[.z.s;x+1;x]}0 / the solution
{             }0 / call lambda function with 0
 @[    ;   ; ]   / @[function;argument;catch]
   .z.s          / call self (ie recurse)
        x+1      / increment x
            x    / return x if function returns error

```
> 1 votes

# Answer
# Excel-VBA, 26 Bytes

```
?Application.MaxIterations

```

Not recursion depth per-se, this actually outputs the maximum number of iterations for a cell in an Excel worksheet. Given that the output pertains to a language other than the language in which this is written, perhaps this is more appropriate:

# Excel + Excel-Vba, 3 + 38 = 41 Bytes

```
Function f:f=Application.MaxIterations

```

As that can be called from a cell with

```
=f(

```

For VBA with no built in:

# Excel-VBA, ~~53~~ ~~44~~ 40 bytes

-9 as variable no longer needs to be initialised or printed

-4 as code execution no longer has to be ended to avoid multiple prints

```
Sub s:[A1]=[A1]+1:On Error Resume Next:s

```

Call with s in the immediate window, outputs to cell A1 of the worksheet

*(warning takes a while to run now, add `Application.ScreenUpdating = False` first)*
> 1 votes

# Answer
# Lua, ~~45~~ 37 bytes

```
x=2
f=load"x=x+1;f()"pcall(f)print(x)

```

Try it online!

I don't know which value to initialize `x` with as I don't know the number of intermediary calls there are...
> 1 votes

# Answer
# Clojure, ~~72~~ ~~55~~ 48 bytes

-23 bytes by getting rid of the atom

-7 bytes thanks to @madstap. Switched to using `fn` over `def` and `#()`, and `pr` over `println`.

```
((fn f[i](try(f(inc i))(catch Error e(pr i))))0)

```

Wrote and tested on my phone. The Clojure REPL app gave me a depth of 13087.

Basic solution. Recurse until a SO is thrown, incrementing a counter each recurse. When it's thrown, the value of the counter is printed.
> 1 votes

# Answer
# VBA, any type, ~~41~~ 39 bytes

```
Function A:On Error Resume Next:A=A()+1

```

Call using `?A()` in the Immediate window, or as worksheet function.

**Note:** Returns 4613 in Excel-VBA, while the answer by @Greedo returns 3666 on my system (highest should be the max). Apparently also varies between Office programs (Access-VBA returns 4622, Word-VBA 4615)

Edit: Guess VBA auto-adds parantheses, so removed them.
> 1 votes

# Answer
# Pyth - 9 bytes

```
L.xyhbbyZ

```

If I can run it like the J answer above, this is 7 bytes because you can take out the last `yZ`.

Try it online here.
> 0 votes

# Answer
# Forth, 48 bytes

Loops until it hits the limit.

```
: m 1+ recurse ;
: f 0 ['] m catch drop ; f .

```

**Try it online**
> 0 votes

# Answer
# Tcl, 18 bytes

```
puts [interp r {}]

```

Try it online!

`recursionlimit` can be abbreviated to `r`

~~Tcl, 31 bytes
```
puts [interp recursionlimit {}]

```
Try it online!
~~
> 0 votes

# Answer
# Tcl, 49 bytes

```
proc R {i\ 1} {if [catch {R [incr i]}] {puts $i}}

```

Try it online!
> 0 votes

# Answer
# Ruby, 39 bytes

```
END{p$.}
$stderr=$<
f=->{$.+=1;f[]}
f[]

```

Suppressing the error message is a little shorter than rescuing it, since by default `rescue` doesn't catch `SystemStackError`.

There's a cheesier answer if I can output in unary, representing `n` with n consecutive newline characters:

# Ruby, 35 bytes

```
$stderr=$<
f=->{puts;$.+=1;f[]}
f[]

```
> 0 votes

# Answer
# Jelly, 18 bytes

:( *

```
“¡żuẋ×HẒpƙ7"8!ƭ»ŒV

```

**Try it online!**

### How?

* Since Jelly as far as I am aware:
(1) sets the Python recursion limit prior to setting up much of its own interpreter and parsing the code to be run; and
(2) has no way of catching Python errors
I'm not sure if there is a way to either reliably evaluate the recursion limit or to print it out as it is discovered other than to actually ask Python what the value was set to (I'd love to see if it can be done though!) so that's what the code here does:

```
“¡żuẋ×HẒpƙ7"8!ƭ»ŒV - Link: no arguments
“¡żuẋ×HẒpƙ7"8!ƭ»   - compression of "sys."+"get"+"recursion"+"limit"+"()"
                ŒV - evaluate as Python code

```
> 0 votes

---
Tags: code-golf
---


title: Collatz's First Conjecture

text:
# Question
Title: Collatz's First Conjecture
## Background

The Collatz Conjecture is quite well-known. Take any natural number. Triple and increment if odd; cut in half if even. Repeat, and it will reach 1 eventually. This famous conjecture, however, is only that, for it is yet unproven.

Little-known to the world, that was not Lothar Collatz's first attempt at fame. His first Conjecture (now proven) was a touch simpler:

* Take any natural number *n*.
* While *n* ≠ 4, find the length of its written-out form (English). Store this value to *n*.

The conjecture is that all natural numbers will eventually become 4. This did not catch on as well as Collatz had hoped, so he returned to the drawing board.

## Your task

Read a positive integer *n* \< 2147483648 (2^31) from input and return/print the number of iterations required to reach 4.

## Things to note

Do not use *and*. 228 is "two hundred twenty-eight," **not** "two hundred and twenty-eight."

Do not use articles. 145 is "one hundred forty-five," not "a hundred forty-five.)

Commas set apart each three orders or magnitude: "one million, four hundred eighty-two thousand, one hundred seventy-five."

Punctuation is counted. Spaces are not. Hyphenate 21-99 except multiples of ten.

## Test cases

> 4 (four): **0**
> 3 (three→five→four): **2**
> 6278 (six thousand, two hundred seventy-eight→thirty-five→eleven→six→three→five→four): **6**
> 1915580 (one million, nine hundred fifteen thousand, five hundred eighty→fifty-five→ten→three→five→four): **5**
> 2147483647 (two billion, one hundred forty-seven million, four hundred eighty-three thousand, six hundred forty-seven→ninety-three→twelve→six→three→five→four): **6**

This is , so the shortest code (in bytes) in each language WINS! Good luck!

# Answer
> 1 votes
# Python 3 \+ inflect,  ~~122~~  114 bytes

Saved 8 bytes thanks to Scrooble.

```
from inflect import*
f=lambda k,i=0:k!=4and f(len(engine().number_to_words(k,andword="").replace(" ","")),i+1)or i

```

This cannot be tested online because of the package it uses. Running the test suite gives:

```
4 -> 0
3 -> 2
6278 -> 6
1915580 -> 5

```

---
Tags: code-golf, number-theory, integer, natural-language
---


title: Generate strong primes

text:
# Question
Title: Generate strong primes
> In number theory, a strong prime is a prime number that is greater than the arithmetic mean of the nearest prime above and below (in other words, it's closer to the following than to the preceding prime).

Given an input integer, `n`, where `n >= 0`, your task is to generate the first `n` strong primes. For example, the sixth, seventh, and eighth primes are 13, 17, and 19, respectively:

```
(13 + 19) / 2 < 17

```

Therefore, 17 is a strong prime.

### Input

* an integer

### Output

* if `n` is 0
    + program: output nothing
    + function: return an empty array
* if `n` is greater than `0`
    + program: output the first `n` strong primes, each on its own line
    + function: return an array containing the first `n` strong primes

### Test cases

```
0
[]

4
[11, 17, 29, 37]

7
[11, 17, 29, 37, 41, 59, 67]

47
[11, 17, 29, 37, 41, 59, 67, 71, 79, 97, 101, 107, 127, 137, 149, 163, 179, 191, 197, 223, 227, 239, 251, 269, 277, 281, 307, 311, 331, 347, 367, 379, 397, 419, 431, 439, 457, 461, 479, 487, 499, 521, 541, 557, 569, 587, 599]

```

See also: Strong primes on OEIS

# Answer
# Husk, ~~12~~ 11 bytes

```
↑§foẊ<Ẋ-tİp

```

Try it online!

-1 byte thanks to H.PWiz.

## Explanation

```
↑§foẊ<Ẋ-tİp  Input is n.
         İp  The infinite list of primes.
      Ẋ-     Take pairwise differences,
   oẊ<       then pairwise comparisons.
        t    Frop the first element from İp
 §f          and filter the rest using the result of oẊ<Ẋ-.
↑            Take first n elements of this list.

```
> 13 votes

# Answer
# Jelly, 14 bytes

```
Æp+ÆnH<ȧÆP
3Ç#

```

Try it online!

## Explanation

```
Æp+ÆnH<ȧÆP  Helper link. Input: k
Æp          Prime less than k
  +         Plus
   Æn       Prime greater than k
     H      Halve
      <     Less than k?
       ȧ    Logical AND
        ÆP  Is k prime?

3Ç#  Main link. Input: n
  #  Find n matches
3Ç     Call the helper link on 3, 4, 5, ...

```
> 6 votes

# Answer
# Java ~~182~~ ~~167~~ 153 bytes

## Second version

Thank's to Roman Gräf for saving 29 bytes!

```
n->{int s[]=new int[n],i=1,p=i,q=i;while(n>0)if(java.math.BigInteger.valueOf(++i).isProbablePrime(n.MAX_VALUE)){if(p>(i+q)/2)s[--n]=p;q=p;p=i;}return s;}
```

### ungolfed

```
int[] strongPrimes(Integer n) {
        int[] strongPrimes = new int[n];
        int i=1;
        int p1=i; //last prime
        int p2=i; //2 primes ago
        while(n>0) if(java.math.BigInteger.valueOf(++i).isProbablePrime(n.MAX_VALUE)) { //increment i and if prime
            //System.out.println("p1:"+p1+" i:"+i+" p2:"+p2);
            if(p1>(i+p2)/2) strongPrimes[--n]=p1; //if the previous one was strong
            p2=p1;
            p1=i;
        }
        return strongPrimes;
    }
```

### General

I don't think I can get it any smaller without help. Doesn't anyone now of an other build in function to check for primes?

### concerns

technically there is 2^(-2^31) chance that `isProbablePrime(Integer.MAX_VALUE)` returns true on a non prime but this doesn't happen for an integer.

It also outputs the numbers in reverse order but I didn't see anything about the order in which the primes should be outputted but that's an easy fix (although it could cost some bytes)
> 6 votes

# Answer
# Python 2, 106 103 bytes

**Edit:** -3 bytes thanks to @Mr.Xcoder

```
n=input()
a=2;b=i=3
while n:
 i+=2
 if all(i%k for k in range(3,i)):
 	if i+a<b*2:print b;n-=1
	a,b=b,i

```

Try it online!

Quite straight forward. Loop through all prime numbers keeping track of the two last primes. When a new prime is found, we check if the previous prime is a strong prime, and then update the two primes kept track of. This is done until n strong primes have been found.
> 4 votes

# Answer
# Mathematica, ~~81~~ 66 bytes

```
Select[Partition[Prime@Range[#^2],3,1],Apply[#+#3<2#2&]][[;;#,2]]&

```

*thanx to @Marthe172 for -15 bytes*
> 3 votes

# Answer
# Pyth, 25 bytes

```
.f&P_Z>yZ+fP_ThZefP_TUZQ3

```

**Try it here!** or **Check out the test Suite!**

---

# Explanation

Quite happy with this golf given that Pyth kind of lacks prime built-ins.

```
.f&P_Z>yZ+fP_ThZefP_TUZQ3    Full program. Note that Q means input.

.f                     Q3    First Q inputs with truthy results, starting at 3 and counting up by 1.
          fPThZ              First prime after the current number.
               efP_TUZ       The last prime before the current number.
         +                   Sum.
      >yZ                    Is the current number doubled higher than the sum?
  &P_Z                       And is the current number prime?
                             Output implicitly.

```
> 3 votes

# Answer
# Actually, 17 bytes

```
⌠;D;⌐P@P+½@P>⌡╓♂P

```

Try it online!

Explanation:

```
⌠;D;⌐P@P+½@P>⌡╓♂P
⌠;D;⌐P@P+½@P>⌡╓    first n values (starting with k=0) where:
  D    P             (k-1)th prime
   ;⌐P@ +            plus (k+1)th prime
         ½           divided by 2
 ;        @P>        is less than kth prime
               ♂P  primes at those indices

```
> 2 votes

# Answer
## C++, 334 bytes, 318 with MSVC

-1 byte thanks to Mr.Xcoder -1 byte thanks to Zacharý

With the MSVC compilation, you don't need to include the `cmath` header yourself, it compiles without

```
#include<vector>
#include<cmath>
typedef std::vector<int>v;v p{2};int i(int t){int m=sqrt(t)+2,i=2;for(;i<m;++i)if(t%i<1)return 0;return 1;}void n(){int l=p.back()+1;while(!i(l))++l;p.push_back(l);}auto s(int m){if(!m)return v();n();n();v r;while(r.size()!=m){if((p[0]+p[2])/2<p[1])r.push_back(p[1]);p.erase(p.begin());n();}return r;}

```

## tsh and Mr.Xcoder answer : 131 bytes

tsh rewrote the answer in 139 bytes ( -195 ), and Mr.Xcoder golfed it more with 131 bytes

```
int N,t,o,a,b,i;void n(){t=++N;for(o=2;++o<t;)if(t%o<1)n();}void s(int m,int*r){b=N=t=5;for(;i<m;)if(a=b,b=t,n(),b+b>a+t)r[i++]=b;}

```

Mr.Xcoder TIO Link

First version ungolfed :

```
#include<vector>
#include<cmath>
typedef std::vector<int> v;
v p{2};
//Tells if a number is prime or not
int i(int t) {
    int m = sqrt(t) + 2, i = 2;
    for (;i < m;++i)
        if (t%i < 1)
            return 0;
    return 1;
}
//Push back the next prime number
void n() {
    int l = p.back() + 1;
    while (!i(l))
        ++l;
    p.push_back(l);
}
//Generate a list of m strong primes
auto s(int m) {
    if (!m)
        return v();
    n();
    n();
    v r;
    while (r.size() != m) {
        if ((p[0] + p[2]) / 2 < p[1])
            r.push_back(p[1]);
        p.erase(p.begin());
        n();
    }
    return r;
}

```
> 2 votes

# Answer
# 05AB1E, 19 bytes

```
µNØN<ØN>Ø+;›i¼NØ}})

```

Try it online!
> 2 votes

# Answer
# Haskell, ~~123~~ ~~121~~ ~~114~~ 85 bytes

```
import Data.List
g=(`take`(tails(nubBy(((>1).).gcd)[2..])>>=(\(a:b:c:_)->[b|b-a>c-b])))

```

(anonymous function courtesy of H.PWiz; I initially thought I must both print and then return, so had a longer code)

(not counting the `g=` bit)

Running it:

```
~> g 7
[11,17,29,37,41,59,67]

```
> 1 votes

# Answer
# Python 2 \+ SymPy, 118 bytes

Not as short as the classic approach, but I think it's worth posting.

```
from sympy.ntheory import*
def f(i):
 k=3
 while i:
	if prevprime(k)+nextprime(k)<k*2and isprime(k):i-=1;yield k
	k+=2

```

Try it online!
> 0 votes

# Answer
# Axiom, 109 bytes

```
h(n)==(c:=s:=3;r:=[];for i in 5..by 2|prime?(i)repeat(#r>=n=>break;p:=c;c:=s;s:=i;p+s<2*c=>(r:=cons(c,r)));r)

```

ungolf and results

```
f(n)==
   p:=c:=s:=3;r:List INT:=[]
   for i in 5.. by 2|prime?(i) repeat
      #r>=n=>break
      p:=c;c:=s;s:=i;(p+s)/2<c=>(r:=cons(c,r))
   r

(4) -> f 47
   (4)
   [599, 587, 569, 557, 541, 521, 499, 487, 479, 461, 457, 439, 431, 419, 397,
    379, 367, 347, 331, 311, 307, 281, 277, 269, 251, 239, 227, 223, 197, 191,
    179, 163, 149, 137, 127, 107, 101, 97, 79, 71, 67, 59, 41, 37, 29, 17, 11]

```
> 0 votes

# Answer
# Python 2, 86 bytes

```
n=input()
u=p=2;v=i=3
while n:
 p*=i;i+=1
 if p*p%i:
	if u+i<2*v:print v;n-=1
	u,v=v,i

```

Try it online!

Uses Wilson's theorem for the primality test.
> 0 votes

# Answer
# Kotlin, ~~181~~ 180 bytes

```
fun f(l:Int):Array<Int>{var a=1
var b=1
var i=0
var c=0
val o=Array(l,{0})
while(l>0){c++
if((1..c).filter{c%it==0}.size==2){if(c-b<b-a){o[i]=b
if(++i>=l)break}
a=b
b=c}}
return o}

```

Try it online!

## Explained

```
fun f(l: Int): Array<Int> {
    var a = 1 // Lowest prime
    var b = 1 // Middle prime
    var i = 0 // Current prime index
    var c = 0 // Highest prime
    val o = Array(l, { 0 }) // Output array
    while (l > 0) {  // Functions as while true, while skipping for the 0 case
        c++ // Increment the highest prime
        if ((1..c).filter { c % it == 0 }.size == 2) { // Only if it is prime
            if (c - b < b - a) {                       // If it is strongly prime
                o[i] = b                               // Then record it
                if (++i >= l) break                    // If we have all the answers then stop
            }
            a = b                                      // Rotate the primes
            b = c                                      // As above
        }
    }
    return o  // Return the answer
}

```
> 0 votes

---
Tags: code-golf, math, number, sequence, primes
---


title: Balanced and Centre-Free Sets of Points

text:
# Question
Title: Balanced and Centre-Free Sets of Points
### Taking in Input

Define a function `f` as follows:

```
IF x < 0:
    f(x) = -√|x|
ELSE:
    f(x) = √x

```

In your programs/functions, each point `(x, y)` given as input will correspond to the point `(f(x), f(y))`. For example, if the points `(4, -2)` and `(-1, 5)` are given as input, your program will be dealing with the points `(2, -√2)` and `(-1, √5)`. From now on, we will be referring to points in this format, rather than points in the format given in the input.

You will take in a set/list of points as input which will then be converted to Cartesian points with the function `f`.

### Balanced Sets of Points

Denote by `PQ` the Euclidean distance from point `P` to point `Q`.

A set of points `S` is *balanced* if, and only if, for all pairs of distinct points `A` and `B` in `S`, there exists a point `C` in `S` such that `AC = BC`. For example, the set of points `{(0, 2), (-√3, -1), (√3, -1)}` is balanced because the points in this set are the vertices of an equilateral triangle. Note that this set of points would be taken as input by the program/function as `{(0, 4), (-3, -1), (3, -1)}`.

### Centre-Free Sets of Points

Again, denote by `PQ` the Euclidean distance from point `P` to point `Q`.

A set of points `S` is *centre-free* if, and only if, for all triples of distinct points `A`, `B` and `C` in `S`, there *does not exist* a point `P` in `S` such that `AP = BP = CP`. For example, the set of points `{(0, 2), (-√3, -1), (√3, -1)}` is centre-free, but if you add the point `(0, 0)` to this set, it is no longer centre-free.

### Formatting the Output

The output will be in the form of a two-digit binary number. Suppose we are given the set of points `S`. After having applied the function `f` to each point (see section "Taking in Input"), the first digit of this binary number will indicate whether this set of points is balanced and the second digit of this binary number will indicate whether this set of points is centre-free. For example, `10` will indicate that the given set of points is balanced, but not centre-free.

Also note that the digits `1` and `0` may be replaced with any truthy and falsy values. As opposed to strings, arrays and ordered pairs are also acceptable.

### Test Cases

```
> {(0, 4), (-3, -1), (3, -1)}
11

> {(0, 4), (3, 1), (3, -1), (0, -4), (-3, -1), (-3, 1)}
01

> {(0, 4), (-3, -1), (3, -1), (0, 0)}
00

> {(0, 4), (-3, -1), (3, -1), (0, -4), (0, 0)}
00

> {(0, 16), (-3, 1),(-12, -4), (0, -4), (12, -4), (3, 1)}
10

```

### Winning Criterion

Make your code as short as possible.

### Credits

This was inspired by Problem 1 from IMO 2015. (Great problem, by the way!)

# Answer
> 3 votes
# Jelly, 36 bytes

```
ạþE€Ṁ
®Œcç€®Ạ
A½×Ṡ×1,ıSµ€©œc3ñ€®Ṁ¬¢,

```

A full program printing the representation of a list of two ones/zeros.

This relies on theoretical infinite-precision floating point arithmetic, which is, of course, not the case. So here is a (43 byte) version which uses a **1e<sup>-10</sup>** leeway for the pair-wise distance comparisons it makes:

```
ạþI€×ȷ10ỊẠ€Ṁ
®Œcç€®Ạ
A½×Ṡ×1,ıSµ€©œc3ñ€®Ṁ¬¢,

```

**Try It Online!**

### How?

(I'll include the replacement code used in place of `E` \- equals to allow the leeway here)

```
ạþI€×ȷ10ỊẠ€Ṁ - Link 1: any all-equal distance complex numbers?: list of lists; list
ạþ           - outer-product with absolute difference
  I€         - incremental differences for €ach
    ×ȷ10     - multiply by 10^10
        Ị    - insignificant (abs(z)<=1) (vectorises)
         Ạ€  - all? for €ach
           Ṁ - maximum

®Œcç€®Ạ - Link 2: isBalanced? no-arguments (requires register to be populated - see Main)
®       - recall from register (the points as a list of complex numbers)
 Œc     - pairs
     ®  - recall from register (the points as a list of complex numbers)
   ç€   - call the last link (1) as a dyad for €ach pair
      Ạ - all truthy?

A½×Ṡ×1,ıSµ€©œc3ñ€®Ṁ¬¢, - Main link: list of (x, y) inputs
         µ€            - for €ach (x,y) pair, p:
A                      -   absolute value of p (vectorises)
 ½                     -   square root (vectorises)
   Ṡ                   -   sign of p (vectorises)
  ×                    -   multiply (vectorises)
     1,ı               -   literal [1, 0+1i]
    ×                  -   multiply (vectorises)
        S              -   sum
           ©           - (copy the result to the register)
            œc3        - combinations of length 3
                 ®     - recall from register
               ñ€      - call the next link (1) as a dyad for €ach triple
                  Ṁ    - maximum (1 if any triple has a centre)
                   ¬   - not (0 if any triple has a centre - hence isCentreFree?)
                    ¢  - call the last link as a nilad
                     , - pair with the calculated isCentreFree?
                       - implicit print

```

# Answer
> 2 votes
# Python 2, 303 302 bytes

**Edit:** -1 byte thanks to @Mr.Xcoder

```
lambda x,y:f((x[0]-y[0])**2+(x[1]-y[1])**2)
f=lambda x:x<0and-f(-x)or x**.5
v=lambda a,b,p:abs(d(a,p)-d(b,p))<1e-9
def e(k):k=[(f(a),f(b))for a,b in k];print+all(any(v(a,b,c)for c in k)for a in k for b in k if a!=b),1-any(any(v(a,b,p)*v(b,c,p)for p in k)*len({a,b,c})>2for a in k for b in k for c in k)

```

Try it online!

---
Tags: code-golf, grid
---


title: Two Makes All The Difference - Cops

text:
# Question
Title: Two Makes All The Difference - Cops
> **NOTICE** \- This challenge is now closed. Any new answers will be ignored and the accepted answer will *not* change

## Challenge

Write a valid program which, when just two characters in the program are changed, removed or added, completely changes the output.

The changed output must have a Levenshtein Distance of **15** or more from your original output.

The output must be non empty and finite. Your program therefore must terminate within 1 minute.

Your output *must* be deterministic, outputting the same thing each time you run the program. It also must not be platform dependent.

Any hash functions are ***disallowed***, as are built in PRNGs. Similarly, seeding an RNG is not allowed.

After a period of three days, an uncracked submission will become safe. In order to claim this safety, you should edit your answer to show the correct answer. (Clarification: Until you reveal the answer, you are not safe and can still be cracked.)

## Formatting

Your answer should be in the following format:

```
# <Language name>, <Program length>

## Code

<code goes here>

## Original Output

<output goes here>

## Changed output

<changed output goes here>

```

## Robbers

The robbers' challenge is to find out which two characters you have changed. If a robber has cracked your solution, they will leave a comment on your answer.

You can find the robbers' thread here.

## Winning

The person with the shortest uncracked solution wins.

## Leaderboard

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script>site = 'meta.codegolf';postID = 5686;isAnswer = false;QUESTION_ID = 54464;var safe_list=[];var uncracked_list=[];var n=0;var bycreation=function(x,y){return (x[0][0]<y[0][0])-(x[0][0]>y[0][0]);};var bylength=function(x,y){return (x[0][1]>y[0][1])-(x[0][1]<y[0][1]);};function u(l,o){ jQuery(l[1]).empty(); l[0].sort(o); for(var i=0;i<l[0].length;i++) l[0][i][1].appendTo(l[1]); if(l[0].length==0) jQuery('<tr><td colspan="3" class="message">none yet.</td></tr>').appendTo(l[1]);}function g(p) { jQuery.getJSON('//api.stackexchange.com/2.2/questions/' + QUESTION_ID + '/answers?page=' + p + '&pagesize=100&order=desc&sort=creation&site=codegolf&filter=!.Fjs-H6J36w0DtV5A_ZMzR7bRqt1e', function(s) { s.items.map(function(a) { var he = jQuery('<div/>').html(a.body).children().first(); he.find('strike').text(''); var h = he.text(); if (!/cracked/i.test(h) && (typeof a.comments == 'undefined' || a.comments.filter(function(b) { var c = jQuery('<div/>').html(b.body); return /^cracked/i.test(c.text()) || c.find('a').filter(function() { return /cracked/i.test(jQuery(this).text()) }).length > 0 }).length == 0)) { var m = /^\s*((?:[^,;(\s]|\s+[^-,;(\s])+)\s*(?:[,;(]|\s-).*?([0-9]+)/.exec(h); var e = [[n++, m ? parseInt(m[2]) : null], jQuery('<tr/>').append( jQuery('<td/>').append( jQuery('<a/>').text(m ? m[1] : h).attr('href', a.link)), jQuery('<td class="score"/>').text(m ? m[2] : '?'), jQuery('<td/>').append( jQuery('<a/>').text(a.owner.display_name).attr('href', a.owner.link)) )]; if(/safe/i.test(h)) safe_list.push(e); else uncracked_list.push(e); } }); if (s.length == 100) g(p + 1); else { var s=[[uncracked_list, '#uncracked'], [safe_list, '#safe']]; for(var p=0;p<2;p++) u(s[p],bylength); jQuery('#uncracked_by_length').bind('click',function(){u(s[0],bylength);return false}); jQuery('#uncracked_by_creation').bind('click',function(){u(s[0],bycreation);return false}); } });}g(1);</script><link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><style>table th,table td { padding: 5px;}th { text-align: left;}.score { text-align: right;}table a { display: block;}.main { float: left; margin-right: 30px;}.main h3,.main div { margin: 5px;}.message { font-style: italic;}</style><div class="main"><h3>Uncracked submissions</h3><table> <tr> <th>Language</th> <th class="score">Length</th> <th>User</th> </tr> <tbody id="uncracked"></tbody></table><div>Sort by: <a href="#" id="uncracked_by_length">length</a> <a href="#" id="uncracked_by_creation">creation</a></div></div><div class="main"><h3>Safe submissions</h3><table> <tr> <th>Language</th> <th class="score">Length</th> <th>User</th> </tr> <tbody id="safe"></tbody></table></div>
```

# Answer
> 6 votes
# CJam, 13 bytes (safe)

```
J{m!_)mQ%2b}/

```

Try it online.

### Original output

```
000010010101001010001101111000111011100110100100001011101101010100011111110010010010001111111111010000010011001110001010011111000010001001110111100000010110000010000111011011110101110010000011100111100

```

### Modified output

```
11101101100011110001011010000100111011000010011101100000001010100111011010011011010111101000000011101111100000000110001000111110110110101111110100101110000101110100110011110000010101110

```

### Solution

```
J{m!_)ci%2b}/

```

Try it online.

### How it works

This takes advantage of how CJam implicitly prints the entire stack after executing the program.

Simply dumping the base-2 representations of a few integers on the stack causes them to be printed without any separator, so it should be hard to figure out where one of them begins and another one ends.

The original code does the following:

```
J{   e# For each I from 0 to 18, do the following:
  m! e#   Calculate the factorial of I.
  _) e#   Push a copy and add 1.
  mQ e#   Compute the result's integer square root.
  %  e#   Calculate the residue of the factorial divided by the square root.
  2b e#   Push the array of base 2-digits of the resulting integer.
}/   e#

```

As @AndreaBiondo notes in the comments, the binary representations of **0!** to **8!** can be found at the beginning of the output (spaces added for clarity):

```
1 1 10 110 11000 1111000 1011010000 1001110110000 1001110110000000

```

The intended change was to replace `mQ` with `ci`, which takes the integer modulo 65536, using 16-bit character arithmetic (casting to an unsigned 16-bit character, then back to integer).

I hoped the idea of using `c` to replace a mathematical operator would be obscure enough.

# Answer
> 39 votes
# Cracked

# Shakespeare, 1721 bytes

I tried a Shakespeare answer. It is not short, and I had difficulties to change the output with only 2 characters, but I think I succeeded quite well. Good Luck everybody. As a side note, I used the "compiler" available at this address and **it may not work with another one.** (it does not work with the online interpreter) The output does not contain any unprintable characters.

## Code

```
The Hidden Change.

Helen, a young woman with a remarkable patience.
Helena, a likewise young woman of remarkable grace.
Claudio, a remarkable man much in dispute with Claudius.
Claudius, the flatterer.
The Archbishop of Canterbury, the useless.

          Act I: Claudius's insults and flattery.

          Scene I: The insulting of Helen.

[Enter Claudius and Helen]

Claudius:
 Thou art as hairy as the sum of a disgusting horrible fatherless
 dusty old rotten fat-kidneyed cat and a big dirty cursed war.
 Thou art as stupid as the product of thee and a fat smelly
 half-witted dirty miserable vile weak son.

[Exeunt]

          Scene II: The complimenting of Helena.

[Enter Claudio and Helena]

Claudio:
 Thou art the sunny amazing proud healthy peaceful sweet joy.
 Thou art as amazing as the product of thee and the pretty
 lovely young gentle handsome rich Hero. Thou art as great
 as the sum of thee and the product of a fair golden prompt good honest
 charming loving noble king and a embroidered rich smooth golden angel.

[Exeunt]

          Scene III: The insulting of Claudio

[Enter Claudius and Helen]

Helen:
 Thou art as stupid as the sum of the sum of thee and a cat and me.
[Exit Helen]

[Enter Claudio]

Claudius:
 Thou art as stupid as the sum of thee and the product of the
 product of me and Helen and Helena

[Exeunt]

          Scene IV: The Final Countdown

[Enter The Archbishop of Canterbury and Claudius]

Claudius:
 Thou art the sum of you and a cat.

The Archbishop of Canterbury:
 Am I better than a fine road?

Claudius:
 If not, let us return to the insulting of Claudio.

[Exit The Archbishop of Canterbury]

[Enter Claudio]

Claudius:
 Open your heart!
 Open your heart!
[Exeunt]
```

## Original Output

```
11324620811132462081

```

## Changed Output

```
11

```

# Answer
> 24 votes
# J, 76 bytes (safe)

## Code

```
,:|.,.<,:>><|.,:>,.<|.>,:<<|.>|.,:,.<,.<,:,.<,:>|.<,:>,.|.<,:,.|.<<,:>126$a.

```

## Original Output

```
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│
││┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐││
│││┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│││
││││┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐││││
│││││     ┌┬┐├┼┤└┴┘│─ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}│││││
││││└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘││││
│││└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│││
││└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘││
│└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

```

## Changed output

```
┌──────────────────────┐
│┌────────────────────┐│
││┌──────────────────┐││
│││┌────────────────┐│││
││││┌──────────────┐││││
│││││┌───────────┬┐│││││
││││││0 0 0 0 0 0│││││││
│││││└───────────┴┘│││││
││││└──────────────┘││││
│││└────────────────┘│││
││└──────────────────┘││
│└────────────────────┘│
└──────────────────────┘

```

# EDIT: Solution `{:` added (shown between `###`)

```
,:|.,.<,:>><|.,:>,.<|.>,:<<|.>|.,:,.<,.<,:,.<,###{:###:>|.<,:>,.|.<,:,.|.<<,:>126$a.

```

Makes use of the monad `{::` Map. Most of the rest of the code is useless garbage.

# Answer
> 12 votes
# Cracked

# Ruby, 14

## Code

```
x=9;puts x*9*9

```

## Original Output

```
729

```

## Changed output

```
99999999999999999

```

# Answer
> 12 votes
# Cracked

# Bash, 15 bytes

```
echo {{{1..9}}}

```

### Original output

```
{{1}} {{2}} {{3}} {{4}} {{5}} {{6}} {{7}} {{8}} {{9}}

```

### Modified output

```
1 2 3 4 5 6 7 8 9

```

# Answer
> 10 votes
# Cracked

# Python 2, 43 bytes

## Code

```
print (sum(range(054321)*9876)*87654)/01234

```

## Original Output

```
334960491355406

```

## Changed output

```
222084148077792

```

The Levenshtein Distance is 15 exactly. Both the original and the changed run under 1 minute on my computer.

# Answer
> 10 votes
# Cracked

# Prolog, 10 bytes

## Code

```
X is 1/42.

```

## Original Output

```
X = 0.023809523809523808.

```

## Changed output

```
X = -2.

```

# Answer
> 8 votes
# Cracked

# BrainFuck , 504 bytes

No one should ever need to analyse a brainfuck code. This is a modified version of an earlier code, but any change in a Brainfuck code make a big difference in the output. I use the Interpreter at http://esoteric.sange.fi/brainfuck/impl/interp/i.html to test my code. Good Luck !

# Code

```
++++++++++[->++++++++<]>>++++++[-<---------->]<-------[----------->>>-<<+<[-->->+<<]]>>>+<<>>>+++[->++++++++++<]>++.<+++++++++[->>>>>>>++++++++++<+++++<++++++++++++++<++++++++++<+++++<++++++++++<<]++++++++++>>+++++...>++>++>-->+>++++<<<<<<<.<<<[->>>>>>.<<>>>>>.<<<<<.>>>>>.<<<<<>>>.<<<<.>>>>>.<<<<.>>>>>.<<<<<.>>>>.<<<<<.>>>>.<<...>.<<<<<<]>[->>>>>.<<...>>>.<<<<.>>>>>.<<<<...>>>>.<<<<<.>>>>.<<...>.<<<<<]>[->>>>.<<>>>>>>.<<<<<<..>>>.<<<<.>>>>>.<<<<>>>>>>.<<<<<<.>>>>>>.<<<<<<>>>>.<<<<<.>>>>.<<...>.<<<<]

```

# Original Output

```
 ___
/   \
|   |
\___/

```

# Changed Output

```
}}}\}}}|.}}}.|///\\}}|.}.|///\\}}|.}.|///\\}}|.}.|///\\}}|.}.|///\\}}|.}.|///\\}}|.}.|///\\}}|.}.|///\\}}|.}.|///\\}}|.}.|///\\}}|.}.|///\

```

Note: The Changed Output contains several STX(ASCII 2) and EOT(ASCII 4) characters

Here is the version with ASCII codes in parenthesis instead of unprintable characters:

```
(2)}}}(2)\}}}|(2).}}}.(2)|///\\(4)}|(2).(4)}(4).(2)|///\\(4)}}|(2).(4)}(4).(2)///\\(4)}}|(2).(4)}(4).(2)|///\\(4)}}(2).(4)}(4).(2)|///\\(4)}}|(2).(4)}(4).(2)|/(4)/\\(4)}}|(2).(4)}(4).(2)|///\\(4)}}|(2).(4)}(4).(2)|///\\(4)}}|(2).(4)}(4).(2)|///\\(4)}}|(2).(4)}(4).(2)|///\\(4)}}|(2).(4)}(4).(2)|///\

```

# Answer
> 8 votes
# cracked

# Wolfram Language (Mathematica or WolframAlpha), 3 bytes

## Code

```
8.!

```

## Original Output

```
40320.

```

## Changed output

```
2.67182 - 0.891969 I

```

For those trying it on WolframAlpha the result shows up as

I deleted my previous answer because it worked only on Mathematica and not in WolframAlpha. That put robbers behind a paywall (instead of the deserved bars), which wasn't fair.

# Answer
> 7 votes
# Cracked

# CJam, 8 characters

## Code

```
"~f":i:#

```

## Original output

```
17290024234092933295664461412112060373713158853249678427974319674060504032816100667656743434803884485234668769970047274563123327020396104330878852891146011372048615474145637592955298601510765168228550988848615653376

```

## Changed output

Output after modification is here. Both take under a minute on my 2GHz laptop.

## Explanation

People seem amazed at how this works. The code works like this:

```
"~f"       Push a string
    :i     Convert to a list of bytes [126 102]
      :#   Fold with # (power)

```

This calculates 126^102. The solution was:

```
"}\t~f"
       :i     Convert to a list of bytes [125 9 126 102]
         :#   Fold with # (power)

```

This calculates ((125^9)^126)^102, which is hundreds of thousands of digits long.

# Answer
> 7 votes
# Cracked

# Pyth, 8 bytes

## Code:

```
%CG^3y21

```

## Initial Output:

```
51230235128920219893

```

## Changed Output:

```
58227066

```

# Answer
> 7 votes
# Cracked

# MATLAB / OCTAVE, 7 bytes

# Code:

```
cos(pi)

```

# Original output:

```
ans =

     -1

```

# Changed output:

```
ans =

   1.5708 - 0.8814i

```

This gives a Levenshtein distance of exactly 15.

# Answer
> 6 votes
# GolfScript, 15 bytes (safe)

## Code

`10,{1+3?}%{*}*]`

## Changed code

`107,{1+3?}%{^}*]`

## Original Output

`47784725839872000000`

## Changed output

`557154`

Explainations:

```
10,             # numbers from 0 to 10
   {1+3?}%      # add one and raise to the cube. (%=for each)
          {*}*] # take the product and place it in a list(useless)`

```

Changed code

```
107,             # numbers from 0 to 107
    {1+3?}%      # add one and raise to the cube. (%=for each)
           {^}*] # xor them and place it in a list(useless)

```

# Answer
> 6 votes
# Cracked

# Python 2, 58 bytes

## Code

```
R=range(01234);print sum(m<<min(m,n)for m in R for n in R)

```

## Original Output

```
2444542772018013876036977350299418162656593659528311114655474359757543862791958572561591492595632222632192542272836836649846934427359810217936317967768095940470375690509652583392001888886352103127515963142

```

## Changed output

```
4669

```

That 15 distance rule sure made things tricky. I hope this goes well.

# Answer
> 6 votes
# Cracked

# Python 2, 50 bytes

Original Code:

```
'~'*sum([(x,y)[x%2]for x in[y for y in range(8)]])

```

Original Output:

```
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

```

Modified Output:

```
'~~~~~~~~~~~~~~~~~~~'

```

Not overly short, and maybe not too hard, I don't really know. I'll try to come up with something better soon.

# Answer
> 6 votes
# Cracked

# PHP, 164 bytes

## Code

```
$S_U_M_M_E_R = 1;
$A_U_T_U_M_N = 2;
$T_I_M_E = 1;

if ($T_I_M_E == $S_U_M_M_E_R) {
    $A_C_=$T_I_=$O_N= 'SWIM' ? 'TAN' : 'DRINK';
}

print $T_I_M_E * $A_U_T_U_M_N;

```

## Original Output

```
2

```

## Changed output

```
-1.1306063769532

```

# Answer
> 5 votes
# Cracked

# APL, 7 bytes

# Code

```
-/3⍴157

```

# Original output

```
157

```

# Changed output

```
0.11479360684269167J0.37526348448410907

```

# Answer
> 4 votes
# Cracked

# C, 53 bytes

## Code

```
main(a,_){puts(_*_*_*_*_-1?"Expected Output":"?");}

```

## Original Output

```
Expected Output

```

## Changed output

```
?

```

Probably too easy, but who knows. (Note: it is technically system dependent but the type of system on which it fails would also fail all the other submissions here, so I figured it was a moot point).

# Cracked

# Edit

I made a mistake. New code which is more secure to the obvious attack:

```
main(a,_){puts(_*_-1||_*_*_-1||_*_*_*_-1?"Expected Output":"?");}

```

same outputs. New size of 65 bytes. Hopefully harder... though still probably too easy.

# Answer
> 4 votes
# CJam, 28 bytes (safe)

```
"jK=\~"5*)ib257b~{G$5$+}*]Jb

```

Try it online.

### Original output

```
7705397905065379035618588652533563996660018265606606763127193120855297133322151462150247488267491212817218321670720380456985476811737021068519164822984561148339610474891720342171053455881107227302663880445203851079295537592154028123394687360216561235621729967011148112746984677807932995700334185726563970223018774

```

### Modified output

```
16650180159137697345989048346412185774444335111603430666402604460993564226370500963166158223117360250140073061887053326627468495236957122711656527124216908303912850181595147494475577084810653496778801228980874902968634143062

```

### Solution

```
"jK=\~"5*Wcib257b~{G$5$+}*]Jb

```

Try it online.

### How it works

I went a little overboard with this one...

The original code does the following:

```
"jK=\~"5* e# Push "jK=\~jK=\~jK=\~jK=\~jK=\~".
)i        e# Pop the last character and cast it to integer.
b257b     e# Convert the remainder of the string from that base to base 257.
~         e# Dump all resulting base-257 digits on the stack:
          e# 137 72 124 88 81 145 85 32 28 251 118 230 53 13 245 147 256 116 187 22 224
{         e# Do the following 224 times:
  G$5$+   e#   Add copies of the 5th and 17th topmost integers on the stack
          e#   (recurrence of a lagged Fibonacci sequence).
}*        e#
]         e# Wrap the entire stack in an array.
Jb        e# Convert from base 19 to integer.
          e# The resulting integer is printed implicitly.

```

The intended change is replacing `(i` with `Wci`.

This leaves the repeated string untouched and pushes **65535** (by casting to an unsigned 16-bit character, then back to integer), so that the first elements of the lagged Fibonacci sequence become

```
87 225 162 210 73 196 142 219 175 61 40 147 0 93 75 55 103 116 237 188 108 122 176 133 135 240 251 155 224 82 181 75 23 87 139 49 148 169 84 109 110 166 52 103 83 185 78 73

```

and the loop is repeated **126** times.

# Answer
> 4 votes
# Javascript, 47 (safe)

## Code

```
for(var i=64460,x=773;i>=1324;)x=i--/x;alert(x)

```

## Original Output

```
11.948938595656971

```

## Changed output

```
3.679331284911481

```

Distance is exactly 15.

Tested in Chrome and IE.

## Solution

```
for(var i=64460,x=773;i>>=1<324;)x=i--/x;alert(x)

```

This uses the bit shift assignment operator `i>>=1` to make the loop interval non-linear. Also this has the amusing property that someone trying to brute force a solution will run into several variations that run infinitely.

# Answer
> 4 votes
Cracked by issacg

# MATLAB, 20 bytes

## Code

```
format long
sin(i^pi)

```

## Original Output

```
0.331393418243797 - 1.109981778186163i

```

## Changed Output

```
0.220584040749698 - 0.975367972083631i

```

# Answer
> 4 votes
# Cracked

# Octave, 20 bytes

```
format long;
cos(1)*1

```

## Output:

```
0.540302305868140

```

## Changed Output:

```
111

```

# Answer
> 3 votes
# Brainfuck, 100 bytes

## Code

```
++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<[>.+<-]

```

## Original output

```
ABCDEFGHIJKLMNOPQRSTUVWXYZ

```

## Changed output

```
[
  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ

```

Note: Possibly easy to crack. But then, nothing is easy in Brainfuck.

# Answer
> 3 votes
# Cracked

# Java, 149 Characters

```
class T{public static void main(String[]a){System.out.print(((Integer.MAX_VALUE^25214903917L)&281474976710655L)*25214903917L+11L&281474976710655L);}}

```

## Original Output

```
174542852132661

```

## Modified Output

```
106906909674100

```

Hint:

> Random.java

# Answer
> 3 votes
# Cracked

# Fantom, 26

## Code

```
Float.makeBits(1123581321)

```

## Original Output

```
5.55122931E-315

```

## Changed output

```
124.24518585205078

```

Security Through Obscurity, if nobody knows the language, nobody can crack it. Levenshtein Distance of 15. Run it in fansh.

# Answer
> 3 votes
# Cracked

# VBA, 72 bytes

```
Sub q()
Dim a(2) As Double
a(0)=-5
a(1)=10
msgbox IRR(a,0.253)
End Sub

```

**Original Output**

```
 0.999999999999136

```

**Adjusted Output**

```
1.82842712474619

```

Need to see some more VBA representation round here.=) Runs in Excel 2007+

# Answer
> 3 votes
# Cracked

# SWI-Prolog, 54 bytes

## Code

```
assert(d(E,F):-(print(E),print(F))). d(123456,123456).

```

## Original Output

```
true.

123456123456
true.

```

## Changed output

```
true.

false.

```

# Answer
> 3 votes
# Cracked

## CJam, 6 characters

```
25mse7

```

**Original output**

```
-1323517.5009777304

```

**Changed output**

```
72004899337.38588

```

This might be too easy. :P

# Answer
> 3 votes
Cracked

# Ruby, 24

## Code

```
p _=?9;p$.+=1until 9#$./

```

## Original Output

```
"9"

```

## Changed output

```
"9"
1
2
3
4
5
6
7
8
9

```

# Answer
> 3 votes
# cracked

# modern Perl 5, 70

## Code

```
@array = (qw smiles) x 11;
s/.*// foreach @array;
print "@array\n";

```

## Original Output

A single newline.

## Changed output

```
 mile mile mile mile mile mile mile mile mile mile

```

The output begins with a space and ends with a newline.

# Answer
> 3 votes
## Cracked

## bc, 22 bytes

```
4518574615489737231532

```

Current output

```
4518574615489737231532

```

Desired output

```
195543687803724

```

# Answer
> 3 votes
# Cracked

# Matlab, 12 bytes

## Code

```
-sin(2:.5:3)

```

## Original output

```
-0.9093   -0.5985   -0.1411

```

## Changed output

```
0.4228    0.7032    0.9228

```

# Answer
> 3 votes
## Cracked

## Lua, 55 bytes

Now with less skimpy underwear! This code might look like my last code that was sadly cracked, but I can assure the solution is completely different

```
G={load="lfkjgGsHjkU83fy6dtrg"}
print(tostring(G.load))

```

Current output:

```
lfkjgGsHjkU83fy6dtrg

```

The correct output on 64 bit machines:

```
26

```

And on 32 bit machines:

```
18

```

# Answer
> 3 votes
## perl, 12 bytes

# cracked

Code

```
print sin 97

```

Original output

```
0.379607739027522

```

Desired output

```
-0.64618863474386

```

# Answer
> 3 votes
## Cracked by Luis Mendo

# MATLAB, 62 bytes

## Code

```
mistake=-1;tragic=rosser;a=hilb(8)*42;
a(:,:)+tragic(8)/mistake

```

## Original Output

```
   13.0000   -8.0000  -15.0000  -18.5000  -20.6000  -22.0000  -23.0000  -23.7500
   -8.0000  -15.0000  -18.5000  -20.6000  -22.0000  -23.0000  -23.7500  -24.3333
  -15.0000  -18.5000  -20.6000  -22.0000  -23.0000  -23.7500  -24.3333  -24.8000
  -18.5000  -20.6000  -22.0000  -23.0000  -23.7500  -24.3333  -24.8000  -25.1818
  -20.6000  -22.0000  -23.0000  -23.7500  -24.3333  -24.8000  -25.1818  -25.5000
  -22.0000  -23.0000  -23.7500  -24.3333  -24.8000  -25.1818  -25.5000  -25.7692
  -23.0000  -23.7500  -24.3333  -24.8000  -25.1818  -25.5000  -25.7692  -26.0000
  -23.7500  -24.3333  -24.8000  -25.1818  -25.5000  -25.7692  -26.0000  -26.2000

```

## Changed Output

```
  -22.0000   19.0000   11.0000  -50.5000  -51.6000    1.0000   -1.0000  -51.7500
   12.0000  -41.0000  -43.5000   -3.6000   -6.0000  -45.0000  -44.7500  -11.3333
   -3.0000  -36.5000  -37.6000  -13.0000  -15.0000  -37.7500  -37.3333  -19.8000
  -29.5000  -17.6000  -20.0000  -31.0000  -30.7500  -25.3333  -26.8000  -29.1818
  -23.6000  -27.0000  -29.0000  -23.7500  -23.3333  -33.8000  -35.1818  -21.5000
  -34.0000  -17.0000  -16.7500  -39.3333  -40.8000  -15.1818  -14.5000  -44.7692
  -43.0000   -9.7500   -9.3333  -47.8000  -49.1818   -7.5000   -6.7692  -53.0000
   -2.7500  -53.3333  -54.8000   -1.1818   -0.5000  -58.7692  -60.0000    1.8000

```

# Answer
> 3 votes
## Cracked by Luiz Mendo

## MATLAB, 40 bytes

# Code

```
format long
arg = [.1 .2 .3];
sin(arg'*exp(9))

```

## Original Output

```
  -0.220680258232564
  -0.430479305680324
  -0.619052457794081

```

## Changed Output

```
  -0.803636351328917
  -0.721159584869623
  -0.148487879352133

```

Hint: there's another solution to this question

# Answer
> 3 votes
# Cracked

# Javascript, 53 bytes

## Code

```
a=(((b=(a=1)+a)+a)-b-a)*(a=[b])['length'];
alert(a);

```

## Original Output

```
0

```

## Changed output

```
5.551115123125783e-18

```

Tested under: Firefox, Chrome, IE

# Answer
> 3 votes
# Cracked.

# Stuck, 21 Bytes

I'll start with an easy one, since nobody has seen this before and there's no documents.. Anyways, Stuck is a stack-based language, very similar in usage to CJam. All you need to know is:

```
NR -> creates a range [1,N] on the stack.
[N]z -> zips together the top 2 lists, unless an optional N is specified, then the top N lists.
] -> Flattens the top list by one "dimension".

```

For the record, while I have made commits since this challenge happened, all of this functionality has been present long before.

### Code:

```
1R2R3R4R5R6R7R8R9R9z]

```

### Original Output:

```
(1, 1, 1, 1, 1, 1, 1, 1, 1)

```

### Changed Output:

```
(1, 1, 1, 1, 1, 1, 1, 1)(2, 2, 2, 2, 2, 2, 2, 2)(3, 3, 3, 3, 3, 3, 3, 3)

```

# Answer
> 3 votes
# Fantom, 30 (safe)

## Code

```
[7115432d/9,219.or(64),37][0]

```

## Original Output

```
790603.5555555556

```

## Changed output

```
55

```

## Solution

```
"7115432d/9,219.or(64),37"[0]

```

By changing the array to a string literal, the index call actually gets the first character of the string. Characters in fantom are actually just ints, so the value of '7' is 55.

# Answer
> 3 votes
# PowerShell v3, 384 (SAFE)

(My second post ever on PPCG, please be gentle. :) I think I'm going to like this community!)

## Code:

```
$s="a*h*t*s*m*i*d*o*n*l*k*e*y*u*g*r*w*LOOD> AIG BAE>!+<R S!>>+<GH MHN JFKL> LOOD AIG BAE>?<+"
$cur="";$l="";[char]$n="A";$st=@{}
foreach($c in [char[]]$s){switch -regex($c){
"[\*\>]" {$st[$n]=$cur.TrimStart(" ");$n=[char]([int]$n-1);if($c-eq">"){$l+=$cur};$cur=""}
"\+" {$l=$cur;$cur=""}
"\<" {$l+$cur;$l="";$cur=""}
default {if($st.Contains($c)){$cur+=$st[$c]}else{$cur+=$c}}}}

```

## Original output:

```
eggs and ham!
eggs and ham!
do you like eggs and ham?

```

## Modified output:

```
!

GH MHN JFKL LOOD aIG BaEt

```

(to be clear, that's a blank line in the middle of the modified output)

Mini-hint:

> h/t to Adam Barr for the inspiration

## Edit - Safe - Below is corrected code, and below that is explanation

```
$s = "a*h*t*s*m*i*d*o*n*l*k*e*y*u*g*r*w*LOOD> AIG BAE>!+<R S!>>+<GH MHN JFKL> LOOD AIG BAE>?<+" # The string we're cycling through
$cur = "" # What word(s) we've currently built
$l = "" # The current line we've finished building
[char]$n = "A" # Cast as a character instead of a string, this is the index of our temporary store
$st = @{} # Our temporary store - the first time through, this will populate out with the first part of the string $s
foreach ($c in [char[]]$s) { # Loop through the string $s as an array, one $c character at a time
    switch -regex ($c) {
        "[\*\>]" {
            $st[$n] = $cur.TrimStart(" ") # Ensures that we're not adding a space, and adds what we've currently built into the store
            $n = [char]([int]$n + 1)    #ONE OF THE CHANGES - Changed the +1 to -1, which causes the indexing of the store to be off
            if ($c -eq ">") { $l += $cur } # If our current character is a >, add that to the line as it's finished
            $cur = "" # Reset what we're building
        }
        "\+" {
            $l += $cur #ONE OF THE CHANGES - Changed the += to =, which causes the line to not get printed
            $cur = "" # Reset what we're building
        }
        "\<" {
            $l + $cur # Add on our current word to the line and print it out
            $l = "" # Reset our line
            $cur = "" # Reset what we're building
        }
        default {
            if ($st.Contains($c)) {
                $cur += $st[$c] # If our store contains the character, add what's in the store's index at $c to our current word
            } else {
                $cur += $c # Else, just add the character to our current word
            }
        }
    }
}

```

# Explanation

The best way to explain this is that we're using the string at the start as a sort of cypher. The first half of the string, demarcated by asterisks, is our cypher results. The rest of the string is the output, encoded based off of the "integer" value of the letter (from an alphabetical perspective, not an ASCII perspective). For example, the `LOOD>` takes the 12th character (an `e`), the 15th character (a `g`) twice, and then the 4th character (a `s`), which forms the word `eggs`, then the `>` case, which trims off what we're building so that our words don't run together.

The script cycles through the string character by character, building the cypher store at first (because of all the asterisks, the first 34 times through the switch causes either the first case or the default case to be called), while the rest of the times through cause either an index lookup (because we've already added that letter) or text manipulation (e.g., the second change which just re-sets a variable rather than print it out).

Please let me know if you have further questions!

# Answer
> 3 votes
# Befunge 98, 30 Bytes(Safe)

## Code

```
153+:*,+:f`#v_
+ ':_;#:-1;#@;,

```

## Original output:

```
@@@@@@@@@@@@@@@@

```

## Changed output:

```
@~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!

```

## Solution

```
g53+:*,+:f`#v_
+ ':_;#:-1;#<@;,

```

# Answer
> 3 votes
# Perl, 49 byes (safe)

## Code

```
$_=cos 99;printf"%.16f",0x7275*sin $_/s/[3-8]/04/

```

## Original Output

```
145.9795577401910975

```

## Changed Output

```
23.3077670014990304

```

---

## Clue

I tried to do this before but there was another unintended (easier) solution. The robber to my previous challenge may help you solve this one. Try to solve it with *three* modifications and you'll be half way to the two modification answer.

# Solution

> ```
> $_=cos 99;printf"%.16f",07275*sin $_/y/[3-8]/04/
> ```
>
> 1. Remove the `x` to turn hexadecimal `0x7275` (decimal 29301) into octal `07275` (decimal 3773)
>
> 2. Change the `s///` (replacement) to `y///` (transliteration) so that instead of *the first* digit from 3-8 becoming the string `04`, *all* digits in that range become `4`. Additionally, both return the number of changes; the `s///` version only makes one change while `y///` makes all 8 changes (the way `s///g` would). If you could change a *third* character, you could do `s/[3-8]/4/g` and have the same result as my `y/[3-8]/04/`. (This was exploited to solve my previous attempt.)
>
> Example of `s///` vs `y///`:
>
> ```
> $_="s: 1234567890, ";s/[3-8]/04/;print; $_="y: 1234567890";y/[3-8]/04/;print
> ```
>
> ```
> s: 12044567890, y: 1244444490
> ```
> So therefore we're multiplying by a changed number and the function at the end alters the default variable differently and divides by a different number.

# Answer
> 3 votes
# Malbolge, 411 bytes

### Code

```
bCBA@?>=<;:9876543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9y76543210/(L,l$H('&%$#"!~}v{zyxwvutm3qponmlkjihgfedcba`_^]?zZYXWVOTSRQPONMFjJIHGFEDC<`@?!=<;4X87w/S3s10/.-,+*)('&%$#"!~}|{zyxq7Xtmrk1onPlkdihg`&dcbD`_^]\[ZYXQutTSRQPONMLKJCgGFEDCBA@?>=<;:z81Uv43210/.'Kl*#G'&f|{A!~}|{zs9qvo5mrqponmle+*hgfe^c\"`_^]\[ZYXWV8Nr5QPONGkKJ,HGFEDCBA@?>=<;:3W76/432+O/o-,+*)('&%|B/

```

### Original output

```
Two Makes All The Difference

```

### Modified output

```
Two

```

(note the trailing space)

### Solution

```
bCBA@?>=<;:9876543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9y76543210/(L,l$H('&%$#"!~}v{zyxwvutm3qponmlkjihgfedcba`_^]?zZYXWcOTSRQPONMFjJIHGFEDC<`@?!=<;4X87w/S3s10/.-,+*)('&%$#"!~}|{zyxq7Xtmrk1onPlkdihg`&dcbD`_^]\[ZYXQutTSRQPONMLKJCgGFEDCBA@?>=<;:z81Uv43210/.'Kl*#G'&f|{A!~}|{zs9qvo5mrqponmle+*hgfe^c\"`_^]\[ZYXWV8sr5QPONGkKJ,HGFEDCBA@?>=<;:3W76/432+O/o-,+*)('&%|B/

```

# Answer
> 2 votes
# Cracked

**C++ 91 Bytes**

```
#include <iostream>
int main()
{
    //can you figure it out?
    std::cout << "I like cake and";
}

```

**Output:**

> I like cake and

**Changed output**

>

# Answer
> 2 votes
# Cracked

# Python 2, 57 bytes

## Code

```
i=long;j=map;print reduce(i.__mul__,j(i,j(ord,`i`)))/1234

```

## Original Output

```
3164217824783520557889

```

## Changed output

```
9072146982802639849575831250318562874251

```

# Answer
> 2 votes
# Python 2/3, 70 bytes (safe)

## Code

```
x=932436
for i in range(99**4):x=(1103515245*x+12345)%2**31
print(x*x)

```

## Original Output

```
211455574532454121

```

## Changed output

```
1039038861760158249

```

## Solution

```
x=9372436
for i in range(59**4):x=(1103515245*x+12345)%2**31
print(x*x)

```

The solution initializes `x` to `9372436` instead of `932436`, and does `range(59**4)` instead of `range(99**4)`. As an aside, the solution runs in about 1/10th of the time.

I probably could have made it shorter without making it too much easier, or at all easier.

# Answer
> 2 votes
# Cracked

# Python 2, 41 bytes

## Code

```
print sum((ord(i)<<0x156 for i in `sum`))

```

## Original Output

```
19718712710133388269747721838124583424582966957653854505259504044885223633870136963133245450763229047291904

```

## Changed output

```
20

```

# Answer
> 2 votes
# Cracked

# PHP 5.4, 92 bytes

```
<?php
define('E','!');

$x = 4;
$t = " Hello World";
$t .= E;
$t .= E;
$t .= E;

print($t);

```

### Output:

```
 Hello World!!!

```

### Changed Output:

```
 Hello World! Hello World! Hello World! Hello World!

```

(Note: both outputs include a leading space)

# Answer
> 2 votes
## Cracked

## Lua, 54 Bytes

```
G={string="gs_hSDrGSFG5;U*ts"}
print(tostring(G.string))

```

Current output:

```
gs_hSDrGSFG5;U*ts

```

Desired output:

```
23

```

Note: I'm not exactly sure why, but if you are using an online compiler (specifically repl.it) the correct output will be 15.

# Answer
> 2 votes
# Cracked

# Javascript, 169 bytes

## Code

```
a=1,b=a*2,c=a+b,d=[a+b];while(c>b)c-=a;for(i=1;i<=c;i++)d.push(i);i=''+c*d['length']*d['length'];alert(Math[String.fromCharCode(i.charCodeAt(0) * i.charCodeAt(1) / 32)])

```

## Original Output

```
undefined

```

## Changed output

```
2.718281828459045

```

# Answer
> 2 votes
# Cracked

# MATLAB / OCTAVE, 28 bytes

# Code:

```
f=@(x)x^.7;g=@(x)7/f(x);g(7)

```

# Original output:

```
ans =

    1.7928

```

# Changed output

```
ans =

  -0.3011 - 0.4144i

```

# Answer
> 2 votes
# Cracked

# Clojure, 35 Bytes

## Code

```
(printf "%d\n" 2155263413256326162)

```

## Original Output

```
2155263413256326162
nil

```

## Changed output

```
3681347803529195
nil

```

# Answer
> 2 votes
# Cracked

# MATLAB / Octave, 33 bytes

## Code

```
eig(cov(reshape(sin(1:60),5,[])))

```

## Original Output

```
ans =

   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
   -0.0000
    0.0000
    0.0000
    0.0000
    0.0000
    2.4410
    4.5766

```

## Changed Output

```
ans =

    0.0064
    0.0000
    0.0000
   -0.0000
   -0.0000
    0.0000

```

# Answer
> 2 votes
# Cracked

# PHP, 21 bytes

## Code

```
print_r(range(i,09));

```

## Original Output

> `Array ( [0] => 0 )`

## Changed output

> `Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 )`

# Answer
> 2 votes
# Fantom, 34

## Code

```
[7115432d/9,219.or(64),37,5555][0]

```

## Original Output

```
790603.5555555556

```

## Changed output

```
55

```

Ok, hopefully this one is a little more competitive than my previous attempt. Levenshtein Distance of 15. Run it in fansh.

## Better Code

@isaacg found an easy solution I hadn't even seen. This code removes that solution while keeping the original one I intended, if anyone still wants the challenge.

```
[7115432d/9,219.or(64),37,55.0f][0]

```

# Answer
> 2 votes
# Cracked

# Matlab/Octave, 10 bytes

this should be a fairly easy one.

I only tried it with Octave online, but it should run fine in matlab.

## Code:

```
e^(i*pi)+1

```

## Output

```
0.0000e+00 + 1.2246e-16i

```

## Changed Output

```
1.9336e+04

```

# Answer
> 2 votes
# Mathematica, 35 bytes (safe)

## Code

```
z=Zeta[4/3,1/2];N[Min[z,Sec[z]],20]

```

## Original Output

```
1.4508303658284314991

```

## Changed output

```
-0.72451364607415832407

```

Edit: Note that the original code will sort-of work on Wolfram Alpha, but the modified code does not.

# Changed Code

```
z=Zeta[4/3,1/2];N[Sin[z,Set[z]],20]

```

`Set[z]` evaluates to `Sequence[]` so `Sin[z,Set[z]] = Sin[z]`. Moreover, Mathematica evaluates function arguments serially and in order, so `Set[z]` is evaluated after the value of `z` is already used.

# Answer
> 2 votes
# Cracked

# GolfScript, 4 bytes

```
9,!9

```

### Original output

```
09

```

(trailing linefeed)

### Modified output

```
0123456789012345678

```

(no trailing linefeeed)

---

If you test your code in Web GolfScript, you have to look at the source code of the output, since the (lack of a) trailing linefeed will be undetectable in the rendered page. For the correct solution, there should be no linefeed between `0123456789012345678` and `</textarea>`.

It might be easier to use the Ruby interpreter for this one.

# Answer
> 2 votes
# MATLAB, 56 bytes (SAFE)

I think this is a step up from some of the previous MATLAB questions, but that remains to be seen I guess:

# Code

```
p=.4 -.2*i;j=.3*i +.7;i=@(c)j./(.6- .4*c);asin(i(p) *5i)

```

# Original output

```
ans =

  -0.2236 + 2.8380i

```

# Changed output

```
ans =

   0.1799 + 6.5793i   0.1798 + 5.4395i

```

# Solution:

```
p=.4 -.2*i;j=.3*'i '+.7;i=@(c)j./(.6- .4*c);asin(i(p) *5i)

```

Simply change `.3*i +.7` to `.3*'i '+.7;` This creates a vector with the numbers `[105 32]`, since MATLAB automatically casts the chars to integers if it's part of an equation.

All the spaces were just to throw people off (it made it possible to do changes like `[.3*i 0.7];`, thus making it possible to create vectors this way too.

# Answer
> 2 votes
# Cracked

# CSS, 53

## Code

```
body:after{counter-reset:a 512;content:counter(a)"₽"}

```

## Original Output

```
512₽

```

## Changed output

```
0%

```

## Snippet

```
body:after{counter-reset:a 512;content:counter(a)"₽"}
```

# Answer
> 2 votes
# Cracked

# APL, 5 characters

```
3⍟877

```

## Current output

```
6.1682424839682115

```

## Modified output

```
0.20016493054644696

```

An edit distance of 16.

# Answer
> 2 votes
# APL, 9 bytes

## Code

```
+/○3-3⍴⍳5

```

## Original output

```
18.84955592153876

```

## Changed output

```
¯0.31830988618379086 0.31830988618379075 0

```

Looks like I just missed the deadline, because I suck at time zones. Have fun solving this, anyway.

# Answer
> 1 votes
# Cracked

# SWI-Prolog, 54 bytes

## Code

```
assert((o(X,Y,Z):-ABC is X**X,print(ABC))). o(99,y,z).

```

## Original Output

```
true.

369729637649726772657187905628805440595668764281741102430259972423552570455277523421410650010128232727940978889548326540119429996769494359451621570193644014418071060667659301384999779999159200499899
true.

```

## Changed output

```
true.

true.

```

# Answer
> 1 votes
# Cracked

# Javascript, 233 bytes

## Code

```
one = 1;
two = one + one;
three = two + one;
zero = three - two - one;
numbers = [three, two, one];

for (i = numbers.length - 1; i >= zero; i--) {
    numbers.pop();
}

infinity = 1 / numbers['length'];
alert(infinity);

```

## Original Output

```
Infinity

```

## Changed output

```
3.333333333333333

```

# Answer
> 1 votes
### Cracked, because I didn't check the simple solution

# MATLAB, 8 bytes

## Code

```
sin(1+1)

```

## Original Output

```
0.909297426825682

```

## Changed Output

```
-0.262374853703929

```

# Answer
> 1 votes
# Cracked

# Python, 227 Bytes

# Original Code:

```
import re;''.join(re.findall('\w(?=\w\w)','t74q joh7 jv f9dfij9j bfjtf0e nnjen3j nnjrb6fgam3gtm5tem3hj s3eim7djsd3ye d5dfhg5un7ljmm8nan3nn6n k m2ftm5bsof5bf r5arm4ken8 adcm3nub0 nfrn6sn3jfeb6n d m6jda5 gdif5vh6 gij7fnb2eb0g '))

```

# Original Output:

```
't7jof9dfijbfjtfnnjennnjrb6fgam3gtm5tem3s3eim7djsd3d5dfhg5un7ljmm8nan3nnm2ftm5bsof5r5arm4keadcm3nunfrn6sn3jfebm6jdgdif5vgij7fnb2eb'

```

# Changed Output:

```
'to iterate is human to recurse divine'

```

# Answer
> 1 votes
# PHP, 299

(I hope I have understood the challenge correctly. It seems hard to produce code where and 2 single-character changes make such a difference, even if ignoring whitespace etc.)

## Code

```
<?php $i=0x61;$x=0x15;$y=0x36;$k="";$me=<<<PHP
\$q=\$i=\$i-1;\$x++;\$x=\$x^\$i^$x;if(\$i>0){
for(\$z=0;\$z<__LINE__;\$z++){for(\$l=strlen
("\$me")-1;\$l>=0;\$l--)\$q=\$q^(int)(\$x^
ord(\$me[\$l]));}\$k.=\$q;\$me="/**/\$me";
\$me.="#";eval(\$me);}
PHP;
eval($me);echo wordwrap($k,30,"\n",true)."\n";

```

FYI: Proof it takes \< 1 minute on any modern hardware:

```
$ time php /tmp/wot.php
711752729711068167264259526921
...
real    0m4.580s
user    0m1.548s
sys     0m3.023s

```

## Original Output

```
969594939291908988878685848382
818079787776757473727170696867
666564636261605958575655545352
515049484746454443424140393837
363534333231302928272625242322
212019181716151413121110987654
321

```

## Changed output

```
127127127127127255255255255255
255255255383383383383383383383
383383383511511511511511511511
511511511511511511511639639767
767767767767767895895895895895
895895895895102310231023102311
511151115111511151115111511151
115111511151127912791279127912
791279127912791407140714071407
140714071407140714071407153515
351535153515351535153515351535

```

# Answer
> 1 votes
# OCTAVE, 157 bytes.

```
format long
sin(cos(tan(csc(sec(cot(asin(acos(atan(acsc(asec(acot(sinh(cosh(tanh(csch(sech(coth(asinh(acosh(atanh(acsch(asech(acoth(i))))))))))))))))))))))))

```

Output:`8.77828266022653e+276+3.46629794728664e+276i`

Modified Output:`1.32478170985912-7.32035312239031i`

# Answer
> 1 votes
## Cracked.

## CJam, 9 bytes

Attempt 3...

```
Ps"."-i2b

```

Try the code at this *correct* link.

## Expected output

```
1011001010010100001100001010001001010110110100100001

```

## Modified output

```
5010670554118

```

Another easy one??

# Answer
> 1 votes
## Cracked

# Perl, 48 bytes

## Code

```
$_=cos 99;printf"%.14f",0x7275*sin $_/s/[3-8]/0/

```

## Original Output

```
287.75699066847318

```

## Changed Output

```
144.01504526079819

```

# Answer
> 1 votes
# Cracked

# Python 3, 57 bytes

## Code:

```
import math, decimal
print(decimal.Decimal(math.tan(749)))

```

## Output:

```
3.615402552802641888973766981507651507854461669921875

```

## Changed Output:

```
0.6610431688506868130872362598893232643604278564453125

```

# Answer
> 1 votes
# Cracked

# APL, 4

## Code

```
9⍟99

```

## Original Output

```
2.091329169322069

```

## Changed output

```
0.11111111111111112

```

Tested here. Note that the last digit is 2. I just wanted to know how hard is an average APL submission.

# Answer
> 0 votes
# Cracked

# Pyth, 4 bytes

```
.!77

```

## Output:

```
145183092028285869634070784086308284983740379224208358846781574688061991349156420080065207861248000000000000000000

```

## Changed Output:

```
3628800

```

# Answer
> 0 votes
# Cracked

# Python 2, 86 Bytes

# Original Code

```
import dis
def torun():
 print "hello world"
try:
 print dis.dis(torun)
except:
 pass

```

# Original Output:

```
 47           0 LOAD_CONST               1 ('hello world')
              3 PRINT_ITEM
              4 PRINT_NEWLINE
              5 LOAD_CONST               0 (None)
              8 RETURN_VALUE
None

```

# Changed Output:

```
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

```

# Answer
> 0 votes
# C, 82 bytes

```
b=64,i,x[64];main(){for(i=b;i--;)x[(i*3)%b]^=x[(i*5)%b]+i,printf("%02u",x[--b]);}

```

Output 1:

> 00006362616059585756555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211100908070605040100

Output 2:

> 000000006312518624630536342047653158563869074179184088893598110261070111311551196123612751313135013861421145514881520155115811610163816651691171617401763178518061826184518631880189619111925193819501961197119801988222001201400

# Answer
> 0 votes
# JS,

```
Math.pow(2,10)

```

Original output:

```
1024

```

Changed output:

```
7.61773480458663923e+85

```

Has a Levenstein distance of 23(!).

---
Tags: cops-and-robbers
---