Skip to content

Commit 7fd30ab

Browse files
committed
finish 5kyu and rank up to 3 kyu
1 parent 79c3a17 commit 7fd30ab

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