import random def newWord(alphabet,dimword): ''' ''' word='' dimAlpha=len(alphabet) for i in range(dimword): pos=random.randint(0,dimAlpha-1) word=word+alphabet[pos] return word def wcheck(wrd,guess): ''' wcheck(wrd,guess) ''' maskw=[1]*len(wrd) maskg=[1]*len(wrd) strikes=balls=0 for i in range(len(wrd)): if wrd[i]==guess[i]: strikes=strikes+1 maskw[i]=maskg[i]=0 if strikes==len(wrd): found=1 else: found=0 for i in range(len(wrd)): for j in range(len(wrd)): if maskw[i] and maskg[j]: if wrd[i]==guess[j]: balls=balls+1 maskw[i]=maskg[j]=0 return found,strikes,balls dnaAlphabet='acgt' aaAlphabet='ACDEFGHIKLMNPQRSTVWY'.lower() alphabet=dnaAlphabet dimAlpha=len(alphabet) header=''' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!! Welcome to the biosequence Mastermind !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Rules: 1. select your biosequence (amino acid / dna) 2. select the length of the site (seuqnce length) 3. select the numner of time you want to try ''' print header numalphabet=input('1) aminoacid\n2) dna\n (1/2)?= ') if numalphabet == 1: alphabet=aaAlphabet else: alphabet=dnaAlphabet dimword=input('word length = ') word=newWord(alphabet,dimword) maxtrials=input('number of time you want to try = ') found=0 i=0 while i