Skip to main content
added 946 characters in body
Source Link
histocrat
  • 22.3k
  • 4
  • 39
  • 81

Ruby, distance 6 [safe]

require'prime';p Prime.take(n=gets.to_i)[-1] #p (((807462154311276410)**n/(5**0.5)).round) 

Coming up with pairs of formulas with short edit distances is fun, but it seems like this approach might be more effective/annoying. You may understand exactly what I did, but that doesn't mean you can reverse it.

EditSolution: I'll leave this up another week before posting the answer as I doubt many people saw it.

require'prime';p=Prime.take(n=gets.to_i)[-1] ! p (((0742154311276/4e10)**n/(5**0.5)).round)

Explanation:

The code generates the Golden Ratio to 11 decimal places and uses it to directly calculate the Fibbonaci sequence. It's just enough precision to get the required number of terms right. That part wasn't obfuscated at all, if you happen to know the formula. To make it harder to brute-force reverse my mutations and recover the constant, I used octal notation (the leading 0) and scientific notation (4e10). Dividing by 4e10 rather than 1e11 makes it look more like I'm dividing by something .0 to force float division, when actually anything in scientific notation is for some reason always a Float in Ruby, even when a Bignum might seem to make more sense. I thought I was being clever with the p= stuff, but the way I wrote it you can just delete the p. I could've reduced the distance by 1 and forced the p= solution by using p&& instead of # on the second line, but I didn't think of it.

Ruby, distance 6

require'prime';p Prime.take(n=gets.to_i)[-1] #p (((807462154311276410)**n/(5**0.5)).round) 

Coming up with pairs of formulas with short edit distances is fun, but it seems like this approach might be more effective/annoying. You may understand exactly what I did, but that doesn't mean you can reverse it.

Edit: I'll leave this up another week before posting the answer as I doubt many people saw it.

Ruby, distance 6 [safe]

require'prime';p Prime.take(n=gets.to_i)[-1] #p (((807462154311276410)**n/(5**0.5)).round) 

Coming up with pairs of formulas with short edit distances is fun, but it seems like this approach might be more effective/annoying. You may understand exactly what I did, but that doesn't mean you can reverse it.

Solution:

require'prime';p=Prime.take(n=gets.to_i)[-1] ! p (((0742154311276/4e10)**n/(5**0.5)).round)

Explanation:

The code generates the Golden Ratio to 11 decimal places and uses it to directly calculate the Fibbonaci sequence. It's just enough precision to get the required number of terms right. That part wasn't obfuscated at all, if you happen to know the formula. To make it harder to brute-force reverse my mutations and recover the constant, I used octal notation (the leading 0) and scientific notation (4e10). Dividing by 4e10 rather than 1e11 makes it look more like I'm dividing by something .0 to force float division, when actually anything in scientific notation is for some reason always a Float in Ruby, even when a Bignum might seem to make more sense. I thought I was being clever with the p= stuff, but the way I wrote it you can just delete the p. I could've reduced the distance by 1 and forced the p= solution by using p&& instead of # on the second line, but I didn't think of it.

added 98 characters in body
Source Link
histocrat
  • 22.3k
  • 4
  • 39
  • 81

Ruby, distance 6

require'prime';p Prime.take(n=gets.to_i)[-1] #p (((807462154311276410)**n/(5**0.5)).round) 

Coming up with pairs of formulas with short edit distances is fun, but it seems like this approach might be more effective/annoying. You may understand exactly what I did, but that doesn't mean you can reverse it.

Edit: I'll leave this up another week before posting the answer as I doubt many people saw it.

Ruby, distance 6

require'prime';p Prime.take(n=gets.to_i)[-1] #p (((807462154311276410)**n/(5**0.5)).round) 

Coming up with pairs of formulas with short edit distances is fun, but it seems like this approach might be more effective/annoying. You may understand exactly what I did, but that doesn't mean you can reverse it.

Ruby, distance 6

require'prime';p Prime.take(n=gets.to_i)[-1] #p (((807462154311276410)**n/(5**0.5)).round) 

Coming up with pairs of formulas with short edit distances is fun, but it seems like this approach might be more effective/annoying. You may understand exactly what I did, but that doesn't mean you can reverse it.

Edit: I'll leave this up another week before posting the answer as I doubt many people saw it.

Source Link
histocrat
  • 22.3k
  • 4
  • 39
  • 81

Ruby, distance 6

require'prime';p Prime.take(n=gets.to_i)[-1] #p (((807462154311276410)**n/(5**0.5)).round) 

Coming up with pairs of formulas with short edit distances is fun, but it seems like this approach might be more effective/annoying. You may understand exactly what I did, but that doesn't mean you can reverse it.