aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-12-18 23:25:35 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-12-18 23:25:35 +0100
commit301c154d3eaa03a673f0ced1c94a623fe9d6e39e (patch)
treebc883df72df82b9503a5e4c3b97e3dc682c052e7
parente3be85a6ed2e17e034d4686d85824238c547d61c (diff)
downloadadventofcode2017-301c154d3eaa03a673f0ced1c94a623fe9d6e39e.tar.gz
adventofcode2017-301c154d3eaa03a673f0ced1c94a623fe9d6e39e.tar.xz
adventofcode2017-301c154d3eaa03a673f0ced1c94a623fe9d6e39e.zip
day17
-rw-r--r--day171
-rw-r--r--day17.cc26
-rw-r--r--day17.k5
3 files changed, 32 insertions, 0 deletions
diff --git a/day17 b/day17
new file mode 100644
index 0000000..d3824c2
--- /dev/null
+++ b/day17
@@ -0,0 +1 @@
+324
diff --git a/day17.cc b/day17.cc
new file mode 100644
index 0000000..8d55407
--- /dev/null
+++ b/day17.cc
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <vector>
+#include <algorithm>
+
+using namespace std;
+
+int
+main()
+{
+ int d;
+ cin >> d;
+
+ vector<int> v{0};
+ v.reserve(2018);
+ for (int i = 1; i <= 2017; i++) {
+ rotate(begin(v), begin(v) + d % size(v), end(v));
+ v.push_back(i);
+ }
+
+ long p2;
+ for (long l = 1, p = 0; l < 50'000'000; p = (p + 1 + d) % ++l)
+ if (p == 0)
+ p2 = l;
+
+ cout << v[0] << endl << p2 << endl; // 1306 20430489
+}
diff --git a/day17.k b/day17.k
new file mode 100644
index 0000000..caa89d2
--- /dev/null
+++ b/day17.k
@@ -0,0 +1,5 @@
+d:.*0:`day17
+*(,0){(x@(#x)!d+!#x),y}/1+!2017 / 1306
+-1+*50000000{(*x|n*~x 1;n!d+1+x 1;1+n:x 2)}/0 0 1 / 20430489
+
+