Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Решение числоребуса при помощи библы itertools
- #
- # один
- # + один
- # --------
- # много
- #
- from itertools import permutations
- alldigs = "023456789"
- m = "1" # так как в сложении возникает перенос,
- # то "М" из слова "много" == 1
- for digs in permutations(alldigs, 5):
- o = digs[0]
- d = digs[1]
- i = digs[2]
- n = digs[3]
- g = digs[4] # из слова "много"
- odin = int(o + d + i + n)
- mnogo = int(m + n + o + g + o)
- if odin + odin == mnogo:
- print(' {0:5}'.format(odin))
- print('+{0:5}'.format(odin))
- print('------')
- print('{0:6}'.format(mnogo))
- print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement