File tree Expand file tree Collapse file tree 4 files changed +76
-0
lines changed Expand file tree Collapse file tree 4 files changed +76
-0
lines changed Original file line number Diff line number Diff line change 1+ Day 1:
2+ 3
Original file line number Diff line number Diff line change 1+ L68
2+ L30
3+ R48
4+ L5
5+ R60
6+ L55
7+ L1
8+ L99
9+ R14
10+ L82
Original file line number Diff line number Diff line change 1+ /* *****************************************************************************
2+ * File: day01.cpp
3+ *
4+ * Author: Eric T. Johnson (yut23)
5+ * Created: 2025-12-01
6+ *****************************************************************************/
7+
8+ #include " day01.hpp"
9+ #include " lib.hpp"
10+ #include < fstream> // for ifstream
11+ #include < iostream> // for cout
12+
13+ int main (int argc, char **argv) {
14+ std::ifstream infile = aoc::parse_args (argc, argv).infile ;
15+
16+ auto rotations = aoc::day01::read_input (infile);
17+
18+ int dial = 50 ;
19+ int part1 = 0 ;
20+ for (const auto rot : rotations) {
21+ dial += rot;
22+ dial %= 100 ;
23+ if (dial == 0 ) {
24+ ++part1;
25+ }
26+ }
27+
28+ std::cout << part1 << " \n " ;
29+
30+ return 0 ;
31+ }
Original file line number Diff line number Diff line change 1+ /* *****************************************************************************
2+ * File: day01.hpp
3+ *
4+ * Author: Eric T. Johnson (yut23)
5+ * Created: 2025-12-01
6+ *****************************************************************************/
7+
8+ #ifndef DAY01_HPP_XFIW6CVE
9+ #define DAY01_HPP_XFIW6CVE
10+
11+ #include < iostream> // for istream
12+ #include < string> // for string, getline
13+ #include < vector> // for vector
14+
15+ namespace aoc ::day01 {
16+
17+ auto read_input (std::istream &is) {
18+ // read file line-by-line
19+ std::string line;
20+ std::vector<int > rotations;
21+ while (std::getline (is, line)) {
22+ int rotation = std::atoi (line.c_str () + 1 );
23+ if (line[0 ] == ' L' ) {
24+ rotation *= -1 ;
25+ }
26+ rotations.push_back (rotation);
27+ }
28+ return rotations;
29+ }
30+
31+ } // namespace aoc::day01
32+
33+ #endif /* end of include guard: DAY01_HPP_XFIW6CVE */
You can’t perform that action at this time.
0 commit comments