solved part 1

master
Jeff Yates 2020-12-09 08:59:14 -05:00
parent 2d3194a653
commit bee31dafb9
1 changed files with 20 additions and 0 deletions

20
day08/solution1.rb Executable file
View File

@ -0,0 +1,20 @@
#!/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