Skip to content

Instantly share code, notes, and snippets.

@gurgeous
Created December 25, 2020 05:25
Show Gist options
  • Save gurgeous/0fddbdc7960644f86ca11cb485ae33eb to your computer and use it in GitHub Desktop.
Save gurgeous/0fddbdc7960644f86ca11cb485ae33eb to your computer and use it in GitHub Desktop.
def solve(key)
(0..).inject(1) do |memo, n|
return n if memo == key
(memo * 7) % 20201227
end
end
def transform(subject, n)
(1..n).inject(1) { |memo, _| (memo * subject) % 20201227 }
end
data = [ 5764801, 17807724 ]
ncard, ndoor = solve(card), solve(door)
p [ ncard, ndoor ]
p [ transform(door, ncard), transform(card, ndoor) ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment