Esempio n. 1
0
def main(argv):
    lines = files.read_lines_of_words(argv[0])

    N     = int(lines[0][0])
    M     = {}
    C     = []

    for p in lines[1:]:
        P = int(p[0]), p[1], p[2]
        print(mac_learning(M, C, P))
def main(argv):
    lines = files.read_lines_of_words(argv[0])

    N = int(lines[0][0])
    M = {}
    C = []

    for p in lines[1:]:
        P = int(p[0]), p[1], p[2]
        print(mac_learning(M, C, P))
Esempio n. 3
0
def main(argv):
    lines = files.read_lines_of_words(argv[0])

    text = lines[0][0]
    patterns = lines[1]

    cm = arrays.count_matrix(text)
    fo = arrays.first_occurrence(''.join(sorted(text)))

    matches = []
    for pattern in patterns:
        matches.append(
            strings.better_burrows_wheeler_matching(pattern, text, cm, fo))

    print ' '.join(str(match) for match in matches)
Esempio n. 4
0
def main(argv):
    lines = files.read_lines_of_words(argv[0])

    text = lines[0][0]
    patterns = lines[1]

    last = arrays.indexed_text_array(text)
    first = arrays.indexed_text_array(''.join(sorted(text)))
    ltof = arrays.last_to_first(first, last)

    matches = []
    for pattern in patterns:
        matches.append(
            strings.burrows_wheeler_matching(pattern, first, last, ltof))

    print ' '.join(str(match) for match in matches)
def main(argv):
    lines = files.read_lines_of_words(argv[0])

    T = int(lines[0][0])
    C = 0

    for _ in range(T):
        C += 1
        N = int(lines[C][0])

        C += 1
        G = defaultdict(list)

        I = 0
        for line in lines[C:C + N + 1]:
            I += 1
            for H in line[1:]:
                G[int(H)].append(I)

        C += I
        P = [float(w) for w in lines[C]]

        CC = depth_first_search(N + 1, G)
        print(rounding(sum(P[n - 1] for n in CC[:-1])))
Esempio n. 6
0
def main(argv):
    lines = files.read_lines_of_words(argv[0])
    n     = int(lines[0][0])
    ar    = [(int(line[0]), line[1]) for line in lines[1:]]

    print(' '.join(sort_values(n, ar)))
Esempio n. 7
0
def main(argv):
    lines = files.read_lines_of_words(argv[0])
    T     = int(lines[0][0])

    for S, P, Q in lines[1:]:
        print(maximum_length(P, Q, int(S)))
Esempio n. 8
0
def main(argv):
    lines  = files.read_lines_of_words(argv[0])
    n      = int(lines[0][0])
    ar     = [int(line[0]) for line in lines[1:]]

    print(' '.join(str(val) for val in count_leq(ar)))
Esempio n. 9
0
def main(argv):
    lines = files.read_lines_of_words(argv[0])
    n = int(lines[0][0])
    ar = [(int(line[0]), line[1]) for line in lines[1:]]

    print(' '.join(sort_values(n, ar)))
Esempio n. 10
0
def main(argv):
    lines = files.read_lines_of_words(argv[0])
    n = int(lines[0][0])
    ar = [int(line[0]) for line in lines[1:]]

    print(' '.join(str(val) for val in count_leq(ar)))
def main(argv):
    lines = files.read_lines_of_words(argv[0])
    T = int(lines[0][0])

    for S, P, Q in lines[1:]:
        print(maximum_length(P, Q, int(S)))