Fifth day

This commit is contained in:
Alexander Munch-Hansen 2017-12-05 23:33:24 +01:00
parent 88a5809bc4
commit 2563a66d9c

26
searching_for_nil.rb Normal file
View File

@ -0,0 +1,26 @@
input = File.read("input_lol").split("\n").map(&:to_i)
i1 = 0
res1 = 0
part1 = input.dup
while part1[i1] != nil do
curr1, part1[i1] =i1 + part1[i1], part1[i1] + 1
i1, res1 = curr1, res1+1
end
puts res1
i2 = 0
res2 = 0
part2 = input.dup
while part2[i2] != nil do
curr2, part2[i2] =i2 + part2[i2], part2[i2] + (if part2[i2] >= 3 then -1 else 1 end)
i2, res2 = curr2, res2+1
end
puts res2