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,18 @@
# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
# How many positions of T hold the base B, with its specification.
def count_base(b: String, t: String) -> Int:
# ENSURE RESULT == LENGTH({ K IN [0, LENGTH(T)) : T[K] == B })
var n: Int
var total: Int
n = t.count_codepoints()
total = 0
# INVARIANT Total == LENGTH({ K IN [0, I) : T[K] == B })
for i in range(n):
if String(t[codepoint=i]) == b:
total = total + 1
return total
def main():
print(count_base("A", "GATTACA"))