Skip to content

Commit 0157841

Browse files
committed
Sublist
1 parent 35db05a commit 0157841

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

sublist/sublist.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,19 @@ def sublist(list_one: list, list_two: list) -> str:
3737
return EQUAL
3838

3939
if len(list_one) == len(list_two) and not (
40-
list_one is list_two or list_one == list_two
40+
list_one is list_two or list_one == list_two
4141
):
4242
return UNEQUAL
4343

4444
l1: str = ",".join(str(i) for i in list_one)
4545
l2: str = ",".join(str(i) for i in list_two)
4646

4747
if len(l1) > len(l2):
48-
for i in range(0, len(l1) - len(l2) + 1):
49-
if l1[i:].startswith(l2):
50-
return SUPERLIST
48+
if l2 in l1:
49+
return SUPERLIST
5150

5251
if len(l2) > len(l1):
53-
for i in range(0, len(l2) - len(l1) + 1):
54-
if l2[i:].startswith(l1):
55-
return SUBLIST
52+
if l1 in l2:
53+
return SUBLIST
5654

5755
return UNEQUAL

sublist/sublist_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=C0301
1+
# pylint: disable=C0301, C0116
22
# These tests are auto-generated with test data from:
33
# https://github.com/exercism/problem-specifications/tree/main/exercises/sublist/canonical-data.json
44
# File last updated on 2023-07-19

0 commit comments

Comments
 (0)