From 517cf67024333915aac336cb7c853eaa08f8a7c1 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 8 Aug 2025 11:44:01 +0000 Subject: [PATCH] [Sync Iteration] python/sublist/1 --- solutions/python/sublist/1/sublist.py | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 solutions/python/sublist/1/sublist.py diff --git a/solutions/python/sublist/1/sublist.py b/solutions/python/sublist/1/sublist.py new file mode 100644 index 0000000..92951b6 --- /dev/null +++ b/solutions/python/sublist/1/sublist.py @@ -0,0 +1,35 @@ +# Possible sublist categories. +# Change the values as you see fit. +SUBLIST = 1 +SUPERLIST = 2 +EQUAL = 3 +UNEQUAL = 4 + +def sublist(A, B): + A_len = len(A) + B_len = len(B) + if A == B: + return EQUAL + elif A_len < B_len: + if A_len == 0: + return SUBLIST + else: + for i in range (B_len - A_len + 1): + j = 0 + while j < A_len and B[i + j] == A[j]: + j += 1 + if j == A_len: + return SUBLIST + return UNEQUAL + elif A_len > B_len: + if B_len == 0: + return SUPERLIST + else: + for i in range (A_len - B_len + 1): + j = 0 + while j < B_len and A[i + j] == B[j]: + j += 1 + if j == B_len: + return SUPERLIST + return UNEQUAL + return UNEQUAL \ No newline at end of file