コード例 #1
0
ファイル: day_10.py プロジェクト: codinguncut/adventofcode
def run(string, num):
    """
    >>> run('1', 5)
    6
    """
    res = p.nth(num, p.iterate(look_and_say, string))
    return p.ilen(res)
コード例 #2
0
ファイル: day_11.py プロジェクト: codinguncut/adventofcode
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
コード例 #3
0
ファイル: mathseries.py プロジェクト: caiorss/prelude
def root(a):
    f = lambda x: 0.5 * (a / x + x)
    return last(take(10, iterate(f, 1.0)))
コード例 #4
0
ファイル: mathseries.py プロジェクト: caiorss/prelude
def fixed_point(iterator, eps, itmax, guess):

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