10 rivejä
225 B
Ruby
10 rivejä
225 B
Ruby
jumpArray = File.open('puzzle_5.txt').read.split("\n").map(&:to_i)
|
|
num_steps = 0
|
|
index = 0
|
|
while (index < jumpArray.length) do
|
|
jumpArray[index] += 1
|
|
index += jumpArray[index] - 1
|
|
num_steps += 1
|
|
end
|
|
puts num_steps
|