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

+17
View File
@@ -0,0 +1,17 @@
# origin: Programming+ exercise hamming
# status: unverified; `corpus.py verify` checks it on the pinned compiler
# probe: how many positions differ between two reads of the same length
# expect-stdout: 2
def hamming(a: String, b: String) -> Int:
# requires: |a| == |b|
# ensures: result == |{ k in [0, |a|) : a[k] != b[k] }|
var differences = 0
for i in range(a.count_codepoints()):
# invariant: differences == |{ k in [0, i) : a[k] != b[k] }|
if a[codepoint=i] != b[codepoint=i]:
differences += 1
return differences
def main():
print(hamming("GATTACA", "GACTATA"))