From 68615a9ad2c942254135cffb00cf25a84a3b1356 Mon Sep 17 00:00:00 2001 From: Prefetch Date: Sat, 31 Dec 2022 22:21:39 +0100 Subject: Initial commit --- 25/main.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 25/main.py (limited to '25/main.py') 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() -- cgit v1.2.3