aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Lasseter <Nat Lasseter nathan@bytemark.co.uk>2017-12-19 18:08:19 +0000
committerNat Lasseter <Nat Lasseter nathan@bytemark.co.uk>2017-12-19 18:08:19 +0000
commit232acc5d33fb30a12bd7d604c0cc96d62136c9ea (patch)
tree4b32713f95eb535672f61dcd13cb59b0f8c850ee
parentdbb4a9a351e95e4af223b7324b0795124c2b8cd9 (diff)
Runtime unacceptably longday17
-rwxr-xr-xday17/part214
1 files changed, 14 insertions, 0 deletions
diff --git a/day17/part2 b/day17/part2
new file mode 100755
index 0000000..09fdd88
--- /dev/null
+++ b/day17/part2
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+
+input = gets.chomp.to_i
+
+buf = [0]
+pos = 0
+
+50_000_000.times do |num|
+ p num if num % 100000 == 0
+ pos = ((pos + input) % buf.length) + 1
+ buf.insert(pos, num + 1)
+end
+
+puts buf[buf.index(0) + 1]