From 232acc5d33fb30a12bd7d604c0cc96d62136c9ea Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Tue, 19 Dec 2017 18:08:19 +0000 Subject: Runtime unacceptably long --- day17/part2 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 day17/part2 (limited to 'day17/part2') 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] -- cgit v1.2.3