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

View file

@ -0,0 +1,56 @@
#include <iostream>
#include <set>
#include <string>
using namespace std;
class Point
{
public:
int x;
int y;
};
bool operator<(Point const &lhs, Point const &rhs)
{
if (lhs.x == rhs.x)
return lhs.y < rhs.y;
return lhs.x < rhs.x;
}
int main()
{
bool robo = false;
set<Point> delivered;
Point position{0, 0};
Point robo_position{0, 0};
delivered.insert(position);
while (!cin.eof())
{
switch (cin.get())
{
case '>':
++(robo ? robo_position : position).x;
break;
case '<':
--(robo ? robo_position : position).x;
break;
case '^':
--(robo ? robo_position : position).y;
break;
case 'v':
++(robo ? robo_position : position).y;
break;
}
robo = !robo;
delivered.insert(robo ? robo_position : position);
}
cout << "Delivered count: " << delivered.size() << "\n";
}