Baseline: tree as shared

This commit is contained in:
alexm committed 2026-10-05 03:03:38 +00:00
commit 31f2fb8a5a
1679 files changed
+1024562

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
# origin: Programming+ exercise first-unknown
# status: unverified; `corpus.py verify` checks it on the pinned compiler
# probe: the position of the first N in t, or the length of t when there is none
# expect-stdout: 3
def first_unknown(t: String) -> Int:
# ensures: 0 <= result <= |t|
# ensures: forall k in [0, result) : t[k] != 'N'
var n: Int = t.count_codepoints()
var i: Int = 0
while i < n and String(t[codepoint=i]) != "N":
# invariant: forall k in [0, i) : t[k] != 'N'
i += 1
return i
def main():
print(first_unknown("GATNACA"))