[2018][ruby][4.x] refactor, add part one back

sorbet
Alpha Chen 6 years ago
parent 57655c6a21
commit 6e8f39dbd2

@ -17,7 +17,13 @@ records.each do |record|
end
end
# Part One
guard, ranges = stats.max_by {|_,v| v.map(&:size).sum }
minute = ranges.flat_map(&:to_a).group_by {|x| x }.transform_values(&:count).max_by(&:last).first
p guard * minute
# Part Two
guard, (minute, _) = stats.map {|k,v|
[k, v.flat_map(&:to_a).group_by {|x| x }.max_by {|_,v| v.count }]
}.max_by {|_,(_,v)| v.count }
[k, v.flat_map(&:to_a).group_by {|x| x }.transform_values(&:count).max_by(&:last)]
}.max_by {|_,(_,v)| v }
p guard * minute

Loading…
Cancel
Save