Re: [pythoncalgary] Meeting? -- Contrib from David Glass

2 views
Skip to first unread message

Greg Saunders

unread,
Jan 10, 2011, 4:54:48 PM1/10/11
to python...@googlegroups.com
I doubt there is a meeting this Thursday ... unless someone else would like the pleasure of organizing it at this point. However, I should probably release David Glass's game contribution from April of last year into the wild :)

@David
Yes, it is your revised code as of November :)


On Wed, Apr 21, 2010 at 12:53 AM, David Glass <david...@gmail.com> wrote:
Hi Greg,

This is a cheat for a (once) popular Facebook game. You are given a word of 6 or 7 letters and asked to figure out all the "subwords" of equal or lesser length (all the way down to length 3). The game gets its subwords from its own (hidden) dictionary and provides blanks corresponding to each subword. You fill in the blanks. You get a higher score for longer subwords completed and there is a time limit.

Using a word list I compiled from the internet, I made a Python script which generated answers (longest subwords first) and I entered them as fast as possible to get unusually high scores. I only tried it a couple of times because I thought the program might get suspicious and somehow get my wife (whose account I was using) kicked off of Facebook.

I've reformulated my solution into two Python scripts, one for the "runner" script, twister_runner.py which ad infinitem accepts input and uses a class from the other script to generate subwords, and one for the  The other contains a Twister class which is used by the first script to generate the subwords. I've attached a zipped word list and the runner script. I'll send my second script solution in a separate email. 

The idea is that PythonCalgary members can develop their own second twister.py script which adheres to the same interface and then, if they like, use the runner script provided. 

Here's some sample output (run on a Powerbook G4):

Word to twist: parrot

'parrot' twisted:

parrot raptor aport atop Parr part Port port prat rapt roar rota Rota taro tarp tora trap apt Art art ATP oar oat opt ort par Pat pat pot pro rap rat rot Tao tap tar top tor a

Twist time: 8.72570109367 seconds

Word to twist: sketch

'sketch' twisted:

sketch chest ketch techs echt etch heck sect Seth tech sec set Set she THC the

Twist time: 1.29570603371 seconds

Note the time of the first word vs. the second. The first incorporates some set-up time. I built it like this rather than doing all the setup before accepting input because I was considering making it a web application on Google App Engine and I didn't want the user to get a big delay before seeing anything. Other solutions might have different trade-offs. For example, they might be able to (a) avoid noticeable set-up time or (b) make it less noticeable by making the computations more incremental, or maybe (c) do it so fast there's no noticeable computation time at all.

Anyway, this might be a fun puzzle for some as it was for me.

Solution script to follow.

Regards,
David

P.S. I haven't even tried the Grolsch yet, but I'm sure it will be delicious when I finally get around to it. Thanks again.



On Mon, Jan 10, 2011 at 11:05 AM, Dafydd Crosby <dtc...@gmail.com> wrote:
Is there going to be a meeting this Thursday? Perhaps a puzzle and a pint?

-Dafydd

--
You received this message because you are subscribed to the Google Groups "calgary python user group" group.
To post to this group, send email to python...@googlegroups.com.
To unsubscribe from this group, send email to pythoncalgar...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythoncalgary?hl=en.

twister.py
Reply all
Reply to author
Forward
0 new messages