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