Baseline: tree as shared

This commit is contained in:
alexm committed 2026-10-05 03:03:38 +00:00
commit 659c03bbf8
1471 files changed
+990535

No files matched your search

@@ -0,0 +1,27 @@
# 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"))