make a script to generate random animals with occupations
This commit is contained in:
37
main.go
Normal file
37
main.go
Normal file
@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
animals := []string{
|
||||
"Fox", "Rabbit", "Panda", "Penguin", "Koala", "Squirrel", "Owl", "Hedgehog", "Cat", "Dog",
|
||||
"Deer", "Elephant", "Otter", "Raccoon", "Sloth", "Mouse", "Turtle", "Bear", "Chick", "Sheep",
|
||||
}
|
||||
|
||||
occupations := []string{
|
||||
"Doctor", "Teacher", "Chef", "Firefighter", "Police Officer", "Astronaut", "Artist", "Musician",
|
||||
"Engineer", "Scientist", "Pilot", "Farmer", "Librarian", "Detective", "Photographer", "Writer",
|
||||
"Carpenter", "Mechanic", "Veterinarian", "Zookeeper",
|
||||
}
|
||||
|
||||
// Seed the random number generator
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
// Shuffle both lists
|
||||
rand.Shuffle(len(animals), func(i, j int) {
|
||||
animals[i], animals[j] = animals[j], animals[i]
|
||||
})
|
||||
|
||||
rand.Shuffle(len(occupations), func(i, j int) {
|
||||
occupations[i], occupations[j] = occupations[j], occupations[i]
|
||||
})
|
||||
|
||||
// Print the randomly paired animals and occupations
|
||||
for i := 0; i < len(animals); i++ {
|
||||
fmt.Printf("%s %s\n", animals[i], occupations[i])
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user