Files
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

18 lines
546 B
Mojo

# 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"))