Sha256: 1f816343eee866aa8110a87f97c68654e047f884533814f35161f81e80294484

Contents?: true

Size: 477 Bytes

Versions: 134

Compression:

Stored size: 477 Bytes

Contents

use "collections"
use "itertools"

primitive PascalsTriangle
  fun rows(count: USize): Array[Array[USize]] =>
    Iter[USize](Range(0, count))
      .map[Array[USize]]({(n: USize): Array[USize] => PascalsTriangle.row(n)})
      .collect(Array[Array[USize]](count))

  fun row(n: USize): Array[USize] =>
    let r = Array[USize](n).>push(1)
    for i in Range(1, n + 1) do
      try
        let last = r(i - 1)
        r.push((last * ((n + 1) - i)) / i)
      end
    end
    r

Version data entries

134 entries across 134 versions & 1 rubygems

Version Path
trackler-2.2.1.6 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.1.5 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.1.4 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.1.3 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.1.2 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.1.1 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.1.0 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.0.6 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.0.5 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.0.4 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.0.3 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.0.2 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.0.1 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.2.0.0 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.1.0.55 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.1.0.54 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.1.0.53 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.1.0.52 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.1.0.51 tracks/pony/exercises/pascals-triangle/example.pony
trackler-2.1.0.50 tracks/pony/exercises/pascals-triangle/example.pony