class Array

Public Instance Methods

max_frequency() click to toggle source
# 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() click to toggle source
# 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