Make day 6 use in_groups_of
This commit is contained in:
parent
99ba049301
commit
80921bdf95
9
day6.cr
9
day6.cr
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user