Add day 6 solutions

This commit is contained in:
Danila Fedorin 2022-12-05 21:47:30 -08:00
parent 07d8457cd8
commit 6eafd1628d
1 changed files with 23 additions and 0 deletions

23
day6.cr Normal file
View File

@ -0,0 +1,23 @@
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
end
end
def part2(input)
offset = 0
loop do
chars = input[offset..offset+13]
return offset + 14 if chars.uniq.size == 14
offset += 1
end
end
puts part1(INPUT.clone)
puts part2(INPUT.clone)