sibinasto

Hot Potato

Jul 9th, 2022
1,071
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. def hot_potato(kids, turn, index):
  2.     if len(kids) == 1:
  3.         print(f'Last is {kids.pop()}')
  4.         return
  5.     index = (index + n - 1) % len(kids)
  6.     print(f'Removed {kids.pop(index)}')
  7.     hot_potato(kids, n, index)
  8.  
  9.  
  10. kids = list(input().split(' '))
  11. n = int(input())
  12. hot_potato(kids, n, 0)
Advertisement
Add Comment
Please, Sign In to add comment