feat: add solution 2025/01
This commit is contained in:
10
data/example/2025/01.txt
Normal file
10
data/example/2025/01.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
L68
|
||||||
|
L30
|
||||||
|
R48
|
||||||
|
L5
|
||||||
|
R60
|
||||||
|
L55
|
||||||
|
L1
|
||||||
|
L99
|
||||||
|
R14
|
||||||
|
L82
|
||||||
0
src/solution/year_2025/__init__.py
Normal file
0
src/solution/year_2025/__init__.py
Normal file
26
src/solution/year_2025/day_01.py
Normal file
26
src/solution/year_2025/day_01.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
|
def part_1_2(input_data) -> Any:
|
||||||
|
d = 50
|
||||||
|
|
||||||
|
c1 = 0
|
||||||
|
c2 = 0
|
||||||
|
|
||||||
|
for line in input_data.splitlines():
|
||||||
|
dir = 1 if line[0] == "L" else -1
|
||||||
|
val = int(line[1:])
|
||||||
|
|
||||||
|
for _ in range(val):
|
||||||
|
d = (d + dir) % 100
|
||||||
|
if d == 0:
|
||||||
|
c2 += 1
|
||||||
|
|
||||||
|
if d == 0:
|
||||||
|
c1 += 1
|
||||||
|
|
||||||
|
return c1, c2
|
||||||
|
|
||||||
|
|
||||||
|
def test_part_1_2(example_data) -> None:
|
||||||
|
assert part_1_2(example_data) == (3, 6)
|
||||||
Reference in New Issue
Block a user