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