Added day 1 & day 2

This commit is contained in:
Hugo Mårdbrink 2021-12-02 13:39:35 +01:00
commit f9c3c61ef7
8 changed files with 3137 additions and 0 deletions

30
solutions/02B.cpp Normal file
View file

@ -0,0 +1,30 @@
#include <iostream>
#include <fstream>
#include <string>
int main()
{
std::ifstream inputFile("../input/02.txt");
std::string input;
long h,d,a = 0;
while(std::getline(inputFile, input))
{
input.pop_back();
int val = input.back() - 48;
switch(input.front())
{
case 'f': d += a * val;
h += val; break;
case 'u': a -= val; break;
case 'd': a += val; break;
}
}
inputFile.close();
std::cout << d*h << std::endl;
return 0;
}