Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [SOLUTION] Dice Roller

Reply
Thread Tools

[SOLUTION] Dice Roller

 
 
Stefan Walk
Guest
Posts: n/a
 
      01-08-2006
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/> - 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 Walk



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[QUIZ.SUMMARY] Dice Roller (#61) Matthew Moss Ruby 11 01-13-2006 08:29 PM
[QUIZ] Dice Roller (#61) Ruby Quiz Ruby 106 01-10-2006 06:48 PM
[QUIZ.SOLUTION] Dice Roller (#61) We don't need no steenking leexer/parsers Paul Novak Ruby 2 01-10-2006 02:28 AM
[SOLUTION] Dice Roller (#61) John Earles Ruby 0 01-08-2006 09:59 PM



Advertisments