package main
import (
"bufio"
"fmt"
"math/rand"
"os"
"time"
)
func main() {
users := make(map[int]string)
users[0] = "Mike"
users[1] = "Paul"
users[2] = "Steve"
users[3] = "Lawrence"
users[4] = "Stephen"
users[5] = "James"
getNextSpeaker(users)
}
func getNextSpeaker(users map[int]string) {
numUsers := len(users)
list := randList(1, numUsers)
for _, element := range list {
fmt.Println(users[element-1])
pressAnyKey()
}
}
func randList(min, max int) []int {
if max < min {
min, max = max, min
}
length := max - min + 1
rand.
Seed(int64(t0.
Nanosecond())) list
:= rand.
Perm(length
) for index, _ := range list {
list[index] += min
}
return list
}
func pressAnyKey() string {
fmt.Println("Press Return To Continue...")
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
if err != nil {
panic(err)
}
return input
}
cGFja2FnZSBtYWluCgppbXBvcnQgKAogICAgImJ1ZmlvIgogICAgImZtdCIKICAgICJtYXRoL3JhbmQiCiAgICAib3MiCiAgICAidGltZSIKKQoKZnVuYyBtYWluKCkgewoKICAgIHVzZXJzIDo9IG1ha2UobWFwW2ludF1zdHJpbmcpCgogICAgdXNlcnNbMF0gPSAiTWlrZSIKICAgIHVzZXJzWzFdID0gIlBhdWwiCiAgICB1c2Vyc1syXSA9ICJTdGV2ZSIKICAgIHVzZXJzWzNdID0gIkxhd3JlbmNlIgogICAgdXNlcnNbNF0gPSAiU3RlcGhlbiIKICAgIHVzZXJzWzVdID0gIkphbWVzIgoKICAgIGdldE5leHRTcGVha2VyKHVzZXJzKQoKfQoKZnVuYyBnZXROZXh0U3BlYWtlcih1c2VycyBtYXBbaW50XXN0cmluZykgewogICAgbnVtVXNlcnMgOj0gbGVuKHVzZXJzKQogICAgbGlzdCA6PSByYW5kTGlzdCgxLCBudW1Vc2VycykKCiAgICBmb3IgXywgZWxlbWVudCA6PSByYW5nZSBsaXN0IHsKICAgICAgICBmbXQuUHJpbnRsbih1c2Vyc1tlbGVtZW50LTFdKQogICAgICAgIHByZXNzQW55S2V5KCkKICAgIH0KCn0KCm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