On Jan 8, 2008 7:15 AM, Ray Case <ray.case / gmail.com> wrote:
> On Jan 6, 9:06 pm, Ken Bloom <kbl... / gmail.com> wrote:

> > K=100 #set this to the number of movies you want in the invented title
> >
> > require 'open-uri'
> >
> > MOVIES=open('http://itafullsite.dev.neptuneweb.com/careers/puzzles/
> > MOVIES.LST'){|f| f.readlines}
> > MOVIES.collect!{|x| x.split}
> >
> > class Array
> >   def shuffle!
> >     size.downto 1 do |n|
> >       push(delete_at(rand(n)))
> >     end
> >     self
> >   end
> > end
> >
> > cstack=[MOVIES.dup.shuffle!]
> > pstack=[cstack[-1].shift]
> >
> > while pstack.size<K
> >   cstack << MOVIES.select{|x| x[0]==pstack[-1][-1]}.shuffle!
> >   while cstack[-1].empty?
> >     cstack.pop
> >     pstack.pop
> >   end
> >   pstack << (pstack[-1][0...-1] rescue [])+cstack[-1].shift
> > end
> >
> > puts pstack[-1].join(" ")
> >

> Although, this is a little suspicious:
>
> HOUSE PARTY 2 DAYS IN THE VALLEY GIRL IN THE CADILLAC MAN TROUBLE
> EVERY DAY FOR
> NIGHT OF THE LIVING DEAD MAN OF THE HOUSE PARTY GIRL IN THE CADILLAC
> MAN
> TROUBLE IN PARADISE ROAD HOUSE PARTY GIRL IN THE CADILLAC MAN OF THE
> HOUSE PARTY 2 DAYS IN THE VALLEY GIRL IN THE CADILLAC MAN

Yep, I'd think that loops shouldn't be considered kosher.


-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/