Skip to content

Commit 6a9fcf6

Browse files
solution: add 2015 day 25
1 parent dba96a0 commit 6a9fcf6

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from typing import List
2+
3+
from adventofcode.util.exceptions import SolutionNotFoundException
4+
from adventofcode.util.helpers import solution_timer
5+
from adventofcode.util.input_helpers import get_input_for_day
6+
7+
mul = 252533
8+
mod = 33554393
9+
10+
11+
def get_next_code(current_code: int, coords: tuple[int, int]) -> int:
12+
x, y = 1, 1
13+
want_x, want_y = coords
14+
15+
while True:
16+
if y == 1:
17+
y = x + 1
18+
x = 1
19+
else:
20+
y -= 1
21+
x += 1
22+
23+
current_code = (current_code * mul) % mod
24+
25+
if x == want_x and y == want_y:
26+
return current_code
27+
28+
29+
@solution_timer(2015, 25, 1)
30+
def part_one(_: List[str]):
31+
row = 2978
32+
column = 3083
33+
answer = get_next_code(20151125, (column, row))
34+
35+
if not answer:
36+
raise SolutionNotFoundException(2015, 25, 1)
37+
38+
return answer
39+
40+
41+
@solution_timer(2015, 25, 2)
42+
def part_two(input_data: List[str]):
43+
answer = 'hooray'
44+
45+
if not answer:
46+
raise SolutionNotFoundException(2015, 25, 2)
47+
48+
return answer
49+
50+
51+
if __name__ == '__main__':
52+
data = get_input_for_day(2015, 25)
53+
part_one(data)
54+
part_two(data)

0 commit comments

Comments
 (0)