module NumMax
Public Class Methods
run(input, count)
click to toggle source
# File lib/nummax.rb, line 6 def self.run(input, count) if input.tty? then raise("Input stream should not be associated with a terminal device") end count = Integer(count) rescue raise("As a parameter required positive integer") unless count > 0 then raise("As a parameter required positive integer") end set = SortedSet.new input.each_int do |i| set << i set.delete(set.first) if (set.length > count) end set.to_a end