Advertisement
Korotkodul

N21_innovate

Apr 19th, 2023 (edited)
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. def f(s, cnt):
  2.     if s >= 43 and cnt - 1 == 2:
  3.         return 1
  4.     if s >= 43 and cnt - 1 < 2:
  5.         return 0
  6.     if s < 43 and cnt - 1 == 2:
  7.         return 0
  8.  
  9.     A = f(s + 1, cnt + 1)
  10.     B = f(s * 3, cnt + 1)
  11.     C = f(s + 4, cnt + 1)
  12.    
  13.     if cnt % 2 == 1:
  14.         return A and B and C
  15.     else:
  16.         return A or B or C
  17.  
  18. for s in range(1, 43):
  19.     A = s + 1 <= 42 and ( (s + 1) * 3 >= 43 or f(s + 1, 0) )
  20.     B = s + 4 <= 42 and ( (s + 4) * 3 >= 43 or f(s + 4, 0) )
  21.     C = s * 3 <= 42 and ( s * 9 >= 43 or f(s * 3, 0) )
  22.    
  23.     if A and B and C:
  24.         print(s)
  25.         break
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement