Skip to content

Instantly share code, notes, and snippets.

@kostasdizas
Last active January 13, 2017 04:29
Show Gist options
  • Save kostasdizas/5c094f7dc8828d18c6b673fa95626700 to your computer and use it in GitHub Desktop.
Save kostasdizas/5c094f7dc8828d18c6b673fa95626700 to your computer and use it in GitHub Desktop.
Calculator tricks
join_digits = lambda i, j: int(str(i) + str(j))
def do_the_thing(a, b):
for i in range(b):
print("{} × {:02d} = {:10d}".format(a, join_digits(i, b-i), a * join_digits(i, b-i)))
do_the_thing(12345679, 9)
do_the_thing(12345679, 3)
12345679 × 03 =   37037037
12345679 × 12 =  148148148
12345679 × 21 =  259259259

do_the_thing(12345679, 6)
12345679 × 06 =   74074074
12345679 × 15 =  185185185
12345679 × 24 =  296296296
12345679 × 33 =  407407407
12345679 × 42 =  518518518
12345679 × 51 =  629629629

do_the_thing(12345679, 9)
12345679 × 09 =  111111111
12345679 × 18 =  222222222
12345679 × 27 =  333333333
12345679 × 36 =  444444444
12345679 × 45 =  555555555
12345679 × 54 =  666666666
12345679 × 63 =  777777777
12345679 × 72 =  888888888
12345679 × 81 =  999999999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment