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.56 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.55 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.54 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.53 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.52 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.51 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.50 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.49 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.48 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.47 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.46 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.45 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.44 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.43 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.42 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.41 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.40 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.39 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.38 tracks/go/exercises/pascals-triangle/example.go
trackler-2.2.1.37 tracks/go/exercises/pascals-triangle/example.go