Day 1 solved
This commit is contained in:
18
Day1/Question1/main.cpp
Normal file
18
Day1/Question1/main.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main() {
|
||||
std::fstream inputFile("input");
|
||||
std::string currentLine;
|
||||
int16_t counter = 50, number = 0, password = 0;
|
||||
|
||||
while (std::getline(inputFile, currentLine)) {
|
||||
number = std::stoi(currentLine.substr(1));
|
||||
counter = (counter + ((currentLine[0] == 'L') * 2 - 1) * number) % 100;
|
||||
password += counter == 0 ? 1 : 0;
|
||||
}
|
||||
std::cout << password << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user