CODE CHALLENGE: Solve the String Composition Problem.
Input: An integer k and a string Text.
Output: Compositionk(Text), where the k-mers are written in lexicographic order.
Input: An integer k and a string Text.
Output: Compositionk(Text), where the k-mers are written in lexicographic order.
Sample Input:
5
CAATCCAAC
5
CAATCCAAC
Sample Output:
AATCC
ATCCA
CAATC
CCAAC
TCCAA
AATCC
ATCCA
CAATC
CCAAC
TCCAA
Первый квиз по чаптеру 4 коррект. Юх-ху
def SCP (k, string):
kmers = []
for i in range(len(string)-k+1):
#print (string[i:(i+k)])
kmers.append(string[i:(i+k)])
kmers.sort()
return kmers
result = SCP(5, "CAATCCAAC")
#print (result)
for i in result:
print (i)
Немає коментарів:
Дописати коментар