Add initial day6 solution.

This commit is contained in:
Danila Fedorin 2020-12-05 21:15:22 -08:00
parent 479b1d745e
commit e79b0344fd

21
day6.cr Normal file
View File

@ -0,0 +1,21 @@
require "advent"
INPUT = input(2020, 6).split("\n\n")
def part1
input = INPUT.clone
answers = input.map do |i|
i.chars.uniq!.count &.ascii_letter?
end
puts answers.sum
end
def part2
input = INPUT.clone
sol = input.map do |i|
i.split("\n").reject(&.empty?).map(&.chars.to_set).reduce { |s1, s2| s1 & s2 }
end
puts(sol.map(&.size).sum)
end
part1
part2