11 lines
281 B
Ruby
11 lines
281 B
Ruby
|
jumpArray = File.open('puzzle_5.txt').read.split("\n").map(&:to_i)
|
||
|
num_steps = 0
|
||
|
index = 0
|
||
|
while (index < jumpArray.length) do
|
||
|
change = (jumpArray[index] >= 3) ? -1 : 1
|
||
|
jumpArray[index] += change
|
||
|
index += jumpArray[index] - change
|
||
|
num_steps += 1
|
||
|
end
|
||
|
puts num_steps
|