24
\$\begingroup\$

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.

\$\endgroup\$

85 Answers 85

2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Good job! I knew it wasn't hard to crack, I just wanted a funny way to print numbers: "hey, let's throw an error and print the line it's on " \$\endgroup\$ – FlipTack Nov 20 '16 at 10:29
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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)
...
\$\endgroup\$
  • \$\begingroup\$ My original solution had odr and stuff.. welp you cracked it; congrats. \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Nov 14 '16 at 3:23
1
\$\begingroup\$

><>, 5 bytes, 10 numbers, Teal pelican

>21n;
>22n;
>23n;
>24n;
>25n;
>26n;
>27n;
>28n;
>29n;
>2an;
\$\endgroup\$
1
\$\begingroup\$

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 )
\$\endgroup\$
1
\$\begingroup\$

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]#+_[___]
\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

R, 8 bytes, 10 numbers by Tensibai

Original code:

_a___+__

Modified:

max(0+1)
max(1+1)
...
max(4+5)
max(5+5)
\$\endgroup\$
  • 1
    \$\begingroup\$ That's the idea, I assume that it's ok as the problem didn't specify if the program should print or return, so cat or max will give the same thing for 1+0 to 1+9. Good job ;) \$\endgroup\$ – Tensibai Nov 15 '16 at 12:41
  • 1
    \$\begingroup\$ @Tesnbai Awesome! I've not used R before so I wasn't sure on IO rules... Thanks for confirming! \$\endgroup\$ – Dom Hastings Nov 15 '16 at 12:44
  • 1
    \$\begingroup\$ Well, on a script call, this one won't output anything, the result will only be printed in an interactive session, but as the original challenge doesn't really specify it, I assume it's ok :) \$\endgroup\$ – Tensibai Nov 15 '16 at 12:47
1
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Holy crap?? This is not even remotely what I was going for, but really nicely done! Let me see if I can add one more character to give you another challenge! \$\endgroup\$ – Gabriel Benamy Nov 15 '16 at 16:22
1
\$\begingroup\$

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
\$\endgroup\$
  • \$\begingroup\$ Unless "control-f" is 2 bytes, this is only 7 bytes, not 8. \$\endgroup\$ – Riley Nov 15 '16 at 21:30
  • \$\begingroup\$ I miscounted. The original was meant to be 7 bytes. \$\endgroup\$ – user62131 Nov 15 '16 at 22:19
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ You're quite lucky, that barely fits... \$\endgroup\$ – ETHproductions Nov 16 '16 at 0:17
  • \$\begingroup\$ Ha, I should've left in a linebreak. \$\endgroup\$ – histocrat Nov 16 '16 at 14:23
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Try solving it without exploiting an unintended easy solution. \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Nov 16 '16 at 0:52
  • \$\begingroup\$ @CrazyPython Do you mean "without literal newlines", or there something further? \$\endgroup\$ – xnor Nov 16 '16 at 0:53
1
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ This is essentially the intended solution, just with a few details changed. Nice work! \$\endgroup\$ – DLosc Nov 16 '16 at 1:22
  • \$\begingroup\$ @DLosc I take it that the original program was print r'10e(3541234+'[0+7]? \$\endgroup\$ – Destructible Lemon Nov 16 '16 at 1:51
  • \$\begingroup\$ No--see edit to cop submission. \$\endgroup\$ – DLosc Nov 16 '16 at 1:56
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

><>, 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!

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Well that was unexpected. No, definitely not the original. ;) \$\endgroup\$ – DLosc Nov 18 '16 at 18:09
1
\$\begingroup\$

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))
\$\endgroup\$
  • \$\begingroup\$ Finally, the intended solution! \$\endgroup\$ – DLosc Nov 18 '16 at 18:48
0
\$\begingroup\$

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. :)

\$\endgroup\$
  • \$\begingroup\$ I laughed into tears because I changed the @ in my mind to a `\` as that looks less repetitive to the last post... Anyway I am impressed to have forced a change to the 1st byte in the code :) \$\endgroup\$ – Sunny Pun Nov 16 '16 at 13:01
0
\$\begingroup\$

Python 2, 110 bytes, 10 numbers CrazyPython

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

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.

\$\endgroup\$
  • \$\begingroup\$ Nice try! Almost correct, but you cannot assume variables like Xmax will be set to certain values. tibasicdev.wikidot.com/graphscreen \$\endgroup\$ – Timtech Nov 17 '16 at 12:06
  • \$\begingroup\$ @Timtech Yes I can. See for example codegolf.stackexchange.com/a/52967/30688 \$\endgroup\$ – feersum Nov 17 '16 at 21:10
  • \$\begingroup\$ Alright then, whatever. I made the mistake of thinking you had to add characters... didn't realize substitutions xD \$\endgroup\$ – Timtech Nov 17 '16 at 21:26
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

ASMD, 10 bytes (non-competing), 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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.