[Tutor] Finding items in list of lists.

Bob Gailer ramrom@earthling.net
Mon Mar 17 15:21:02 2003


--=======43E4748F=======
Content-Type: text/plain; x-avg-checked=avg-ok-30CD20FC; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 01:21 PM 3/17/2003 -0500, Doug.Shawhan@gecits.ge.com wrote:
>[snip]
>Say I have a set of critera that can be matched: (fat, skinny), (hairy,
>bald), (ugly, svelte), (smelly, sweet).
>
>These criteria are spread through several lists that are contained in other
>lists:
>
>I need to match the criteria like so:
>
>-------------------------
>in: [['joe', 'fat', 'light', 'dark'], ['joe','hairy','nekkid','ugly'],
>['joe', 'skinny', 'ugly', 'sweet'], ['joe','bald','silly','wacky]]
>
>out:    [['joe', 'fat', 'light', 'dark'],['joe', 'skinny', 'ugly', 'sweet']]
>         [['joe','hairy','nekkid','ugly'], ['joe','bald','silly','wacky]]
>-------------------------

Now I'm really confused. It looks like you want the sub-lists rearranged in 
some way, but it's not clear from the example what you want. I see the two 
lists that "match" (fat, skinny) are in 1st and 2nd place, and the two that 
match (hairy, bald) are in 3rd and 4th place. What do you wnat if there are 
more or less matches? Can you give us an algorithm instead of examples?

Bob Gailer
mailto:bgailer@alum.rpi.edu
303 442 2625

--=======43E4748F=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-30CD20FC
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.459 / Virus Database: 258 - Release Date: 2/25/2003

--=======43E4748F=======--