Skip to content

Instantly share code, notes, and snippets.

@ya8282
Created June 18, 2019 17:00
Show Gist options
  • Save ya8282/f173cbbde8131eb4ce4c3ed266e407d4 to your computer and use it in GitHub Desktop.
Save ya8282/f173cbbde8131eb4ce4c3ed266e407d4 to your computer and use it in GitHub Desktop.
Pair teachers and learners
package main
import (
"fmt"
"hash/fnv"
)
func hnv_hash(s string) uint32 {
h := fnv.New32a()
h.Write([]byte(s))
return h.Sum32()
}
func main() {
teachers := []string{"Mike Hampton", "Chris Cho", "Rebecca Lau", "Jack Ratner", "Brian Buchholz"}
learners := []string{"Colin MacKenzie", "Emily Giurleo", "Joseph Kim", "Mike Boyle", "Scott Rigby", "Xavier Lopez", "Michael Hoffman", "Josh Goldberg"}
for i := 0; i < len(learners); i++ {
hval := int(hnv_hash(learners[i])) % len(teachers)
fmt.Printf("%s: %s\n", learners[i], teachers[hval])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment