Added older advents

This commit is contained in:
Jos van Goor 2022-12-01 13:46:47 +01:00
parent 8db2505049
commit 9cf858b860
78 changed files with 13807 additions and 0 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,18 @@
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string buffer;
while(getline(cin, buffer))
{
int up = count(buffer.begin(), buffer.end(), '(');
int down = count(buffer.begin(), buffer.end(), ')');
cout << "Floor: " << up - down << "\n";
}
}

View file

@ -0,0 +1,27 @@
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string buffer;
while(getline(cin, buffer))
{
int floor = 0;
for (size_t idx = 0; idx != buffer.size(); ++idx)
{
floor += buffer[idx] == '(' ? 1 : -1;
if (floor == -1)
{
cout << "Entered basement in step " << idx + 1 << "\n";
return 0;
}
}
}
}