You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/2017/ruby/day_05.rb

15 lines
263 B

instructions = ARGF.read.strip.split("\n").map(&:to_i)
pc = 0
count = 0
while (0...instructions.size).cover?(pc)
offset = instructions[pc]
if offset >= 3
instructions[pc] -= 1
else
instructions[pc] += 1
end
pc += offset
count += 1
end
p count