make a script to generate random animals with occupations

This commit is contained in:
2024-08-13 00:08:07 -06:00
commit d0315a0e94
5 changed files with 65 additions and 0 deletions

37
main.go Normal file
View 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])
}
}