Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = 7
- b = 11
- d = {}
- def f(x, y, ops):
- global a, b, d
- if x > a or y > b or x < 0 or y < 0:
- return
- if ops < d.get((x, y), max):
- d[(x, y)] = ops
- else:
- return
- f(0, x + y, ops + 1)
- f(x + y, 0, ops + 1)
- f(x + y - b, b, ops + 1)
- f(a, x + y - a, ops + 1)
- f(a, y, ops + 1)
- f(x, b, ops + 1)
- f(0, y, ops + 1)
- f(x, 0, ops + 1)
- f(0, 0, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement