Example #1
0
def run(string, num):
    """
    >>> run('1', 5)
    6
    """
    res = p.nth(num, p.iterate(look_and_say, string))
    return p.ilen(res)
Example #2
0
def get_passwords(string):
    """
    >>> next(get_passwords('abcdefgh'))
    'abcdffaa'

    >> next(get_passwords('ghijklmn'))
    'ghjaabcc'
    """
    seq = p.drop(1, p.iterate(inc_string, string))
    passwords = filter(meets_reqs, seq)
    return passwords
Example #3
0
def root(a):
    f = lambda x: 0.5 * (a / x + x)
    return last(take(10, iterate(f, 1.0)))
Example #4
0
def fixed_point(iterator, eps, itmax, guess):

    stream = iterate(iterator, guess)
    return last(until_converge(stream, eps, itmax))