summary refs log tree commit diff
path: root/22.20/main.py
diff options
context:
space:
mode:
authordzwdz2022-12-20 23:12:30 +0100
committerdzwdz2022-12-20 23:12:30 +0100
commit4b7e027f5ac3cf1f62f986573708f3a85aa1d955 (patch)
tree3894ed1788f3edb7f2b39ca38b6c7e6ab27538d8 /22.20/main.py
parent8cf452005e0c87ecb9cb98500f9dee2b2e479baa (diff)
day 20 part 1
Diffstat (limited to '22.20/main.py')
-rw-r--r--22.20/main.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/22.20/main.py b/22.20/main.py
new file mode 100644
index 0000000..7cb46de
--- /dev/null
+++ b/22.20/main.py
@@ -0,0 +1,16 @@
+from sys import stdin
+a = [int(n) for n in stdin.readlines()]
+
+p = list(range(len(a)))
+
+for i, n in enumerate(a):
+    og_idx = p.index(i)
+    p.pop(og_idx)
+    og_idx = (og_idx + n) % len(p)
+    if og_idx == 0 and n < 0: og_idx = len(p)
+    p.insert(og_idx, i)
+
+a = [a[i] for i in p]
+def g(n): return a[(a.index(0) + n) % len(a)]
+
+print(g(1000) + g(2000) + g(3000))