From e49d6c4bef1c2d582da5d9515c6f7a5cb33cfd76 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sun, 6 Dec 2020 20:57:39 -0800 Subject: [PATCH] [2020][ruby][6.x] refactor --- 2020/ruby/day_06.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/2020/ruby/day_06.rb b/2020/ruby/day_06.rb index a4f0a32..01b7fb6 100644 --- a/2020/ruby/day_06.rb +++ b/2020/ruby/day_06.rb @@ -1,6 +1,6 @@ -# p ARGF.read.split("\n\n").map {|g| g.gsub("\n", "").chars.uniq.count }.sum p ARGF.read.split("\n\n").map {|group| - people = group.split("\n").map(&:chars) - first = people.shift - first.count {|answer| people.all? {|answers| answers.include?(answer) }} -}.sum + group.split("\n").map(&:chars) +}.map {|group| + # group.inject(&:|) + group.inject(&:&) +}.map(&:size).sum