Advertisement
viligen

josephus_permutation

Oct 5th, 2021
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. list_ppl = input().split()
  2. step = int(input())
  3.  
  4. output_list = []
  5. i = 0
  6. while len(list_ppl) != 0:
  7.    
  8.     i += step - 1
  9.    
  10.     i = i % len(list_ppl)
  11.     output_list.append(list_ppl[i])
  12.     list_ppl.pop(i)
  13.    
  14. print(f"[{','.join(output_list)}]")
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement