commit
401084bab3
265 files changed
+69224
No files matched your search
@@ -0,0 +1,16 @@
|
||||
# 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"))
|
||||
Reference in new issue
Block a user