Baseline: tree as shared

This commit is contained in:
alexm committed 2026-10-05 03:03:38 +00:00
commit 31f2fb8a5a
1679 files changed
+1024562

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
# origin: Programming+ exercise translate-codons
# status: unverified; `corpus.py verify` checks it on the pinned compiler
# probe: translate a reading frame into amino acids, stopping at the first stop codon
# expect-stdout: MAK
def translate(t: String) raises -> String:
var stops = ["TAA", "TAG", "TGA"]
var table = {"ATG": "M", "GCC": "A", "AAA": "K", "TTT": "F", "GGC": "G"}
var protein = String("")
var n = t.count_codepoints()
var i = 0
while i + 3 <= n:
var codon = String("")
for j in range(3):
codon += String(t[codepoint=i + j])
if codon in stops:
break
elif codon in table:
protein += table[codon]
else:
protein += "X"
i += 3
return protein^
def main() raises:
print(translate("ATGGCCAAATAGTTT"))