This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,17 @@
|
||||
# origin: Programming+ exercise tally
|
||||
# status: unverified; `corpus.py verify` checks it on the pinned compiler
|
||||
# probe: how many times each base appears in t, in a Dict
|
||||
# expect-stdout: {G: 1, A: 3, T: 2, C: 1}
|
||||
def tally_bases(t: String) raises -> Dict[String, Int]:
|
||||
var tally = Dict[String, Int]()
|
||||
for i in range(t.count_codepoints()):
|
||||
var b = String(t[codepoint=i])
|
||||
if b in tally:
|
||||
tally[b] += 1
|
||||
else:
|
||||
tally[b] = 1
|
||||
return tally^
|
||||
|
||||
|
||||
def main() raises:
|
||||
print(tally_bases("GATTACA"))
|
||||
Reference in new issue
Block a user