File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ # for is_part1 in [True, False]:
3
+ for is_part1 in [True , False ]:
4
+ # n = [int(i) for i in "476138259"]
5
+ n = [int (i ) for i in "389125467" ]
6
+
7
+ if not is_part1 :
8
+ n += list (range (10 , 1_000_001 ))
9
+
10
+ if is_part1 :
11
+ n_moves = 100
12
+ else :
13
+ n_moves = 10_000_000
14
+
15
+ l = len (n )
16
+ idx = 0
17
+ for move in range (n_moves ):
18
+ if move % 100 == 0 :
19
+ print (move , end = " " , flush = True )
20
+
21
+ curr = n [idx ]
22
+ i = (idx + 1 ) % l
23
+ sel = []
24
+ for _ in range (3 ):
25
+ sel .append (n [i ])
26
+ i = (i + 1 ) % l
27
+
28
+ for e in sel :
29
+ n .remove (e )
30
+
31
+ dest = curr
32
+ while True :
33
+ dest -= 1
34
+ if dest == 0 :
35
+ dest = l
36
+ if dest not in sel :
37
+ break
38
+
39
+ pos = n .index (dest ) + 1
40
+ n = n [:pos ] + sel + n [pos :]
41
+ idx = (n .index (curr ) + 1 ) % l
42
+
43
+ print ()
44
+ oneidx = n .index (1 )
45
+ if is_part1 :
46
+ print ("" .join ([str (c ) for c in n [oneidx + 1 :]+ n [:oneidx ]]))
47
+ else :
48
+ print (n [oneidx + 1 ]* n [oneidx + 2 ])
You can’t perform that action at this time.
0 commit comments