commit f3ae7216c3204022df7f93a55d8953a2522a9711 Author: Reimar Date: Mon Dec 15 14:27:48 2025 +0100 Solve day 1 part 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ef8157 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +input.txt +.idea/ +day_* +!*.cpp diff --git a/day_1.cpp b/day_1.cpp new file mode 100644 index 0000000..4a98f29 --- /dev/null +++ b/day_1.cpp @@ -0,0 +1,31 @@ +#include +#include + +int main() +{ + int dial = 50; + int password = 0; + + std::ifstream file("input.txt"); + std::string line; + + while (getline(file, line)) { + int delta = std::stoi(line.substr(1)); + + switch (line[0]) { + case 'L': + dial -= delta; + while (dial < 0) dial += 100; + break; + case 'R': + dial = (dial + delta) % 100; + break; + } + + if (dial == 0) password++; + } + + std::cout << password << std::endl; + + return 0; +}