From 48e48a84295c1a89cf47720ec841a6b6119981a6 Mon Sep 17 00:00:00 2001 From: trwnh Date: Sun, 6 Dec 2020 15:41:08 -0600 Subject: [PATCH] simpler ruby --- 06/06_refactored.rb | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 06/06_refactored.rb diff --git a/06/06_refactored.rb b/06/06_refactored.rb new file mode 100644 index 0000000..58b8b48 --- /dev/null +++ b/06/06_refactored.rb @@ -0,0 +1,3 @@ +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? \ No newline at end of file