This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,16 @@
|
||||
# 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"))
|
||||
Reference in new issue
Block a user