From: Leslie Viljoen Date: 2006-10-02T02:29:11+09:00 Subject: Re: [QUIZ] Story Generator (#96) On 10/1/06, James Edward Gray II wrote: > On Oct 1, 2006, at 9:45 AM, Jim Menard wrote: > > > I believe the 48 hours are up, so here's my solution: > > http://www.io.com/~jimm/rubyquiz/quiz96/ > > Dang that's clever Jim! > > Here's the tragedy.rb file I was taunting the list with yesterday: > > #!/usr/bin/env ruby -w > > class Array > def rand > fetch(Kernel.rand(size)) > end > end > > characters = %w[James Ruby] > sentence_structure = [ "S falls in love with O.", > "S (slays|kills) O(.|.|.|!)", > "S cries." ] > > output = String.new > (ARGV.shift || 5).to_i.times do > sentence = sentence_structure.rand.gsub(/\b[SO]\b/) > { characters.rand } > output << " " << sentence.gsub(/\([^()|]+(?:\|[^()|]+)+\)/) do | > choices| > choices[1..-2].split("|").rand > end > end > > puts output.strip.gsub(/(.{1,80}|\S{81,})(?: +|$\n?)/, "\\1\n") > > __END__ I just get: jim.rb:17: odd number list for Hash something to do with the email formatting? I'll have to look later. Les