Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. def lastStanding(n):
  2. start = 1
  3. d = 2
  4. end = n
  5.  
  6. while True:
  7. if (end - start) % d == 0:
  8. start += d
  9. else:
  10. end = end - (d / 2)
  11. print start, end, d
  12.  
  13. d *= 2
  14.  
  15. if start == end:
  16. print 'Done: %d' % start
  17. break
  18.  
  19. if start + d > end:
  20. print 'Done: %d' % start
  21. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement