summaryrefslogtreecommitdiff
path: root/25
diff options
context:
space:
mode:
authorPrefetch2022-12-31 22:21:39 +0100
committerPrefetch2022-12-31 22:21:39 +0100
commit68615a9ad2c942254135cffb00cf25a84a3b1356 (patch)
tree1ed3131f673207b2ef0bdaee3ee98bb68d6640ca /25
Initial commit
Diffstat (limited to '25')
-rw-r--r--25/input.txt1
-rwxr-xr-x25/main.py47
-rwxr-xr-x25/test.py17
3 files changed, 65 insertions, 0 deletions
diff --git a/25/input.txt b/25/input.txt
new file mode 100644
index 0000000..c5c38e6
--- /dev/null
+++ b/25/input.txt
@@ -0,0 +1 @@
+To continue, please consult the code grid in the manual. Enter the code at row 2947, column 3029.
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()
diff --git a/25/test.py b/25/test.py
new file mode 100755
index 0000000..5b34e3e
--- /dev/null
+++ b/25/test.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+import unittest
+
+import main
+
+
+
+class ExamplesPart1(unittest.TestCase):
+ def test_example1(self):
+ until = (1, 6)
+ self.assertEqual(main.solve_part1(until), 33511524)
+
+
+
+if __name__ == "__main__":
+ unittest.main()