17 lines
504 B
Mojo
17 lines
504 B
Mojo
# origin: Programming+ exercise five-bugs
|
|
# status: unverified; `corpus.py verify` checks it on the pinned compiler
|
|
# probe: count the G and C bases in t; this version has mistakes to find by stepping
|
|
# expect-stdout: 1
|
|
def count_gc(t: String) -> Int:
|
|
var total: Int = 0
|
|
for i in range(t.count_codepoints() - 1):
|
|
total = 0
|
|
var b: String = String(t[codepoint=i])
|
|
if b == "G" or b == "C":
|
|
total += 1
|
|
return total
|
|
|
|
|
|
def main():
|
|
print(count_gc("GATTACA"))
|