From: Brian Adkins Date: 2007-11-28T22:55:01+09:00 Subject: Re: Most elegant way to do this? On Nov 28, 8:10 am, Lloyd Linklater wrote: > William James wrote: > > That C-code is hideous. Let's compare it to something > > that isn't insanely low-level. > > OOOOO! I know this one! > > If you meant this as pascal, this is the code: > > function roll( n: integer ): integer; > var i: integer; > begin > for i := 1 to n do result := inc(result, random(6) + 1); > end; > > There is no += in pascal. If only... :) Your version where you init > the result so you do not have to add may run faster but I golfed it a > bit. Still, it is far better than the C version. I liked seeing it > here too. :) You do realize that the C code I embedded in the Ruby program actually ran automatically via "ruby myfile.rb", and that was the point, right?