Title / Description
Code class MainController < ApplicationController def index @range = (0..params[:amount].to_i - 1).to_a @array = @range.collect { rand(params[:min].to_i..params[:max].to_i) } @sorted = @array.sort @unique = @sorted.uniq @frequency = @unique.collect { |item| @sorted.count(item) } @collected_frequency = (1..@frequency.length).collect { |i| @frequency.first(i).inject(:+) } end end
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code