Skip to main content
1 of 4
mellamokb
  • 6.1k
  • 3
  • 27
  • 34

JavaScript (169)

r=(M=Math).floor(M.random()*6+1);alert('-----\n|'+[[e?'o':' ' for each(e in t)].join('') for each(t in [[r>1,0,r>3],[r>5,r&1,r>5],[r>3,0,r>1]])].join('|\n|')+'|\n-----')

Doesn't look quite right in alert because it's not fixed-width font, but rest assured it is correct, or test by emitting a <pre> tag and doing writeln :-)

Proof: http://jsfiddle.net/d4YTn/2/ (only works in JS 1.7-compliant browsers, such as FF2+)

Credits: Hacked Math trick from @minitech and die print logic from @Keith.

mellamokb
  • 6.1k
  • 3
  • 27
  • 34