testing a sequence for 'identicalness'

Daniel Dittmar daniel.dittmar at sap.com
Thu Jul 4 12:44:27 EDT 2002


>   does anybody knwo how I can check a sequence for 'identical ness',
> ie given a sequence:
>
> [1,1,1,1,1,1,1,1,1,1]
>
> it would be classified as 100% identical
>
> and
>
> [1,1,1,1,1,1,1,1,1,2]
>
> would be classified as 90% identical.

Assuming [2,1,1,1,1,1,1,1,1,1] is also 90% identical:
- create a dictionary where you count the occurrences (a Bag in Smalltalk
speak)
- counters = bag.values ()
- identicalness = sum (counters) / max (counters)

Daniel






More information about the Python-list mailing list