Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/ruby_marks.rb
Instance Method Summary collapse
Instance Method Details
#max_frequency ⇒ Object
78 79 80 81 82 |
# File 'lib/ruby_marks.rb', line 78 def max_frequency group_by{ |w| w } .map{ |w, v| [w, v.size] } .max { |a, b| a[1] <=> b[1] } end |
#to_ranges ⇒ Object
72 73 74 75 76 |
# File 'lib/ruby_marks.rb', line 72 def to_ranges compact.sort.uniq.inject([]) do |r,x| r.empty? || r.last.last.succ != x ? r << [x,x] : r[0..-2] << [r.last.first, x] end end |