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-1.0.1.1 tracks/python/exercises/pascals-triangle/example.py
trackler-1.0.1.0 tracks/python/exercises/pascals-triangle/example.py
trackler-1.0.0.1 tracks/python/exercises/pascals-triangle/example.py
trackler-1.0.0 tracks/python/exercises/pascals-triangle/example.py