问题描述
我寻找一个快速的方法来执行我的问题。
I search a fast method to perform my problem.
想象从1 numeroted至8有序的座位,想象他们是人的座位[2,6,5,3]。我希望人们以后的座位号4(初始值)
imagine ordered seats numeroted from 1 to 8, imagine they are people on seats [ 2, 6, 5, 3 ]. i want to get back the second (interval +2) people after the seat number 4 (start value)
有关的例子:
这个数组: [2,5,8,7,1] 后,我开始与值 3 我移动 +2 次,
在列表中的下一个三号码是5,第二个是的 7 ,该方法必须返回该值
with this array : [2, 5, 8, 7, 1] , i started with value 3 and i move +2 times,the third next number in the list is 5, the second is 7, the method must return this value
以相同的 [2,5,8,7,1] ,我从开始的 7 我移动 +3 倍
这里的方法必须返回到最小值。 trought 8。1。2 ..,结果是: 2
with the same [2, 5, 8, 7, 1] , i started from 7 and i move +3 timeshere the method must return to the minimal value. trought 8.. 1.. 2.., result : 2
是 [1,3] ,启动 4 ,计数 +2 ,结果 3
with [1, 3], start 4, count +2, result 3
是 [5,3,9] ,启动 3 ,计数 +1 ,结果 5
with [5, 3, 9], start 3, count +1, result 5
是 [5,3,9] ,启动 3 ,计数 +2 ,结果 9
with [5, 3, 9], start 3, count +2, result 9
我希望有人会明白我的问题。
感谢您
I hope someone will understand my problem.thanks you
推荐答案
排序列表,使用找到起始索引,那么国防部增加了列表的长度的结果。
Sort your list, use bisect
to find the starting index, then mod the result of the addition by the length of the list.
这篇关于获取在遵循一个初始值从区间无序直一些的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!