29
\$\begingroup\$

For the main cops' challenge, click here

NOTICE - This challenge is now closed. Any cracks which are posted now will not be counted on the leaderboard and the accepted answer will not change.

Challenge

Given the original program, its output and the output of the changed program, you have to find out which characters need to be changed, removed or added to get the expected output.

When you crack someone's code, leave a comment with a link to your crack on their answer.

Formatting

# [<language>, <username of program owner>](<link to answer>)

## Description

<description of change and how you found it>

## Code

<changed code>

Winning

The person who has cracked the most solutions wins.

Leaderboard

13 cracks:

  • Dennis

8 cracks:

  • Alex Van Liew

5 cracks:

  • Sp3000
  • isaacg

3 cracks:

  • Luis Mendo
  • jimmy23013
  • Dom Hastings

2 cracks:

  • mbomb007
  • Sluck49

1 crack:

  • TheNumberOne
  • Jakube
  • ProudHaskeller
  • David Zhang
  • samgak
  • paul.oderso
  • rayryeng
  • mgibsonbr
  • n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳
  • Stewie Griffin
  • abligh
\$\endgroup\$
  • 1
    \$\begingroup\$ @mbomb007 Can you refrain from editing this post, because it makes it harder for me to know where I am when updating the leaderboard \$\endgroup\$ – Beta Decay Aug 13 '15 at 20:25

61 Answers 61

10
+50
\$\begingroup\$

CJam, by Mauris

Description

Mauris' original code does the following:

"f~"     e# Push that string on the stack.
    :i   e# Cast each to integer. Pushes [102 126].
      :# e# Reduce by exponentiation. Pushes 102^126.

No other of CJam's mathematical operators would yield a number that large for small inputs, so :# cannot be modified. Since #, when used for exponentiation, only takes integers as input, :i cannot be removed as well. This leaves only one place to modify the input: the string "f~".

No matter how many characters the string holds, the result will be a left-associative power tower. CJam supports characters in the range from 0 to 65535 (with the exception of surrogates), so we have to express the output as bn×k×j, where b, n, k and j are integers in that range.

The decimal logarithm of the integer that results from the modified code is slightly smaller than log10(2.44×10242545) = log10(2.44) + 242545, so we can divide this value by the logarithms of all possible bases to find proper values for n×k×j.

In fact:

$ cjam <(echo '65536,2>{2.44AmL242545+1$AmL/i:I#s8<"24399707"=}=SIN')
5 347004

Comparing the first 8 digits turned out to be sufficient.

This means that we can express the output as 5347,004 = 1562557,834 = 1259×102×126, so it suffices to replace "f~" with "㴉" or "} f~".

Code

"㴉":i:#

or

"}  f~":i:#

Note that the spaces in the ASCII code should actually be a tabulator.

Attempting to execute this code in the online interpreter is probably a bad idea, but here's how you can verify the results from the command line:

$ wget -q https://bpaste.net/raw/f449928d9870
$ cjam <(echo '[15625 57834]:c`":i:#") > mauris.cjam
$ cat mauris.cjam; echo
"㴉":i:#
$ cjam mauris.cjam | diff -s - f449928d9870
Files - and f449928d9870 are identical
$ echo -en '"}\tf~":i:#' > mauris-ascii.cjam
$ cat mauris.cjam; echo
"}  f~":i:#
$ cjam mauris-ascii.cjam | diff -s - f449928d9870
Files - and f449928d9870 are identical
\$\endgroup\$
  • 11
    \$\begingroup\$ One does not simply beat Dennis in CJam \$\endgroup\$ – Fatalize Aug 11 '15 at 20:10
  • \$\begingroup\$ How did you figure out what numbers to use? \$\endgroup\$ – Alex Van Liew Aug 11 '15 at 20:13
  • \$\begingroup\$ @AlexVanLiew Brute force. I'm currently writing an explanation. I just wanted to get the crack posted before somebody else did. \$\endgroup\$ – Dennis Aug 11 '15 at 20:14
  • \$\begingroup\$ @Dennis: Fair enough. I was trying this one but I don't know CJam; I figured the intended solution involved actually using ~f somewhere in the program. \$\endgroup\$ – Alex Van Liew Aug 11 '15 at 20:16
  • 1
    \$\begingroup\$ @Mauris The question says when just two characters in the program are changed (emphasis mine), so I assumed this was OK. Anyway, factorizing the number was the hard part. \$\endgroup\$ – Dennis Aug 11 '15 at 20:23
4
\$\begingroup\$

Brainfuck, Kurousagi

Description

Remove the first > and change the first < to .

Tested at brainfuck.tk. Note that the output doesn't match Kurousagi's post exactly, due to SE eating up unprintable characters.

Code

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[>.+<-]
\$\endgroup\$
  • \$\begingroup\$ @muddyfish I linked this answer in my second comment, but I'm still awaiting confirmation from Kurousagi \$\endgroup\$ – Sp3000 Aug 11 '15 at 13:23
4
\$\begingroup\$

C, LambdaBeta

Description

Change -1 into *0 so that the result of the multiplication is 0 (a falsy value).

Code

main(a,_){puts(_*_*_*_*_*0?"Expected Output":"?");}
\$\endgroup\$
  • \$\begingroup\$ Oops, looks like I introduced a (security flaw?) during my golfing. I'll idly mull it over to see if I can fix it. Nice catch though. \$\endgroup\$ – LambdaBeta Aug 11 '15 at 13:33
10
\$\begingroup\$

Prolog, Fatalize

Description

Add two \s. \ is bitwise negation and \/ is bitwise or.

Code

X is \1\/42.
\$\endgroup\$
  • \$\begingroup\$ Correct solution \$\endgroup\$ – Fatalize Aug 11 '15 at 15:18
7
\$\begingroup\$

C, LambdaBeta

Description

Turn main(a,_) into main(_). The first argument of main is argc which is initialized as 1.

Code

main(_){puts(_*_-1||_*_*_-1||_*_*_*_-1?"Expected Output":"?");}
\$\endgroup\$
  • \$\begingroup\$ That's the solution I had in mind. Nice catch. Incidentally if the argv happens to be loaded into memory cell 1 this will not work. I just can't think of any system that would do that that can also run the various interpreted languages on that page. \$\endgroup\$ – LambdaBeta Aug 11 '15 at 15:50
3
\$\begingroup\$

Java, TheNumberOne

Description

The program is a one-off implementation of Random.next() with a initial seed of Integer.MAX_INT and all the hex numbers converted to decimal. Changing the seed to the complement of MAX_INT generates the output:

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

(since there must be exactly two changes, pick any sort of no-op change: adding a space somewhere, an extra semicolon, etc)

\$\endgroup\$
  • 1
    \$\begingroup\$ Nice, You could have also turned Integer.MAX_VALUE into Integer.MAX_VALUE+1 or Integer.MIN_VALUE \$\endgroup\$ – TheNumberOne Aug 11 '15 at 17:42
  • \$\begingroup\$ Oh, you know what? I tried +1 but since I was doing it in Python it just rolled over to a long, ahaha. That was my first thought, actually. \$\endgroup\$ – Alex Van Liew Aug 11 '15 at 18:04
4
\$\begingroup\$

Fantom, Cain

Security through obscurity is a very poor form of security (especially when the two methods are right next to each other in the Fantom docs and anyone who knows what a float looks like will immediately know what to do).

Float.makeBits32(1123581321)
\$\endgroup\$
  • 1
    \$\begingroup\$ You got me by 1 min !!! well played \$\endgroup\$ – AboveFire Aug 11 '15 at 19:16
  • 1
    \$\begingroup\$ Haha you got me, enjoy the free crack \$\endgroup\$ – Cain Aug 11 '15 at 20:10
  • \$\begingroup\$ @Cain Was that intentional o.o \$\endgroup\$ – The_Basset_Hound Aug 12 '15 at 0:29
  • 1
    \$\begingroup\$ @BassetHound I mean, it was more of a social experiment, to see if people would bother learning some obscure language for the crack. I should have made it harder though, to take some actual work. \$\endgroup\$ – Cain Aug 12 '15 at 4:44
3
\$\begingroup\$

Brainfuck, AboveFire

this program is a modification of this code me a cookie answer. that answer works by first pre-calculating a table of useful ascii codes of useful characters, and then has three conditional statements made up by three loops which are entered to by having a 1 in the correct position.

the start of how i broke the code is that the repeating pattern in the changed output is mostly what is printed if you enter the third loop with the table shifted left.

++++++++++[->++++++++<]>>++++++[-<---------->]<-------[----------->>>-<<+<[->->+<<]]>>>+<<>>>+++[->++++++++++<]>(<)++ .<+++++++++[->>>>>>>++++++++++<+++++<++++++++++++++<++++++++++<+++++<++++++++++<<]++++++++++>>+++++...>++>++>-->+>(>)++++<<<<<<<.<<<[->>>>>>.<<>>>>>.<<<<<.>>>>>.<<<<<>>>.<<<<.>>>>>.<<<<.>>>>>.<<<<<.>>>>.<<<<<.>>>>.<<...>.<<<<<<]>[->>>>>.<<...>>>.<<<<.>>>>>.<<<<...>>>>.<<<<<.>>>>.<<...>.<<<<<]>[->>>>.<<>>>>>>.<<<<<<..>>>.<<<<.>>>>>.<<<<>>>>>>.<<<<<<.>>>>>>.<<<<<<>>>>.<<<<<.>>>>.<<...>.<<<<]

(the additional characters are marked with parentheses)

\$\endgroup\$
2
\$\begingroup\$

C++, f41lurizer

Good old trigraphs.

#include <iostream>
int main()
{
    //can you figure it out??/
    std::cout << "I like cake and";
}
\$\endgroup\$
  • \$\begingroup\$ g++ won't accept the trigraph without additional compiler flags. Removing the newline should work with all compilers. \$\endgroup\$ – Dennis Aug 11 '15 at 22:11
  • \$\begingroup\$ Heh, I suppose that does work, huh? I'm pretty sure this was the intended solution, but it doesn't really matter since the original is invalid anyway. \$\endgroup\$ – Alex Van Liew Aug 11 '15 at 22:29
4
\$\begingroup\$

CJam, by Basset Hound

25me

Calculates e25. Try it online.

The online interpreter gives a slightly different result in my browser, which seems to be a rounding issue.

The Java interpreter prints 7.200489933738588E10, which is the desired output, but in a different format.

\$\endgroup\$
  • \$\begingroup\$ Hehe, it was easy. Especially for a CJam god. Correct. \$\endgroup\$ – The_Basset_Hound Aug 11 '15 at 22:22
12
\$\begingroup\$

Python 2, muddyfish

Description

Through trials and tribulations involving factorizing large numbers and looking for consequtive factors, I realized that changing the 87654 to 58116 would be enough. Then, I factorized 58116 as 87*668. Then I realised that 01234 = 668, so I just needed to change 87654 to 87 and remove the 01234 entirely. This is accomplished with a comment.

Code

print (sum(range(054321)*9876)*87)#654)/01234
\$\endgroup\$
  • \$\begingroup\$ Yep, almost exactly how I had it (Mine was print sum(range(054321)*9876)*87#654)/01234) \$\endgroup\$ – Blue Aug 12 '15 at 7:32
  • \$\begingroup\$ Clever clever! I'm glad someone got it, and that it was more interesting than "play with numbers"! \$\endgroup\$ – Alex Van Liew Aug 12 '15 at 16:48
5
\$\begingroup\$

Bash, Dennis

Original code:

echo {{{1..9}}}

Original output:

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

Modified code:

echo {,{1..9},}

Modified output:

1 2 3 4 5 6 7 8 9

Explanation:

In Bash you can output a comma separated list of items inside a pair of braces, like this:

echo {a,b,c}

prints

a b c

So the modified code is printing out a list of nothing, the numbers 1..9, nothing.

\$\endgroup\$
2
\$\begingroup\$

Python 2, muddyfish

Description

Change `i` to `id` = '<built-in function id>' and 1234 to 01234 (octal). Found by recalling the wise words of Sir @xnor (paraphrased): "If you ever need a string that's 22 chars long..."

Code

i=long;j=map;print reduce(i.__mul__,j(i,j(ord,`id`)))/01234
\$\endgroup\$
8
\$\begingroup\$

MATLAB/OCTAVE, Stewie Griffin

A simple bit of complex arithmetic.

acos(i)
\$\endgroup\$
1
\$\begingroup\$

PHP, Dom Hastings

Comment out the first two lines so they all append together.

define('E','!');

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

print($t);
\$\endgroup\$
  • \$\begingroup\$ Not quite, I get: ` Hello World!tt`... UsingPHP 5.4 if that makes a difference... I'll update the other with the version. \$\endgroup\$ – Dom Hastings Aug 12 '15 at 12:11
3
\$\begingroup\$

Python 2, muddyfish

Description

Change << to <> (deprecated version of !=) and 0x156 to 0156, the code point for "n" (which appears 3 times in the length 23 string '<built-in function sum>').

Code

print sum((ord(i)<>0156 for i in `sum`))
\$\endgroup\$
2
\$\begingroup\$

VBA, JimmyJazzx

Description

First of all the call of a(2) was strange since only a(0) and a(1) get used, that was actually a big hint.

Next i looked into what the function IRR really does (see here). There is no combination of integer a(0) and a(1) that can possibly yield the modified output.

So I looked for combinations of a(0) and a(2) (<- first character changed) that resulted in the desired output and found a(0) = -1 and a(2) = 8. Since multiplying a(0) and a(2) with the same number doesn't change the outcome I simply multiplied both with 5 so a(0) would stay the same.

Code

Sub q()
Dim a(2) As Double
a(0) = -5
a(2) = 40
MsgBox IRR(a, 0.253)
End Sub
\$\endgroup\$
  • \$\begingroup\$ Though this may yeild the correct result this is not what I had done. mbomb007 did get what i had done correct. Good try though and im not sure which one the judge will accept as this one did come in first and ends up with the same result as the real answer. As for the a(2) that was there to mislead people, as it took the same amount of bytes as a(1) would have. But wanted to keep people away from seeing what IRR really does. \$\endgroup\$ – JimmyJazzx Aug 13 '15 at 17:50
15
\$\begingroup\$

Ruby, histocrat

Description

Changed x to be an array instead of scalar by adding *

Changed the last 9 to be a string instead of a number by adding ?

The result is made of an array with a single element ([9]) multipled 9 times then imploded with "9" as separator.

Code

x=*9;puts x*9*?9
\$\endgroup\$
3
\$\begingroup\$

JavaScript, by Razvan

Description

The modified output is clearly Euler's natural number, which can be accessed as Math['E'].

By changing '' to '3' and 32 to 36, String.fromCharCode generates the E.

Code

a=1,b=a*2,c=a+b,d=[a+b];while(c>b)c-=a;for(i=1;i<=c;i++)d.push(i);i='3'+c*d['length']*d['length'];alert(Math[String.fromCharCode(i.charCodeAt(0) * i.charCodeAt(1) / 36)])
\$\endgroup\$
  • \$\begingroup\$ Yes, that's correct. Still it was actually something deeper but it seems that you could bypass it with this trick. I'll think of something else and I'll come back. \$\endgroup\$ – Razvan Aug 12 '15 at 22:26
2
\$\begingroup\$

Clojure, Bob Jarvis

Base conversions are fun.

(printf "%d\n" 7r2155263413256326162)
\$\endgroup\$
1
\$\begingroup\$

Lua, TreFox

In Lua, # is the "sizeof" operator. The discrepancy in the original behavior (15 or 23) is because the solution involves the size of the string created by converting a table to a string, and that string contains the address of the table (which is 16 characters on a 64-bit system and 8 on a 32-bit system). It looks like the particular distribution TreFox has is 64-bit. Also, apparently arguments in Lua work like arguments in Javascript, in which they don't seem to care how many arguments are passed, so changing the . to a , only causes G to be printed.

G={string="gs_hSDrGSFG5;U*ts"}
print(#tostring(G,string))

Secretly, I think this challenge was designed to make you think about skimpy underwear the whole time you were working on it.

\$\endgroup\$
4
\$\begingroup\$

Python 2, Sp3000

Description

Changed 01234 to 0x1234 and min to 9in.

The fact that 4669 = (01234-1)*sum(m<<m in R for m in R) is misleading.

Code

R=range(0x1234);print sum(m<<9in(m,n)for m in R for n in R)
\$\endgroup\$
  • \$\begingroup\$ Nicely done! I had m<<m in(m,n), but the main thing was to change the min to in. \$\endgroup\$ – Sp3000 Aug 13 '15 at 0:33
4
\$\begingroup\$

MATLAB / Octave, Stewie Griffin

Description

This required negating the input into the anonymous function g, as well as changing the scaling factor of the g function to 2 instead of 7:

Code

>> f=@(x)x^.7;g=@(x)2/f(x);g(-7)

ans =

  -0.3011 - 0.4144i
\$\endgroup\$
  • \$\begingroup\$ Thanks for your comment on my (now deleted) answer. I posted a new (very similar) one that can be cracked using WolframAlpha. I believe it's fairer. \$\endgroup\$ – Dr. belisarius Aug 13 '15 at 17:03
2
\$\begingroup\$

PHP, Ismael Miguel

print_r(range(1,07));

I guess it really was that simple.

\$\endgroup\$
  • \$\begingroup\$ Yup, it was that simple. I didn't put that much effort on it, I was just warming up. \$\endgroup\$ – Ismael Miguel Aug 12 '15 at 21:35
  • \$\begingroup\$ PHP could be a great language for this challenge because of all the wonky stuff it's got in there. \$\endgroup\$ – Alex Van Liew Aug 12 '15 at 21:37
  • \$\begingroup\$ Yeah, I think I will come up with something \$\endgroup\$ – Ismael Miguel Aug 12 '15 at 21:37
1
\$\begingroup\$

Matlab / Octave, rayryeng

Description

Change eig to eigs and sin to sind.

The main clue was that the modified output has six eigenvalues sorted by magnitude, which is what eigs returns.

Code

eigs(cov(reshape(sind(1:60),5,[])))
\$\endgroup\$
  • 2
    \$\begingroup\$ Very well done! How long did that take you to figure out? :) \$\endgroup\$ – rayryeng - Reinstate Monica Aug 12 '15 at 22:46
  • 2
    \$\begingroup\$ It took quite a while... but I see now that the main clue had already been given in Matlab's chat room ! \$\endgroup\$ – Luis Mendo Aug 12 '15 at 23:34
3
\$\begingroup\$

Fantom, Cain

Description

The array indexing is set up already, so I just need to make a 55. Honestly, the hardest part was downloading the language.

Code

[7115432d/9,219.or(64),37,55,55][3]

(Inserted a comma, 0 -> 3)

\$\endgroup\$
  • \$\begingroup\$ Well crap, that wasn't the intended solution, my red herring was an actual solution \$\endgroup\$ – Cain Aug 13 '15 at 1:36
2
\$\begingroup\$

modern Perl 5, msh210

Description

The s/// call has to only apply to the first element in the @array and using each with the for covers it off!

Code

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

Added space in between for and each. I

\$\endgroup\$
  • 1
    \$\begingroup\$ Works in ideone. You can just add an arbitrary space for the second changed character. \$\endgroup\$ – Alex Van Liew Aug 13 '15 at 2:10
1
\$\begingroup\$

SWI-Prolog, Fatalize

Description

Replace an E for an F (or the other way around) and change a single digit in one of the numbers input.

Code

assert(d(F,F):-(print(E),print(F))). d(123456,123457).
\$\endgroup\$
  • 1
    \$\begingroup\$ That's not how I did it, but that works nonetheless! Well done. The way I did it was changing d(123456,123456) to dif(123456,123456), to call the builtin predicate dif/2 which returns false if its two arguments are the same. \$\endgroup\$ – Fatalize Aug 13 '15 at 5:17
  • 1
    \$\begingroup\$ @Fatalize I really wish I've seen this earlier :P \$\endgroup\$ – mgibsonbr Aug 13 '15 at 5:47
2
\$\begingroup\$

Matlab/Octave, paul.oderso

Description

I took the natural log, and recognized it as near pi ^ 2. From there it was easy.

Code

e^(pi*pi)+2

Added a p, 1 -> 2

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

SWI-Prolog, mgibsonbr

Description

Change , (conjunction) to ; (disjunction).

Add a space to make the distance 2.

Code

assert((o(X,Y,Z):-ABC is X**X; print(ABC))). o(99,y,z).
\$\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.