MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / match_sublist

Function match_sublist

evaluation.py:80–92  ·  view source on GitHub ↗

:param the_list: [1, 2, 3, 4, 5, 6, 1, 2, 4, 5] :param to_match: [1, 2] :return: [(0, 1), (6, 7)]

(the_list, to_match)

Source from the content-addressed store, hash-verified

78 return gold_list
79
80def match_sublist(the_list, to_match):
81 """
82 :param the_list: [1, 2, 3, 4, 5, 6, 1, 2, 4, 5]
83 :param to_match: [1, 2]
84 :return:
85 [(0, 1), (6, 7)]
86 """
87 len_to_match = len(to_match)
88 matched_list = list()
89 for index in range(len(the_list) - len_to_match + 1):
90 if to_match == the_list[index:index + len_to_match]:
91 matched_list += [(index, index + len_to_match - 1)]
92 return matched_list
93
94def record_to_offset(instance):
95 """

Callers 1

record_to_offsetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected