On Jan 6, 9:06 pm, Ken Bloom <kbl... / gmail.com> wrote:
> On Fri, 04 Jan 2008 17:58:15 -0500, Giles Bowkett wrote:
> >> > Tangent: city ITA Software has a really cool interview question: come
> >> > up with maximum number of combinations of movie titles, e.g., "The
> >> > Unbearable Lightness Of Being John Malkovich."
>
> >> Hat trick: Gone with the Winds of War and Peace.
>
> > No, the whole point is to do it in Ruby.
>
> >> Can this get any more off topic?
>
> > OK, do it in Ruby, and then tell everybody you're going to kick their
> > ass.
>
> 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(" ")
>
> HANGMANS CURSE OF THE PUPPET MASTER NINJA I LIKE IT LIKE THAT DARN CAT
> PEOPLE WILL TALK RADIO DAYS OF HEAVEN AND EARTH GIRLS ARE EASY COME EASY
> GO NOW YOU SEE HIM NOW YOU DONT TELL MOM THE BABYSITTERS DEAD HEAT AND
> DUST TO GLORY ROAD HOUSE OF DRACULA PAGES FROM A VIRGINS DIARY OF A MAD
> BLACK WOMAN ON TOP GUN CRAZY PEOPLE WILL TALK RADIO DAYS OF HEAVEN CAN
> WAIT UNTIL DARK BLUE CAR 54 WHERE ARE YOU ONLY LIVE ONCE AROUND THE WORLD
> IN 80 DAYS OF HEAVEN AND EARTH GIRLS ARE EASY COME EASY GO NOW YOU SEE
> HIM NOW YOU DONT GO IN THE HOUSE OF DRACULA DEAD AND LOVING IT COULD
> HAPPEN TO YOU CAN COUNT ON ME WITHOUT YOU LIGHT UP MY LIFE AS A 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 TROUBLE IN
> PARADISE ROAD HOUSE PARTY 3 NINJAS KICK BACK TO THE BEACH PARTY MONSTER
> IN A BOX OF MOON LIGHT OF DAY FOR NIGHT FALLS ON MANHATTAN MURDER MYSTERY
> TRAIN RIDE TO HOLLYWOOD
>
> --
> Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory.
> Department of Computer Science. Illinois Institute of Technology.http://www.iit.edu/~kbloom1/

Ken, thanks for closing this thread with a bang!