Advertisement
Guest User

hui 2.0

a guest
Jan 23rd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. def f():
  2.     s = input().split(' ')
  3.     x = int(s[0])  
  4.     y = int(s[1])
  5.     res = 0
  6.     while y != x and res < 101:
  7.         if abs(y - x - 3) >= abs(y - 4*x):
  8.             if (x + 12 == x * 4) or x*4 == y:
  9.                 x*=4
  10.             else:
  11.                 x+=3
  12.         else:
  13.             x+=3
  14.         res+=1
  15.         if res == 101:
  16.             print(-1)
  17.     if res < 101:
  18.         print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement