module DaniiltyNmax

Constants

VERSION

Public Class Methods

get_count() click to toggle source
# File lib/daniilty_nmax.rb, line 18
def DaniiltyNmax.get_count
  ARGV[0] ? ARGV[0].to_i : 4
end
quick_sort(array) click to toggle source
# File lib/daniilty_nmax.rb, line 5
def DaniiltyNmax.quick_sort(array)
  if array.length > 1
    pivot = array.pop
    left, right = [], []
    for value in array
      value >= pivot ? left.push(value) : right.push(value)
    end

    array = quick_sort(left) + [pivot] + quick_sort(right)
  end

  array
end
read_and_sort(ins) click to toggle source
# File lib/daniilty_nmax.rb, line 21
def DaniiltyNmax.read_and_sort(ins)
  nums = self.quick_sort(ins.read.split(" ").map(&:to_i))
  puts nums.first(self.get_count)
end