Files
pplus-library/mojo/local/count-base-proved.mojo
T
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

17 lines
581 B
Mojo

# origin: Programming+ exercise count-base-proved
# status: unverified; `corpus.py verify` checks it on the pinned compiler
# probe: count_base with its claims as comments, as the matho pane states them
# expect-stdout: 3
def count_base(b: String, t: String) -> Int:
# ensures: result == |{ k in [0, |t|) : t[k] == b }|
var total: Int = 0
for i in range(t.count_codepoints()):
# invariant: total == |{ k in [0, i) : t[k] == b }|
if String(t[codepoint=i]) == b:
total += 1
return total
def main():
print(count_base("A", "GATTACA"))