Baseline: tree as shared
This commit is contained in:
commit
659c03bbf8
1471 files changed
+990535
No files matched your search
@@ -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"))
|
||||
Reference in new issue
Block a user