Sha256: 2627c1ed4bb011b1cf3cf17df6d481a35f970a1cf71a641a02c107fca6e16df0

Contents?: true

Size: 290 Bytes

Versions: 344

Compression:

Stored size: 290 Bytes

Contents

def triangle(nth):
    return [row(i) for i in range(nth + 1)]


def is_triangle(t):
    new_t = triangle(len(t) - 1)
    return t == new_t


def row(nth):
    r = [1]
    for i in range(1, nth + 1):
        r.append(int(r[-1] * (nth - i + 1) / i))
    return " ".join([str(i) for i in r])

Version data entries

344 entries across 344 versions & 1 rubygems

Version Path
trackler-2.2.1.127 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.126 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.125 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.124 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.123 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.122 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.121 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.120 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.119 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.118 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.117 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.116 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.115 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.114 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.113 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.111 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.110 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.109 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.108 tracks/python/exercises/pascals-triangle/example.py
trackler-2.2.1.107 tracks/python/exercises/pascals-triangle/example.py