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