This commit is contained in:
2025-12-02 16:15:18 +01:00
parent cb3b5e2569
commit 5cbcebf443
8 changed files with 4903 additions and 0 deletions

43
src/main.cpp Normal file
View File

@@ -0,0 +1,43 @@
#include <iostream>
#include "fmt/base.h"
#include <fstream>
#include <iterator>
#include <string>
#include <vector>
int main() {
std::vector<std::string> rotations;
int currentPos { 50 };
int zeroCount { 0 };
// Step 1: Read file
std::ifstream file("src/rotations.txt");
std::string line;
if (!file) {
fmt::print("Sex");
return 1;
}
while (std::getline(file, line)) {
rotations.push_back(line);
}
for (const auto& rotation : rotations) {
char direction = rotation[0];
int distance = std::stoi(rotation.substr(1));
if (direction == 'L') {
currentPos = (currentPos - distance + 100) % 100;
} else {
currentPos = (currentPos + distance) % 100;
}
if (currentPos == 0) {
zeroCount++;
}
}
fmt::print("{}\n", zeroCount);
}

4510
src/rotations.txt Normal file

File diff suppressed because it is too large Load Diff