Top Level Namespace

Includes:
Math, RubyLabs

Defined Under Namespace

Modules: Enumerable, RubyLabs Classes: Fixnum, String

Constant Summary collapse

SCRIPT_LINES__ =

RubyLabs gem, top level module.

Hash.new

Instance Method Summary collapse

Methods included from RubyLabs

#TestArray, #count, #hello, #log2, #max, #min, #time, #trace

Instance Method Details

#permute!(x) ⇒ Object

:begin :permute! :random



8
9
10
11
12
13
14
# File 'lib/permute.rb', line 8

def permute!(x)
  for i in 0..x.length-2
    r = random(i, x.length-1)
    x[i], x[r] = x[r], x[i]
  end
  return x
end

#random(min, max) ⇒ Object

:begin :random



24
25
26
27
28
# File 'lib/permute.rb', line 24

def random(min, max)
  return nil if max < min
  range = max - min + 1
  return rand(range) + min
end