# game_theory

Nov 25th, 2021
591
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. print('Задача 19')
2.
3.
4. def f(x, y, p):
5.     if x + y >= 77 and p == 3:
6.         return True
7.     elif x + y < 77 and p == 3:
8.         return False
9.     return f(x + 1, y, p + 1) or f(x * 2, y, p + 1) or f(x, y + 1, p + 1) or f(x, y * 2, p + 1)
10.
11.
12. for s in range(1, 70):
13.     if f(7, s, 1):
14.         print(s)
15.         break
16.
17. print('Задача 20')
18.
19.
20. def f(x, y, p):
21.     if x + y >= 77 and p == 4:
22.         return True
23.     elif x + y < 77 and p == 4:
24.         return False
25.     elif x + y >= 77 and p != 4:
26.         return False
27.     if p % 2 == 1:
28.         return f(x + 1, y, p + 1) or f(x * 2, y, p + 1) or f(x, y + 1, p + 1) or f(x, y * 2, p + 1)
29.     else:
30.         return f(x + 1, y, p + 1) and f(x * 2, y, p + 1) and f(x, y + 1, p + 1) and f(x, y * 2, p + 1)
31.
32.
33. for s in range(1, 70):
34.     if f(7, s, 1):
35.         print(s)
36.
37. print('Задача 21')
38.
39.
40. def f(x, y, p):
41.     if x + y >= 77 and (p == 5 or p == 3):
42.         return True
43.     elif x + y < 77 and p == 5:
44.         return False
45.     elif x + y >= 77 and p != 5:
46.         return False
47.     if p % 2 == 0:
48.         return f(x + 1, y, p + 1) or f(x * 2, y, p + 1) or f(x, y + 1, p + 1) or f(x, y * 2, p + 1)
49.     else:
50.         return f(x + 1, y, p + 1) and f(x * 2, y, p + 1) and f(x, y + 1, p + 1) and f(x, y * 2, p + 1)
51.
52.
53. for s in range(1, 70):
54.     if f(7, s, 1):
55.         print(s)
56.
57.
RAW Paste Data