Skip to content

Instantly share code, notes, and snippets.

@timtan
Created May 16, 2020 09:08
Show Gist options
  • Save timtan/95e7db885118157555b75a2e4bd02c4b to your computer and use it in GitHub Desktop.
Save timtan/95e7db885118157555b75a2e4bd02c4b to your computer and use it in GitHub Desktop.
def digit(num, position):
return int(str(num)[position])
def is_of_digit(num, number):
return len(str(num)) == number
def up_to(num, to):
return int(str(num)[:to+1])
answer = ()
for top in range(80000, 99999):
if digit(top, 2) != 8:
continue
for left in range(100, 999):
first_row = digit(top, 0) * left
second_row = 8 * left
third_row = digit(top,4)*left
middle = top * left
if not is_of_digit(first_row, 3):
continue
if not is_of_digit(second_row, 3):
continue
if not is_of_digit(third_row, 4):
continue
if not is_of_digit(middle, 8):
continue
alpha = up_to(middle, 3)
beta = alpha - first_row
if not is_of_digit(beta, 2):
continue
if beta* 10 + digit(middle,4) > left:
continue
full_beta = beta * 100 + digit(middle,4) * 10 + digit(middle, 5)
garma = full_beta - second_row
if not is_of_digit(garma, 2):
continue
if garma*10+ digit(middle, 6) > left:
continue
answer = (top, left, middle)
print answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment