Created
June 18, 2019 17:00
-
-
Save ya8282/f173cbbde8131eb4ce4c3ed266e407d4 to your computer and use it in GitHub Desktop.
Pair teachers and learners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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