Sha256: 1a7acb4e05f59dd4ddf9121b06d36af96d39c76b7b9586e62a3771fe38542a46

Contents?: true

Size: 421 Bytes

Versions: 15

Compression:

Stored size: 421 Bytes

Contents

module Eddy
  module Util

    # Given an array of numbers, returns the lowest number not included in the array.
    #
    # @param existing [Array<Integer>]
    # @return [Integer]
    def self.new_number(existing)
      n = nil
      i = 1
      loop do
        if existing.include?(i)
          i += 1
          next
        else
          n = i
          break
        end
      end
      return n
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
eddy-0.10.0 lib/eddy/util/new_number.rb
eddy-0.9.2 lib/eddy/util/new_number.rb
eddy-0.9.1 lib/eddy/util/new_number.rb
eddy-0.9.0 lib/eddy/util/new_number.rb
eddy-0.8.4 lib/eddy/util/new_number.rb
eddy-0.8.3 lib/eddy/util/new_number.rb
eddy-0.8.2 lib/eddy/util/new_number.rb
eddy-0.8.1 lib/eddy/util/new_number.rb
eddy-0.8.0 lib/eddy/util/new_number.rb
eddy-0.7.0 lib/eddy/util/new_number.rb
eddy-0.6.0 lib/eddy/util/new_number.rb
eddy-0.5.1 lib/eddy/util/new_number.rb
eddy-0.5.0 lib/eddy/util/new_number.rb
eddy-0.4.0 lib/eddy/util/new_number.rb
eddy-0.3.0 lib/eddy/util/new_number.rb