title: Code ladder, Robbers

text:
# Question
Title: Code ladder, Robbers
This is the robbers' thread. The cops' thread goes here.

Write a code that has the same number of bytes as the cop post and where the revealed characters are identical. The code must produce `1` in its initial state, and produce the numbers `2, 3 ..` when single alterations are made.

The winner will be the robber that cracked the most posts.

**Example post:**

# MyLang, 9 bytes, 8 numbers (including link to answer), Cop's username.

Original code:

```
abc1efghi

```

Code that produces 1 - 8:

```
1: abc1efghi
2: abc2efghi
3: abc2efghij
4: kbc2efghij
5: kbc23fghij
6: kbc23fghi
7: kbc63fghi
8: kbc63fhi

```

Explanations are encouraged. The exact format of the robber post is optional.

# Answer
# Retina, 2 bytes, 10 numbers, by Martin Ender.

Original code:

```

1

```

This replaces the empty input by the number 1.

Code that produces 1 - 10 (showing newlines as `\n` for convenience):

```
1 : \n1
2 : \n1\n
3 : \n11\n
4 : \n111\n
5 : \n1111\n
6 : \n11111\n
7 : \n111111\n
8 : \n1111111\n
9 : \n11111111\n
10: \n111111111\n

```

For 2 and onwards, we count the number of empty strings in the previous stage. For 2, there is an empty string before and after the 1. For 3 there is an empty string before the ones, in between the ones and after the ones. This works all the way up to 10.

Try it online
> 13 votes

# Answer
# Perl, 12 bytes, 10 numbers, by ais523

Original code:

```
____;say__-9

```

Code that produces 1 - 10:

```
wait;say$!-9
wait;say$!-8
wait;say$!-7
wait;say$!-6
wait;say$!-5
wait;say$!-4
wait;say$!-3
wait;say$!-2
wait;say$!-1
wait;say$!-0

```

Explanation:

```
wait;         # waits for a child process to end (there is no child so it just returns)
     say      # put the following on the screen:
        $!    # current value of the C errno. In this case, ECHILD (No child processes)
              # which has a value of 10
          -9  # minus 9

```
> 8 votes

# Answer
# JavaScript, 30 bytes, 10 numbers, by ETHproductions.

Original code:

```
1: alert(Array(2).join(3).length)

```

Other numbers

```
 2: alert(Array(2).join(31).length)
 3: alert(Array(2).join(314).length)
 4: alert(Array(2).join(3141).length)
 5: alert(Array(2).join(31415).length)
 6: alert(Array(2).join(314159).length)
 7: alert(Array(2).join(3141592).length)
 8: alert(Array(2).join(31415926).length)
 9: alert(Array(2).join(314159265).length)
10: alert(Array(2).join(3141592653).length)

```

### Explanation

`Array(2)` creates an Array with two empty cells. The `.join` method joins all the elements in an Array using a delimiter, which converts it into a String. In the Original Code, the delimiter was `3`. This meant that the two empty cells in the Array are joined together used `3` as their delimiter. This evaluates `"3"`, without anything on either side of the `3` because the Array is empty. And since the `length` of `"3"` is `1`, this value is outputted to the console.

For the other numbers, I add 1 more digit to the delimiter that is joining the elements of the Array. Hence, this increases its length, thus `alert`ing with increasing values. Note that the numerical value of the delimiter is not important, only its length is.

## Snack Snippet!

**Note:** I used `console.log` instead of `alert` in my Snack Snippet for obvious reasons. Also, output from the console is display in the snippet.

```
console.log(Array(2).join(3).length)
console.log(Array(2).join(31).length)
console.log(Array(2).join(314).length)
console.log(Array(2).join(3141).length)
console.log(Array(2).join(31415).length)
console.log(Array(2).join(314159).length)
console.log(Array(2).join(3141592).length)
console.log(Array(2).join(31415926).length)
console.log(Array(2).join(314159265).length)
console.log(Array(2).join(3141592653).length)
```
> 7 votes

# Answer
# Octave, 17 bytes, 10 numbers, by Stewie Griffin

```
original:
_i_(__i__(2_5_))

solution:
fix( 'i'-(2*52))
fix( 'j'-(2*52))
fix( 'k'-(2*52))
fix( 'l'-(2*52))
fix( 'm'-(2*52))
fix( 'n'-(2*52))
fix( 'o'-(2*52))
fix( 'p'-(2*52))
fix( 'q'-(2*52))
fix( 'r'-(2*52))

```
> 7 votes

# Answer
# Python 2, 17 bytes, 10 numbers, by xnor

```
print len(['  '])
print len(*['  '])
print len(*['   '])
print len(*['    '])
print len(*['     '])
print len(*['      '])
print len(*['       '])
print len(*['        '])
print len(*['         '])
print len(*['          '])

```

**repl.it**
> 7 votes

# Answer
## Python 2, 9 bytes, 10 numbers, xnor

```
print 8/8
print 18/8
print 28/8
print 38/8
print 38/7
print 38&7
print 31&7
print 31&72
print 31&73
print 31&74

```
> 7 votes

# Answer
# Perl, 14 bytes, 10 numbers, by Dada

Original code:

```
say_!"___"%""_

```

Code that produces 1 - 10:

1. `say"!"+1#"%""r`
2. `say"!"+2#"%""r`
3. `say"!"+3#"%""r`
4. `say"!"+4#"%""r`
5. `say"!"+5#"%""r`
6. `say"!"+6#"%""r`
7. `say"!"+7#"%""r`
8. `say"!"+8#"%""r`
9. `say"!"+9#"%""r`
10. `say"1"+9#"%""r`

I have a feeling this isn't what you were going for.
> 6 votes

# Answer
# JavaScript, 22 bytes, 10 numbers, by Arnauld

Original program:

```
alert(0_6_4_>_0_2_0_7)

```

Cracked:

1. `alert(0+6^42>101210^7)`
2. `alert(0+5^42>101210^7)`
3. `alert(0+4^42>101210^7)`
4. `alert(0+3^42>101210^7)`
5. `alert(0+2^42>101210^7)`
6. `alert(0+1^42>101210^7)`
7. `alert(0+0^42>101210^7)`
8. `alert(0+0^42>101210^8)`
9. `alert(0+0^42>101210^9)`
10. `alert(0+3^42>101210^9)`

The hard part is to deal with the `>`, which has a very low precedence. I tried changing it to an `>>`, but it's easiest to just absorb it by making it uselessly calculate a boolean false (the `42>101210` section) which is numerically 0, and just generate the numbers from 1 to 10 with operators with an even lower precedence than `>`. I used `^`, bitwise xor, because it can generate the numbers from 1 to 10 fairly easily (conveniently, the 6 and 7 in the original input let me simplify the expression down to `6^7` which is 1).
> 6 votes

# Answer
# JavaScript, 9 bytes, Hedi

Original code:

```
alert(+1)

```

Modifications:

```
alert(1+1)   // 2
alert(2+1)   // 3
alert(3+1)   // 4
alert(4+1)   // 5
alert(5+1)   // 6
alert(6+1)   // 7
alert(7+1)   // 8
alert(8+1)   // 9
alert(9+1)   // 10

```
> 5 votes

# Answer
## JavaScript, 22 bytes, 10 numbers by Arnauld

**Original code**:

```
alert(__14_337__xc_de)

```

**Modified**:

```
alert(00140337-0xc0de) // 1
alert(00140337-0xc0dd) // 2
alert(00140337-0xc0dc) // 3
alert(00140337-0xc0db) // 4
alert(00140337-0xc0da) // 5
alert(00140337-0xc0d9) // 6
alert(00140337-0xc0d8) // 7
alert(00140337-0xc0d7) // 8
alert(00140337-0xc0d6) // 9
alert(00140337-0xc0d5) // 10

```

I'm guessing this isn't the intended solution, but I'm hoping it's not too far off...
> 5 votes

# Answer
## Octave, 55 bytes, 10 numbers, flawr

```
(o=@(O,o)(@(O,o)o{2-O} ) (0<O,{ (yo=O-1)+1,@()1}))(1,o)

```

The final `1` can be cycled up to 9, and then change the `+1` to `+2`.
> 5 votes

# Answer
## Python 3, 16 bytes, 10 numbers, by Sp3000

This was fun.

```
print(?%??f?r?t)

print(1%0xfor t)
print(2%0xfor t)
...
print(8%0xfor t)
print(84%0xfor t)
print(85%0xfor t)

```

Exploits the fact (which I didn't know till now) that a hex literal ends as soon as a character that isn't `0-9a-fA-F` is encountered--thus `0xfor` is a very sneaky way to write `15 or`. After that, it was a matter of finding the right value congruent to 10 modulo 15.
> 5 votes

# Answer
# Octave, 32 bytes, 10 numbers, by Luis Mendo

Original code:

```
nnz(isprime(floor(s=3):i*-2i))+1

```

Modified codes:

```
2:  nnz(isprime(floor(s=3):i*-3i))+1
3:  nnz(isprime(floor(s=3):i*-5i))+1
4:  nnz(isprime(floor(s=3):i*-9i))+1
5:  nnz(isprime(floor(s=3):i*-9i))+2
6:  nnz(isprime(floor(s=3):i*-9i))+3
7:  nnz(isprime(floor(s=3):i*-9i))+4
8:  nnz(isprime(floor(s=3):i*-9i))+5
9:  nnz(isprime(floor(s=3):i*-9i))+6
10: nnz(isprime(floor(s=3):i*-9i))+7

```

There are many ways to make modifications here (for instance `s=2` and `+0` in the beginning).

Edit: A more probable alternative:

```
nnz(isprime(floor(s=2):i*-2i))+0
nnz(isprime(floor(s=2):i*-2i))+1
nnz(isprime(floor(s=2):i*-2i))+2
nnz(isprime(floor(s=2):i*-2i))+3
nnz(isprime(floor(s=2):i*-2i))+4
nnz(isprime(floor(s=2):i*-2i))+5
nnz(isprime(floor(s=2):i*-2i))+6
nnz(isprime(floor(s=2):i*-2i))+7
nnz(isprime(floor(s=2):i*-2i))+8
nnz(isprime(floor(s=2):i*-2i))+9

```
> 4 votes

# Answer
# 05AB1E, 11 bytes, 10 numbers, by Oliver

Original code:

```
 1: 3628801zï0>

```

Other numbers

```
 2: 3628801zï0>>
 3: 3628801zï0>>>
 4: 3628801zï0>>>>
 5: 3628801zï0>>>>>
 6: 3628801zï0>>>>>>
 7: 3628801zï0>>>>>>>
 8: 3628801zï0>>>>>>>>
 9: 3628801zï0>>>>>>>>>
10: 3628801zï0>>>>>>>>>>

```

### Explanation

```
3628801                        # push this number
       z                       # find its reciprocal
        ï                      # round it to the nearest integer (becomes 0)
         0                     # push 0
          >>>>                 # increment by 1 for each `>` present (this is for 4)
                               # implicit output

```

To summarise it, push `3628801`, take its reciprocal and round that to the nearest integer (evaluates to `0`). Then increment the stack. TADA!

Try it online! For output = 1 Then add as many `>`s as you want depending on what number you want to output.
> 4 votes

# Answer
# JavaScript, 12 bytes, 10 numbers, Hedi

Original code:

```
alert(+[+1])

```

2 through 10:

```
alert(+[1+1])
alert(+[2+1])
alert(+[3+1])
alert(+[4+1])
alert(+[5+1])
alert(+[6+1])
alert(+[7+1])
alert(+[8+1])
alert(+[9+1])

```

There's only so much you can do with this much code...
> 4 votes

# Answer
# Jelly, 7 bytes, 10 numbers, Jonathan Allan

Original code:

```
“1‘ỌȮḊ‘

```

Then:

```
“1‘‘ỌȮḊ‘
“1‘‘‘ỌȮḊ‘
“1‘‘‘‘ỌȮḊ‘
“1‘‘‘‘‘ỌȮḊ‘
“1‘‘‘‘‘‘ỌȮḊ‘
“1‘‘‘‘‘‘‘ỌȮḊ‘
“1‘‘‘‘‘‘‘‘ỌȮḊ‘
“1‘‘‘‘‘‘‘‘‘ỌȮḊ‘
“1‘‘‘‘‘‘‘‘‘ỌvḊ‘

```

You can check the last one on TryItOnline!

---

Another way would be
```
“2‘ỌȮḊ‘
“3‘ỌȮḊ‘
...
“9‘ỌȮḊ‘
“9‘ỌvḊ‘

```
> 4 votes

# Answer
# Octave, 21 bytes, 10 numbers, by Stewie Griffin

The `fpr` was a nice misguidance=) But I love the `(1') -> 2(1') -> 2+(1')` sequence!

```
original:
disp(fpr___f__e_(_'_)     % original
disp(fprintf= e=(1'))     % my solution
disp(fprintf= e=2(1'))
disp(fprintf= e=2+(1'))
disp(fprintf= e=3+(1'))
disp(fprintf= e=4+(1'))
disp(fprintf= e=5+(1'))
disp(fprintf= e=6+(1'))
disp(fprintf= e=7+(1'))
disp(fprintf= e=8+(1'))
disp(fprintf= e=9+(1'))

```
> 4 votes

# Answer
# Hexagony, 7 bytes, 10 numbers, by Martin Ender

Original:

```
1<@|!__

```

Code that produces 1 - 10:

```
1<@|!).
2<@|!).
3<@|!).
4<@|!).
5<@|!).
6<@|!).
7<@|!).
8<@|!).
9<@|!).
9<@|!).!

```

1: Try it Online!
9: Try it Online!
10: Try it Online!

Here is the hex for the first 9 programs (where # is the number that you want to print):

```
 # <
@ | !
 ) .

```

The memory edge is just set to the value you want to print, deflected to the SE and printed.

And the hex for 10:

```
  9 < @
 | ! ) .
! . . . .
 . . . .
  . . .

```

Here, I added a character to the end which increased the hex size. First, the memory edge is set to 9, the pointer is deflected to the SE, memory is incremented, wraps around, the pointer is deflected to the SW, the value is printed and the program ends.

---

Here is a second solution:

```
1<@|!$)
2<@|!$)
3<@|!$)
...
8<@|!$)
9<@|!$)
9#@|!$)

```

1: Try it Online!
9: Try it Online!
10: Try it Online!

The hex for 1 - 9 (this time `*` is the number to print):

```
 * <
@ | !
 $ )

```

This works the same as 1 - 9 above.

The hex for 10:

```
 9 #
@ | !
 $ )

```

This hits `9` then `#` switched the instruction pointer to the lower right one, memory is incremented to 10, `$` jumps over the `!`, the pointer is reversed back east where it jumps over `)` and ends.
> 4 votes

# Answer
# C#, 90 bytes, 10 numbers, Scepheo

Original:

```
using ______________________________________________;class C{static void Main(){_______;}}

```

First:

```
using System;class D{public D(){Console.Write(+1);}};class C{static void Main(){new D();}}

```

Then:

```
using System;class D{public D(){Console.Write(1+1);}};class C{static void Main(){new D();}}
using System;class D{public D(){Console.Write(2+1);}};class C{static void Main(){new D();}}
using System;class D{public D(){Console.Write(3+1);}};class C{static void Main(){new D();}}
using System;class D{public D(){Console.Write(4+1);}};class C{static void Main(){new D();}}
using System;class D{public D(){Console.Write(5+1);}};class C{static void Main(){new D();}}
using System;class D{public D(){Console.Write(6+1);}};class C{static void Main(){new D();}}
using System;class D{public D(){Console.Write(7+1);}};class C{static void Main(){new D();}}
using System;class D{public D(){Console.Write(8+1);}};class C{static void Main(){new D();}}
using System;class D{public D(){Console.Write(9+1);}};class C{static void Main(){new D();}}

```
> 4 votes

# Answer
# Ruby, 81 bytes, 10 numbers, histocrat

Original code:

```
x=##/=#%#
)
###x

```

Cracked:

```
x=/$/=~%q
)

p x

```

This was a tricky one. Many characters that were revealed turned out to be red herrings! `/` isn't division but part of a regex literal. `%` isn't mod but part of an uncommon string literal syntax. This program simply prints the length of a string delimited by newlines. The subsequent programs can be obtained by inserting additional characters in the second line.
> 4 votes

# Answer
# Octave, 25 bytes, 10 numbers, by Luis Mendo

```
mean(repmat(1,ones(1,1)))
mean(repmat(2,ones(1,1)))
mean(repmat(3,ones(1,1)))
mean(repmat(4,ones(1,1)))
mean(repmat(5,ones(1,1)))
mean(repmat(6,ones(1,1)))
mean(repmat(7,ones(1,1)))
mean(repmat(8,ones(1,1)))
mean(repmat(9,ones(1,1)))

```
> 3 votes

# Answer
# 아희(Aheui), 19 bytes, 10 numbers, by JHM

Original code:

```
봃法희
반자뭉

```

Modified:

```
2
봃法희
반반뭉
3
봃法희
반밬뭉
4
봃法희
반밭뭉
5
봃法희
반발뭉
6
봃法희
반타뭉
7
봃法희
반밝뭉
8
봃法희
반밣뭉
9
봃法희
반밢뭉
10
봃法희
반다뭉

```
> 3 votes

# Answer
## *Acc!!*, 10 bytes, 9 numbers, by DLosc

Original code :

```
Write 49+_

```

To produce the numbers 1 to 9 :

```
Write 49+_
Write 49+1
Write 49+2
Write 49+3
Write 49+4
Write 49+5
Write 49+6
Write 49+7
Write 49+8

```

49 is the ascii code of `1`. `_` contains 0 by default (so `49+_ = 1`). And `Write` prints the character corresponding to the ascii code of its argument. Pretty straight forward.
> 3 votes

# Answer
# Octave, 24 bytes, 9 numbers, by flawr

```
max(repmat(1,ones(),1))%
max(repmat(2,ones(),1))%
max(repmat(3,ones(),1))%
max(repmat(4,ones(),1))%
max(repmat(5,ones(),1))%
max(repmat(6,ones(),1))%
max(repmat(7,ones(),1))%
max(repmat(8,ones(),1))%
max(repmat(9,ones(),1))%

```

**Octave, 24 bytes ~~9~~ 10 numbers**

Note: This crack is for the first version of the cop post (posted the wrong snippet), with the revealed code looking like this: `___a__repmat(__one__),__)`. The correct version is above.

Original code:

```
+mean(repmat(1,ones(),1))

```

Modified versions that print 2-10

```
1+mean(repmat(1,ones(),1))
2+mean(repmat(1,ones(),1))
3+mean(repmat(1,ones(),1))
4+mean(repmat(1,ones(),1))
5+mean(repmat(1,ones(),1))
6+mean(repmat(1,ones(),1))
7+mean(repmat(1,ones(),1))
8+mean(repmat(1,ones(),1))
9+mean(repmat(1,ones(),1))

```
> 3 votes

# Answer
# Octave, 21 bytes, 9 numbers, by flawr

I really enjoyed this one... Clever :)

```
a='repmat(1one'(1,8)
a='repmat(2one'(1,8)
a='repmat(3one'(1,8)
a='repmat(4one'(1,8)
a='repmat(5one'(1,8)
a='repmat(6one'(1,8)
a='repmat(7one'(1,8)
a='repmat(8one'(1,8)
a='repmat(9one'(1,8)

```
> 3 votes

# Answer
# JavaScript, 15 bytes, 10 numbers, ETHProductions

Original code:

```
alert( +"+1"+0)  // Prints 1

```

Programs:

```
alert( +"+1"+1)  // Prints 2
alert( +"+1"+2)  // Prints 3
alert( +"+1"+3)  // Prints 4
alert( +"+1"+4)  // Prints 5
alert( +"+1"+5)  // Prints 6
alert( +"+1"+6)  // Prints 7
alert( +"+1"+7)  // Prints 8
alert( +"+1"+8)  // Prints 9
alert( +"+1"+9)  // Prints 10

```
> 3 votes

# Answer
# Python 2, 49 bytes, 10 numbers, AlexRacer

Maybe (just maybe) the intended solution, but if so, plenty of bytes could have been golfed off:

```
y=10-6;s='0901100000';print int(s[8-8+y-2+0+0:y])
y=10-6;s='0902100000';print int(s[8-8+y-2+0+0:y])
y=10-6;s='0903100000';print int(s[8-8+y-2+0+0:y])
y=10-6;s='0904100000';print int(s[8-8+y-2+0+0:y])
y=10-6;s='0905100000';print int(s[8-8+y-2+0+0:y])
y=10-6;s='0906100000';print int(s[8-8+y-2+0+0:y])
y=10-6;s='0907100000';print int(s[8-8+y-2+0+0:y])
y=10-6;s='0908100000';print int(s[8-8+y-2+0+0:y])
y=10-6;s='0909100000';print int(s[8-8+y-2+0+0:y])
y=10-4;s='0909100000';print int(s[8-8+y-2+0+0:y])

```
> 3 votes

# Answer
## Befunge-93, 11 bytes, 10 numbers, James Holderness

```
905:**-8-.@
905:**-7-.@
905:**-6-.@
905:**-5-.@
905:**-4-.@
905:**-3-.@
905:**-2-.@
905:**-1-.@
905:**-0-.@
905:**-~-.@

```

Try it online!

Probably not the intended solution.

What I did was get rid of the pesky 25 (`5:*`) by multiplying it by `0`. If we then put a `9` at the beginning then the outputs will be `9 - N` where need to generate `N` from a single command. The only issue is `-1` to get `10`, but trying to read an integer if there's no input conveniently pushes a `-1`.
> 3 votes

# Answer
# 05AB1E, 5 bytes, 10 numbers, by Adnan.

Original code:

```
…[==1

```

1-10:

```
…[==1
…[==2
…[==3
…[==4
…[==5
…[==6
…[==7
…[==8
…[==9
…[==T

```

**Explanation:**

```
…[==   3 char string
    1  Push number

```
> 3 votes

# Answer
# 05AB1E, 6 bytes, 10 numbers, Adnan

Original code:

```
¼ [==q

```

Keep adding `¼`'s to output up to 10:

```
¼¼ [==q
¼¼¼ [==q
¼¼¼¼ [==q
¼¼¼¼¼ [==q
¼¼¼¼¼¼ [==q
¼¼¼¼¼¼¼ [==q
¼¼¼¼¼¼¼¼ [==q
¼¼¼¼¼¼¼¼¼ [==q
¼¼¼¼¼¼¼¼¼¼ [==q

```

Try it online

How it works:

```
¼        # Increment counter_variable to count_of(¼), it's printed at some point...
  [      # Infinite loop start
   ==    # Print nothing because stack is empty
     q   # Quit

```
> 3 votes

# Answer
## Python 3, 19 bytes, 10 numbers, Sp3000

Newlines are a real bummer.

```
print(##bin()

0+1)

```

`0+1` ... `9+1`.
> 3 votes

# Answer
# JavaScript, 21 Bytes, 10 Numbers, Shaun H

Original:

```
alert(b_oa_"3____1"))

```

First:

```
alert(btoa|"3"&("1"))

```

Then:

```
alert(btoa|"3"-("1"))
alert(btoa|"3"-("0"))
alert(btoa|"4"-("0"))
alert(btoa|"5"-("0"))
alert(btoa|"6"-("0"))
alert(btoa|"7"-("0"))
alert(btoa|"8"-("0"))
alert(btoa|"9"-("0"))
alert(btoa|"9"-(~"0"))

```

```
//Using console.log instead of alert

console.log(btoa|"3"&("1"))
console.log(btoa|"3"-("1"))
console.log(btoa|"3"-("0"))
console.log(btoa|"4"-("0"))
console.log(btoa|"5"-("0"))
console.log(btoa|"6"-("0"))
console.log(btoa|"7"-("0"))
console.log(btoa|"8"-("0"))
console.log(btoa|"9"-("0"))
console.log(btoa|"9"-(~"0"))
```
> 3 votes

# Answer
## Python 2, 26 bytes, 10 numbers, DLosc

Original:

```
print r___e(3______+_[___]

```

Solve:

```
print range(3,)[1]#+_[___]
print range(3,)[-1]#+_[___]
print range(3,4)[-1]#+_[___]
print range(3,5)[-1]#+_[___]
print range(3,6)[-1]#+_[___]
print range(3,7)[-1]#+_[___]
print range(3,8)[-1]#+_[___]
print range(3,9)[-1]#+_[___]
print range(3^9)[-1]#+_[___]
print range(2^9)[-1]#+_[___]

```

Yeah, I'm fairly sure this still isn't the intended solve.
> 3 votes

# Answer
## Befunge-93, 11 bytes, 10 numbers, James Holderness

```
"15:**-6-.@
"15:**-6-2.@
"15:**-6-2+.@
"15:**-6-3+.@
...
"15:**-6-9+.@

```

A more complete crack of James' Befunge cop, after Martin's here. Because Befunge-93 has a limited board, the IP actually waits until it gets to the end of the board before wrapping around, unlike other 2D languages such as \>\<\>. This means that a wraparound char push with `"` ends up pushing the values of the empty cells too, which by default is 32 for space.

Hence here at the start we push a bunch of chars, with 32 on top, then `1:5**-` on that gives `32 - (1*(5*5)) = 32 - 25 = 7`. Subtract another 6, and we have 1 to start off the ladder.
> 3 votes

# Answer
## Python 2, 111 bytes, 10 numbers, feersum

Original, then the program for `1`:

```
print +int('''3EE5EE6EE0EE2EE5EE6EE4EE9EE1EE5EE9EE4EE6EE7EE5EE7E''')%int('''2EE0EE9EE8EE9EE2EE3EE5EE0EE3EE6''')
print +int('''39951562603020050069949998519154798549467371659275''')%int('''2000009008009002\x3005000\x3006''')

```

The other programs are just appending `1-9` before the `+`. With numbers of this size the problem is fairly simple, since we have a lot of freedom in the lower digits of the larger number. To make things a bit easier, a few of the `3`s in the modulus have been turned into `\x30`, which is the code point for `0`.
> 3 votes

# Answer
# Perl, 31 bytes, 10 numbers, by Gabriel Benamy

I'm pretty sure this is the intended answer this time (up to trivial variations, such as using `'<'` rather than `"<"`).

Original code (must be *saved to a file* and run via giving the file at the command line, it doesn't matter what the name is):

```
__e_$a,_<__$_;1 while_$a_;say$_

```

Crack for 1:

```
open$a,"<",$0;1 while<$a>;say$.

```

To crack for the other values, append a newline to the file each time (e.g. the above prints 2 with one newline appended, 3 with two newlines appended, and so on). The program works by reading its own source code from disk (this isn't a quine competition, so you're allowed to do that!) and printing the line number of the line just beyond the end.

I found this via deducing that it probably started with a keyword or built-in function with a four letter name, and searching the list of keywords and builtin functions for functions matching `..e.`. As soon as you realise that `open` is a possibility, everything is straightforward from there (the unknown character before the final semicolon is in retrospect very suspicious).
> 3 votes

# Answer
## Pyth, 3 bytes, 10 numbers, by Yotam Salmon

Original code was `__Q`, with`_` unknown.

`1.Q`: Implicit print `1`, throw error when trying to evaluate empty input. Same answer for 2-9 (with the number 1 replaced by 2-9), and the code `T.Q` for 10 (since `T` is initialized to 10).
> 2 votes

# Answer
# Octave, 19 bytes, 10 numbers, by flawr

Probably not the intended solution, but hey.

```
'psca'(1 )+'1'-160'
'qsca'(1 )+'1'-160'
...
'ysca'(1 )+'1'-160'

```
> 2 votes

# Answer
# Octave, 26 bytes, 10 numbers, by LuisMendo

```
original
__a__repmat(_+one___1+__))

solution:
mean(repmat(0+ones, 1+0 ))
mean(repmat(1+ones, 1+0 ))
mean(repmat(2+ones, 1+0 ))
...

```
> 2 votes

# Answer
# Octave, 17 bytes, 10 numbers, by flawr

From

```
_od(3_13_13_7_1_)

```

To the original code:

```
mod(3113+1387,11) #1

```

The rest of the numbers:

```
mod(3113+1388,11) #2
mod(3113+1389,11) #3
mod(3114+1389,11) #4
mod(3115+1389,11) #5
mod(3116+1389,11) #6
mod(3117+1389,11) #7
mod(3118+1389,11) #8
mod(3119+1389,11) #9
mod(3119+1379,11) #10

```

Try it online! for the first case

### Explanation

`mod(x, y)` computes the modulo of x and y. Here is the docs for `mod`.

## Process

I don't know Octave, I've never used it, but I was interested in this particular sumbission. So I decided to try to crack it. First, I used this website to help me find an Octave command that is three characters long and has an `od` in the end. I found it to be `mod`. Then I began experimenting with the numbers in its online interpreter. After some time, I ended up with

```
mod(3_13+13_7,1_)

```

after which time I decided to create a python script (on TIOv2!) to brute-force the solution. The script printed the values for the `_` whenever `first_param%second_param==1`. I first ran the python script for `10` (the second paramter to the `mod` function). I got tons of hits. Then I ran it again for `11`. I got only a few hits this time, after which I decided to use `11` as the second parameter and the following values for the first parameter `3113+1387` just out of randomness. Now I got the original code. From there, I began incrementing the last digit of the numbers, so that I did `1387->1388->1389` and then `3113->3114->3115->3116->3117->3118->3119`. Now I got the first `9` numbers.

```
mod(3119+1389,11) #evaluates to 9

```

Now `10` was the only one remaining. I tried changing the `1389` to `1399` to see if it becomes `10`, but instead it resulted to `8`. So I changed it to `1379`, and it resulted in 10!
> 2 votes

# Answer
## C, 216 bytes, 10 numbers, by Joshua

Original code :

```
#include <stdio.h>

FILE *a, *b;

void x() { ___________ int x; x = __; ________a____d____x_;}
void y() { ___________ int x; fprintf(b,"%d\n",x);}
int main() { a=fopen("/dev/null", "w");b=stdout;x();y();return 0;}

```

Cracked code :

```
#include <stdio.h>

FILE *a, *b;

void x() { volatile    int x; x =  0; fprintf(a," %d",++x);}
void y() { volatile    int x; fprintf(b,"%d\n",x);}
int main() { a=fopen("/dev/null", "w");b=stdout;x();y();return 0;}

```

Change the `x = 0` to the number you want to print minus 1 : `x=0` for `1`, `x=1` for `2`, `x=2` for `3` etc, until `x=9` for `10`.
> 2 votes

# Answer
## PowerShell, 7 bytes, 10 numbers, by TimmyD

Original code :

```
___(__0

```

Cracked code :

```
+1#(__0
+2#(__0
+3#(__0
...
+9#(__0
1+9#(__0

```
> 2 votes

# Answer
# Java, 70 bytes, 10(+) numbers, by masterX244

```
//Submission v
__________________________ ____(_____________________________)________
//Original code v
class A{public static void main(String[]a){System.out.print(')'-40);}}//1

```

This makes use of the character codes for numbers. The `char` `)` is `41`. So when you subtract `40` from it, it evaluates to `1`. By incrementing the `char` by `1`, we effectively increase the output by `1` too.

Try it online in Ideone!. **Note:** in Ideone, you need to have `public` before `class` and the name of the class should be `HelloWorld`

Other numbers:

```
class A{public static void main(String[]a){System.out.print('*'-40);}}//2
class A{public static void main(String[]a){System.out.print('+'-40);}}//3
class A{public static void main(String[]a){System.out.print(','-40);}}//4
class A{public static void main(String[]a){System.out.print('-'-40);}}//5
class A{public static void main(String[]a){System.out.print('.'-40);}}//6
class A{public static void main(String[]a){System.out.print('/'-40);}}//7
class A{public static void main(String[]a){System.out.print('0'-40);}}//8
class A{public static void main(String[]a){System.out.print('1'-40);}}//9
class A{public static void main(String[]a){System.out.print('2'-40);}}//10
...
class A{public static void main(String[]a){System.out.print('~'-40);}}//86

```

> Edit: fixed mistake
>
> Edit 2: Yes, this can go upto `86` and maybe even more!
> 2 votes

# Answer
## Java, 126 bytes, 10 numbers, masterX244

Yes we have seen Unicode escapes many times here at PPCG.

```
cl\u0061ss Z\u007bpublic st\u0061tic void main(String[]a){System. out.print(/*_"___42*/0+1/*_00____00____".*/)/*______0)_*/;}}

```

`s/0+1/1+1/` ... `9+1`.
> 2 votes

# Answer
## QBasic, 13 bytes by DLosc

```
?+INT(LOG(3))  'Fixed thanks to feersome
?1+INT(LOG(3))
?2+INT(LOG(3))
?3+INT(LOG(3))
?4+INT(LOG(3))
?5+INT(LOG(3))
?6+INT(LOG(3))
?7+INT(LOG(3))
?8+INT(LOG(3))
?9+INT(LOG(3))

```

Try QBasic at archive.org.

Seems like the intended solution is:

```
? INT(LOG(3))    '1
? INT(LOG(13))   '2
? CINT(LOG(13))   '3

```

but that can't possibly work because the natural log function grows too quickly. There are no sequences of this form that get past 4.
> 2 votes

# Answer
# Python 2, 26 bytes, 10 numbers, DLosc

```
print range(11)[1or+ [  ]]
print range(11)[2or+ [  ]]
print range(11)[3or+ [  ]]
print range(11)[4or+ [  ]]
print range(11)[5or+ [  ]]
print range(11)[-5or+ [  ]]
print range(11)[-4or+ [  ]]
print range(11)[-3or+ [  ]]
print range(11)[-2or+ [  ]]
print range(11)[-1or+ [  ]]

```

I thought I'd try this with comments or newlines or anything. Definitely not the intended solution...
> 2 votes

# Answer
## JavaScript (ES6), 63 bytes, 10 numbers by Arnauld

**Original code**:

```
eval([...(n=0,"l?0?a?(?x?")].sort(_=>[...????+[]][n++]).join``)

```

**Modified**:

```
eval([...(n=0,"le0ta1(rx)")].sort(_=>[...8/73+[]][n++]).join``)
eval([...(n=0,"le0ta2(rx)")].sort(_=>[...8/73+[]][n++]).join``)
...
eval([...(n=0,"le0ta9(rx)")].sort(_=>[...8/73+[]][n++]).join``)
eval([...(n=0,"le0taa(rx)")].sort(_=>[...8/73+[]][n++]).join``)

```

This was a lot of fun to get to the bottom of, even though my first approach was off!
> 2 votes

# Answer
# Perl, 31 bytes, 10 numbers, by Gabriel Benamy

Original code:

```
__e_$a__<__$_;1 while_$a_;say$_

```

Cracked:

1. `the;$a+=<1\$>;1 while!$a ;say$a`
2. `the;$a+=<1\$>+1 while!$a ;say$a`
3. `the;$a+=<1\$>+2 while!$a ;say$a`
4. `the;$a+=<1\$>+3 while!$a ;say$a`
5. `the;$a+=<1\$>+4 while!$a ;say$a`
6. `the;$a+=<1\$>+5 while!$a ;say$a`
7. `the;$a+=<1\$>+6 while!$a ;say$a`
8. `the;$a+=<1\$>+7 while!$a ;say$a`
9. `the;$a+=<1\$>+8 while!$a ;say$a`
10. `the;$a+=<1\$>+9 while!$a ;say$a`

The principle using `q<>` I used last time doesn't seem to quite work here, so I used one of the intended uses of `<>` brackets (if a fairly obscure one) to create the string `1$` via globbing. Using `+=` rather than `=` for the assignment to `$a` converts it to an integer, thus just `1`, and then the solution continues the same way as my previous crack.

Fun fact: random sequences of letters in void context (such as `the`) are no-ops in Perl if they don't happen to spell a keyword.
> 2 votes

# Answer
## Perl, 26 bytes, 10 numbers by Gabriel Benamy

Original code:

```
____;@a=($_..10);say$a[__]

```

Cracked:

```
$_=0;@a=($_..10);say$a[+1]
$_=1;@a=($_..10);say$a[+1]
$_=2;@a=($_..10);say$a[+1]
$_=3;@a=($_..10);say$a[+1]
$_=4;@a=($_..10);say$a[+1]
$_=5;@a=($_..10);say$a[+1]
$_=6;@a=($_..10);say$a[+1]
$_=7;@a=($_..10);say$a[+1]
$_=8;@a=($_..10);say$a[+1]
$_=9;@a=($_..10);say$a[+1]

```

In fact I tested this on my Mac using `print` instead of `say` with `perl -e`... However I do think they should work basically the same.

This is incrementing the "base" of the array and `say` the second element of the array. Replacing `_`s by other characters should work too.
> 2 votes

# Answer
# Perl, 26 bytes, 10 numbers, by Gabriel Benamy

Original code:

```
____;@a=($_..10);say$a[__]

```

Cracked:

1. `____;@a=($|..10);say$a[+1]`
2. `____;@a=($|..10);say$a[1+1]`
3. `____;@a=($|..10);say$a[2+1]`
4. `____;@a=($|..10);say$a[3+1]`
5. `____;@a=($|..10);say$a[4+1]`
6. `____;@a=($|..10);say$a[5+1]`
7. `____;@a=($|..10);say$a[6+1]`
8. `____;@a=($|..10);say$a[7+1]`
9. `____;@a=($|..10);say$a[8+1]`
10. `____;@a=($|..10);say$a[9+1]`

I didn't even need the blanks at the start (and as `____` is a legal but pointless Perl statement, I left them as is). The only subtlety here is finding a variable that starts at 0, but there are plenty to choose from; I chose `$|`.
> 2 votes

# Answer
# C++, 10 numbers, 468 bytes, by Joshua

Original program:

```
#include <unistd.h>
#include <iostream>
#include <fstream>

$$$$$$$$$$$$$ {
    std::ofstream *garbalgase()
    {
        std::ofstream *golgi = new std::ofstream;
        golgi->open("/dev/null");
        return golgi;
    }

    std::ostream * const jawbone = garbalgase();
    $$$$$ int value = $_$$$$$$;
}

int main()
{
    $$$$$ $$$$$$$$/$$int vl = value;
    if (fork() == 0)
    {
        $$$$$$$$$$$<std::ostream $*>($jawbone) = &std::cout;
        vl -= 4;
        _exit(0);
    }
    (*jawbone) << (vl - 9) << std::endl;
}

```

My crack (prints 1):

```
#include <unistd.h>
#include <iostream>
#include <fstream>

extern "C++"  {
    std::ofstream *garbalgase()
    {
        std::ofstream *golgi = new std::ofstream;
        golgi->open("/dev/null");
        return golgi;
    }

    std::ostream * const jawbone = garbalgase();
    /*$*/ int value = '_',vl=1;
}

int main()
{
    std:: cout<<+1/1;int vl = value;
    if (fork() == 0)
    {
        //$$$$$$$$$<std::ostream $*>($jawbone) = &std::cout;
        vl -= 4;
        _exit(0);
    }
    (*jawbone) << (vl - 9) << std::endl;
}

```

To get a crack for 2 up to 10, change the `+1/1` to `1+1/1`, `2+1/1`, `3+1/1`, and so on.

I originally tried to comment out much more of the program than this, but it turns out that most of it is naturally harmless and cancels itself out. (Because it happens to use `_exit` rather than `exit`, we can put the number to print out into the stdout buffer in both threads; the parent thread won't have time to flush it before it exits.) The hardest part is dealing with the `}` character just before `int main()`; you can't make it the closing brace of a function without `-fpermissive`, but you *can* make it the closing brace of a calling convention block (in this case I used `extern "C++"`, the default, to basically cancel the braces out).

I also accidentally declared `vl` twice, but oh well. It doesn't break the crack, just shows how many spare characters there are here.
> 2 votes

# Answer
# COW, 51 bytes, 10 numbers, by Gabriel Benamy

```
MoO ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ OOM // incomplete
MoO Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ OOM //original code outputs 1

```

Other numbers:

```
MoO MoO Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ OOM //2
MoO MoO MoO Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ OOM //3
MoO MoO MoO MoO Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ OOM //4
MoO MoO MoO MoO MoO Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ OOM //5
MoO MoO MoO MoO MoO MoO Mo_ Mo_ Mo_ Mo_ Mo_ Mo_ OOM //6
MoO MoO MoO MoO MoO MoO MoO Mo_ Mo_ Mo_ Mo_ Mo_ OOM //7
MoO MoO MoO MoO MoO MoO MoO MoO Mo_ Mo_ Mo_ Mo_ OOM //8
MoO MoO MoO MoO MoO MoO MoO MoO MoO Mo_ Mo_ Mo_ OOM //9
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Mo_ Mo_ OOM //10

```

### Explanation

```
MoO //increment current memory block value by 1.
OOM //print current memory block as output to STDOUT
Mo_ //gets ignored since the compiler doesn't recognise it

```

Try it online!

> Cows don't moo, Cows quack!
> 2 votes

# Answer
## Hexagony, 15 bytes, 10 numbers, Sunny Pun

```
\!?\1<<3@_!?_<3
\!?\2<<3@_!?_<3
\!?\3<<3@_!?_<3
\!?\4<<3@_!?_<3
\!?\5<<3@_!?_<3
\!?\6<<3@_!?_<3
\!?\7<<3@_!?_<3
\!?\8<<3@_!?_<3
\!?\9<<3@_!?_<3
\!?\9)<<3@_!?_<3

```

Try it online!

I'm afraid this wasn't sufficiently well constrained (as this is almost definitely nowhere near the intended solution).
> 2 votes

# Answer
## Python 2, 26 bytes, 10 numbers DLosc

Original: `print r___e(3_4____+_[___]`

```
print range(304)[ 1+#[
0 ]

```

Where the `0` character is incremented up through `9`.
> 2 votes

# Answer
# JavaScript, 33 Bytes, 10 Numbers, Shaun H

Original:

```
alert(_to__"_Xc0__0_B6____Zp=="))

```

First:

```
alert(atob|"0Xc0"/0xB6||("Zp=="))

```

Then:

```
alert(atob|"0X1c0"/0xB6||("Zp=="))
alert(atob|"0X2c0"/0xB6||("Zp=="))
alert(atob|"0X2F0"/0xB6||("Zp=="))
alert(atob|"0X3F0"/0xB6||("Zp=="))
alert(atob|"0X4F0"/0xB6||("Zp=="))
alert(atob|"0X4F0"/0xB0||("Zp=="))
alert(atob|"0X5F0"/0xB0||("Zp=="))
alert(atob|"0X5F0"/0xA0||("Zp=="))
alert(atob|"0X5F0"/0x90||("Zp=="))

```

```
// Using console.log instead of alert

console.log(atob|"0Xc0"/0xB6||("Zp=="))
console.log(atob|"0X1c0"/0xB6||("Zp=="))
console.log(atob|"0X2c0"/0xB6||("Zp=="))
console.log(atob|"0X2F0"/0xB6||("Zp=="))
console.log(atob|"0X3F0"/0xB6||("Zp=="))
console.log(atob|"0X4F0"/0xB6||("Zp=="))
console.log(atob|"0X4F0"/0xB0||("Zp=="))
console.log(atob|"0X5F0"/0xB0||("Zp=="))
console.log(atob|"0X5F0"/0xA0||("Zp=="))
console.log(atob|"0X5F0"/0x90||("Zp=="))
```

---

The intended version:
```
alert(_to__"_Xc0__0_Bf____Zp=="))

```

First:

```
alert(atob|"0Xc0"/0xBf||("Zp=="))

```

Then:

```
alert(atob|"0X1c0"/0xBf||("Zp=="))
alert(atob|"0X2c0"/0xBf||("Zp=="))
alert(atob|"0X2c0"/0xB0||("Zp=="))
alert(atob|"0X3c0"/0xB0||("Zp=="))
alert(atob|"0X4c0"/0xB0||("Zp=="))
alert(atob|"0X4F0"/0xB0||("Zp=="))
alert(atob|"0X5F0"/0xB0||("Zp=="))
alert(atob|"0X5F0"/0xA0||("Zp=="))
alert(atob|"0X5F0"/0x90||("Zp=="))

```

```
// Using console.log instead of alert

console.log(atob|"0Xc0"/0xBf||("Zp=="))
console.log(atob|"0X1c0"/0xBf||("Zp=="))
console.log(atob|"0X2c0"/0xBf||("Zp=="))
console.log(atob|"0X2c0"/0xB0||("Zp=="))
console.log(atob|"0X3c0"/0xB0||("Zp=="))
console.log(atob|"0X4c0"/0xB0||("Zp=="))
console.log(atob|"0X4F0"/0xB0||("Zp=="))
console.log(atob|"0X5F0"/0xB0||("Zp=="))
console.log(atob|"0X5F0"/0xA0||("Zp=="))
console.log(atob|"0X5F0"/0x90||("Zp=="))
```

**Intended crack?**

```
alert(atob|"0Xc0"-0xBf||("Zp=="))
alert(atob|"0Xc0"-0xBe||("Zp=="))
alert(atob|"0Xc0"-0xBd||("Zp=="))
alert(atob|"0Xc0"-0xBc||("Zp=="))
alert(atob|"0Xc0"-0xBb||("Zp=="))
alert(atob|"0Xc0"-0xBa||("Zp=="))
alert(atob|"0Xc0"-0xB9||("Zp=="))
alert(atob|"0Xc0"-0xB7||("Zp=="))
alert(atob|"0Xc0"-0xB6||("Zp=="))

```

```
// Using console.log instead of alert

console.log(atob|"0Xc0"-0xBf||("Zp=="))
console.log(atob|"0Xc0"-0xBe||("Zp=="))
console.log(atob|"0Xc0"-0xBd||("Zp=="))
console.log(atob|"0Xc0"-0xBc||("Zp=="))
console.log(atob|"0Xc0"-0xBb||("Zp=="))
console.log(atob|"0Xc0"-0xBa||("Zp=="))
console.log(atob|"0Xc0"-0xB9||("Zp=="))
console.log(atob|"0Xc0"-0xB7||("Zp=="))
console.log(atob|"0Xc0"-0xB6||("Zp=="))
```
> 2 votes

# Answer
# Python 3, 56 bytes, 6 numbers, by Flp.Tkc

Cop's post:

```
print(_______(str(ord(x))for x in ________).___________)

```

Crack:

```
print(0+1)#__(str(ord(x))for x in ________).___________)
print(1+1)#__(str(ord(x))for x in ________).___________)
print(2+1)#__(str(ord(x))for x in ________).___________)
...

```
> 2 votes

# Answer
# Ocaml, 51 bytes, 10 numbers, by feersum

Original code:

```
^^t^r^^^^-^^^^-^^r^^^^=^^^^^^^r^^^^r^^^^^^^(^^^^/0)

```

Cracks for 1-10:

1. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/0)`
2. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/1)`
3. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/2)`
4. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/3)`
5. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/4)`
6. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/5)`
7. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/6)`
8. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/7)`
9. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/8)`
10. `let(r, (-/)(*- r*)) =0,(+);;r;; print_int(1 -/9)`

The hard part is to get rid of the `/0`, which would normally cause an error. There's just enough room to define a new operator `(-/)`, which I defined to be an alias for addition `(+)`. Then I could construct the answer with `1-/0`, `1-/1`, `1-/2`, and so on. The rest of the solution fits the other required characters into place with comment marks `(* *)` and statement marks `;;`, and mostly just cancels itself out (although I had to define `r` in order to handle the first `r` in the program and in order for `;;r;;` to correctly be a no-op).
> 2 votes

# Answer
# OCaml, 51 bytes, 10 numbers, by feersum

Original code:

```
^^t^r^^^^-^^^^-^^r^^^^=^^^^^^^r^^^^r^^^^^^^(^^^0/0)

```

Code that produces 1-10:

1. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/0/0)`
2. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/1/0)`
3. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/2/0)`
4. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/3/0)`
5. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/4/0)`
6. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/5/0)`
7. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/6/0)`
8. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/7/0)`
9. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/8/0)`
10. `let r,((*-^^^^-^^r*)/)=0,(+);;r;; print_int( 1/9/0)`

The same trick still works; there's rather less room, because now I have to redefine division to mean addition rather than using a new operator, but there's still enough.
> 2 votes

# Answer
## R, 22 bytes, 10 numbers by Gregor

Original code:

```
_et_______)____is_____

```

Cracked:

For 1

```
#et
cat(+1)#___is_____

```

For 2

```
#et
cat(1+1)#___is_____

```

For the rest just increment the 1's

found a short enough print to sneak it in a gap with newline and comment.
> 2 votes

# Answer
## Octave, 16 bytes, 10 numbers by Stewe Griffin

Original code:

```
ev_l('P_NIS'-2_)

```

Cracked:

```
eval('PFNIS'-28)
eval('PFNIR'-28)
eval('PFNIQ'-28)
eval('PFNIP'-28)
eval('PFNIO'-28)
eval('PFNIN'-28)
eval('PFNIM'-28)
eval('PFNzM'-28)
eval('PFNGM'-28)
eval('PFNGN'-28)

```

After finding a way around the 8 without a zero it was easy. Trick was to use the 1 as a exponent which is a no-op and then contineru with +
relevant part unobfuscated here:

```
4*2-1
eval('PFNIM'-28)
4*2^1
eval('PFNzM'-28)
4*2+1
eval('PFNGM'-28)

```
> 2 votes

# Answer
## Python, 10+ numbers, 61 bytes, Flp.Tkc

```
try:x
except:print(__import__('sys').exc_info()[2].tb_lineno)

```

For subsequent numbers, add a newline to the start of the program.
> 2 votes

# Answer
# Pyth, 4 bytes, 9 numbers, isaacg

Original code:

```
."1Q

```

Which is a packed string containing the character `1`. The other programs:

```
."2Q
."3Q
."4Q
."5Q
."6Q
."7Q
."8Q
."9Q

```

I thought this would also contain some unprintables, but if you insert a `l` in the beginning of each code, you can see that the length of each string is always 1 (only containing the digit).
> 1 votes

# Answer
# Python, 28 bytes, 10 numbers, by CrazyPython

```
print (0+1+0*1000)+(0*0*0*4)
print (1+1+0*1000)+(0*0*0*4)
print (2+1+0*1000)+(0*0*0*4)
...

```
> 1 votes

# Answer
# \>\<\>, 5 bytes, 10 numbers, Teal pelican

```
>21n;
>22n;
>23n;
>24n;
>25n;
>26n;
>27n;
>28n;
>29n;
>2an;

```
> 1 votes

# Answer
# Javascript 19 bytes 10 numbers, by Shaun H

Original:

```
alert((_1*1_10__1_)

```

Code that produces 1 - 10:

```
alert(( 1*1%10)/1 )
alert(( 2*1%10)/1 )
alert(( 3*1%10)/1 )
alert(( 4*1%10)/1 )
alert(( 5*1%10)/1 )
alert(( 6*1%10)/1 )
alert(( 7*1%10)/1 )
alert(( 8*1%10)/1 )
alert(( 9*1%10)/1 )
alert(( 9*1%10)+1 )

```
> 1 votes

# Answer
## Python 2, 26 bytes, 10 numbers by DLosc, non-competing

Non-competing because Sp3000 beat me to it.

```
print r___e(_______+_[___]

print range(19)[1]#+_[___]
print range(19)[2]#+_[___]
print range(19)[3]#+_[___]
print range(19)[4]#+_[___]
print range(19)[5]#+_[___]
print range(19)[6]#+_[___]
print range(19)[7]#+_[___]
print range(19)[8]#+_[___]
print range(19)[9]#+_[___]
print range(19)[-9]#+_[___]

```
> 1 votes

# Answer
## R, 21 bytes, 10 numbers, Gregor

* Cop's: `__i___________i______`
* Rob's: `write(a<-1+0,file="")`

Of course there's a bunch of possibility as `a` can be any letter (and is not needed at all)...
> 1 votes

# Answer
## R, 8 bytes, 10 numbers by Tensibai

**Original code**:

```
_a___+__

```

**Modified**:

```
max(0+1)
max(1+1)
...
max(4+5)
max(5+5)

```
> 1 votes

# Answer
# ASMD, 8 bytes, 10 numbers, by Oliver

* For 1, `1t-t+++C`
* For 2, `1t-t+++C{`
* For 3, `1t-t+++C{{`
*

Works with the latest commit at the time of posting. `C` claims to be implemented, but it isn’t.

Each program works as follows:

```
1              Push 1.             1
 t             Triplicate.         1 1 1
  -            Subtract.           1 0
   t           Triplicate.         1 0 0 0
    +          Add.                1 0 0
     +         Add.                1 0
      +        Add.                1
       C       Do nothing.         1
        {{{    Increment n times.  4

```
> 1 votes

# Answer
# Perl, 31 bytes, 10 numbers, by Gabriel Benamy

Original code:

```
__e_$a__<__$_;1 while_$__;say$_

```

Code that produces 1 to 10 (note: these answers each have a leading space that doesn't show up in StackExchange's markdown):

1. `$e=$a+q<1_$>;1 while!$e ;say$e`
2. `$e=$a+q<1_$>+1 while!$e ;say$e`
3. `$e=$a+q<1_$>+2 while!$e ;say$e`
4. `$e=$a+q<1_$>+3 while!$e ;say$e`
5. `$e=$a+q<1_$>+4 while!$e ;say$e`
6. `$e=$a+q<1_$>+5 while!$e ;say$e`
7. `$e=$a+q<1_$>+6 while!$e ;say$e`
8. `$e=$a+q<1_$>+7 while!$e ;say$e`
9. `$e=$a+q<1_$>+8 while!$e ;say$e`
10. `$e=$a+q<1_$>+9 while!$e ;say$e`

I'm genuinely unsure whether you intended something like this and were aiming for misdirection, or whether this solution is completely different from the intended one.

The main trick I used is Perl's ability to get rid of unwanted characters by using a `q`, thus changing them into custom quotation marks (while allowing me to drop something that looks like 1 as an integer into the string that's actually quoted). It's not a trick that's normally that useful when golfing, because Perl has quote marks that use fewer bytes, but it comes in handy for challenges like this.
> 1 votes

# Answer
## Perl, 7 bytes, 10 numbers, ais523

`^F` means a "Control-F" character. `$^F` is a magic variable that equals 2.

```
say$^F-1
say$^F*1
say$^F+1
say$^F+2
say$^F+3
say$^F+4
say$^F+5
say$^F+6
say$^F+7
say$^F+8

```
> 1 votes

# Answer
# Alternate crack to DLosc, 26 bytes, 10 numbers

original:

```
print r___e(3_4____+_[___]

```

crack

```
>>> print r'10e(3642345+'[0+0]
1
>>> print r'10e(3642345+'[0+7]
2
>>> print r'10(3642345+'[0+7]
3
>>> print r'103642345+'[0+7]
4
>>> print r'10642345+'[0+7]
5
>>> print r'10642345+'[0+2]
6
>>> print r'10742345+'[0+2]
7
>>> print r'10842345+'[0+2]
8
>>> print r'10942345+'[0+2]
9
>>> print r'10942345+'[0:2]
10

```

programs 2 to 5's purpose is to place a number next to 10, so that for 10, we can change \[0+2\] to \[0:2\], and get the number 10. the rest just change the number to get the other numbers

nice challenge :)

Intended solution?
> 1 votes

# Answer
## Ruby, 81 bytes, 10 numbers, histocrat

Yay comments...

```
require'digest/md5'
p Digest::MD5.digest('')&&0+1#')[n=0].ord^'straYNpraq'[n].ord

```

`0+1` ... `9+1` as usual.
> 1 votes

# Answer
# Python 2, 33 bytes, 9 numbers, CrazyPython

Original code:

```
#__________________
riny
________

```

Code to print 1:

```
# my comment
riny=1
riny
print +1

```

And then just increment the `1` from there on out.
> 1 votes

# Answer
## Hexagony, 12 bytes, 10 numbers, Sunny Pun

```
[!_>!@!1)@!_
[!_>!@!2)@!_
[!_>!@!3)@!_
[!_>!@!4)@!_
[!_>!@!5)@!_
[!_>!@!6)@!_
[!_>!@!7)@!_
[!_>!@!8)@!_
[!_>!@!9)@!_
[!__!@!9)@!_

```

Try it online!

Unfortunately, this is again a cheap solution.
> 1 votes

# Answer
## Hexagony, 18 bytes, 10 numbers, Riley

```
.<.{_]5[$@!.=@.!!1
.<.{_]5[$@!.=@.!!2
.<.{_]5[$@!.=@.!!3
.<.{_]5[$@!.=@.!!4
.<.{_]5[$@!.=@.!!5
.<.{_]5[$@!.=@.!!6
.<.{_]5[$@!.=@.!!7
.<.{_]5[$@!.=@.!!8
.<.{_]5[$@!.=@.!!9
.<.{_]5[$@!.=@)!!9

```

Try it online!

Certainly not the intended solution.
> 1 votes

# Answer
## Acc!!, 46 bytes, 10 numbers, DLosc

```
1
Count i while 0^_-i  {
Write 49
}
Write _+48

```

The first character goes 1, 2, 3, 4, 5, 6, 7, 8, 9, 0. This uses a Python golfing trick that `0**_` is like `+(not _)`. So if `_` (which is set by the first line) is zero, the loop will execute once, while if it is nonzero the loop will execute zero times.
> 1 votes

# Answer
## \>\<\>, 23 bytes, Teal pelican

```
"H"|;v+2i~?
  _  >l?!;n

```

For the remaining 9 numbers, replace the `i` with `0`, `1`, ..., `8` successively.

Try it online!
> 1 votes

# Answer
# QBasic, 12 bytes, 10 numbers, by DLosc

Cop:

```
_I_T__O_(3))

```

Crack:

```
?I+T-(O<(3))
?I+1-(O<(3))
?I+2-(O<(3))
?I+3-(O<(3))
?I+4-(O<(3))
?I+5-(O<(3))
?I+6-(O<(3))
?I+7-(O<(3))
?I+8-(O<(3))
?I+9-(O<(3))

```

Still downloading QB64. But I think this should work. Not sure whether it is the original, though.

QBasic uses bitwise operators as logical operators, instead of having both of them. So true is -1.
> 1 votes

# Answer
# QBasic, 12 bytes, 10 numbers, by DLosc

Cop:

```
_INT(_O_(3))

```

Crack:

```
?INT(LOG(3))
?INT(LOG(13))
?INT(LOG(33))
?INT(LOG(73))
?INT(LOG(173))
?INT(LOG(573))
?INT(LOG(1573))
?INT(LOG(5573))
?INT(LOG(9573))
?INT(LOG(39573))

```
> 1 votes

# Answer
## Hexagony, 15 bytes, 10 numbers, Sunny Pun

```
[!?>!@!1)\!?!!!
[!?>!@!2)\!?!!!
[!?>!@!3)\!?!!!
[!?>!@!4)\!?!!!
[!?>!@!5)\!?!!!
[!?>!@!6)\!?!!!
[!?>!@!7)\!?!!!
[!?>!@!8)\!?!!!
[!?>!@!9)\!?!!!
$!?>!@!9)\!?!!!

```

Try it online!

This *might* be the intended solution this time, but I'm not entirely sure. This one was definitely a lot more challenging in any case. :)
> 0 votes

# Answer
# Python 2, 110 bytes, 10 numbers CrazyPython

```
from hashlib import *
h=md5()
h.update('*F[`')
if h.hexdigest()=='88f4002e27b0902c7018359da9bc5b44':print(0+1)

```
> 0 votes

# Answer
## TI-Basic, 13(?) bytes, 10 numbers, Timtech

```
DelVar A1→θ
BL>A
θ

```

The `1` goes up to `9`, and then we change it to `Xmax`. I'm too good at remembering useless information I don't even want to know.
> 0 votes

# Answer
# PHP, 38 bytes, 10 numbers, by Leo

Original code:

```
<?php__n_p___(_n=___(__=1___echo___?>

```

Cracks for 1-10:

1. `<?php "n p ( n= ( =1"; echo +1?>`
2. `<?php "n p ( n= ( =1"; echo 1+1?>`
3. `<?php "n p ( n= ( =1"; echo 2+1?>`
4. `<?php "n p ( n= ( =1"; echo 3+1?>`
5. `<?php "n p ( n= ( =1"; echo 4+1?>`
6. `<?php "n p ( n= ( =1"; echo 5+1?>`
7. `<?php "n p ( n= ( =1"; echo 6+1?>`
8. `<?php "n p ( n= ( =1"; echo 7+1?>`
9. `<?php "n p ( n= ( =1"; echo 8+1?>`
10. `<?php "n p ( n= ( =1"; echo 9+1?>`

Unfortunately, you left way too much space after the `echo` and it became possible to sneak a `+1` in there.
> 0 votes

# Answer
# ASMD, 10 bytes, by Oliver

Original:

```
1_**_**_*÷

```

Code that produces 1 - 10:

```
1t**t**t*÷
1t**t**t*÷{
1t**t**t*÷{{
...
1t**t**t*÷{{{{{{{{{

```

Did I miss something? I had to mess around with the interpreter to get it to work on my system, and this seems too easy.
> 0 votes

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


title: Substring Substitution

text:
# Question
Title: Substring Substitution
## Challenge

Implement a program that given three strings `a`, `b`, and `c`, substitutes all instances of the substring `b` in `a` with `c`.

In other words, implement Ruby's `String#gsub` with strings instead of regexes (`a.gsub b, c`).

## Rules

* Standard loopholes apply.
* You may not use a builtin that performs this exact task.
* This is , shortest answer wins.

## Dupe alert

Not a duplicate of this challenge.

## Test case

```
sub("test 1 test 1 test 1", "1", "what")
  --> "test what test what test what"

```

# Answer
# Jelly, 4 bytes

```
œṣj⁵

```

Try it online!

### How it works

```
œṣj⁵  Main link. Arguments: x, y, z (strings)

œṣ    Split x around occurrences of y.
  j⁵  Join the resulting string array with separator z.

```
> 2 votes

# Answer
## JavaScript (ES6), 27 bytes

```
(a,b,c)=>a.split(b).join(c)

```
> 2 votes

# Answer
## Haskell, 44 bytes

```
import Data.Lists
(.splitOn).(.).intercalate

```

Argument order is `c` `b` `a`. Usage example: `( (.splitOn).(.).intercalate ) "ww" "ee" "aeedwwfeegeh"` -\> `"awwdwwfwwgeh"`.

Just some library functions to split the input string at every `b` and rejoin the parts with `c` in-between.
> 1 votes

---
Tags: code-golf, string, substitution
---


title: Random Golf of the Day #6: Roll a d20

text:
# Question
Title: Random Golf of the Day #6: Roll a d20
## About the Series

First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.

Although I have a bunch of ideas lined up for the series, the future challenges are not set in stone yet. If you have any suggestions, please let me know on the relevant sandbox post.

## Hole 6: Roll a d20

A very common die in table-top RPGs is the twenty-sided die (an icosahedron, commonly known as **d20**). It is your task to roll such a die. However, if you were just returning a random number between 1 and 20, that would be a bit trivial. So your task is to generate a random net for a given die.

We'll use the following net:

It's a triangle strip, so it can be easily represented as a list of integers. E.g. if you are given the input:

```
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

```

That would correspond to the following die (fun fact: this is the net used by Magic: the Gathering life counters/spin-down dice).

However, this is not the only net representing this die. Depending on how we unroll the faces, there are 60 different nets. Here are two more:

```
[1, 8, 9, 10, 2, 3, 4, 5, 6, 7, 17, 18, 19, 11, 12, 13, 14, 15, 16, 20]
[10, 9, 18, 19, 11, 12, 3, 2, 1, 8, 7, 17, 16, 20, 13, 14, 4, 5, 6, 15]

```

Or graphically (I didn't rotate the face labels for simplicity):

## The Challenge

Given an a list of integers representing a die (as described above) and an integer `N`, output `N` independently, uniformly random d20 nets corresponding to the given die. (That is, each of the 60 possible nets should have the same probability of being generated.)

Of course, due to the technical limitations of PRNGs, perfect uniformity will be impossible. For the purpose of assessing uniformity of your submission, the following operations will be regarded as yielding perfectly uniform distributions:

* Obtaining a number from a PRNG (over any range), which is documented to be (approximately) uniform.
* Mapping a uniform distribution over a larger set of numbers onto a smaller set via modulo or multiplication (or some other operation which distributes values evenly). The larger set has to contain at least 1024 times as many possible values as the smaller set.

Given these assumptions your algorithm must yield a perfectly uniform distribution.

Your program should be able to generate 100 nets in less than a second (so don't try generating random nets until one corresponds to the die given above).

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

Input and output may be in any convenient, unambiguous, flat list format. You may assume that the face values of the d20 are distinct, positive integers, which fit into your language's natural integer type.

This is code golf, so the shortest submission (in bytes) wins. And of course, the shortest submission per user will also enter into the overall leaderboard of the series.

## Sample Outputs

For the input

```
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

```

The 60 possible nets (provided I didn't make a mistake), in no particular order, are:

```
[11, 10, 9, 18, 19, 20, 13, 12, 3, 2, 1, 8, 7, 17, 16, 15, 14, 4, 5, 6]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
[8, 7, 17, 18, 9, 10, 2, 1, 5, 6, 15, 16, 20, 19, 11, 12, 3, 4, 14, 13]
[3, 12, 13, 14, 4, 5, 1, 2, 10, 11, 19, 20, 16, 15, 6, 7, 8, 9, 18, 17]
[3, 4, 5, 1, 2, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 18, 19, 20, 16, 17]
[11, 19, 20, 13, 12, 3, 2, 10, 9, 18, 17, 16, 15, 14, 4, 5, 1, 8, 7, 6]
[4, 14, 15, 6, 5, 1, 2, 3, 12, 13, 20, 16, 17, 7, 8, 9, 10, 11, 19, 18]
[2, 10, 11, 12, 3, 4, 5, 1, 8, 9, 18, 19, 20, 13, 14, 15, 6, 7, 17, 16]
[4, 5, 1, 2, 3, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 19, 20, 16, 17, 18]
[10, 2, 1, 8, 9, 18, 19, 11, 12, 3, 4, 5, 6, 7, 17, 16, 20, 13, 14, 15]
[3, 2, 10, 11, 12, 13, 14, 4, 5, 1, 8, 9, 18, 19, 20, 16, 15, 6, 7, 17]
[7, 8, 1, 5, 6, 15, 16, 17, 18, 9, 10, 2, 3, 4, 14, 13, 20, 19, 11, 12]
[13, 12, 11, 19, 20, 16, 15, 14, 4, 3, 2, 10, 9, 18, 17, 7, 6, 5, 1, 8]
[16, 15, 14, 13, 20, 19, 18, 17, 7, 6, 5, 4, 3, 12, 11, 10, 9, 8, 1, 2]
[15, 16, 17, 7, 6, 5, 4, 14, 13, 20, 19, 18, 9, 8, 1, 2, 3, 12, 11, 10]
[20, 13, 12, 11, 19, 18, 17, 16, 15, 14, 4, 3, 2, 10, 9, 8, 7, 6, 5, 1]
[5, 4, 14, 15, 6, 7, 8, 1, 2, 3, 12, 13, 20, 16, 17, 18, 9, 10, 11, 19]
[10, 11, 12, 3, 2, 1, 8, 9, 18, 19, 20, 13, 14, 4, 5, 6, 7, 17, 16, 15]
[4, 3, 12, 13, 14, 15, 6, 5, 1, 2, 10, 11, 19, 20, 16, 17, 7, 8, 9, 18]
[19, 20, 13, 12, 11, 10, 9, 18, 17, 16, 15, 14, 4, 3, 2, 1, 8, 7, 6, 5]
[1, 8, 9, 10, 2, 3, 4, 5, 6, 7, 17, 18, 19, 11, 12, 13, 14, 15, 16, 20]
[8, 1, 5, 6, 7, 17, 18, 9, 10, 2, 3, 4, 14, 15, 16, 20, 19, 11, 12, 13]
[18, 9, 8, 7, 17, 16, 20, 19, 11, 10, 2, 1, 5, 6, 15, 14, 13, 12, 3, 4]
[12, 3, 2, 10, 11, 19, 20, 13, 14, 4, 5, 1, 8, 9, 18, 17, 16, 15, 6, 7]
[2, 3, 4, 5, 1, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 17, 18, 19, 20, 16]
[10, 9, 18, 19, 11, 12, 3, 2, 1, 8, 7, 17, 16, 20, 13, 14, 4, 5, 6, 15]
[9, 8, 7, 17, 18, 19, 11, 10, 2, 1, 5, 6, 15, 16, 20, 13, 12, 3, 4, 14]
[16, 17, 7, 6, 15, 14, 13, 20, 19, 18, 9, 8, 1, 5, 4, 3, 12, 11, 10, 2]
[17, 7, 6, 15, 16, 20, 19, 18, 9, 8, 1, 5, 4, 14, 13, 12, 11, 10, 2, 3]
[1, 5, 6, 7, 8, 9, 10, 2, 3, 4, 14, 15, 16, 17, 18, 19, 11, 12, 13, 20]
[9, 18, 19, 11, 10, 2, 1, 8, 7, 17, 16, 20, 13, 12, 3, 4, 5, 6, 15, 14]
[16, 20, 19, 18, 17, 7, 6, 15, 14, 13, 12, 11, 10, 9, 8, 1, 5, 4, 3, 2]
[5, 1, 2, 3, 4, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 20, 16, 17, 18, 19]
[8, 9, 10, 2, 1, 5, 6, 7, 17, 18, 19, 11, 12, 3, 4, 14, 15, 16, 20, 13]
[13, 20, 16, 15, 14, 4, 3, 12, 11, 19, 18, 17, 7, 6, 5, 1, 2, 10, 9, 8]
[6, 15, 16, 17, 7, 8, 1, 5, 4, 14, 13, 20, 19, 18, 9, 10, 2, 3, 12, 11]
[6, 5, 4, 14, 15, 16, 17, 7, 8, 1, 2, 3, 12, 13, 20, 19, 18, 9, 10, 11]
[7, 6, 15, 16, 17, 18, 9, 8, 1, 5, 4, 14, 13, 20, 19, 11, 10, 2, 3, 12]
[19, 18, 17, 16, 20, 13, 12, 11, 10, 9, 8, 7, 6, 15, 14, 4, 3, 2, 1, 5]
[14, 15, 6, 5, 4, 3, 12, 13, 20, 16, 17, 7, 8, 1, 2, 10, 11, 19, 18, 9]
[17, 18, 9, 8, 7, 6, 15, 16, 20, 19, 11, 10, 2, 1, 5, 4, 14, 13, 12, 3]
[6, 7, 8, 1, 5, 4, 14, 15, 16, 17, 18, 9, 10, 2, 3, 12, 13, 20, 19, 11]
[14, 13, 20, 16, 15, 6, 5, 4, 3, 12, 11, 19, 18, 17, 7, 8, 1, 2, 10, 9]
[20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
[7, 17, 18, 9, 8, 1, 5, 6, 15, 16, 20, 19, 11, 10, 2, 3, 4, 14, 13, 12]
[15, 6, 5, 4, 14, 13, 20, 16, 17, 7, 8, 1, 2, 3, 12, 11, 19, 18, 9, 10]
[9, 10, 2, 1, 8, 7, 17, 18, 19, 11, 12, 3, 4, 5, 6, 15, 16, 20, 13, 14]
[2, 1, 8, 9, 10, 11, 12, 3, 4, 5, 6, 7, 17, 18, 19, 20, 13, 14, 15, 16]
[12, 13, 14, 4, 3, 2, 10, 11, 19, 20, 16, 15, 6, 5, 1, 8, 9, 18, 17, 7]
[17, 16, 20, 19, 18, 9, 8, 7, 6, 15, 14, 13, 12, 11, 10, 2, 1, 5, 4, 3]
[18, 17, 16, 20, 19, 11, 10, 9, 8, 7, 6, 15, 14, 13, 12, 3, 2, 1, 5, 4]
[18, 19, 11, 10, 9, 8, 7, 17, 16, 20, 13, 12, 3, 2, 1, 5, 6, 15, 14, 4]
[11, 12, 3, 2, 10, 9, 18, 19, 20, 13, 14, 4, 5, 1, 8, 7, 17, 16, 15, 6]
[15, 14, 13, 20, 16, 17, 7, 6, 5, 4, 3, 12, 11, 19, 18, 9, 8, 1, 2, 10]
[19, 11, 10, 9, 18, 17, 16, 20, 13, 12, 3, 2, 1, 8, 7, 6, 15, 14, 4, 5]
[12, 11, 19, 20, 13, 14, 4, 3, 2, 10, 9, 18, 17, 16, 15, 6, 5, 1, 8, 7]
[20, 16, 15, 14, 13, 12, 11, 19, 18, 17, 7, 6, 5, 4, 3, 2, 10, 9, 8, 1]
[13, 14, 4, 3, 12, 11, 19, 20, 16, 15, 6, 5, 1, 2, 10, 9, 18, 17, 7, 8]
[5, 6, 7, 8, 1, 2, 3, 4, 14, 15, 16, 17, 18, 9, 10, 11, 12, 13, 20, 19]
[14, 4, 3, 12, 13, 20, 16, 15, 6, 5, 1, 2, 10, 11, 19, 18, 17, 7, 8, 9]

```

For any other net, simply replace every occurrence of `i` with the `i`th number in the input (where `i` is 1-based).

## Related Challenges

# Leaderboard

**The first post of the series generates a leaderboard.**

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

```
## Language Name, N bytes

```

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

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

```

*(The language is not currently shown, but the snippet does require and parse it, and I may add a by-language leaderboard in the future.)*

# Answer
# Ruby, 160 bytes (rev B)

17 bytes saved thanks to suggestions from Martin Büttner.

```
->a,n{n.times{k=rand 60
%w{ABCD@GHIJKLMNEFPQRSO PFENOSRQHG@DCMLKJIAB GFPQHIA@DENOSRJKBCML}.map{|b|k.times{a=b.chars.map{|i|a[i.ord-64]}}}
k>29&&a.reverse!
p a}}

```

# Ruby, 177 bytes (rev A)

```
->n,a{n.times{k=rand(60)
h=->b{k.times{|j|a=(0..19).map{|i|a[b[i].ord-64]}}}
h['ABCD@GHIJKLMNEFPQRSO']
h['PFENOSRQHG@DCMLKJIAB']
h['GFPQHIA@DENOSRJKBCML']
k>29&&a.reverse!
p a}}

```

**Explanation**

It is possible to generate all possible orientations by rotations about one face (3-fold), one vertex (5-fold) and two edges (2-fold). But not just any face and edges. The axes must have the correct relationship and the rotations must be done in the correct order, or strange things can happen.

This is the way I did it (though I understand Martin did it differently.)

All orientations of a tetrahedron can be generated by combinations of the following three symmetry operations:

a)Rotation about two 2-fold axes at right through the midpoints of the edges (these are at right angles to each other. If we multiply them together we discover a third 2-fold axis through the remaining pair of edges.)

b) Rotation about a 3 fold axis diagonal to the 2-fold axes, passing through a vertex and a face.

The icosahedron's symmetry is a superset of that of the tetrahedron. In the image below from https://en.wikipedia.org/wiki/Icosahedron, the yellow faces and red faces define two different tetrahedra (or alternatively a single octahedron), while the edges common to two blue faces are in three pairs at right angles (and lie on the faces of a cube.)

All orientations of the icosahedron can be generated by those symmetry operations mentioned above plus an additional 5-fold operation.

The rotations about three out of the four axes mentioned above are represented by the magic strings between the `''` marks. Rotation about the second 2-fold axis is different, and can be done just by reversing the array `a[]`.

Ungolfed in test program:

```
f=->a,n{
  n.times{                     #Iterate n times, using the result from the previous iteration to generate the next
    k=rand(60)                 #pick a random number

    h=->b{                     #helper function taking a string representing a transformation
      k.times{|j|              #which is performed on a using the number of times according to k
        a=(0..19).map{|i|a[b[i].ord-64]}
      }
    }

    #Rotate about axes k times (one 5-fold, one 3-fold, two 2-fold)
    #The first three axes have coprime rotation orders
    #And the rotations themselves take care of the modulus operation so no need to add it.
    #The second 2-fold rotation is equivalent to reversing the order
    #And is applied to the last 30 numbers as it is not coprime with the first 2-fold rotation.

    h['ABCD@GHIJKLMNEFPQRSO']  #rotate k times about 5-fold axis
    h['PFENOSRQHG@DCMLKJIAB']  #rotate k times about 3-fold axis
    h['GFPQHIA@DENOSRJKBCML']  #rotate k times about 2-fold axis
    k>29&&a.reverse!
    p a
  }
}

z=(1..20).map{|i|i}
f[z,50]

```

**Alternative solution 131 bytes (Invalid due to binary random walk approach, only gives an approximately correct distribution.)**

```
->a,n{(n*99).times{|i|s=['@DEFGHIABCMNOPQRJKLS','ABCD@GHIJKLMNEFPQRSO'][rand(2)]
a=(0..19).map{|i|a[s[i].ord-64]}
i%99==98&&p(a)}}

```

This is a scramble (much like the programs used to scramble rubik's cube.)

The specific rotations I use are two of the most obvious ones:

-A 120 degree rotation (about faces 1 and 20 per the first diagram)

-A 72 degree rotation (about the vertices common to 1,2,3,4,5 and 16,17,18,19,20 per the first diagram.)

we flip a coin 99 times, and each time we perform one of these two rotations depending if it is heads or tails.

Note that alternating these deterministically leads to fairly short sequences. For example, with the correct rotation senses, a 180 degree rotation can be produced with a period of just 2.
> 7 votes

# Answer
# IA-32 machine code, 118 bytes

Hexdump:

```
60 33 c0 51 8b 74 24 28 8b fa 6a 05 59 f3 a5 e8
21 00 00 00 20 c4 61 cd 6a 33 00 84 80 ad a8 33
32 00 46 20 44 8e 48 61 2d 2c 33 32 4a 00 21 20
a7 a2 90 8c 00 5b b1 04 51 0f c7 f1 83 e1 1f 49
7e f7 51 8b f2 56 8d 7c 24 e0 b1 14 f3 a4 5f 8b
f3 ac 8b ee d4 20 86 cc e3 0a 56 8d 74 04 e0 f3
a4 5e eb ed 59 e2 db 8b dd 59 e2 cc 59 83 c2 14
e2 91 61 c2 04 00

```

It's a bit long, so some explanations go first. I used almost the same algorithm as the existing answer by Level River St. To make my answer different, I took other basic permutations, which don't necessarily have intuitive geometrical meaning, but are somehow more convenient.

The code basically has to generate a permutation, which is a sequential application of the following:

1. A permutation of order 3, which I call `p3`, applied 0...2 times
2. A permutation of order 2, which I call `q2`, applied 0 or 1 times
3. A permutation of order 5, which I call `p5`, applied 0...4 times
4. Another permutation of order 2, which I call `p2`, applied 0 or 1 times

There are many possible choices for these permutations. One of them is as follows:

```
p3 = [0   4   5   6   7   8   9   1   2   3  13  14  15  16  17  18  10  11  12  19]
q2 = [4   5   6   7   0   1   2   3  13  14  15  16  17   8   9  10  11  12  19  18]
p5 = [6   7   0   4   5  14  15  16  17   8   9   1   2   3  13  12  19  18  10  11]
p2 = [1   0   7   8   9  10  11   2   3   4   5   6  16  17  18  19  12  13  14  15]

```

This choice is better than others because the permutations here have long runs of sequential indices, which can be compressed by run-length encoding - only 29 bytes for the 4 permutations.

To simplify the generation of random numbers, I chose the powers (how many times each permutation is applied) in the range 1...30 for all of them. This leads to much extra work in the code, because e.g. `p3` becomes an identity permutation each time it's multiplied by itself 3 times. However, the code is smaller that way, and as long as the range is divisible by 30, the output will have uniform distribution.

Also, powers should be positive so the run-length decoding operation is performed at least once.

The code has 4 nested loops; the outline is like this:

```
void doit(int n, uint8_t* output, const uint8_t input[20])
{
    uint8_t temp[20];

    n_loop: for i_n = 0 ... n
    {
        memcpy(output, input, 20);
        expr_loop: for i_expr = 0 ... 3
        {
            power = rand(1 ... 30);
            power_loop: for i_power = 0 ... power
            {
                memcpy(temp, output, 20);
                output_index = 0;
                perm_loop: do while length > 0
                {
                    index = ...; // decode it
                    length = ...; // decode it
                    memcpy(output + output_index, temp + index, length);
                    output_index += length;
                }
            }
        }
        output += 20;
    }
}

```

I hope this pseudo-code is clearer than the inline-assembly code below.

```
_declspec(naked) void __fastcall doit(int n, uint8_t* output, const uint8_t* input)
{
    _asm {
        pushad
        xor eax, eax

        n_loop:
            push ecx

            ; copy from input to output
            mov esi, [esp + 0x28]
            mov edi, edx
            push 5
            pop ecx
            rep movsd

            call end_of_data
#define rl(index, length) _emit(length * 32 + index)
            rl(0, 1)
            rl(4, 6)
            rl(1, 3)
            rl(13, 6)
            rl(10, 3)
            rl(19, 1)
            _emit(0)

            rl(4, 4)
            rl(0, 4)
            rl(13, 5)
            rl(8, 5)
            rl(19, 1)
            rl(18, 1)
            _emit(0)

            rl(6, 2)
            rl(0, 1)
            rl(4, 2)
            rl(14, 4)
            rl(8, 2)
            rl(1, 3)
            rl(13, 1)
            rl(12, 1)
            rl(19, 1)
            rl(18, 1)
            rl(10, 2)
            _emit(0)

            rl(1, 1)
            rl(0, 1)
            rl(7, 5)
            rl(2, 5)
            rl(16, 4)
            rl(12, 4)
            _emit(0)

            end_of_data:
            pop ebx ; load the address of the encoded data
            mov cl, 4

            expr_loop:
                push ecx

                make_rand:
                rdrand ecx
                and ecx, 31
                dec ecx
                jle make_rand

                ; input: ebx => encoding of permutation
                ; output: ebp => encoding of next permutation
                power_loop:
                    push ecx

                    ; copy from output to temp
                    mov esi, edx
                    push esi
                    lea edi, [esp - 0x20]
                    mov cl, 20
                    rep movsb
                    pop edi

                    ; ebx => encoding of permutation
                    ; edi => output
                    mov esi, ebx
                    perm_loop:
                        ; read a run-length
                        lodsb
                        mov ebp, esi

                        _emit(0xd4)             ; divide by 32, that is, split into
                        _emit(32)               ; index (al) and length (ah)
                        xchg cl, ah             ; set ecx = length; also makes eax = al
                        jecxz perm_loop_done    ; zero length => done decoding
                        push esi
                        lea esi, [esp + eax - 0x20]
                        rep movsb
                        pop esi
                        jmp perm_loop

                    perm_loop_done:
                    pop ecx
                    loop power_loop

                mov ebx, ebp
                pop ecx
                loop expr_loop

            pop ecx
            add edx, 20
            loop n_loop

        popad
        ret 4
    }
}

```

Some fun implementation details:

* I used indented assembly, like in high-level languages; otherwise the code would be an incomprehensible mess
* I use `call` and subsequent `pop` to access data (encoded permutations) stored in code
* The `jecxz` instruction conveniently lets me use a zero byte as termination for the run-length decoding process
* By luck, the number 30 (2 * 3 * 5) is almost a power of 2. This lets me use short code to generate a number in the range 1...30:

```
        and ecx, 31
        dec ecx
        jle make_rand

```
* I use a "general-purpose division" instruction (`aam`) to separate a byte into bit fields (3-bit length and 5-bit index); by luck, at that position in code, `cl = 0`, so I benefit from both "sides" of `xchg`
> 2 votes

---
Tags: code-golf, geometry, random, permutations, abstract-algebra
---


# Question
Title: Comment-free polyglot with different, nontrivial, behaviour per language
This challenge is inspired by this other challenge, which you may want to read first for some context. However, a competitive answer is likely to look very different, so after reading some posts on Meta I decided it was best posted as a separate question.

The goal here is to write a program; that is, a program that works in multiple languages. However, typically polyglot challenges are answered via some standard techniques (listed below). I think it's much more interesting if the standard techniques are avoided, and thus this challenge has a number of **restrictions** that your program must obey; each restriction is designed to close a standard loophole (although if you can somehow exploit the loophole while remaining within the restriction, go ahead). Here are the restrictions, and the reasons behind them:

1. **Deleting any non-whitespace character from your program must cause it to fail to function in all your languages. Your program may not read its own source.**

One of the most common tricks for creating polyglots is to hide code intended for one language inside syntax that's a comment block in each other language. In order to define "comments" (and other non-coding syntax, which similarly needs to be disallowed) in a language-independent way, we define a character to be part of a comment if it could be deleted without affecting the operation of the program. (This definition was based on that in nneonneo's challenge, linked above; not counting the removal of whitespace isn't quite loophole-free as some languages have particularly significant whitespace, but in general it's hard to find a *lot* of languages which use it for computation, and I don't want the focus of the challenge to be on minor details about which languages require whitespace where.)

To clarify "failing to function", the intention is that the program works like this: deleting a character from the program causes it to break at least one of the other restrictions (e.g. it errors out, or prints the output that does nor comply with the specification).

It's fairly clear that a program could work around the spirit of this restriction via examining its own source code (e.g. via opening the file that stores it on disk, or using a command similar to Befunge's `g`); as such, doing that is banned too. To be precise, you may not use language features that would act differently if a comment were added to the source code.
2. **The program may not error out, either at run time or (if applicable) at compile time.**

A common trick with polyglots is to not worry about executing parts of the program intended for other languages that aren't valid in one of the languages; you just write them anyway, then let the program crash. Banning errors closes the loophole. Warning messages are acceptable, unless the language is one that downgrades situations that would be errors in most typical languages (e.g. invalid syntax) as warnings.
3. **The program must not use any language features that return the name or version of the language in use**.

For example, no using `$]` in a submission that's intended to work in Perl. A common trick when answering polyglot questions is to take two languages which are very similar (such as Python 2 and Python 3) and claim that a program is a polyglot in both of them; however, if the languages are that similar, it makes the programs much easier to write and is uninteresting in a way. This restriction requires any solution to the problem that uses similar languages to focus on the differences between them, rather than the similarities.
4. **When executed, the program must: print the name of the language it is executing in; print the name (e.g. "A000290") of a sequence from OEIS; then print the sequence itself. The sequence must be different for each language.**

One final trick for writing polyglots is to write a very simple program that uses only code constructs which have the same meaning in a wide range of languages, such as `print(1)` (which is a complete program that outputs `1` in sufficiently many languages that it or something like it would probably win without this loophole being closed). As such, there's a requirement here for the program to do a nontrivial amount of work. The program must *calculate* the sequence elements, not just produce hardcoded output (i.e. do not exploit this standard loophole). If the sequence you choose is an infinite one, this means that the program should run forever producing more and more terms.

There's a large enough variety of sequences in OEIS that you should be able to find something that's relatively easy to implement in each of the languages you use, so long as your construction can handle some nontrivial code in addition to just printing constant strings.

This requirement also closes another standard loophole for implementing polyglots: observing that a file is missing a marker such as `<?php` and thus echoes itself, and claiming that that's a valid program. (Deleting a character would definitely change the result then!) Forcing the program to calculate something prevents that.

Note: this isn't really a challenge about implementing bignums, so it's OK if the output becomes incorrect after a while or even if the program errors out due to things like word size concerns, so long as you don't try to abuse this by picking a language with very small integers. Likewise, there aren't any hard requirements on the output format. You can output in unary for all I care.

Incidentally, the requirement to print the sequence number is to prevent a solution accidentally becoming invalid because deleting a character changes the sequence that's printed without changing anything else (and therefore is there to make the first restriction easier to comply with).

The winner will be the **answer that works in the most languages**, making this a . If there's a tie, the tiebreak is to favour the submission that was posted earlier. Unlike many challenges on this site, there's no benefit to writing a short program, so feel free to make it as readable as the restrictions allow (which, admittedly, is probably still not very readable). Good luck!

# Answer
> 16 votes
# Perl + Lua + JavaScript (Rhino) + Ruby + Python (3), 5 languages

```
m=[[']|^$=;eval($n=q@sub t {(chr 39)=~//&&"["=~//&&0!~//||die; 690 == length $n.$_[0][0][0] and print "Perl: A004442$/1$/"; print 1^++$.,$/ while 1;}@);t([ [q 9)',
    ']] n=[[function t(p) if #(m..n..p)-1==688 then print("Lua: A000045") a=1 b=1 while true do print(a) print(b) a=a+b b=b+a end end end]] loadstring(n)() t([['],
   '\x3044',
   'if((""+m).length == 640) print("JavaScript: A000217"); for(i=1;;i++)print(i*(i+1)/2)',
   'm.inspect.length == 700 and print("Ruby: A000027\n"); $i=0; print(++$i, "\n") while $i=$i+1',
   'exec(m[5])',
   'print("Python: A000012" if len(repr(m)) == 676 else ""); exec(m[6])',
   'while True: print(1)',
   'eval(m[eval(m[1][2])])',
   'eval(m[([22]+[7])[1] ])',
   8];eval(m[m[9]])

```

I used Rhino, an offline (non-browser-dependent) JavaScript implementation, because it makes local testing easier; it produces output using `print` instead of `alert`. You can change each occurrence of `print` to `alert` in the fourth line to get a program that will work in a browser.

This program uses the technique of storing most of the strings used for the various languages in data structures and `eval`uating them. We can determine if a character was deleted via checking the size of the resulting structure. That might sound easy, but it's surprisingly hard to ensure that for each language, every character of the program is either inside a string somewhere or else will break the syntax if deleted.

The program works in three different ways, depending on what language is in use.

## Lua

The Lua interpretation of the program is one of the simplest and shows off the general techniques in use, so it's a good place to start. Because `[[...]]` is a string literal in Lua, the program parses like this:

```
m=[[...]] n=[[...]] loadstring(n)() t([[...]])

```

Here, `m` and the argument to `t()` are used to capture the parts of the program used by "other languages" in order to check them for modification; `n` contains the majority of the Lua code (it defines a function `t` when evaluated via `loadstring`). It should be fairly obvious that every byte that isn't inside a string literal will break the program if deleted; deleting one of `=()[]`, the first use of `m` and `n`, or the final `t` will cause a syntax error; and deleting the argument to `loadstring`, or corrupting the name of the function itself, will make it impossible for the program to do anything useful as the content of `n` is never run. (Note that the trick of defining and then calling a function allows us to read the rest of the program "from the left", meaning that we don't need to write any Lua code physically to the right of the final `]])` in order to continue executing Lua after the entire program has been read.)

The implementation of `t` is fairly simple; it checks to ensure that `m`, `n` and `p` have the expected total length, then prints out the required information (the language's name, sequence number, and the Fibonacci sequence). One slight subtlety here is that I subtract 1 from the length and compare it to 688, rather than comparing to 689 directly; this is to avoid putting a literal `9` digit in the source code (the reason for this will become clear later).

## JavaScript, Ruby, Python

All three of these languages parse the program the same way: as a definition of a nested data structure `m`, followed by `eval(m[m[9]])`. The definition of `m` looks like this:

```
m=[['...','...'],'...','...','...','...','...','...','...','...',8];

```

In other words, `m` is a nested list here, and we can index it to get at various strings within the list. The `eval(m[m[9]])` check ensures that `m` has the expected number of elements; the program will therefore do nothing useful if one of the commas gets deleted (other than the first), even if the language can parse it. This ensures that all the strings from `m[1]` onwards are either intact or have one character deleted. We can observe that deleting any character outside a string literal here will break the program; without the initial `m` or an intact `eval` it can't run anything, without the `=` or `;` or a parenthesis or square bracket it won't parse, deleting an apostrophe will cause an unterminated string (all the apostrophes in the program are used as string delimiters and none are escaped), and it won't find the right string to run without the final `m`s and `9` intact.

Assuming that everything is fine except for possibly the contents of the strings inside `m`, we then try to determine which entry to run. This uses fragments of code that are written in the common subset of the languages' *syntaxes*, but have different *meanings* in the languages in question. To distinguish between JavaScript and the other languages, we run `([22]+[7])[1]`; this collapses to `[22, 7][1]` (i.e. `7`) in Ruby and Python, but `"227"[1]` (i.e. `"2"`, which JavaScript is happy to treat as `2` for the purpose of list indexing) in JavaScript. Then to distinguish between Ruby and Python, we take the third character of the string `'\x3044'`; Python expands `\x` escapes in both `''` and `""` strings, thus seeing this as `4`, whereas Ruby does not expand escapes in strings if they're delimited using `''`, and thus sees the third character as `3`. (We convert these strings to integers in a portable way by using `eval` yet again. It's not a recommended method of converting a string to an integer, but it does work in more languages than most other methods do.)

This means that a different string gets executed in each language, so we can start using language-specific syntax. All three programs basically do the same thing; they convert the entire data structure `m` to a string, measure its length, and compare it to an expected value. If it's wrong, they refuse to print the language name and sequence number, thus failing to comply with the spec (as required). Then they print an appropriate sequence. Ruby prints the consecutive integers, whereas JavaScript prints the triangular numbers (this is mostly because I'm more experienced with Java than I am with Ruby). Python is a bit more complex, because `eval` in Python only runs expressions, and you need `exec` for statements; additionally, Python isn't hugely fond of semicolons, and thus I needed to split the Python program over two `exec`s to make it work. Because I'm not very experienced at Python one-liners, I chose to print the sequence of all-1s; boring, I know, but based on the tiebreak we've selected I wanted to get this submitted.

## Perl

Saving the best for last. People who have any experience with Perl will know that variable names have to start with a punctuation mark (with `$` being by far the most common; other names are used for special cases like lists and dictionaries). Some of the languages I'm using don't like dollars in variable names (Ruby is OK with it, but one other language besides Perl isn't so useful…), which means that I can't start the program with a variable assignment. What Perl *does* have is a fairly wide range of interesting quoting operators, so it would be trivial to hide the start of the program from Perl by capturing it in a string literal with `q= ... =` (which is one of the many, many ways to write a string in Perl). However, hiding the text from Perl is something we can't do; in order to make the quine comment-free, we need to be able to see everything!

The obvious approach is to read the string entirely from the right, but I couldn't think of a way to do that while writing the program, so I had to take a different approach. It's possible to match a regex against `$_` (Perl's "variable used by default") via writing the regex as an expression by itself; something like `/:(.):/` would look for a character between two colons in `$_` and store it in `$1`. We can change the quote marks used for regexes by preceding the first with `m`; thus, as our program starts with `m=[[']|^$=`, Perl will parse this as `/[[']|^$/`. Matching that regex against `$_` might seem fairly useless; however, Perl has a convenience feature that allows the use of the notation `//` to repeat the last successfully matched regex. It matches (`$_` is the empty string, thus it matches the `^$` branch of the regex), meaning that we can determine if any characters got deleted from the regex by testing it on various strings to see if it matches! Some characters being deleted from the regex (such as the `]`) will cause a parse failure. For the others, we match it against `chr 39` (i.e. an apostrophe, written as a character code so as not to alarm Python), against `"["`, and against `0` (which Perl stringifies to `"0"`, expecting two matches and a non-match:

* If the `|` is deleted, the original regex won't match, and thus the `//` will match anything.
* Conversely, if the `^` or `$` is deleted, the original regex will match, but it still matches anything (as all strings have a start and and end, just not necessarily both together).
* If either `[` is deleted, the regex won't match `"["`.
* If the `'` is deleted, the regex won't match `'`.

Apart from the regex experimentation, everything works much the same way as in Lua. The program is arranged slightly differently:

```
m= ... =;eval($n=q@ ... @);t([ [q 9 ... 9]])

```

but it still comes down to basically the same thing (just with weirder quote marks; `q` can make basically anything into a quote mark, including in this case the digit `9`, which is why we couldn't use it in the rest of the program). Likewise, deleting any of these characters will break the parse for the same reason it does in the corresponding Lua. The code that's assigned to `$n` (and evaluated) defines `t` to ensure that the regex is intact, then check to ensure that `$n` and its own argument are intact, then print the required output (I chose sequence A004442 this time, because I was feeling a bit quirky and creative). Note that we can safely use a 9 in `690`, the expected total lengths of `$n` and `$_[0][0][0]` ("the first element of the first element of the first argument"), as it appears to the left of the `q 9` open-quote in the program.

## Extensions?

I think this program is close to its limit in terms of languages. You'd either need to find a new creative way to quote strings that doesn't clash with the existing constructions, or else to find another language with syntax close enough to JavaScript/Ruby/Python that the define-lists-and-`eval` trick works. (I tried looking into esolangs, but they tend to be worse with respect to string literals than more exoteric languages do, and the rules against reading the source make it hard to cheat with them.)

---
Tags: sequence, polyglot, rosetta-stone
---