Exemplo n.º 1
0
def main():
    source = """
    ejp mysljylc kd kxveddknmc re jsicpdrysi
    rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd
    de kr kd eoya kw aej tysr re ujdr lkgc jv
    y qee
    """
    target = """
    our language is impossible to understand
    there are twenty six factorial possibilities
    so it is okay if you want to just give up
    a zoo
    """

    trans = generate_translation(source, target)

    fin_name = sys.argv[1]
    with open(fin_name) as fin:
        lines = stripped_lines(fin)

        numcases = int(lines.next())

        for caseno in range(1, numcases + 1):
            result = solve_next_case(lines, trans)

            outstr = 'Case #%d: %s' % (caseno, result)
            print outstr
Exemplo n.º 2
0
def main():
    lines = stripped_lines(sys.stdin)
    numcases = int(lines.next())

    for i in range(numcases):
        start, stop = ints(lines.next())

        total = solve(start, stop)

        print 'Case #%d: %s' % (i + 1, total)
Exemplo n.º 3
0
def main():
    lines = stripped_lines(sys.stdin)
    numcases = int(lines.next())

    for i in range(numcases):
        start, stop = ints(lines.next())

        total = solve(start, stop)

        print 'Case #%d: %s' % (i + 1, total)
Exemplo n.º 4
0
def main():
    lines = stripped_lines(sys.stdin)
    numcases = int(lines.next())

    for i in range(numcases):
        grid = list(islice(lines, 4))
        lines.next()

        result = solve(grid)

        print 'Case #%d: %s' % (i + 1, result)
Exemplo n.º 5
0
def main():
    lines = stripped_lines(sys.stdin)
    numcases = int(lines.next())

    for i in range(numcases):
        size = ints(lines.next())[0]
        pattern = [ints(line) for line in islice(lines, size)]

        result = 'YES' if possible(pattern) else 'NO'

        print 'Case #%d: %s' % (i + 1, result)
Exemplo n.º 6
0
def main():
    lines = stripped_lines(sys.stdin)
    numcases = int(lines.next())

    for i in range(numcases):
        word, n = lines.next().split()
        n = int(n)

        result = solve(word, n)

        print 'Case #%d: %s' % (i + 1, result)
Exemplo n.º 7
0
def main():
    lines = stripped_lines(sys.stdin)
    numcases = int(lines.next())

    for i in range(numcases):
        grid = list(islice(lines, 4))
        lines.next()

        result = solve(grid)

        print 'Case #%d: %s' % (i + 1, result)
Exemplo n.º 8
0
def main():
    lines = stripped_lines(sys.stdin)
    numcases = int(lines.next())

    for i in range(numcases):
        line = lines.next()
        counts = [int(c) for c in line.split()[-1]]

        result = solve(counts)

        print 'Case #%d: %s' % (i + 1, result)
Exemplo n.º 9
0
def main():
    fin_name = sys.argv[1]
    with open(fin_name) as fin:
        lines = stripped_lines(fin)

        numcases = int(lines.next())

        for caseno in range(1, numcases + 1):
            result = solve_next_case(lines)

            outstr = 'Case #%d: %s' % (caseno, result)
            print outstr
Exemplo n.º 10
0
def main():
    lines = stripped_lines(sys.stdin)
    numcases = int(lines.next())

    for i in range(numcases):
        numchests = ints(lines.next())[1]
        starting_keys = ints(lines.next())
        chest_lines = (ints(line) for line in islice(lines, numchests))
        chests = [(chest_line[0], set(chest_line[2:]))
                  for chest_line in chest_lines]

        result = solve(starting_keys, chests)
        output = ' '.join(map(str, result)) if result else 'IMPOSSIBLE'
        print 'Case #%d: %s' % (i + 1, output)