1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
def part1(row, col): row -= 1 col -= 1 n = row + col n = n * (n + 1) // 2 + col code = 20151125 for i in range(n): code = code * 252533 % 33554393 return code if __name__ == '__main__': row = 2978 col = 3083 print(part1(1, 1)) print(part1(3, 4)) print(part1(row, col))