From: James Coglan Date: 2008-09-21T00:03:50+09:00 Subject: Re: One-Liners Mashup (#177 again) ------=_Part_4098_10144075.1221923504372 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline > > Oops... I forgot to put up a new one-liner question! (Don't forget you > guys!!!) Really sorry, just can't think of anything immediately... if something pops up I'll post it, promise! > Here's something simple: define method roll(n, s) to roll a s-sided > die n times and display a bar graph of the results. So roll(20, 4) > might look like this: > > 1|##### > 2|##### > 3|###### > 4|#### def roll(n,s) (1..n).map { |x| "#{x}|#{'#' * (1 + rand(s))}" } * "\n" end puts roll(20,4) ------=_Part_4098_10144075.1221923504372--