Make day 6 use in_groups_of

This commit is contained in:
Danila Fedorin 2022-12-08 22:20:55 -08:00
parent 99ba049301
commit 80921bdf95

View File

@ -2,11 +2,10 @@ require "advent"
INPUT = input(2022, 6).lines[0].chars INPUT = input(2022, 6).lines[0].chars
def part1(input) def part1(input)
offset = 0 idx = 0
loop do input.each_cons(4) do |x|
chars = input[offset..offset+3] return idx + 4 if x.uniq.size == 4
return offset + 4 if chars.uniq.size == 4 idx += 1
offset += 1
end end
end end