about summary refs log tree commit diff
path: root/day11.cc
diff options
context:
space:
mode:
Diffstat (limited to 'day11.cc')
-rw-r--r--day11.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/day11.cc b/day11.cc
new file mode 100644
index 0000000..9c51591
--- /dev/null
+++ b/day11.cc
@@ -0,0 +1,28 @@
+#include <algorithm>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+using namespace std;
+
+int
+main() {
+	string sym;
+	int x{0}, y{0}, d{0}, maxd{0};
+
+	while (getline(cin, sym, ',')) {
+		if (cin.eof()) sym.pop_back();
+
+		if      (sym == "n" ) x--;
+		else if (sym == "s" ) x++;
+		else if (sym == "se")      y++;
+		else if (sym == "nw")      y--;
+		else if (sym == "ne") x--, y++;
+		else if (sym == "sw") x++, y--;
+
+		maxd = max(maxd, d = max({x,-x,y,-y,x+y,-x-y}));
+	}
+
+	cout << d << endl << maxd << endl;
+}