# Recover the mutated source code (for robbers)

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:

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

• 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. – Timtech Dec 30 '14 at 14:07

# Python 2, FryAmTheEggman

x=n=1;j=input();
while j>2:
x,n=n,x+n;j-=1;
##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.

• You need to use all 13 edits, but that can easily be fixed by adding another character in the comment. – Doorknob Dec 29 '14 at 4:23
• Dammit, I forgot comments were a thing :/ Originally I changed the range to start at 1 and removed the ~ ;P – FryAmTheEggman Dec 29 '14 at 4:24
• @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. – Sp3000 Dec 29 '14 at 4:25
• 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 ;) – FryAmTheEggman Dec 29 '14 at 4:29

# Python 2, Sp3000

from fractions import*
n=input()
k,=P=[1]
while n>len(P):k+=1;z=reduce(lambda x,y:x+y,P[~1:]);P+=[z]#*(gcd(z,k)<2)
print P[-1]

• On closer inspection, this is slightly different to the approach I originally had. Interesting... – Sp3000 Dec 29 '14 at 15:29

# J, grc

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

f 45
1134903170


# 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
print(x)


# Python 3, matsjoyce

a,c,n=1,1,int(input())
while n-1:
#c+=1
##########list(map(c.__mod__,range(2,46))).count(0):
a,c=a+c,a
n-=1
print(c)


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

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

# CJam by Martin Büttner

T1l~({_2\$+}*p];


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
,p[-1]+i)
print f([1,1,1],2)[input('!')]


I used 9 edits to get a Fibonacci program.

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

# JAGL, globby

T~2]d]2C{cSdc+c]}wSP


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]