advent-of-code/src/holt59/aoc/2015/day25.py
Mikaël Capelle 91ba8ec86f
Some checks failed
continuous-integration/drone/push Build is failing
2015 day 25.
2024-12-14 21:02:23 +01:00

17 lines
493 B
Python

import re
from typing import Any, Iterator
from ..base import BaseSolver
from ..tools.math import pow_mod
class Solver(BaseSolver):
def solve(self, input: str) -> Iterator[Any]:
m = re.search(r"row\s*([0-9]+)\s*,\s*column\s*([0-9]+)", input)
assert m is not None
row, col = int(m.group(1)), int(m.group(2))
n = (row * (row - 1)) // 2 + col * (col + 1) // 2 + (row - 1) * (col - 1)
yield (20151125 * pow_mod(252533, n - 1, 33554393)) % 33554393