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

+21
View File
@@ -0,0 +1,21 @@
# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
# How many times each word of K letters occurs in T.
def kmer_counts(t: String, k: Int) raises -> Dict[String, Int]:
# REQUIRE K >= 1
var counts = Dict[String, Int]()
var word: String
for i in range(t.count_codepoints() - k + 1):
var _piece2 = String("")
for _at1 in range(i, i + k):
_piece2 += String(t[codepoint=_at1])
word = _piece2
if word in counts:
counts[word] = counts[word] + 1
else:
counts[word] = 1
return counts.copy()
def main() raises:
print(kmer_counts("GATTACAGATT", 3))