Baseline: tree as shared
This commit is contained in:
1679 files changed
+1024562
No files matched your search
@@ -0,0 +1,16 @@
|
||||
# origin: Programming+ exercise gc-fraction
|
||||
# status: unverified; `corpus.py verify` checks it on the pinned compiler
|
||||
# probe: the fraction of t that is G or C, as a Float64
|
||||
# expect-stdout: 0.2857142857142857
|
||||
def gc_fraction(t: String) -> Float64:
|
||||
# requires: |t| > 0
|
||||
var gc = 0
|
||||
for cp in t.codepoint_slices():
|
||||
var b = String(cp)
|
||||
if b == "G" or b == "C":
|
||||
gc += 1
|
||||
return Float64(gc) / Float64(t.count_codepoints())
|
||||
|
||||
|
||||
def main():
|
||||
print(gc_fraction("GATTACA"))
|
||||
Reference in new issue
Block a user