-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathV11.py
101 lines (81 loc) · 2.17 KB
/
V11.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Solved by Ostap Baranov in preparation for the Russian Unified State Exam in CS, 2023.
#
# All tasks were developed by Krulov S. S. in 2023 and belongs to the © National Education Publishing, LLC.
import math
from turtle import *
from itertools import product, permutations
from functools import lru_cache
print("№2:") # xzyw
def columns(x, y, z, w):
return (x <= y) and z and (not w)
for holes in product([0, 1], repeat=5):
table = [(0, holes[0], 0, 0), (1, holes[1], holes[2], 0), (0, holes[3], holes[4], 0)]; F = [1, 1, 1]
if len(table) == len(set(table)):
for answer2 in permutations('xyzw'):
print(*answer2, sep='') if [columns(**dict(zip(answer2, variations)))for variations in table] == F else None
print("№5:") #
print("№6:") # 101
screensize(4000, 4000)
tracer(0)
ht()
speed(10)
pensize(0.1)
color("beige", "red")
scale = 45
counter6 = 0
begin_fill()
lt(90)
rt(180)
fd(2 * scale)
rt(90)
fd(30 * scale)
rt(90)
fd(2 * scale)
rt(30)
for rep in range(6):
fd(5 * scale)
rt(120)
fd(5 * scale)
rt(240)
end_fill()
up()
canvas = getcanvas()
for X in range(-200 * scale, 200 * scale, scale):
for Y in range(-200 * scale, 200 * scale, scale):
scan = canvas.find_overlapping(X, Y, X, Y)
counter6 += 1 if len(scan) == 1 and scan[0] == 5 else 0
print(counter6)
update()
exitonclick()
print("№8:") #
print("№12:") #
print("№14:") #
print("№15:") #
print("№16:") # 78731
@lru_cache(None)
def F(n):
if n == 1:
return 1
elif n % 2 == 0:
return n + F(n - 1)
elif n > 1 and n % 2 != 0:
return 2 * F(n - 1) + F(n - 2)
print(F(20))
print("№17:") #
print("№19:") #
print("№20:") #
print("№21:") #
print("№23:") # 72
func23 = lambda start, end: func23(start - 1, end) + func23(start // 3, end) if start > end else start == end
print(func23(33, 9) * func23(9, 1))
print("№24:") # 34
with open('24var09-13.txt') as file24:
f = file24.read().strip()
max_len = cur_len = 0
for symbol in f:
if symbol != 'Z':
cur_len += 1; max_len = max(max_len, cur_len)
else:
position = 0
print(max_len)
print("№25:") #