Files
pplus-core/tests/snapshots/sync-mojo/gc-fraction.mojo
T
alexm 401084bab3
Test / gate (push) Failing after 19m0s
Initial commit
2026-11-12 22:23:54 -05:00

17 lines
463 B
Mojo

# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
# The fraction of T that is G or C.
def gc_fraction(t: String) -> Float64:
# REQUIRE LENGTH(T) > 0
var gc: Int
gc = 0
for _b_pos1 in range(t.count_codepoints()):
var b = String(t[codepoint=_b_pos1])
if b == "G" or b == "C":
gc = gc + 1
return Float64(gc) / Float64(t.count_codepoints())
def main():
print(gc_fraction("GATTACA"))