-
解决Codewars网站上的Josephus Survivor问题,即Josephus_Survivor!
资源介绍
约瑟夫斯幸存者
在此kata中,您必须正确返回谁是“幸存者”,即: 的最后一个元素。
基本上,您必须假设将n个人围成一个圈,并按照k个元素的步骤将其消除,如下所示:
josephus_survivor(7,3) => means 7 people in a circle;
one every 3 is eliminated until one remains
[1,2,3,4,5,6,7] - initial sequence
[1,2,4,5,6,7] => 3 is counted out
[1,2,4,5,7] => 6 is counted out
[1,4,5,7] => 2 is counted out
[1,4,5] => 7 is counted out
[1,4] => 5 is counted out
[4] => 1 counted out, 4 is the l
- 上一篇: Win2khw移机工具
- 下一篇: XP电脑维护工具箱绿色版