From 487c3425a23ef52c6de3c045f1110d5e7342d042 Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Tue, 22 Oct 2019 18:40:19 +0100 Subject: Day 14, part 2 not working (very slow) --- day14/part1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 day14/part1 (limited to 'day14/part1') diff --git a/day14/part1 b/day14/part1 new file mode 100755 index 0000000..2f46375 --- /dev/null +++ b/day14/part1 @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby + +input = $stdin.readlines[0].strip.to_i + +scores = [3, 7] +elf1 = 0 +elf2 = 1 + +loop do + se1 = scores[elf1] + se2 = scores[elf2] + + sum = se1 + se2 + scores += sum.to_s.chars.map(&:to_i) + + slen = scores.length + + elf1 = (elf1 + 1 + se1) % slen + elf2 = (elf2 + 1 + se2) % slen + + break if slen > (input + 10) +end + +puts scores[input...(input+10)].join -- cgit v1.2.3