2014-04-09 07:34:19 -03:00
|
|
|
SUBLIST = 0
|
|
|
|
|
SUPERLIST = 1
|
|
|
|
|
EQUAL = 2
|
|
|
|
|
UNEQUAL = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_lists(l1, l2):
|
|
|
|
|
if l1 == l2:
|
|
|
|
|
return EQUAL
|
2015-09-08 22:01:57 +02:00
|
|
|
if contains(l1, l2):
|
2014-04-09 07:34:19 -03:00
|
|
|
return SUPERLIST
|
2015-09-08 22:01:57 +02:00
|
|
|
if contains(l2, l1):
|
2014-04-09 07:34:19 -03:00
|
|
|
return SUBLIST
|
|
|
|
|
return UNEQUAL
|
|
|
|
|
|
|
|
|
|
|
2015-09-08 22:01:57 +02:00
|
|
|
def contains(l1, l2):
|
|
|
|
|
if not l2:
|
|
|
|
|
return True
|
|
|
|
|
if len(l2) > len(l1):
|
2014-04-09 07:34:19 -03:00
|
|
|
return False
|
2015-09-08 22:01:57 +02:00
|
|
|
for i in range(len(l1) - len(l2) + 1):
|
|
|
|
|
if l1[i] != l2[0]:
|
|
|
|
|
continue
|
|
|
|
|
for j in range(len(l2)):
|
|
|
|
|
if l1[i + j] != l2[j]:
|
|
|
|
|
break
|
|
|
|
|
else:
|
2014-04-09 07:34:19 -03:00
|
|
|
return True
|
2015-09-08 22:01:57 +02:00
|
|
|
return False
|