Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2012
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. a = 7
  2. b = 11
  3. d = {}
  4.  
  5. def f(x, y, ops):
  6. global a, b, d
  7. if x > a or y > b or x < 0 or y < 0:
  8. return
  9. if ops < d.get((x, y), max):
  10. d[(x, y)] = ops
  11. else:
  12. return
  13. f(0, x + y, ops + 1)
  14. f(x + y, 0, ops + 1)
  15. f(x + y - b, b, ops + 1)
  16. f(a, x + y - a, ops + 1)
  17. f(a, y, ops + 1)
  18. f(x, b, ops + 1)
  19. f(0, y, ops + 1)
  20. f(x, 0, ops + 1)
  21.  
  22. f(0, 0, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement