This isn't so much a solution to the quiz, but more of an addition to
the whole dice rolling thing. Assume you have an array of numbers
between 1-6... outputs the face of the dice in ascii art, one for each
element in the array:
class Array
def to_dice
logic = [
lambda{|n| '+-----+ '},
lambda{|n| (n>3 ? '|O ' : '| ')+(n>1 ? ' O| ' : ' | ')},
lambda{|n| (n==6 ? '|O ' : '| ')+
(n%2==1 ? 'O' : ' ')+(n==6 ? ' O| ' : ' | ')},
lambda{|n| (n>1 ? '|O ' : '| ')+(n>3 ? ' O| ' : ' | ')}
]
str=''
5.times {|row|
self.each {|n| str += logic[row%4].call(n) }
str+="\n"
}
str
end
end
#Example:
puts [1,2,3,4,5,6].to_dice
-Joby