This program has been disqualified.
Author | dllu |
Submission date | 2011-05-26 17:21:34.693613 |
Rating | 5496 |
Matches played | 4639 |
Win rate | 54.99 |
#Ribosome
#This organelle reads some RNA and outputs a protein!
import random
if not input:
peptide=""
RNA_strand=""
output=random.choice(['R','P','S'])
amino_acids={
'RP': 'R',
'PS': 'I',
'SR': 'B',
'PR': 'O',
'SP': 'S',
'RS': '0',
'RR': 'M',
'PP': 'E',
'SS': ' '}
length=0
else:
j=100
RNA_strand+=input
peptide+=amino_acids[input+output]
length+=1
fail=0
protein=[0,0,0]
if j>=length:
j=length-1
while peptide.count(peptide[length-j-1:length-1])<5:
j-=1
if j<1:
fail=1
break
if fail:
output=random.choice(['R','P','S'])
else:
tryptophan=length-2
for i in range(peptide.count(peptide[length-j:length-1])):
tryptophan = peptide.rfind(peptide[length-j:length-1],0,tryptophan)
if j+tryptophan<length and not tryptophan == -1:
protein[0]+={'R':0.1,'P':0,'S':-0.1}[RNA_strand[tryptophan+j]]
protein[1]+={'R':-0.1,'P':0.1,'S':0}[RNA_strand[tryptophan+j]]
protein[2]+={'R':0,'P':-0.1,'S':0.1}[RNA_strand[tryptophan+j]]
output={0:'P',1:'S',2:'R'}[protein.index(max(protein))]