last program

0 views
Skip to first unread message

Mike Preshman

unread,
May 15, 2008, 9:44:15 PM5/15/08
to learning...@googlegroups.com
Thanks everyone!

Good luck!

-Mike
test.py
patch.txt

Craig Smith

unread,
May 16, 2008, 9:09:17 AM5/16/08
to learning...@googlegroups.com

Here's my solution.  I rewrote the recurse function a little bit. I think it makes the code a little neater if I do an extra level of recursion and put all the stop cases at the beginning of the function. Also, to make validation easier I reconstruct original map from my list of groups.

There might be errors, I haven't tested it that much.

Thanks everyone for a great class!

Craig


patch-search.py

Craig Smith

unread,
May 16, 2008, 11:33:57 AM5/16/08
to learning...@googlegroups.com
Oh, one thing I found interesting that others might have an answer for is I wanted to flatten the group list so I could print out the patch map as seen in the patch.txt file.  So I originally did the following:

flat_list = []
for g in group_list:
    flat_list.append(g)

which of course didn't work, it just recreated the original contents of the group_list.  I hunted around for an operator in the list object (by examining the output of dir(flat_list) but couldn't find anything. I looked on the web and found I could use the '+' operator to flatten the list by:

flat_list = []
for g in group_list:
    flat_list += g

Now my question is what is the '+' operator in this context? I would think it would behave like the append method.

Craig
Reply all
Reply to author
Forward
0 new messages