#!/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()