AoC2020/day08/solution1.rb

20 lines
387 B
Ruby
Executable File

#!/bin/env ruby
input = File.readlines('./input').to_ary.map(&:strip)
acc = 0
tracker = Array.new(input.length, false)
i = 0
while tracker[i] == false do
tracker[i] = true
case input[i][0..2]
when 'acc'
acc += input[i].split(' ')[1].to_i
i += 1
when 'jmp'
i += input[i].split(' ')[1].to_i
when 'nop'
i += 1
end
end
p acc, tracker