about summary refs log tree commit diff
path: root/day05.cc
diff options
context:
space:
mode:
Diffstat (limited to 'day05.cc')
-rw-r--r--day05.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/day05.cc b/day05.cc
new file mode 100644
index 0000000..a5af122
--- /dev/null
+++ b/day05.cc
@@ -0,0 +1,20 @@
+#include <iostream>
+#include <iterator>
+#include <vector>
+
+using namespace std;
+
+int
+main() {
+	vector<int> v{istream_iterator<int>(cin), {}};
+	auto w = v;
+	int p1 = 0, p2 = 0;
+
+	for (unsigned int pc = 0; pc < v.size(); p1++)
+		pc += v[pc]++;
+
+	for (unsigned int pc = 0; pc < v.size(); p2++)
+		pc += w[pc] >= 3 ? w[pc]-- : w[pc]++;
+
+	cout << p1 << endl << p2 << endl;
+}