40 lines
		
	
	
		
			637 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			637 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package main
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"hash/crc32"
 | |
| 	"hash/crc64"
 | |
| 	"math/rand"
 | |
| )
 | |
| 
 | |
| var (
 | |
| 	names = []string{
 | |
| 		"John",
 | |
| 		"Paul",
 | |
| 		"Peter",
 | |
| 		"Sam",
 | |
| 		"Susan",
 | |
| 		"Sarah",
 | |
| 		"Melony",
 | |
| 	}
 | |
| 	date = "2024-08-14"
 | |
| )
 | |
| 
 | |
| func removeIndex(s []string, i int) []string {
 | |
| 	ret := make([]string, 0)
 | |
| 	ret = append(ret, s[:i]...)
 | |
| 	return append(ret, s[i+1:]...)
 | |
| }
 | |
| 
 | |
| func main() {
 | |
| 	seed := crc64.Checksum([]byte(date), crc64.MakeTable(crc32.IEEE))
 | |
| 	r := rand.New(rand.NewSource((int64(seed))))
 | |
| 
 | |
| 	totalNames := len(names) - 1
 | |
| 	for i := 0; i <= totalNames; i++ {
 | |
| 		index := r.Intn(len(names))
 | |
| 		fmt.Printf("%s\n", names[index])
 | |
| 		names = removeIndex(names, index)
 | |
| 	}
 | |
| }
 |