fork download
  1. n = 10
  2. k = 3
  3.  
  4. people = list(range(1, n+1))
  5. print(people)
  6.  
  7. i = k - 1
  8. while len(people) > 1:
  9. print(people[i])
  10. people.pop(i)
  11. i = (i + k - 1) % len(people)
  12.  
  13. print("Survivor: " + str(people[0]))
Success #stdin #stdout 0.03s 9644KB
stdin
Standard input is empty
stdout
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
3
6
9
2
7
1
8
5
10
Survivor: 4