# Two Makes All The Difference - Robbers

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.

## Formatting

## Description

<description of change and how you found it>

## Code

<changed code>

## Winning

The person who has cracked the most solutions wins.

• Dennis

### 8 cracks:

• Alex Van Liew

• Sp3000
• isaacg

• Luis Mendo
• jimmy23013
• Dom Hastings

• mbomb007
• Sluck49

### 1 crack:

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

# 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 • One does not simply beat Dennis in CJam – Fatalize Aug 11 '15 at 20:10 • How did you figure out what numbers to use? – Alex Van Liew Aug 11 '15 at 20:13 • @AlexVanLiew Brute force. I'm currently writing an explanation. I just wanted to get the crack posted before somebody else did. – Dennis Aug 11 '15 at 20:14 • @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. – Alex Van Liew Aug 11 '15 at 20:16 • @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. – Dennis Aug 11 '15 at 20:23 # 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 # 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 • Yep, almost exactly how I had it (Mine was print sum(range(054321)*9876)*87#654)/01234) – Blue Aug 12 '15 at 7:32 • Clever clever! I'm glad someone got it, and that it was more interesting than "play with numbers"! – Alex Van Liew Aug 12 '15 at 16:48 # Shakespeare, AboveFire In Scene III, one has to change Claudius into Claudio in the following snippet: [Enter Claudio] Claudius: Thou art as stupid as the sum of thee and the product of the product of me and Helen and Helena [Exeunt] ## Modified code: The Hidden Change. Helen, a young woman with a remarkable patience. Helena, a likewise young woman of remarkable grace. Claudio, a remarkable man much in dispute with Claudius. Claudius, the flatterer. The Archbishop of Canterbury, the useless. Act I: Claudius's insults and flattery. Scene I: The insulting of Helen. [Enter Claudius and Helen] Claudius: Thou art as hairy as the sum of a disgusting horrible fatherless dusty old rotten fat-kidneyed cat and a big dirty cursed war. Thou art as stupid as the product of thee and a fat smelly half-witted dirty miserable vile weak son. [Exeunt] Scene II: The complimenting of Helena. [Enter Claudio and Helena] Claudio: Thou art the sunny amazing proud healthy peaceful sweet joy. Thou art as amazing as the product of thee and the pretty lovely young gentle handsome rich Hero. Thou art as great as the sum of thee and the product of a fair golden prompt good honest charming loving noble king and a embroidered rich smooth golden angel. [Exeunt] Scene III: The insulting of Claudio [Enter Claudius and Helen] Helen: Thou art as stupid as the sum of the sum of thee and a cat and me. [Exit Helen] [Enter Claudio] Claudio: Thou art as stupid as the sum of thee and the product of the product of me and Helen and Helena [Exeunt] Scene IV: The Final Countdown [Enter The Archbishop of Canterbury and Claudius] Claudius: Thou art the sum of you and a cat. The Archbishop of Canterbury: Am I better than a fine road? Claudius: If not, let us return to the insulting of Claudio. [Exit The Archbishop of Canterbury] [Enter Claudio] Claudius: Open your heart! Open your heart! [Exeunt] Using the compiler linked by @AboveFire, this prints 11. • Can you please make it more clear which characters were changed? It's not exactly easy to see looking back and forth. – mbomb007 Aug 13 '15 at 15:55 • Damn, 15 minutes late. Congratulations. – Sumyrda - remember Monica Aug 13 '15 at 15:56 • Jeebus H. Christ. Nice job! – rayryeng Aug 13 '15 at 16:16 • @mbomb007 I hope my edit made it clearer. AboveFire: sorry :) – plannapus Aug 14 '15 at 6:39 • @plannapus Haha, it's okay, but the intended way to clear it was to replace the word "king" by "pig".With this change, Helena was equal to 0 and "the sum of thee and the product of the product of me and Helen and Helena" was equal to 1. I had made a list of all words that could be inverted with two letters and used a lot of them in my code(ex: joy->hog->son, war->cat, road->toad, Hero->Hell, curse->purse, helen->helena, claudio->claudius and many others) The only things that can change a Shakespeare program with 2 char is the change of a variable, the change of a noun and the change of a goto. – AboveFire Aug 14 '15 at 11:39 # Prolog, Fatalize ## Description Add two \s. \ is bitwise negation and \/ is bitwise or. ## Code X is \1\/42. • Correct solution – Fatalize Aug 11 '15 at 15:18 ## MATLAB/OCTAVE, Stewie Griffin A simple bit of complex arithmetic. acos(i) # 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":"?");} • 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. – LambdaBeta Aug 11 '15 at 15:50 # Python 2, rp.belrann Change the outermost list comprehension into a set comprehension. Partial credit to @mbomb007, who eliminated all of the "boring" solutions (swapping x and y around, tweaking operators, changing the range). '~'*sum({(x,y)[x%2] for x in[y for y in range(8)]}) ### Explanation: In the original, [(x,y)[x%2]for x in[y for y in range(8)]] generates the following list: [0, 7, 2, 7, 4, 7, 6, 7] This is because in Python 2.7, the y in the inner list comprehension leaks into the enclosing scope at it's last known value (which, at the end of a range, is 7). So, in the tuple, y is always 7. x, however, goes through the list as normal, ranging from 0 to 7. When x is even, it chooses the value of x, when it's odd, it chooses y (which is always 7). I noticed that if I included exactly one 7 and all the rest of the values of x, I got 19; then I realized that I could transform the outer comprehension into a set comprehension, which would eliminate all duplicate values and leave me with exactly 19. This was pretty clever, I don't think I've ever used a set comprehension before. Kudos. • nope. That's not it. print len('~'*sum([(x,y)[x%2]for x in[y for y in range(6)]])) returns 21. Just assign the code to a variable then print if it equals the string you want. If you see True, you cracked it. – mbomb007 Aug 13 '15 at 16:40 • Bizarre. _ betrayed me, I guess. – Alex Van Liew Aug 13 '15 at 16:45 • @mbomb007 I got it. – Alex Van Liew Aug 13 '15 at 16:53 • You got me. Well done. – rp.beltran Aug 13 '15 at 17:01 # Jonas, Matlab/Octave ## Description I noticed the answer was i^pi, so then I justed had to turn sin into a nop. ## Code 0i+(i^pi) s -> 0, n -> + • Nicely done sir. – rayryeng Aug 13 '15 at 21:28 • Very well done!! – Luis Mendo Aug 13 '15 at 21:46 # 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. # MATLAB, Luis Mendo Original code: -sin(2:.5:3) ans = -0.9093 -0.5985 -0.1411 New answer: psi(2:.5:3) ans = 0.4228 0.7032 0.9228 # Description: Changed -sin to psi, the polygamma function in MATLAB. The - sign is substituted by p and the n is removed. # 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":"?");} • 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. – LambdaBeta Aug 11 '15 at 13:33 # 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 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[>.+<-] • @muddyfish I linked this answer in my second comment, but I'm still awaiting confirmation from Kurousagi – Sp3000 Aug 11 '15 at 13:23 # 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) • You got me by 1 min !!! well played – AboveFire Aug 11 '15 at 19:16 • Haha you got me, enjoy the free crack – Cain Aug 11 '15 at 20:10 • @Cain Was that intentional o.o – The_Basset_Hound Aug 12 '15 at 0:29 • @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. – Cain Aug 12 '15 at 4:44 # 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. • Hehe, it was easy. Especially for a CJam god. Correct. – The_Basset_Hound Aug 11 '15 at 22:22 # 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) • Nicely done! I had m<<m in(m,n), but the main thing was to change the min to in. – Sp3000 Aug 13 '15 at 0:33 # 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 • 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. – Dr. belisarius Aug 13 '15 at 17:03 # Perl, abligh ## Description Add in string repetition operator, x and insert additional digit! ## Code print sin 95x7 # 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) • Nice, You could have also turned Integer.MAX_VALUE into Integer.MAX_VALUE+1 or Integer.MIN_VALUE – TheNumberOne Aug 11 '15 at 17:42 • 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. – Alex Van Liew Aug 11 '15 at 18:04 # 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) # 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`)) # 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)]) • 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. – Razvan Aug 12 '15 at 22:26 # 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) • Well crap, that wasn't the intended solution, my red herring was an actual solution – Cain Aug 13 '15 at 1:36 # Shakespeare, AboveFire # NOT CORRECT - sorry :( Will look further into it when i get home from work In the original Claudio's value is 1132462081 and Claudius' value is 1 In the final Scene Claudio's value is printed twice, [Enter Claudio] Claudius: Open your heart! Open your heart! open your heart x2 = print value of the other person on stage (Claudio). So if you change Claudius to Claudio(2 chars) - the value of Claudius will be printed - which is 1 - twice The Hidden Change. Helen, a young woman with a remarkable patience. Helena, a likewise young woman of remarkable grace. Claudio, a remarkable man much in dispute with Claudius. Claudius, the flatterer. The Archbishop of Canterbury, the useless. Act I: Claudius's insults and flattery. Scene I: The insulting of Helen. [Enter Claudius and Helen] Claudius: Thou art as hairy as the sum of a disgusting horrible fatherless dusty old rotten fat-kidneyed cat and a big dirty cursed war. Thou art as stupid as the product of thee and a fat smelly half-witted dirty miserable vile weak son. [Exeunt] Scene II: The complimenting of Helena. [Enter Claudio and Helena] Claudio: Thou art the sunny amazing proud healthy peaceful sweet joy. Thou art as amazing as the product of thee and the pretty lovely young gentle handsome rich Hero. Thou art as great as the sum of thee and the product of a fair golden prompt good honest charming loving noble king and a embroidered rich smooth golden angel. [Exeunt] Scene III: The insulting of Claudio [Enter Claudius and Helen] Helen: Thou art as stupid as the sum of the sum of thee and a cat and me. [Exit Helen] [Enter Claudio] Claudius: Thou art as stupid as the sum of thee and the product of the product of me and Helen and Helena [Exeunt] Scene IV: The Final Countdown [Enter The Archbishop of Canterbury and Claudius] Claudius: Thou art the sum of you and a cat. The Archbishop of Canterbury: Am I better than a fine road? Claudius: If not, let us return to the insulting of Claudio. [Exit The Archbishop of Canterbury] [Enter Claudio] Claudio: << changed Claudius to Claudio Open your heart! Open your heart! [Exeunt] • Nope, Claudio value is not 1 xD. Better luck next time. – AboveFire Aug 13 '15 at 11:31 • @AboveFire - crud.. I'll have another look at it when i get home, really thought I had it :( – Alex Carlsen Aug 13 '15 at 11:33 • That was my first guess, too, but I didn't have a chance to try it, yet. Anyway, the only part I didn't understand yet is the one with the archbishop so I'll have a look at that when I get home. – Sumyrda - remember Monica Aug 13 '15 at 12:07 # VBA by JimmyJazzx Changed IRR to MIRR and changed 5 to a , so there are 3 parameters. I found this while looking for how Excel's IRR function works. There was an article: How Excel's MIRR Function Can Fix the IRR Function. That tipped me off. Clever attempt, though. I'd never used VBA before, so that was interesting as well. Sub q() Dim a(2) As Double a(0)=-5 a(1)=10 msgBox MIRR(a,0.2,3) End Sub • Nice. Technically i added both the M and the , so the middle arg was 0.25 but i think they end up having the same result anyway. Thought using some finance functions could stump the programmers but was revealed by the documentation. Good job – JimmyJazzx Aug 13 '15 at 17:22 # Matlab / Octave, Jonas ## Description In the last line, add ' to transform arg' into the string 'arg', which will then be interpreted as ASCII numbers. And then add another ' at the end to maintain the column format. The almost unnecessary ' in the original code was the main clue. Also, in restrospect, the fact that arg was defined separately (instead of directly within the sin line) should have looked suspicious. ## Code format long arg = [.1 .2 .3]; sin('arg'*exp(9))' # bc, abligh Merely inserted the math operators. Took about 1 minute to solve once I looked up what bc was and what math operations it had. The first thing I thought of was division, but there weren't common factors that looked nice. So I immediately went for exponentiation and modulus. At least 15 digits were necessary for the modulus b/c of the expected output. After that, I guessed twice and found it. 4518^574%615489737231532 # Lua, TreFox ## Description "_G" is the global table, making "_G.load" refer to the global function "load". Converting a function to a string results in returning the function's address, which is then made into the length of the string by the length-operator "#". ## Code G={load="lfkjgGsHjkU83fy6dtrg"} print(#tostring(_G.load)) Also, since this is my first post on here, I can't make a comment on the original answer. • I've left a comment on the cop answer. By the way, this doesn't quite work for me. The address is I get is 0x321a40c6d0, for a final output of 22. – Dennis Aug 14 '15 at 3:35 • I am not sure why you are getting 22... on everything I tested it was 18 or 26. – Nico A Aug 14 '15 at 11:29 • @Dennis Try it in the official lua demo. – Xrott Aug 14 '15 at 13:10 • Aha, I was so close! I knew I needed the global load, and I knew _G referred to the global symbol table... I just didn't put the two together. – Alex Van Liew Aug 14 '15 at 16:39 # Python, rp.beltran ## Description I noticed that the needed letters were always 2 in front of a digit. changing the third \w to \d got all of the right letters except the spaces. \D was the only \ group I could find that allowed letters and spaces. ## Code import re;''.join(re.findall('\D(?=\w\d)','t74q joh7 jv f9dfij9j bfjtf0e nnjen3j nnjrb6fgam3gtm5tem3hj s3eim7djsd3ye d5dfhg5un7ljmm8nan3nn6n k m2ftm5bsof5bf r5arm4ken8 adcm3nub0 nfrn6sn3jfeb6n d m6jda5 gdif5vh6 gij7fnb2eb0g ')) w -> D, w -> d in the regex. # Pyth, isaacg ### Description The original code does the following: CG Convert "abcdefghijklmnopqrstuvwxyz" from base 256 to integer, yielding 156490583352162063278528710879425690470022892627113539022649722. ^3y21 Compute 3^(2 * 21). % Calculate the modulus. Since 156490583352162063278528710879425690470022892627113539022649722 - 58227066 gives 156490583352162063278528710879425690470022892627113538964422656, which equals 226 × 3 × 7 × 7477 × 381524422711 × 17007550201751761 × 2288745700077000184147, the desired output can be obtained by replacing ^3y21 with something that evaluates to a divisor of this product and is larger than 58227066. The ^ in the original code suggests that we might use it to calculate a power of 2, the 3 that we could calculate a fitting divisor of the form 3 × 2n. Both are misleading. Solutions with a Levenshtein distance of 3 (%CG^2 26, %CG^y2 13, %CG^4y13) or 4 (%CG.<3y13) are readily found, but the solution at distance 2 requires a different approach. The lowercase alphabet (G) has 26 letters, so its power set (the set of all strictly increasing sequences of lowercase letters) has 226 elements. By replacing y2 with yG, we compute this power set. We can retrieve the set's length by replacing 3 with l, which leaves us with ^lyG1, i.e., 226 raised to the first power. ### Code %CG^lyG1 Note that this will only work on a computer with enough available memory (roughly 6.43 GiB, according to time), so it will not work with the online interpreter. Here's how you can verify the results from the command line:$ \time -v pyth -c '%CG^lyG1'
58227066
Command being timed: "pyth/pyth.py -c %CG^lyG1"
User time (seconds): 30.73
System time (seconds): 2.12
Percent of CPU this job got: 100%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:32.85
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 6742564
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 2269338
Voluntary context switches: 1
Involuntary context switches: 58
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0