Exemplo n.º 1
0
def run(string, num):
    """
    >>> run('1', 5)
    6
    """
    res = p.nth(num, p.iterate(look_and_say, string))
    return p.ilen(res)
Exemplo n.º 2
0
def run(reindeers, num):
    """
    >>> rds = [('Comet', 14, 10, 127), ('Dancer', 16, 11, 162)]
    >>> list(run(rds, 1000))
    [1120, 1056]
    """
    queues = [enqueue(r) for r in reindeers]
    distances = zip(*queues)
    return p.nth(num+1, distances)
Exemplo n.º 3
0
def accum(reindeers, num):
    """
    >>> rds = [('Comet', 14, 10, 127), ('Dancer', 16, 11, 162)]
    >>> list(accum(rds, 1000))
    [312, 689]
    """
    queues = [enqueue(r) for r in reindeers]
    winners = (is_max(x) for x in zip(*queues))
    scores = p.scan(lambda s, x: map(sum, zip(s, x)), winners, it.repeat(0))
    return p.nth(num+1, scores)