aoc/06/06_refactored.rb

3 lines
251 B
Ruby
Raw Normal View History

2020-12-06 21:41:08 +00:00
groups = File.read("input.txt").split("\n\n").map(&:split)
puts groups.map { |group| group.join.chars.uniq.size }.sum # TIL about uniq
puts groups.map { |group| group.map(&:chars).reduce(&:&).size }.sum # TIL you can use & on arrays and not just sets?