Sha256: 0c179b70d014d6557ce54757d1997328997c476bfcfac838cb80ed66a0533d38

Contents?: true

Size: 398 Bytes

Versions: 173

Compression:

Stored size: 398 Bytes

Contents

package transpose

func Transpose(m []string) []string {
	max := maxLen(m)
	t := make([]string, max)
	for i, row := range m {
		for j, c := range row {
			t[j] += string(c)
		}
		remMax := maxLen(m[i:])
		for j := len(row); j < remMax; j++ {
			t[j] += " "
		}
	}
	return t
}

func maxLen(m []string) (length int) {
	for _, l := range m {
		if len(l) > length {
			length = len(l)
		}
	}
	return
}

Version data entries

173 entries across 173 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/transpose/example.go
trackler-2.2.1.179 tracks/go/exercises/transpose/example.go
trackler-2.2.1.178 tracks/go/exercises/transpose/example.go
trackler-2.2.1.177 tracks/go/exercises/transpose/example.go
trackler-2.2.1.176 tracks/go/exercises/transpose/example.go
trackler-2.2.1.175 tracks/go/exercises/transpose/example.go
trackler-2.2.1.174 tracks/go/exercises/transpose/example.go
trackler-2.2.1.173 tracks/go/exercises/transpose/example.go
trackler-2.2.1.172 tracks/go/exercises/transpose/example.go
trackler-2.2.1.171 tracks/go/exercises/transpose/example.go
trackler-2.2.1.170 tracks/go/exercises/transpose/example.go
trackler-2.2.1.169 tracks/go/exercises/transpose/example.go
trackler-2.2.1.167 tracks/go/exercises/transpose/example.go
trackler-2.2.1.166 tracks/go/exercises/transpose/example.go
trackler-2.2.1.165 tracks/go/exercises/transpose/example.go
trackler-2.2.1.164 tracks/go/exercises/transpose/example.go
trackler-2.2.1.163 tracks/go/exercises/transpose/example.go
trackler-2.2.1.162 tracks/go/exercises/transpose/example.go
trackler-2.2.1.161 tracks/go/exercises/transpose/example.go
trackler-2.2.1.160 tracks/go/exercises/transpose/example.go