about summary refs log tree commit diff
path: root/day05.cc
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-12-06 13:38:53 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-12-06 13:38:53 +0100
commit89d3deb836bf6bb0f314e18755f7301517112198 (patch)
tree140e64d4f90e17d1ba5f1206ec000b0210c51994 /day05.cc
parent25ec91e725bdf495722034a0331c77d45ab9b266 (diff)
downloadadventofcode2017-89d3deb836bf6bb0f314e18755f7301517112198.tar.gz
adventofcode2017-89d3deb836bf6bb0f314e18755f7301517112198.tar.xz
adventofcode2017-89d3deb836bf6bb0f314e18755f7301517112198.zip
day05
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;
+}