make a script to generate random animals with occupations
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
9
.idea/animal-occupations.iml
generated
Normal file
9
.idea/animal-occupations.iml
generated
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="Go" enabled="true" />
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/animal-occupations.iml" filepath="$PROJECT_DIR$/.idea/animal-occupations.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
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