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
1 changed files with 4 additions and 5 deletions

View File

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