fuente numero 1

by donpepe on July 22nd, 2010

test

Syntax: Python
Show lines - Hide lines - Show in textbox - Download
print('hola caracola')
a = [2, 4, 6, 8, 10]
b = [4, 6, 8]
c = [6, 4]
d = [10]
 
def test(x, y):
    delta = 0
    while delta <= (len(x)-len(y)):
        i = 0
        condition = (x[i+delta] == y[i])
        while condition and i < len(y)-1:
            i += 1
            condition = condition and (x[i+delta] == y[i])
        if condition:
            return True
        delta += 1
    return False
 
print(test(a,b))
print(test(b,a))
print(test(a,c))
print(test(a,d))
 

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS