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 @@
# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
# How many positions differ between two reads of the same length.
def hamming(a: String, b: String) -> Int:
# REQUIRE LENGTH(A) == LENGTH(B)
# ENSURE RESULT == LENGTH({ K IN [0, LENGTH(A)) : A[K] != B[K] })
var differences: Int
differences = 0
# INVARIANT Differences == LENGTH({ K IN [0, I) : A[K] != B[K] })
for i in range(a.count_codepoints()):
if String(a[codepoint=i]) != String(b[codepoint=i]):
differences = differences + 1
return differences
def main():
print(hamming("GATTACA", "GACTATA"))