[Tutor] comparing seqs by successive intervals

don arnold darnold02 at sprynet.com
Sun Jan 18 01:48:38 EST 2004


----- Original Message -----
From: "kevin parks" <kp8 at mac.com>
To: <tutor at python.org>
Sent: Saturday, January 17, 2004 11:37 PM
Subject: [Tutor] comparing seqs by successive intervals


> hi all.
>
> I am trying to take some lists and compares them by measuring the
> intervals or gaps between each successive list item. I should also
> point out that everything here is modulo 12), so if we have a list like
> so:
>
> seq01 = [5, 7, 8, 11]
>
> the interval from list item 0 (5) to list item 1(7) is 2, item 1(7) to
> item 2 (8) is 1, and item 2 (8) to the last (11) is 3.
>
> seq02 = [1, 3, 4, 7]
>
> by this criteria seq02 would be the same as the intervals between each
> successive sequence item is the same:
>
> 2-1-3
>
> so it would be great if it indicated whether they were the same or not
> and if so printed out the interval sequence.
>
> Yet i am not quite sure how best to do this. Do i do parallel
> traversals with something like for (x, y) in foo ...? or do i first
> measure the intervals in one list and then the other? What if i have
> more than 2 lists? is that too hairy to deal with? How can i do this
> with lists of different lengths and have it at least compare the
> sequences as far as the shortest list?
>
> hmm.... So many question for such a small brain such as i have. I have
> had a need to do similar things before. I am hoping some one can give
> me a push in the right direction or talk me through the steps. I would
> love to see how something like this would be done. It may seem odd, but
> is something i keep coming across and am not yet able to get my head
> 'round.

>
> Help... Anyone...?
>
> cheers,
>
> kevin
>

Forgive my asking, but what would this sort of comparison be used for? The
problem seems strange enough to make it sound an awful lot like a homework
assignment.

Don




More information about the Tutor mailing list