advent-of-code/2015/day-01/part_two.rb
Patrick Auernig 3c57921438 Refactor 2015 days 01 to 10
Split parts into separate files and remove some unused files
2021-12-08 01:05:17 +01:00

16 lines
250 B
Ruby
Executable File

#!/usr/bin/env ruby
require_relative "common"
def part_two(chars)
chars.each.with_index(1).reduce(0) do |acc, (char, index)|
acc += match_paren(char)
return index if acc == -1
acc
end
nil
end
result = part_two(INPUT)
puts result