Skip to content

Instantly share code, notes, and snippets.

@pjvds
Created August 30, 2014 18:29
Show Gist options
  • Save pjvds/56a5b2f4f517d144da7f to your computer and use it in GitHub Desktop.
Save pjvds/56a5b2f4f517d144da7f to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
input := getRandomList(25 * 1000 * 1000)
fmt.Println(len(input))
}
func getRandomList(length int) []int {
result := make([]int, length, length)
for i := 0; i < length; i++ {
result[i] = i + 1
}
for i := 0; i < length; i++ {
randomIndex := rand.Intn(length - 1)
left := result[i]
right := result[randomIndex]
result[i] = right
result[randomIndex] = left
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment