Initial commit
Test / gate (push) Failing after 19m0s

This commit is contained in:
alexm committed 2026-11-12 22:23:54 -05:00
commit 401084bab3
265 files changed
+69224

No files matched your search

@@ -0,0 +1,28 @@
# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
# MATCH, with the specification from "Specifying the problem",
# and the two invariants that prove it.
def match_(p: String, t: String) -> List[Int]:
# REQUIRE LENGTH(P) >= 1
# ENSURE RESULT == SORTED({ S IN [0, LENGTH(T) - LENGTH(P) + 1) : FORALL K IN [0, LENGTH(P)) : T[S + K] == P[K] })
var n: Int
var m: Int
var matched: Bool
var answer = List[Int]()
n = t.count_codepoints()
m = p.count_codepoints()
# INVARIANT Answer == SORTED({ S IN [0, I) : FORALL K IN [0, M) : T[S + K] == P[K] })
for i in range(n - m + 1):
matched = True
# INVARIANT Matched == (FORALL K IN [0, J) : T[I + K] == P[K])
for j in range(m):
if String(t[codepoint=i + j]) != String(p[codepoint=j]):
matched = False
break
if matched:
answer.append(i)
return answer.copy()
def main():
print(match_("ATT", "GATTACA"))