热土豆/约瑟夫问题
# 热土豆/约瑟夫问题
def func1(s: list, n: int):
temp = []
while len(s) > 0:
if len(s) > 1:
for i in range(n):
s.append(s.pop(0))
temp.append(s.pop())
return temp
if __name__ == '__main__':
s = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k']
n = 4
print(func1(s, n))
# 输出结果:['d', 'h', 'b', 'g', 'c', 'k', 'j', 'a', 'f', 'e']