Skip to content

Instantly share code, notes, and snippets.

@jbfink
Created September 6, 2018 23:31
Show Gist options
  • Save jbfink/8001fe9be26fb0960c8c28249cd27a7f to your computer and use it in GitHub Desktop.
Save jbfink/8001fe9be26fb0960c8c28249cd27a7f to your computer and use it in GitHub Desktop.
package hamming
//import "errors"
import "strings"
//import "fmt"
func Distance(a, b string) (int, error) {
a1 := strings.Split(a, "")
b1 := strings.Split(b, "")
if len(a1) != len(b1) {
return -1, nil
} else if a == b {
return 0, nil
}
// Here, a loop of some sort, nested?
// Like, loop elements from 0 to len(a1) (by this point a1 and b1 will have identical len)
// for each element:
// if a1[x] == b1[x] then add 0 to distance variable
// if a1[x] != b1[x] then add 1 to distance variable
// after len(a1), return variable, nil
// (why error at all? buh)
return 0, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment