Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def m(n1, n2, k, p, w, l):
- if k > max(w):
- return False
- if p:
- if n1 >= 50 or n2 >= 50:
- if n1+n2 <= 109:
- return False
- else:
- return True
- r = [m(n1 + 1, n2, k + 1, not p, w, l + 'А'), m(n1 + 2, n2, k + 1, not p, w, l + 'Б'), m(n1 * 2, n2, k + 1, not p, w, l + 'В'),
- m(n1, n2 + 1, k + 1, not p, w, l + 'А'), m(n1, n2 + 2, k + 1, not p, w, l + 'Б'), m(n1, n2 * 2, k + 1, not p, w, l + 'В')]
- return any(r)
- else:
- if n1 >= 50 or n2 >= 50:
- if n1+n2 <= 109:
- if k in w:
- return True
- else:
- return False
- else:
- return False
- r = [m(n1 + 1, n2, k + 1, not p, w, l + 'А'), m(n1 + 2, n2, k + 1, not p, w, l + 'Б'), m(n1 * 2, n2, k + 1, not p, w, l + 'В'),
- m(n1, n2 + 1, k + 1, not p, w, l + 'А'), m(n1, n2 + 2, k + 1, not p, w, l + 'Б'), m(n1, n2 * 2, k + 1, not p, w, l + 'В')]
- if k == 2 and all(r):
- print(l)
- return all(r)
- for s in range(1, 49 + 1):
- if m(24, s, 1, True, [4], ''):
- print(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement