Skip to content

Commit 3931568

Browse files
committed
Merge branch 'master' of https://github.com/sdwh/codewarsPython
2 parents a6aadcd + 7fd30ab commit 3931568

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

[5 kyu]josephus survivor

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def josephus_survivor(n,k):
2+
res = [i for i in range(1,n+1)]
3+
current = (k-1) % len(res)
4+
5+
while len(res) > 1:
6+
res = res[:current] + res[current+1:]
7+
current = (current + k - 1) % len(res)
8+
return res[0]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy