Sha256: 01db00f9468ec826defbac33767d6247b65f81e1a036386f559f049d0e0addfb

Contents?: true

Size: 315 Bytes

Versions: 166

Compression:

Stored size: 315 Bytes

Contents

package pascal

const testVersion = 1

func Triangle(n int) (t [][]int) {
	if n < 1 {
		return
	}
	t = make([][]int, n)
	r := []int{1}
	t[0] = r
	for i := 1; i < n; i++ {
		last := r
		r = make([]int, i+1)
		r[0] = 1
		r[i] = 1
		for j := 1; j < i; j++ {
			r[j] = last[j-1] + last[j]
		}
		t[i] = r
	}
	return t
}

Version data entries

166 entries across 166 versions & 1 rubygems

Version Path
trackler-2.2.1.16 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.15 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.14 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.13 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.12 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.11 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.10 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.9 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.8 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.7 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.6 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.5 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.4 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.3 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.2 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.1 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.0 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.0.6 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.0.5 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.0.4 tracks/go/exercises/pascals-triangle/example.go