-
Notifications
You must be signed in to change notification settings - Fork 0
/
sublistSearch.py
54 lines (44 loc) · 960 Bytes
/
sublistSearch.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
cards = [
"2s","3s","4s","5s","6s","7s","8s","9s","10s","Js","Qs","Ks","As",
"2h","3h","4h","5h","6h","7h","8h","9h","10h","Jh","Qh","Kh","Ah",
"2d","3d","4d","5d","6d","7d","8d","9d","10d","Jd","Qd","Kd","Ad",
"2c","3c","4c","5c","6c","7c","8c","9c","10c","Jc","Qc","Kc"
]
sub = ["10h","Jh","Qh","Kh","Ah"]
cards.sort()
sub.sort()
print(cards)
print(sub)
def subListSearch(parent, child):
res = True
for e in parent:
if e == child[0]:
child.pop(0)
if len(child) == 0:
break
#print(e, child[0])
if e > child[0]:
res = False
break
return res
print(subListSearch(cards, sub))
'''
curr = 0
started = 0
res = False
for c in cards:
print(c, curr)
if started:
if c == sub[curr]:
curr += 1
else:
curr == 0
started = 0
if curr == len(sub) - 1:
res = True
break
if not started and c == sub[0]:
started = 1
curr += 1
print(res)
'''