# Dice Roller

**URL:** <https://www.ruby-forum.com/t/dice-roller/94765>\
**Category:** Ruby\
**Created:** [January 8, 2006, 11:57pm UTC](https://www.ruby-forum.com/t/dice-roller/94765 "2006-01-08T23:57:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@Stefan\_W](https://www.ruby-forum.com/u/Stefan_W)\
**Post date:** [January 8, 2006, 11:57pm UTC](https://www.ruby-forum.com/t/dice-roller/94765/1 "2006-01-08T23:57:34Z")

</div>

Hi, here is my solution… I don’t know if it handles every case right,  
but it was fun to write… 😉

By the way, does someone of you know what became of rockit  
[http://rockit.sourceforge.net/](http://rockit.sourceforge.net/) - it would’ve been very handy for this  
quiz, but I could not get it to work somehow…

But here’s the code:

class Integer;def d(v)r=0;times{r+=1+rand(v)};r;end;end;x,y=  
$\*;e=x.gsub(‘%’,“100”).gsub(/(^|\D|))d/,‘\11d’).gsub(/d(\d  
_)/x){$1==“”? “.d”: “.d(#$1)”};puts (“1”…y).map{eval e}_" "

(Sorry… I just had to… ;))

Regards,  
Stefan W.
