Skip to content

Commit a77bfef

Browse files
committed
partial day 23
1 parent 1966f13 commit a77bfef

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

day23/main.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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])

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy