# 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.

# 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

# 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  # 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 alerting 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) • Nice! That was the intended solution (although I wasn't as imaginative with the joining number ;) ) Nov 12, 2016 at 16:27 # 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))  • Hah, far from my solution! Well done! :) I'll post the intended one in my post :) Nov 12, 2016 at 23:03 # 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 ## 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  • Congrats! That's the one I thought of too. I was curious and ran a search. It turns out there are many solutions, including ones that don't use bitwise operations. – xnor Nov 16, 2016 at 11:27 • print 10/10 is quite an interesting one if you ban &, according to the tree search. Or, if you require going to 11. – xnor Nov 16, 2016 at 11:39 # 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. • I should have more letters... The original code was say"!"=~y"%""c (so say"!!"=~y"%""c, etc, with one more ! each time). But well played! :) – Dada Nov 12, 2016 at 23:09 • Right, there was enough of a gap to sneak an integer constant into the middle and comment out the rest of the line. That seems dangerous in a challenge like this one. – user62131 Nov 12, 2016 at 23:12 • I didn't want to give to much information : = or ~ would have been a huge hint, and the structure of the " as I showed them was misleading (I hope)... But I should have consider that commenting half of it was doable! – Dada Nov 12, 2016 at 23:16 • I'd actually guessed that there was an =~ in the intended solution. However, I was busy trying s, m and / and didn't think of y. – user62131 Nov 12, 2016 at 23:19 • Welcome on PPCG btw! Nice to see new perl golfers! – Dada Nov 12, 2016 at 23:31 # 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). # 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  ## 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. • Good job, did you perhaps find my post about this on SO? :) Nov 15, 2016 at 9:42 • @flawr Hmm? About what? Nov 15, 2016 at 16:59 • Oh, I see you've written something about recursive functions in the original post. My crack doesn't use any recursion. Nov 15, 2016 at 19:16 • Oh now I see, I wasn't even able to tell the difference at first glance ^^ Nov 15, 2016 at 19:21 ## 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. • Fast :P But at least it should be obvious now how the bin() one was intended to be solved too. Nov 15, 2016 at 6:32 ## 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... • That's the intended solution indeed. Well done! Nov 14, 2016 at 15:45 • It really should have been alert(0140337-0xc0de) (one byte shorter) but I mistakenly used the ES6 octal notation 0o140337 and decided to let it that way. Nov 14, 2016 at 15:52 • @Arnauld I'm glad I was able to get the 'right' solution! Thanks for the challenge! Nov 14, 2016 at 18:01 # 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  # 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. # 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... • 'There's only so much you can do with this much code...' yet you found a solution I didn't think of ^^' The solution I had don't need +. – Hedi Nov 13, 2016 at 10:12 # 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Ḋ‘  # 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'))  • That sequence is a nice trick indeed! Nov 14, 2016 at 15:57 # 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<@|!).!  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#@|!$)  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.

• That's amazing. :D I was trying to design a cop where those two solutions (going to side-length 3 and using # on 9) were possible but always ended up with cops that also had boring shortcuts. I was looking for ages whether there was a way to make the # solution work with the | in the centre but didn't find one. Nice work on sorting that out anyway! :) Nov 14, 2016 at 19:22

# 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();}}

• That's exactly the intended solution. Nice work. Nov 15, 2016 at 22:44
• ... tried the same but had a weird compiler error on ideone... knew it was something obvious... Nov 16, 2016 at 7:25

# 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.

• This is very similar to my intended solution, but mine doesn't use p-~x. Can you point to a Ruby version where that's interpreted correctly? In the two I have locally, p~-x works, but p-~x is interpreted as p()-~x causing an undefined method '-' for nil error. Nov 17, 2016 at 16:34
• @histocrat Thanks for pointing that out. I assumed it would work and did not test it. Hopefully this edit is what you had in mind.
– xsot
Nov 17, 2016 at 23:44
• Even closer, but that prints 0 unmodified. There's one last trick left to find. Nov 18, 2016 at 2:10
• @histocrat I think I finally figured it out.
– xsot
Nov 18, 2016 at 4:28
• Ding! Well done :) Nov 18, 2016 at 4:45

# 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)))

• New iteration here Nov 13, 2016 at 3:40

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

Original code:

봃法희
반자뭉


Modified:

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


# 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))


# 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


# 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)

• What the heck, no that was still not my solution =) Nov 12, 2016 at 23:04
• WHAT? Are you kidding me? My oh my... Nov 12, 2016 at 23:06
• Well I'll post my solution now=) Nov 12, 2016 at 23:08

## 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.

# 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])

• Blast I didn't notice you already cracked it until I was about to submit mine. I did: y=10*6;s='0910_____1';print int(s[8+(y>4or-6):y]) changing that final 1 to a 2, ... , 9 and then the * to -: repl.it/EW5q :( Nov 13, 2016 at 6:39
• Wow, nice one, I knew I hid too many characters :) Nov 13, 2016 at 12:41

## 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.

# 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


# 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