#3
a=int("3211",4)/4
b=int("126",8)/8
mem=int(a+b)
num="0123456"
rez=""
if mem==0:
rez="0"
else:
while mem>0:
per=mem%7
rez=str(num[per])+rez
mem=mem//7
print(rez)
#5
#(z ≡ w) ∧ (x → y) ∨ ¬w
from itertools import permutations,product
def f(x,y,w,z):
return (z==w) and (x<=y) or not(w)
for x1,x2,x3,x4,x5,x6,x7,x8,x9 in product([0,1],repeat=9):
t=(
(x1,x2,0,0,0),
(x3,0,0,0,0),
(x4,0,0,x5,0),
(x5,x6,x7,0,0),
(x7,x8,0,x9,0)
)
if len(t)==len(set(t)):
for p in permutations("xyzw",r=4):
if all(f(**dict(zip(p,line))) ==line[-1] for line in t):
print(*p)
#6
from itertools import product,permutations
letters = sorted("ВЕСНА")
words= list(product(letters,repeat=4))
cnt=0
for word in words:
otv="".join(word)
cnt+=1
if otv.count("Е")==0 and "АА" not in otv:
break
print(cnt)
#10
"""from turtle import *
tracer(0)
screensize(10000,10000)
m=40
for _ in range(2):
fd(14*m);lt(270);bk(12*m);rt(90)
up()
fd(9*m);rt(90);bk(7*m);lt(90)
down()
for i in range(2):
fd(13*m);rt(90);fd(6*m);rt(90)
up()
for x in range(0,50):
for y in range(0,50):
goto(x*m,y*m)
dot(3,"blue")
update()
exitonclick()"""
#11
alf="0123456789ABCDE"
for x in alf:
otv=int("3"+x+"5A",15)+int("28"+x+"4",15)
if otv%17==0:
print(otv//17)
#12
result = bin(-38 & 0xFF)[2:]
print(result)
#13
with open('13') as f:
a = [int(x) for x in f]
n = min([x for x in a if x % 15 != 0])
count = 0
max_sum = float('-inf')
for i in range(len(a) - 1):
if a[i] % n == 0 and a[i + 1] % n == 0:
count += 1
current_sum = a[i] + a[i + 1]
if current_sum > max_sum:
max_sum = current_sum
print(count, max_sum)