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.0.3 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.0.2 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.0.1 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.0.0 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.55 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.54 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.53 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.52 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.51 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.50 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.49 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.48 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.47 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.46 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.45 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.44 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.43 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.42 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.41 tracks/go/exercises/pascals-triangle/example.go
trackler-2.1.0.40 tracks/go/exercises/pascals-triangle/example.go