@@ -134,27 +134,29 @@ std::string get_path(std::string path, std::map<char, Pos> char_to_pos, std::map
134134 return output_path;
135135}
136136
137- int part1 (const Data &data)
138- {
139- int n_robots = 2 ;
140- int sum = 0 ;
137+ int64_t press_keys (const Data& data, int n_robots) {
138+ int64_t sum = 0 ;
141139 for (const auto & code : data.codes ) {
142- int val = std::stoi (code.substr (0 , code.size () - 1 ));
140+ int64_t val = std::stoi (code.substr (0 , code.size () - 1 ));
143141 auto numeric_path = get_path (code, numeric_keyapd_char_to_pos, numeric_shortest_paths, numeric_keypad);
144142 std::string directional_path = numeric_path;
145143 for (int i = 0 ; i < n_robots; ++i) {
146144 directional_path = get_path (directional_path, directional_keyapd_char_to_pos, directional_shortest_paths, directional_keypad);
147145 }
148- std::cout << std::format (" {}: {} ({} * {})\n " , code, directional_path, directional_path.size (), val);
149146 sum += val * directional_path.size ();
150147 }
151148
152149 return sum;
153150}
154151
155- int part2 (const Data &data)
152+ int64_t part1 (const Data &data)
153+ {
154+ return press_keys (data, 2 );
155+ }
156+
157+ int64_t part2 (const Data &data)
156158{
157- return 0 ;
159+ return press_keys (data, 25 ) ;
158160}
159161
160162Data parse ()
@@ -210,8 +212,8 @@ int main(int argc, char **argv)
210212{
211213 Data data = parse ();
212214
213- int answer1 = 176452 ;
214- int answer2 = 0 ;
215+ int64_t answer1 = 176452 ;
216+ int64_t answer2 = 0 ;
215217
216218 auto first = part1 (data);
217219 std::cout << " Part 1: " << first << std::endl;
0 commit comments