Created
April 24, 2021 03:02
-
-
Save opparco/442bf4894efd54aa0d2423ccb4d34518 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for code in "1000".."9999" | |
a, b, c, d = code.bytes.map {|byte| byte - 0x30} | |
n = code.to_i | |
x = a + b + c + d | |
# min(x) = 1 | |
# max(x) = 36 | |
next if x == 1 | |
expx = 1 | |
while expx < n | |
expx = expx * x | |
if expx == n | |
puts "hit n:#{n} x:#{x}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment