diff --git a/searching_for_nil.rb b/searching_for_nil.rb new file mode 100644 index 0000000..66ef6ce --- /dev/null +++ b/searching_for_nil.rb @@ -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 + + +