File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed
Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 11.cache /
22build /
3- .vscode /
3+ .vscode /
4+ * .swp
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ namespace AdventOfCode24 ::Day2 {
4+ const int BUFFER_SIZE{1024 };
5+ bool is_safe (std::istringstream line);
6+ };
Original file line number Diff line number Diff line change 1+ #include " advenr_of_code/day_2.hxx"
2+
3+ namespace AdventOfCode24 ::Day2 {
4+ bool safe_pair (int val_1, int val_2, int direction) {
5+ const int interval{val_2 - val_1};
6+ const int abs_interval{std::abs (interval)};
7+
8+
9+ if (direction > 0 && val_2 - val_1 <= 0 ) {
10+ return false ;
11+ }
12+ else if (direction < 0 && val_2 - val_1 >= 0 ) {
13+ return false ;
14+ }
15+ }
16+ bool level_is_safe (std::istringstream line) {
17+ std::string element;
18+ int previous{-1 };
19+ int direction{0 };
20+
21+
22+ while (std::getline (line, element, ' ' )) {
23+ if (element.empty ()) continue ;
24+
25+ const int number{std::stoi (element)};
26+
27+ if (previous > -1 ) {
28+ if (direction >
29+ }
30+ }
31+ };
You can’t perform that action at this time.
0 commit comments