Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 100 people stay in circle, first have sword and kill second,
- # and he gives sword to next one (third) which kills next one (forth), etc.
- # Finally last only one. Which one ?
- data = list(range(1, 101))
- position = 1 # first killed (not first killing) - it is list index (which starts at 0), not person number (which start at 1)
- while len(data) > 1:
- print('killed:', data.pop(position))
- position = (position+1) % len(data)
- print('last:', data[0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement