solved part 1
parent
2d3194a653
commit
bee31dafb9
|
@ -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
|
Loading…
Reference in New Issue