From da911d4ae5548c062341d13a7d109f3e2c43737d Mon Sep 17 00:00:00 2001 From: Inanc Gumus Date: Mon, 22 Oct 2018 22:44:36 +0300 Subject: [PATCH] refactor: variables/assignment exercises and questions --- .../exercise/solution/golang/cmd/main.go | 2 +- .../exercises/{01 => 01-make-it-blue}/main.go | 7 +++--- .../{01 => 01-make-it-blue}/solution/main.go | 0 .../exercises/{02 => 02-vars-to-vars}/main.go | 20 ++++++++------- .../{02 => 02-vars-to-vars}/solution/main.go | 0 .../main.go | 7 +++--- .../solution/main.go | 0 .../main.go | 9 ++++--- .../solution/main.go | 0 .../exercises/{05 => 05-multi-assign}/main.go | 7 +++--- .../{05 => 05-multi-assign}/solution/main.go | 0 .../{06 => 06-multi-assign-2}/main.go | 7 +++--- .../solution/main.go | 0 .../{07 => 07-multi-short-func}/main.go | 11 ++++---- .../solution/main.go | 0 .../exercises/{08 => 08-swapper}/main.go | 7 +++--- .../{08 => 08-swapper}/solution/main.go | 0 .../exercises/{09 => 09-swapper-2}/main.go | 7 +++--- .../{09 => 09-swapper-2}/solution/main.go | 0 .../{10 => 10-discard-the-file}/main.go | 7 +++--- .../solution/main.go | 0 .../04-assignment/exercises/README.md | 25 +++++++++++++++++++ .../questions/{questions.md => README.md} | 0 23 files changed, 76 insertions(+), 40 deletions(-) rename 06-variables/04-assignment/exercises/{01 => 01-make-it-blue}/main.go (82%) rename 06-variables/04-assignment/exercises/{01 => 01-make-it-blue}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{02 => 02-vars-to-vars}/main.go (66%) rename 06-variables/04-assignment/exercises/{02 => 02-vars-to-vars}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{03 => 03-assign-with-expressions}/main.go (82%) rename 06-variables/04-assignment/exercises/{03 => 03-assign-with-expressions}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{04 => 04-find-the-rectangle-area}/main.go (79%) rename 06-variables/04-assignment/exercises/{04 => 04-find-the-rectangle-area}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{05 => 05-multi-assign}/main.go (87%) rename 06-variables/04-assignment/exercises/{05 => 05-multi-assign}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{06 => 06-multi-assign-2}/main.go (85%) rename 06-variables/04-assignment/exercises/{06 => 06-multi-assign-2}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{07 => 07-multi-short-func}/main.go (74%) rename 06-variables/04-assignment/exercises/{07 => 07-multi-short-func}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{08 => 08-swapper}/main.go (85%) rename 06-variables/04-assignment/exercises/{08 => 08-swapper}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{09 => 09-swapper-2}/main.go (81%) rename 06-variables/04-assignment/exercises/{09 => 09-swapper-2}/solution/main.go (100%) rename 06-variables/04-assignment/exercises/{10 => 10-discard-the-file}/main.go (80%) rename 06-variables/04-assignment/exercises/{10 => 10-discard-the-file}/solution/main.go (100%) create mode 100644 06-variables/04-assignment/exercises/README.md rename 06-variables/04-assignment/questions/{questions.md => README.md} (100%) diff --git a/05-write-your-first-library-package/exercise/solution/golang/cmd/main.go b/05-write-your-first-library-package/exercise/solution/golang/cmd/main.go index 3679ee8..b60a5fb 100644 --- a/05-write-your-first-library-package/exercise/solution/golang/cmd/main.go +++ b/05-write-your-first-library-package/exercise/solution/golang/cmd/main.go @@ -10,7 +10,7 @@ package main import ( "fmt" // You should replace this with your username - "github.com/inancgumus/learngo/05-write-your-first-library-package/printer-exercise/solution/golang" + "github.com/inancgumus/learngo/05-write-your-first-library-package/exercise/solution/golang" ) func main() { diff --git a/06-variables/04-assignment/exercises/01/main.go b/06-variables/04-assignment/exercises/01-make-it-blue/main.go similarity index 82% rename from 06-variables/04-assignment/exercises/01/main.go rename to 06-variables/04-assignment/exercises/01-make-it-blue/main.go index 6a5334b..fe1c36c 100644 --- a/06-variables/04-assignment/exercises/01/main.go +++ b/06-variables/04-assignment/exercises/01-make-it-blue/main.go @@ -8,10 +8,11 @@ package main // --------------------------------------------------------- -// EXERCISE -// 1- Change `color` variable's value to "blue" +// EXERCISE: Make It Blue // -// 2- Print it +// 1. Change `color` variable's value to "blue" +// +// 2. Print it // // EXPECTED OUTPUT // blue diff --git a/06-variables/04-assignment/exercises/01/solution/main.go b/06-variables/04-assignment/exercises/01-make-it-blue/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/01/solution/main.go rename to 06-variables/04-assignment/exercises/01-make-it-blue/solution/main.go diff --git a/06-variables/04-assignment/exercises/02/main.go b/06-variables/04-assignment/exercises/02-vars-to-vars/main.go similarity index 66% rename from 06-variables/04-assignment/exercises/02/main.go rename to 06-variables/04-assignment/exercises/02-vars-to-vars/main.go index 98b78e4..575b65e 100644 --- a/06-variables/04-assignment/exercises/02/main.go +++ b/06-variables/04-assignment/exercises/02-vars-to-vars/main.go @@ -8,25 +8,27 @@ package main // --------------------------------------------------------- -// EXERCISE -// 1- Change the value of `color` variable to "dark green" +// EXERCISE: Variables To Variables // -// 2- Do not assign "dark green" to `color` directly +// 1. Change the value of `color` variable to "dark green" +// +// 2. Do not assign "dark green" to `color` directly // // Instead, use the `color` variable again // while assigning to `color` // -// 3- Print it +// 3. Print it // // RESTRICTIONS -// WRONG ANSWER, DO NOT DO THIS: -// `color = "dark green"` +// WRONG ANSWER, DO NOT DO THIS: +// `color = "dark green"` // // HINT -// + operator can concatenate string values +// + operator can concatenate string values // -// Example: -// "h" + "e" + "y" returns "hey" +// Example: +// +// "h" + "e" + "y" returns "hey" // // EXPECTED OUTPUT // dark green diff --git a/06-variables/04-assignment/exercises/02/solution/main.go b/06-variables/04-assignment/exercises/02-vars-to-vars/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/02/solution/main.go rename to 06-variables/04-assignment/exercises/02-vars-to-vars/solution/main.go diff --git a/06-variables/04-assignment/exercises/03/main.go b/06-variables/04-assignment/exercises/03-assign-with-expressions/main.go similarity index 82% rename from 06-variables/04-assignment/exercises/03/main.go rename to 06-variables/04-assignment/exercises/03-assign-with-expressions/main.go index ab0a651..6065e97 100644 --- a/06-variables/04-assignment/exercises/03/main.go +++ b/06-variables/04-assignment/exercises/03-assign-with-expressions/main.go @@ -10,10 +10,11 @@ package main import "fmt" // --------------------------------------------------------- -// EXERCISE -// 1- Multiply 3.14 with 2 and assign it to `n` variable +// EXERCISE: Assign With Expressions // -// 2- Print the `n` variable +// 1. Multiply 3.14 with 2 and assign it to `n` variable +// +// 2. Print the `n` variable // // HINT // Example: 3 * 2 = 6 diff --git a/06-variables/04-assignment/exercises/03/solution/main.go b/06-variables/04-assignment/exercises/03-assign-with-expressions/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/03/solution/main.go rename to 06-variables/04-assignment/exercises/03-assign-with-expressions/solution/main.go diff --git a/06-variables/04-assignment/exercises/04/main.go b/06-variables/04-assignment/exercises/04-find-the-rectangle-area/main.go similarity index 79% rename from 06-variables/04-assignment/exercises/04/main.go rename to 06-variables/04-assignment/exercises/04-find-the-rectangle-area/main.go index 1cf3b75..89bc42c 100644 --- a/06-variables/04-assignment/exercises/04/main.go +++ b/06-variables/04-assignment/exercises/04-find-the-rectangle-area/main.go @@ -8,14 +8,15 @@ package main // --------------------------------------------------------- -// EXERCISE -// 1- Find the length of a rectangle +// EXERCISE: Find the Rectangle's Area +// +// 1. Find the length of a rectangle // Its width is 5 // Its height is 6 // -// 2- Assign the result to the `length` variable +// 2. Assign the result to the `length` variable // -// 3- Print the `length` variable +// 3. Print the `length` variable // // HINT // Rectangle formula = 2 * (width + height) diff --git a/06-variables/04-assignment/exercises/04/solution/main.go b/06-variables/04-assignment/exercises/04-find-the-rectangle-area/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/04/solution/main.go rename to 06-variables/04-assignment/exercises/04-find-the-rectangle-area/solution/main.go diff --git a/06-variables/04-assignment/exercises/05/main.go b/06-variables/04-assignment/exercises/05-multi-assign/main.go similarity index 87% rename from 06-variables/04-assignment/exercises/05/main.go rename to 06-variables/04-assignment/exercises/05-multi-assign/main.go index d36c8a5..abdebc4 100644 --- a/06-variables/04-assignment/exercises/05/main.go +++ b/06-variables/04-assignment/exercises/05-multi-assign/main.go @@ -10,12 +10,13 @@ package main import "fmt" // --------------------------------------------------------- -// EXERCISE -// 1- Assign "go" to `lang` variable +// EXERCISE: Multi Assign +// +// 1. Assign "go" to `lang` variable // and assign 2 to `version` variable // using a multiple assignment statement // -// 2- Print the variables +// 2. Print the variables // // EXPECTED OUTPUT // go version 2 diff --git a/06-variables/04-assignment/exercises/05/solution/main.go b/06-variables/04-assignment/exercises/05-multi-assign/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/05/solution/main.go rename to 06-variables/04-assignment/exercises/05-multi-assign/solution/main.go diff --git a/06-variables/04-assignment/exercises/06/main.go b/06-variables/04-assignment/exercises/06-multi-assign-2/main.go similarity index 85% rename from 06-variables/04-assignment/exercises/06/main.go rename to 06-variables/04-assignment/exercises/06-multi-assign-2/main.go index 342486c..5402d6a 100644 --- a/06-variables/04-assignment/exercises/06/main.go +++ b/06-variables/04-assignment/exercises/06-multi-assign-2/main.go @@ -8,11 +8,12 @@ package main // --------------------------------------------------------- -// EXERCISE -// 1- Assign the correct values to the variables +// EXERCISE: Multi Assign #2 +// +// 1. Assign the correct values to the variables // to match to the EXPECTED OUTPUT below // -// 2- Print the variables +// 2. Print the variables // // HINT // Use multiple Println calls to print each sentence. diff --git a/06-variables/04-assignment/exercises/06/solution/main.go b/06-variables/04-assignment/exercises/06-multi-assign-2/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/06/solution/main.go rename to 06-variables/04-assignment/exercises/06-multi-assign-2/solution/main.go diff --git a/06-variables/04-assignment/exercises/07/main.go b/06-variables/04-assignment/exercises/07-multi-short-func/main.go similarity index 74% rename from 06-variables/04-assignment/exercises/07/main.go rename to 06-variables/04-assignment/exercises/07-multi-short-func/main.go index 93ee098..a553c9c 100644 --- a/06-variables/04-assignment/exercises/07/main.go +++ b/06-variables/04-assignment/exercises/07-multi-short-func/main.go @@ -8,14 +8,15 @@ package main // --------------------------------------------------------- -// EXERCISE -// 1- Multiple short declare two variables +// EXERCISE: Multi Short Func // -// 2- Initialize variables using `multi` function below +// 1. Multiple short declare two variables // -// 3- Discard the 1st variable's value in the declaration +// 2. Initialize variables using `multi` function below // -// 4- Print only the 2nd variable +// 3. Discard the 1st variable's value in the declaration +// +// 4. Print only the 2nd variable // // NOTE // You should use `multi` function diff --git a/06-variables/04-assignment/exercises/07/solution/main.go b/06-variables/04-assignment/exercises/07-multi-short-func/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/07/solution/main.go rename to 06-variables/04-assignment/exercises/07-multi-short-func/solution/main.go diff --git a/06-variables/04-assignment/exercises/08/main.go b/06-variables/04-assignment/exercises/08-swapper/main.go similarity index 85% rename from 06-variables/04-assignment/exercises/08/main.go rename to 06-variables/04-assignment/exercises/08-swapper/main.go index fe0c4a6..7f81e7c 100644 --- a/06-variables/04-assignment/exercises/08/main.go +++ b/06-variables/04-assignment/exercises/08-swapper/main.go @@ -8,13 +8,14 @@ package main // --------------------------------------------------------- -// EXERCISE -// 1- Change `color` to "orange" +// EXERCISE: Swapper +// +// 1. Change `color` to "orange" // and `color2` to "green" at the same time // // (use multiple-assignment) // -// 2- Print the variables +// 2. Print the variables // // EXPECTED OUTPUT // orange green diff --git a/06-variables/04-assignment/exercises/08/solution/main.go b/06-variables/04-assignment/exercises/08-swapper/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/08/solution/main.go rename to 06-variables/04-assignment/exercises/08-swapper/solution/main.go diff --git a/06-variables/04-assignment/exercises/09/main.go b/06-variables/04-assignment/exercises/09-swapper-2/main.go similarity index 81% rename from 06-variables/04-assignment/exercises/09/main.go rename to 06-variables/04-assignment/exercises/09-swapper-2/main.go index 4188b4f..4503d4c 100644 --- a/06-variables/04-assignment/exercises/09/main.go +++ b/06-variables/04-assignment/exercises/09-swapper-2/main.go @@ -8,10 +8,11 @@ package main // --------------------------------------------------------- -// EXERCISE -// 1- Swap the values of `red` and `blue` variables +// EXERCISE: Swapper #2 // -// 2- Print them +// 1. Swap the values of `red` and `blue` variables +// +// 2. Print them // // EXPECTED OUTPUT // blue red diff --git a/06-variables/04-assignment/exercises/09/solution/main.go b/06-variables/04-assignment/exercises/09-swapper-2/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/09/solution/main.go rename to 06-variables/04-assignment/exercises/09-swapper-2/solution/main.go diff --git a/06-variables/04-assignment/exercises/10/main.go b/06-variables/04-assignment/exercises/10-discard-the-file/main.go similarity index 80% rename from 06-variables/04-assignment/exercises/10/main.go rename to 06-variables/04-assignment/exercises/10-discard-the-file/main.go index 1212890..be52c19 100644 --- a/06-variables/04-assignment/exercises/10/main.go +++ b/06-variables/04-assignment/exercises/10-discard-the-file/main.go @@ -8,10 +8,11 @@ package main // --------------------------------------------------------- -// EXERCISE -// Print only the directory using `path.Split` +// EXERCISE: Discard The File // -// Discard the file part +// 1. Print only the directory using `path.Split` +// +// 2. Discard the file part // // RESTRICTION // Use short declaration diff --git a/06-variables/04-assignment/exercises/10/solution/main.go b/06-variables/04-assignment/exercises/10-discard-the-file/solution/main.go similarity index 100% rename from 06-variables/04-assignment/exercises/10/solution/main.go rename to 06-variables/04-assignment/exercises/10-discard-the-file/solution/main.go diff --git a/06-variables/04-assignment/exercises/README.md b/06-variables/04-assignment/exercises/README.md new file mode 100644 index 0000000..7a8fdfb --- /dev/null +++ b/06-variables/04-assignment/exercises/README.md @@ -0,0 +1,25 @@ +# Assignments + +Assignment means "copying" values. Everything is get copied in Go. You'll learn more about this afterwards. + +Now, get your feet wet and try some assignment exercises. + +1. **[Make It Blue](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/01-make-it-blue)** + +2. **[Variables To Variables](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/02-vars-to-vars)** + +3. **[Assign With Expressions](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/03-assign-with-expressions)** + +4. **[Find the Rectangle's Area](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/04-find-the-rectangle-area)** + +5. **[Multi Assign](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/05-multi-assign)** + +6. **[Multi Assign #2](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/06-multi-assign-2)** + +7. **[Multi Short Func](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/07-multi-short-func)** + +8. **[Swapper](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/08-swapper)** + +9. **[Swapper #2](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/09-swapper-2)** + +10. **[Discard The File](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/10-discard-the-file)** diff --git a/06-variables/04-assignment/questions/questions.md b/06-variables/04-assignment/questions/README.md similarity index 100% rename from 06-variables/04-assignment/questions/questions.md rename to 06-variables/04-assignment/questions/README.md