Added day 1 & day 2
This commit is contained in:
commit
f9c3c61ef7
8 changed files with 3137 additions and 0 deletions
30
solutions/02B.cpp
Normal file
30
solutions/02B.cpp
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue