substring search without using built in utils

Hendrik van Rooyen mail at microcorp.co.za
Fri Nov 10 00:43:43 EST 2006


"Steven D'Aprano" <steve at REMOVE.THIS.cybersource.com.au> wrote:
8<--------------------------

> Given a source list, find the offset of a target sub-list within the
> source list, in other words, find for lists.
>
> i.e. search(source, target) returns n if source[n:n+len(target)] == target
> for any sequence type.
>
> Yes, I know I'm changing the constraints of the problem. Now for a real
> challenge, change the search from a one-dimensional data structure to two.
>
> (The solution is left as an exercise for the class.)

do you mean like a cross word puzzle - find for fit both across and down, and
possibly reversed too, in both dimensions? - sounds like a lot of nested loops
to me...

- Hendrik






More information about the Python-list mailing list