Commit a61cb0b0 authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

add alt solution for exercise on kmer

add solution using a defaultdict
parent de19a22e
......@@ -275,6 +275,16 @@ solution ::
for kmer, occurence in kmers.items():
print kmer, " = ", occurence
we can use also a defaultdict: ::
import collections
s = s.replace('\n', '')
kmers = collection.defaultdict(int)
for i in range(len(s) - 3):
kmer = s[i:i+3]
kmers[kmer] += 1
solution bonus ::
list_of_kmers = kmers.items()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment