This is the companion thread to the main Recover the mutated source code (link) challenge. If you have successfully cracked a cop's answer, post your solution as an answer to this question.

As a reminder, here are the robber rules from the main challenge again:

The robber will attempt to change the cop's program (which completes Task #1) into a program that completes Task #2 (not necessarily the original program written by the cop) in the edit distance specified by the cop.

An already-cracked submission cannot be cracked again (only the first robber who cracks a submission gets credit).

After cracking a submission, please do the following:

  • Post an answer to this challenge's accompanying question (link), providing the language, your solution, and a link to the original answer.
  • Leave a comment with the text "Cracked" that links to your posted answer.
  • Edit the cop's answer if you have edit privileges (if you do not, either wait until someone else with the required privileges does so for you or suggest an edit).

And scoring:

If a robber successfully cracks a cop's submission, the robber's score goes up by the edit distance of that submission. For example, a robber that cracks a submission with an edit distance of 3 and one with a distance of 5 earns 8 points. The robber with the highest score wins. In the event of a tie, the robber who earned the score first wins.


There are no cracked submissions yet.

  • 2
    \$\begingroup\$ Who is maintaining the leaderboard? And also, I think reader's score should go up more if the distance is less, since that would seem harder to me. \$\endgroup\$ – Timtech Dec 30 '14 at 14:07

Python 2, FryAmTheEggman

while j>2:
    ##while~-all(n%i for i in range(2,n)):n+=1;
print n

Used 12 edits. Put in an extra # to make it 13.

  • \$\begingroup\$ You need to use all 13 edits, but that can easily be fixed by adding another character in the comment. \$\endgroup\$ – Doorknob Dec 29 '14 at 4:23
  • \$\begingroup\$ Dammit, I forgot comments were a thing :/ Originally I changed the range to start at 1 and removed the ~ ;P \$\endgroup\$ – FryAmTheEggman Dec 29 '14 at 4:24
  • \$\begingroup\$ @FryAmTheEggman If you want no comments, you can change the range to be from n to n, so that the all evaluates to True. But ~-True is False, so the while won't run. \$\endgroup\$ – Sp3000 Dec 29 '14 at 4:25
  • \$\begingroup\$ I didn't "want" no comments, it just made this much easier than I thought it would be. Besides that, that is a much neater idea than what I came up with ;) \$\endgroup\$ – FryAmTheEggman Dec 29 '14 at 4:29

Python 2, Sp3000

from fractions import*
while n>len(P):k+=1;z=reduce(lambda x,y:x+y,P[~1:]);P+=[z]#*(gcd(z,k)<2)
print P[-1]
  • \$\begingroup\$ On closer inspection, this is slightly different to the approach I originally had. Interesting... \$\endgroup\$ – Sp3000 Dec 29 '14 at 15:29

J, grc

   f=:3 :'{.+/(!|.)i.y'

   f 45

Python 3, Sp3000

x=n= int(input())       # 3
P = [1,1]               #+2 = 5
k = 2
while n >=len(P):       #+1 = 6
 k += 1
 for x in P:
  if k%x ==~0: break    #+1 = 7
 else: P += [P[-2]+x]   #+7 = 14

Python 3, matsjoyce

while n-1:

The Fibonacci program was strangely already in there...only needed 5 edits to get it.

  • \$\begingroup\$ Yeah, I designed it from the wrong end (and posted it, until Sp3000 spotted it), so it looks a little weird. \$\endgroup\$ – matsjoyce Dec 29 '14 at 19:15

CJam by Martin Büttner


Takes input n from STDIN


Python 2, Pietu1998

f=lambda p,i:p if p[45:]else f(p+[i]#f all(i%q for q in p[1:])else
print f([1,1,1],2)[input('!')]

I used 9 edits to get a Fibonacci program.

  • \$\begingroup\$ @MartinBüttner I do have 12. See the pointless argument to input. \$\endgroup\$ – feersum Dec 29 '14 at 22:59
  • \$\begingroup\$ Well... I believe this would output the !. Still accepting this as valid, you could put any chars in the comment, \$\endgroup\$ – PurkkaKoodari Dec 30 '14 at 13:33
  • \$\begingroup\$ @Pietu1998 What's wrong with having a prompt on user input? \$\endgroup\$ – feersum Dec 30 '14 at 18:51
  • \$\begingroup\$ Nothing, but this is operationally different. \$\endgroup\$ – PurkkaKoodari Dec 30 '14 at 19:26

JAGL, globby


It might not be the most efficient approach, it it is almost definitely not the Cop's code, but it works, and its 12 away.


Ruby, histocrat

p [x=1,y=1,*(1..200).map{|i|z=y;y+=(y*x**(i-1)+x%2).divmod(i)[2-1]?x:1;x=z;y}].-([x-1])[gets.to_i-1]

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.