16 lines
279 B
Crystal
16 lines
279 B
Crystal
|
lines = File.read("day2").split("\n")
|
||
|
lines.pop
|
||
|
|
||
|
CHARS = ('a'..'z').to_a
|
||
|
|
||
|
def has_n?(string, n)
|
||
|
CHARS.each do |c|
|
||
|
return true if string.count(c) == n
|
||
|
end
|
||
|
return false
|
||
|
end
|
||
|
|
||
|
two = lines.count { |s| has_n?(s, 2) }
|
||
|
three = lines.count { |s| has_n?(s, 3) }
|
||
|
puts two * three
|