Added older advents
This commit is contained in:
parent
8db2505049
commit
9cf858b860
78 changed files with 13807 additions and 0 deletions
53
advent_of_code_2015/day3/main1.cc
Normal file
53
advent_of_code_2015/day3/main1.cc
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#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()
|
||||
{
|
||||
set<Point> delivered;
|
||||
Point position{0, 0};
|
||||
delivered.insert(position);
|
||||
|
||||
while (!cin.eof())
|
||||
{
|
||||
switch (cin.get())
|
||||
{
|
||||
case '>':
|
||||
++position.x;
|
||||
break;
|
||||
|
||||
case '<':
|
||||
--position.x;
|
||||
break;
|
||||
|
||||
case '^':
|
||||
--position.y;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
++position.y;
|
||||
break;
|
||||
}
|
||||
|
||||
delivered.insert(position);
|
||||
}
|
||||
|
||||
cout << "Delivered count: " << delivered.size() << "\n";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue