class DiceMatrix def initialize(num_dice, die_size, adjustment = 1) @matrix = Array.new() permutations = die_size ** num_dice permutations.times do |x| @matrix[x] = Array.new() num_dice.times do |y| @matrix[x][y] = ((x / (die_size ** y)).floor % die_size) + adjustment end end end def reduce(from_bottom = 0, from_top = 0) @matrix.each_index do |x| @matrix[x].sort! @matrix[x] = @matrix[x].slice(from_bottom, @matrix[x].length - (from_bottom + from_top)) end end def length @matrix.length end def each @matrix.each end def to_array @matrix end end