Advertisement
PowerCell46

Josephus Permutation Python

Jan 6th, 2023
1,042
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. list_of_nums = input().split()
  2. rotation = int(input())
  3. index = 0
  4. list_of_killed_people = []
  5.  
  6. while len(list_of_nums) > 0:
  7.     index += (rotation - 1)
  8.     while index >= len(list_of_nums):
  9.         index -= len(list_of_nums)
  10.     list_of_killed_people.append((list_of_nums.pop(index)))
  11.  
  12.  
  13. print(f'[{",".join(list_of_killed_people)}]')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement