Skip to content

Commit 2e91267

Browse files
committed
Started Day 2
1 parent ff35a79 commit 2e91267

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.cache/
22
build/
3-
.vscode/
3+
.vscode/
4+
*.swp

include/advent_of_code/day_2.hxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
namespace AdventOfCode24::Day2 {
4+
const int BUFFER_SIZE{1024};
5+
bool is_safe(std::istringstream line);
6+
};

src/day_2.cxx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
};

0 commit comments

Comments
 (0)