Sha256: 23f5537cbcf1761d1bfd1678c5c922ecea876fdc211dc0c56887cdc0cc5214d0
Contents?: true
Size: 343 Bytes
Versions: 1
Compression:
Stored size: 343 Bytes
Contents
require 'set' class Nmax MAX_LENGTH = 1000 def initialize @s = Set.new end def add_numbers_from str @s.merge str.scan(/\d{1,#{MAX_LENGTH}}/).map(&:to_i) end def top n = nil n ||= @s.size @s.sort { |a, b| b <=> a } [0..n-1] end private def _size @s.size end def _max top.first end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
c100bit-nmax-0.2.2 | lib/c100bit-nmax.rb |