This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,21 @@
|
||||
# origin: Programming+ exercise match-off-by-one
|
||||
# status: unverified; `corpus.py verify` checks it on the pinned compiler
|
||||
# probe: one bound is wrong: the outer loop runs i past the last start a match could have
|
||||
# expect: fail
|
||||
def match_pattern(p: String, t: String) -> List[Int]:
|
||||
var n = t.count_codepoints()
|
||||
var m = p.count_codepoints()
|
||||
var answer = List[Int]()
|
||||
for i in range(n):
|
||||
var matched = True
|
||||
for j in range(m):
|
||||
if t[codepoint=i + j] != p[codepoint=j]:
|
||||
matched = False
|
||||
break
|
||||
if matched:
|
||||
answer.append(i)
|
||||
return answer^
|
||||
|
||||
|
||||
def main():
|
||||
print(match_pattern("ATT", "GATTACA"))
|
||||
Reference in new issue
Block a user