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.119 tracks/go/exercises/transpose/example.go
trackler-2.2.1.118 tracks/go/exercises/transpose/example.go
trackler-2.2.1.117 tracks/go/exercises/transpose/example.go
trackler-2.2.1.116 tracks/go/exercises/transpose/example.go
trackler-2.2.1.115 tracks/go/exercises/transpose/example.go
trackler-2.2.1.114 tracks/go/exercises/transpose/example.go
trackler-2.2.1.113 tracks/go/exercises/transpose/example.go
trackler-2.2.1.111 tracks/go/exercises/transpose/example.go
trackler-2.2.1.110 tracks/go/exercises/transpose/example.go
trackler-2.2.1.109 tracks/go/exercises/transpose/example.go
trackler-2.2.1.108 tracks/go/exercises/transpose/example.go
trackler-2.2.1.107 tracks/go/exercises/transpose/example.go
trackler-2.2.1.106 tracks/go/exercises/transpose/example.go
trackler-2.2.1.105 tracks/go/exercises/transpose/example.go
trackler-2.2.1.104 tracks/go/exercises/transpose/example.go
trackler-2.2.1.103 tracks/go/exercises/transpose/example.go
trackler-2.2.1.102 tracks/go/exercises/transpose/example.go
trackler-2.2.1.101 tracks/go/exercises/transpose/example.go
trackler-2.2.1.100 tracks/go/exercises/transpose/example.go
trackler-2.2.1.99 tracks/go/exercises/transpose/example.go