22from advent_of_code .year_2025 .day_01 import (
33 solve ,
44 turn_dial ,
5- position_counter ,
5+ target_position_counter ,
6+ points_at_zero_counter ,
67)
78
89
@@ -32,16 +33,16 @@ def test_solver(day_01_test_input, day_01_expected_output):
3233 assert result == day_01_expected_output
3334
3435@pytest .fixture (params = [
35- (50 , - 1 , 68 , 82 , 0 , 1 ),
36- (82 , - 1 , 30 , 52 , 0 , 0 ),
37- (52 , 1 , 48 , 0 , 1 , 1 ),
38- (0 , - 1 , 5 , 95 , 0 , 0 ),
39- (95 , 1 , 60 , 55 , 0 , 1 ),
40- (55 , - 1 , 55 , 0 , 1 , 1 ),
41- (0 , - 1 , 1 , 99 , 0 , 0 ),
42- (99 , - 1 , 99 , 0 , 1 , 1 ),
43- (0 , 1 , 14 , 14 , 0 , 0 ),
44- (14 , - 1 , 82 , 32 , 0 , 1 ),
36+ (50 , - 1 , 68 , 82 , 0 , 1 ), # case 0
37+ (82 , - 1 , 30 , 52 , 0 , 0 ), # case 1
38+ (52 , 1 , 48 , 0 , 1 , 1 ), # case 2
39+ (0 , - 1 , 5 , 95 , 0 , 0 ), # case 3
40+ (95 , 1 , 60 , 55 , 0 , 1 ), # case 4
41+ (55 , - 1 , 55 , 0 , 1 , 1 ), # case 5
42+ (0 , - 1 , 1 , 99 , 0 , 0 ), # case 6
43+ (99 , - 1 , 99 , 0 , 1 , 1 ), # case 7
44+ (0 , 1 , 14 , 14 , 0 , 0 ), # case 8
45+ (14 , - 1 , 82 , 32 , 0 , 1 ), # case 9
4546 ],
4647)
4748def turn_case (request ):
@@ -57,25 +58,27 @@ def test_turn_dial(turn_case):
5758 assert new_position == expected_new_position
5859
5960
60- def test_position_counter (turn_case ):
61+ def test_target_position_counter (turn_case ):
6162 _ , _ , _ , expected_new_position , expected_count , _ = turn_case
62- actual_count = position_counter (expected_new_position )
63+ actual_count = target_position_counter (expected_new_position )
6364 assert actual_count == expected_count
6465
66+ def test_points_at_zero_counter (turn_case ):
67+ current_position , turn_direction , distance , _ , _ , expected_count = turn_case
68+ actual_count = points_at_zero_counter (current_position , turn_direction , distance )
69+ assert actual_count == expected_count
6570
66- # @pytest.mark.parametrize(
67- # "start_position, turn_direction, distance, expected_count",
68- # [
69- # (50, 1, 1000, 10),
70- # # (50, 1, 49, 0),
71- # # (50, -1, 49, 0),
72- # # (50, -1, 50, 1),
73- # # (50, -1, 51, 1),
74- # # (99, 1, 1, 1),
75- # # (99, -1, 1, 0),
76- # # (0, 1, 100, 1),
77- # ]
78- # )
79- # def test_passing_zero_counter(start_position, turn_direction, distance, expected_count):
80- # count = passing_zero_counter(start_position, turn_direction, distance)
81- # assert count == expected_count
71+ @pytest .mark .parametrize (
72+ "start_position, turn_direction, distance, expected_count" ,
73+ [
74+ (50 , 1 , 1000 , 10 ),
75+ (50 , 1 , 1050 , 11 ),
76+ (0 , 1 , 100 , 1 ),
77+ (0 , 1 , 1 , 0 ),
78+ (50 , - 1 , 68 , 1 ),
79+ (50 , 1 , 68 , 1 ),
80+ ]
81+ )
82+ def test_points_at_zero_counter_extra_test_cases (start_position , turn_direction , distance , expected_count ):
83+ count = points_at_zero_counter (start_position , turn_direction , distance )
84+ assert count == expected_count
0 commit comments