From d0315a0e9426c904f8d5655a090cb7409bb3ad57 Mon Sep 17 00:00:00 2001 From: Mason Payne Date: Tue, 13 Aug 2024 00:08:07 -0600 Subject: [PATCH] make a script to generate random animals with occupations --- .idea/.gitignore | 8 ++++++++ .idea/animal-occupations.iml | 9 +++++++++ .idea/modules.xml | 8 ++++++++ go.mod | 3 +++ main.go | 37 ++++++++++++++++++++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/animal-occupations.iml create mode 100644 .idea/modules.xml create mode 100644 go.mod create mode 100644 main.go diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -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 diff --git a/.idea/animal-occupations.iml b/.idea/animal-occupations.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/animal-occupations.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..bfdd647 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ea22100 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module animal-occupations + +go 1.22 diff --git a/main.go b/main.go new file mode 100644 index 0000000..86bdc9a --- /dev/null +++ b/main.go @@ -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]) + } +}