summaryrefslogtreecommitdiff
path: root/25/main.py
diff options
context:
space:
mode:
authorPrefetch2022-12-31 22:21:39 +0100
committerPrefetch2022-12-31 22:21:39 +0100
commit68615a9ad2c942254135cffb00cf25a84a3b1356 (patch)
tree1ed3131f673207b2ef0bdaee3ee98bb68d6640ca /25/main.py
Initial commit
Diffstat (limited to '25/main.py')
-rwxr-xr-x25/main.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/25/main.py b/25/main.py
new file mode 100755
index 0000000..48ca1f7
--- /dev/null
+++ b/25/main.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+
+
+
+def coord_list(until):
+ return result
+
+
+
+def solve_part1(until):
+ # Generate a list of table (row, col) coordinates in the order
+ # that are filled by the algorithm described in the puzzle text.
+ coords = []
+ r = 1
+ c = 0
+ while (r, c) != until:
+ if r == 1:
+ r = c + 1
+ c = 1
+ else:
+ r -= 1
+ c += 1
+ coords.append((r, c))
+
+ code = 20151125 # first code is given
+ for i in range(1, len(coords)):
+ code *= 252533
+ code %= 33554393
+
+ return code
+
+
+
+def main():
+ # Read target coordinate from input text file
+ with open("input.txt", "r") as f:
+ words = f.read().split()
+ row = int(words[-3].rstrip(","))
+ col = int(words[-1].rstrip("."))
+ coord = (row, col)
+
+ print("Part 1 solution:", solve_part1(coord)) # 19980801 for me
+
+
+
+if __name__ == "__main__":
+ main()