@asyasb

Почему функция f1 не работает?

print('задание21')
def f(x,y,p):
    if x+y>=83 and (p==5 or p==3):
        return True
    elif x+y<83 and p==5:
        return False
    elif x+y>=83:
        return False
    if p%2==0:
        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)
    else:
         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)

def f1(x,y,p):
    if x+y>=83 and  p==3:
        return True
    elif x+y<83 and p==3:
        return False
    elif x+y>=83:
        return False
    if p%2==0:
        return f1(x+1,y,p+1) or  f1(x*2,y,p+1) or f1(x,y+1,p+1) or  f1(x,y*2,p+1)
    elif p%2!=0:
         return f1(x+1,y,p+1) and  f1(x*2,y,p+1) and f1(x,y+1,p+1) and  f1(x,y*2,p+1)

        
for i in range(1,73+1):
    if f(9,i,1):
        print(i)
print('-----------')
for i in range(1,73+1):
    if f1(9,i,1):
        print(i)
  • Вопрос задан
  • 117 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы