You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

46 lines
1014 B

#!/usr/bin/env python3
from blist import blist
def destination(c, out):
while True:
if c-1>0 and c-1 not in out:
return c-1, order.index(c-1)
else:
if c>1:
c = c-1
else:
c = highest+1
def move(order):
rem = order
a = rem.pop(1)
b = rem.pop(1)
c = rem.pop(1)
_, dest = destination(order[0], [a,b,c])
rem.insert(dest+1, a)
rem.insert(dest+2, b)
rem.insert(dest+3, c)
if __name__ == "__main__":
#test_order = [3,8,9,1,2,5,4,6,7]
order = blist([1,9,8,7,5,3,4,6,2])
for x in range(10,1000001):
order.append(x)
current_index = 0
lowest = min(order)
highest = 1000000
#highest = max(order)
for i in range(10000000):
print(i)
move(order)
current_index += 1
last = order.pop(0)
order.append(last)
order = order[order.index(1):] + order[:order.index(1)]
print(order)
print(order[1]*order[2])