Skip to content

Instantly share code, notes, and snippets.

@be5invis
Created March 14, 2012 14:10
Show Gist options
  • Save be5invis/2036719 to your computer and use it in GitHub Desktop.
Save be5invis/2036719 to your computer and use it in GitHub Desktop.
An solution of Vczh's problem
var MakeTest(a0, d):
var j = 0;
return (x) =>
def r = a0 + d * j;
j += 1;
return x === r
def guess(test):
var counter = 0
for var segment in 1..infinity:
for var term in 1...segment:
for var mod in 0..term:
var testA0 = (segment - term) * term + mod
var testD = term
if test (counter * testD + testA0):
tracel ('found ' + testA0 + ', ' + testD)
counter += 1
-- testing
guess MakeTest(555, 19)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment