-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSublist.py
33 lines (28 loc) · 1.05 KB
/
Sublist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
This exercise stub and the test suite contain several enumerated constants.
Since Python 2 does not have the enum module, the idiomatic way to write
enumerated constants has traditionally been a NAME assigned to an arbitrary,
but unique value. An integer is traditionally used because its memory
efficient.
It is a common practice to export both constants and functions that work with
those constants (ex. the constants in the os, subprocess and re modules).
You can learn more here: https://en.wikipedia.org/wiki/Enumerated_type
"""
# Possible sublist categories.
# Change the values as you see fit.
SUBLIST = "sublist"
SUPERLIST = "superlist"
EQUAL = "equal"
UNEQUAL = "unequal"
def sublist(list_one, list_two):
if list_one == list_two:
return EQUAL
if len(list_one) == len(list_two):
return UNEQUAL
list_one = " ".join(map(lambda x: str(x), list_one))
list_two = " ".join(map(lambda x: str(x), list_two))
if list_one in list_two:
return SUBLIST
if list_two in list_one:
return SUPERLIST
return UNEQUAL