Sha256: 92f3fcd49b0a424b32436d4e940ba40f2291b0ce5d3c0702c0b6788f58e98226

Contents?: true

Size: 235 Bytes

Versions: 122

Compression:

Stored size: 235 Bytes

Contents

package hamming

import "errors"

func Distance(a, b string) (d int, err error) {
	if len(b) != len(a) {
		return 0, errors.New("strings of unequal length")
	}
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			d++
		}
	}
	return
}

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/go/exercises/hamming/example.go
trackler-2.2.1.138 tracks/go/exercises/hamming/example.go
trackler-2.2.1.137 tracks/go/exercises/hamming/example.go
trackler-2.2.1.136 tracks/go/exercises/hamming/example.go
trackler-2.2.1.135 tracks/go/exercises/hamming/example.go
trackler-2.2.1.134 tracks/go/exercises/hamming/example.go
trackler-2.2.1.133 tracks/go/exercises/hamming/example.go
trackler-2.2.1.132 tracks/go/exercises/hamming/example.go
trackler-2.2.1.131 tracks/go/exercises/hamming/example.go
trackler-2.2.1.130 tracks/go/exercises/hamming/example.go
trackler-2.2.1.129 tracks/go/exercises/hamming/example.go
trackler-2.2.1.128 tracks/go/exercises/hamming/example.go
trackler-2.2.1.127 tracks/go/exercises/hamming/example.go
trackler-2.2.1.126 tracks/go/exercises/hamming/example.go
trackler-2.2.1.125 tracks/go/exercises/hamming/example.go
trackler-2.2.1.124 tracks/go/exercises/hamming/example.go
trackler-2.2.1.123 tracks/go/exercises/hamming/example.go
trackler-2.2.1.122 tracks/go/exercises/hamming/example.go
trackler-2.2.1.121 tracks/go/exercises/hamming/example.go
trackler-2.2.1.120 tracks/go/exercises/hamming/example.go