Skip to content

Instantly share code, notes, and snippets.

@matryer
Last active May 21, 2020 01:54
Show Gist options
  • Save matryer/361c4765d5a2a4efd38f6b42bb038c33 to your computer and use it in GitHub Desktop.
Save matryer/361c4765d5a2a4efd38f6b42bb038c33 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
// all the peeps in a map ensures no duplicates
peeps := map[string]bool{
"micuffaro": true,
"atla_": true,
"lucafmarques": true,
"msvechla": true,
"halderstein": true,
"villevalto": true,
"bleogf": true,
"martinbeentjes": true,
"SaScala": true,
"tpanum": true,
"sonir1c0": true,
"AttahJhojho": true,
"DillemaHedgehog": true,
"_adonese": true,
"erikaarohans": true,
"nothinux": true,
"zaguerinho": true,
"_fgrosse": true,
"jekabolt": true,
"alissonbrunosa": true,
"suddengunter": true,
"nilpointer1": true,
"ashvyas8": true,
"steffenlundin": true,
"OdemAlexander": true,
"molmedoz": true,
"tidymince": true,
"vidyuthd": true,
"_lffg": true,
"rafaribe10": true,
"V_Ravi_Chandra": true,
"thrauglor": true,
"icernn": true,
"nahue_js": true,
"nunolopes_99": true,
"AstartesKC": true,
"qneyrat": true,
"danvixent": true,
"serafdev": true,
"cars10w": true,
"jesserlucas": true,
"codingCookie": true,
"willdot1": true,
"jub0bs": true,
"rockey5520": true,
"dBu_fs": true,
"DanielPedro09": true,
"scea1951": true,
"thanksforask1ng": true,
"GlennPaquette": true,
"dlpetrie": true,
"FofiuIancu": true,
"monirz001": true,
"MonuTripathi": true,
"Fallion": true,
"Dean1s": true,
"AngelDev15": true,
"javkarparesh": true,
"vnwrt_io": true,
"CarlHembrough": true,
"DeeDeji20": true,
"arun_v_m": true,
"_davgod": true,
"pawel_lekki": true,
"Oluwakorede_": true,
"shashankS68": true,
"Abo_Shanab": true,
"Hardiansyah14": true,
"arturoaviles": true,
"arsidada": true,
"dertseha": true,
"runner_ca_to_me": true,
"emaele_": true,
"w0rddriven": true,
"cyrus_javan": true,
"codematix": true,
"Andrew_Brudnak": true,
"smaziano": true,
"sudokhanh": true,
"patrickseidler": true,
"codingpop": true,
"felixwostal": true,
"KarlRanseier": true,
"minhluanor": true,
"herecomesjaycee": true,
"adeshinaHH": true,
"TheRealSabreezy": true,
"olibaumann": true,
"seannalexander": true,
"TheGolurk": true,
"aguwatudde": true,
"brownio_": true,
"MathisEngelbart": true,
"lchausmann": true,
"AdrianMester": true,
}
// put the names into a slice
peepsSlice := make([]string, 0, len(peeps))
for name := range peeps {
peepsSlice = append(peepsSlice, name)
}
// randomise the seed
rand.Seed(time.Now().UnixNano())
// shuffle the slice
rand.Shuffle(len(peepsSlice), func(i, j int) {
peepsSlice[i], peepsSlice[j] = peepsSlice[j], peepsSlice[i]
})
// eleven winners
winners := 11
// pick the first ten
peepsSlice = peepsSlice[:winners]
fmt.Println("And the winners are...")
// print the winners slowly, for dramatic effect
for i, peep := range peepsSlice {
time.Sleep(2 * time.Second)
fmt.Printf("Winner #%d: %s\n", i+1, peep)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment