added code to solve part 2

master^2
Jeff Yates 2020-12-15 09:59:07 -05:00
parent 2330820811
commit 7574cfa2ae
1 changed files with 3 additions and 1 deletions

View File

@ -3,7 +3,9 @@ require 'pry'
numbers = File.read('./input').split(',') numbers = File.read('./input').split(',')
numbers.map!(&:to_i) numbers.map!(&:to_i)
2020.times do |i| runs = 30000000
runs.times do |i|
next if i < numbers.size next if i < numbers.size
num = numbers[-1] num = numbers[-1]
prev_turn = numbers[..-2].reverse.find_index(num) prev_turn = numbers[..-2].reverse.find_index(num)