Files
alexm 401084bab3
Test / gate (push) Failing after 19m0s
Initial commit
2026-11-12 22:23:54 -05:00

28 lines
769 B
Mojo

# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
# One bound is wrong. Every position where pattern P occurs exactly in text T.
def match_(p: String, t: String) -> List[Int]:
# Set up
var n: Int
var m: Int
var matched: Bool
var answer = List[Int]()
n = t.count_codepoints()
m = p.count_codepoints()
# Visit each legal start
for i in range(n):
# Test: does the pattern match here?
matched = True
for j in range(m):
if String(t[codepoint=i + j]) != String(p[codepoint=j]):
matched = False
break
# Update
if matched:
answer.append(i)
return answer.copy()
def main():
print(match_("ATT", "GATTACA"))