11import pytest
22
3- from adventofcode .year_2023 .day_09_2023 import part_two , part_one , parse_input , parse_sequence , find_next_in_sequence
3+ from adventofcode .year_2023 .day_09_2023 import find_next_in_sequence , parse_input , parse_sequence , part_one , part_two
44
55test_input = [
66 "0 3 6 9 12 15" ,
99]
1010
1111
12- @pytest .mark .parametrize (["sequence" , "expected" ], [
13- ("0 3 6 9 12 15" , [0 , 3 , 6 , 9 , 12 , 15 ]),
14- ("1 3 6 10 15 21" , [1 , 3 , 6 , 10 , 15 , 21 ]),
15- ("10 13 16 21 30 45" , [10 , 13 , 16 , 21 , 30 , 45 ]),
16- ("-1 -20 -300 400" , [- 1 , - 20 , - 300 , 400 ]),
17- ("5 1 -3 -7 -11 -15 -19 -23 -27 -31 -35 -39 -43 -47 -51 -55 -59 -63 -67 -71 -75" , [5 , 1 , - 3 , - 7 , - 11 , - 15 , - 19 , - 23 , - 27 , - 31 , - 35 , - 39 , - 43 , - 47 , - 51 , - 55 , - 59 , - 63 , - 67 , - 71 , - 75 ]),
18- ])
12+ @pytest .mark .parametrize (
13+ ["sequence" , "expected" ],
14+ [
15+ ("0 3 6 9 12 15" , [0 , 3 , 6 , 9 , 12 , 15 ]),
16+ ("1 3 6 10 15 21" , [1 , 3 , 6 , 10 , 15 , 21 ]),
17+ ("10 13 16 21 30 45" , [10 , 13 , 16 , 21 , 30 , 45 ]),
18+ ("-1 -20 -300 400" , [- 1 , - 20 , - 300 , 400 ]),
19+ (
20+ "5 1 -3 -7 -11 -15 -19 -23 -27 -31 -35 -39 -43 -47 -51 -55 -59 -63 -67 -71 -75" ,
21+ [5 , 1 , - 3 , - 7 , - 11 , - 15 , - 19 , - 23 , - 27 , - 31 , - 35 , - 39 , - 43 , - 47 , - 51 , - 55 , - 59 , - 63 , - 67 , - 71 , - 75 ],
22+ ),
23+ ],
24+ )
1925def test_parse_sequence (sequence , expected ):
2026 assert list (parse_sequence (sequence )) == expected
2127
@@ -24,15 +30,89 @@ def test_parse_input():
2430 assert len (list (parse_input (test_input ))) == 3
2531
2632
27- @pytest .mark .parametrize (["sequence" , "expected" ], [
28- ([13 , 23 , 46 , 97 , 206 , 436 , 919 , 1924 , 3971 , 8016 , 15765 , 30243 , 56875 , 105604 , 195153 , 361805 , 677725 , 1289089 ,
29- 2494076 , 4898137 , 9713336 ], 19316320 ),
30- ([- 7 , 6 , 44 , 130 , 309 , 672 , 1404 , 2864 , 5712 , 11113 , 21082 , 39112 , 71386 , 129156 , 233312 , 422773 , 769075 ,
31- 1400300 , 2538072 , 4551386 , 8029995 ], 13877188
32- ),
33- ([5 , 1 , - 3 , - 7 , - 11 , - 15 , - 19 , - 23 , - 27 , - 31 , - 35 , - 39 , - 43 , - 47 , - 51 , - 55 , - 59 , - 63 , - 67 , - 71 , - 75 ,
34- ], - 79 )
35- ])
33+ @pytest .mark .parametrize (
34+ ["sequence" , "expected" ],
35+ [
36+ (
37+ [
38+ 13 ,
39+ 23 ,
40+ 46 ,
41+ 97 ,
42+ 206 ,
43+ 436 ,
44+ 919 ,
45+ 1924 ,
46+ 3971 ,
47+ 8016 ,
48+ 15765 ,
49+ 30243 ,
50+ 56875 ,
51+ 105604 ,
52+ 195153 ,
53+ 361805 ,
54+ 677725 ,
55+ 1289089 ,
56+ 2494076 ,
57+ 4898137 ,
58+ 9713336 ,
59+ ],
60+ 19316320 ,
61+ ),
62+ (
63+ [
64+ - 7 ,
65+ 6 ,
66+ 44 ,
67+ 130 ,
68+ 309 ,
69+ 672 ,
70+ 1404 ,
71+ 2864 ,
72+ 5712 ,
73+ 11113 ,
74+ 21082 ,
75+ 39112 ,
76+ 71386 ,
77+ 129156 ,
78+ 233312 ,
79+ 422773 ,
80+ 769075 ,
81+ 1400300 ,
82+ 2538072 ,
83+ 4551386 ,
84+ 8029995 ,
85+ ],
86+ 13877188 ,
87+ ),
88+ (
89+ [
90+ 5 ,
91+ 1 ,
92+ - 3 ,
93+ - 7 ,
94+ - 11 ,
95+ - 15 ,
96+ - 19 ,
97+ - 23 ,
98+ - 27 ,
99+ - 31 ,
100+ - 35 ,
101+ - 39 ,
102+ - 43 ,
103+ - 47 ,
104+ - 51 ,
105+ - 55 ,
106+ - 59 ,
107+ - 63 ,
108+ - 67 ,
109+ - 71 ,
110+ - 75 ,
111+ ],
112+ - 79 ,
113+ ),
114+ ],
115+ )
36116def test_find_next_in_sequence (sequence , expected ):
37117 assert find_next_in_sequence (sequence , []) == expected
38118
@@ -42,4 +122,4 @@ def test_part_one():
42122
43123
44124def test_part_two ():
45- assert part_two (test_input ) == 'x'
125+ assert part_two (test_input ) == "x"
0 commit comments