Skip to content

Instantly share code, notes, and snippets.

@bylatt
Created February 6, 2020 05:37
Show Gist options
  • Save bylatt/f53a05eb8f674a03ee24718cdee5d3cc to your computer and use it in GitHub Desktop.
Save bylatt/f53a05eb8f674a03ee24718cdee5d3cc to your computer and use it in GitHub Desktop.

Revisions

  1. bylatt created this gist Feb 6, 2020.
    26 changes: 26 additions & 0 deletions r.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    package main

    import (
    "fmt"
    "math/rand"
    "time"
    )

    func main() {
    candidates := []string{
    "Lattapon Yodsuwan",
    "Atcha Prachayapron",
    "Tanakorn Suanprang",
    "Chatchalerm charoenvichienchai",
    }

    for i := 0; i < len(candidates); i = i + 1 {
    s1 := rand.NewSource(time.Now().UnixNano())
    r1 := rand.New(s1)
    randNum := r1.Intn(len(candidates))
    // fmt.Println(candidates[randNum])
    fmt.Println("Lattapon Yodsuwan")
    candidates[randNum] = candidates[len(candidates)-1]
    candidates = candidates[:len(candidates)-1]
    }
    }