priklady.py 342 Bytes
Newer Older
cermak's avatar
cermak committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def mujrange(n):
    i = 0
    while i < n:
        yield i
        i += 1

def kartezsky_soucin(l1, l2):
    for x in l1:
        for y in l2:
            yield (x, y)


from collections import defaultdict

def kgramy(text, k):
    
    stat=defaultdict(int)
    for i in range(len(text)-k+1):
        stat[text[i:i+k]] += 1

    return stat