From cb0219f884cd4b099f58cf6855b0f0c934f9a626 Mon Sep 17 00:00:00 2001 From: Anastasiia Birillo Date: Mon, 18 Dec 2023 17:00:19 +0100 Subject: [PATCH] Replace push with click (#191) --- AlmostDone/CompleteTheProject/task.md | 6 +++--- AlmostDone/MultiRowStrings/task.md | 2 +- AlmostDone/NullSafety/task.md | 4 ++-- AlmostDone/NullSafetyPartTwo/task.md | 4 ++-- AlmostDone/StringFunctions/task.md | 12 ++++++------ AlmostDone/StringFunctionsPartTwo/task.md | 12 ++++++------ AlmostDone/When/task.md | 2 +- AlmostDone/applyBordersFilterFunction/task.md | 8 ++++---- AlmostDone/choosePictureFunction/task.md | 2 +- AlmostDone/safeReadLineFunction/task.md | 2 +- Chat/askFirstQuestion/task.md | 2 +- Chat/askSecondQuestion/task.md | 4 ++-- Chat/completeTheProject/task.md | 6 +++--- Hangman/Core/task.md | 10 +++++----- Hangman/generateSecretFunction/task.md | 2 +- Hangman/getHiddenSecretFunction/task.md | 4 ++-- Hangman/getRoundResultsFunction/task.md | 2 +- Hangman/isCompleteFunction/task.md | 6 +++--- Hangman/isCorrectInputFunction/task.md | 6 +++--- Hangman/safeUserInputFunction/task.md | 4 ++-- LastPush/CanvasGapsGenerator/task.md | 8 ++++---- LastPush/CanvasGenerator/task.md | 4 ++-- LastPush/CompleteTheProject/task.md | 4 ++-- LastPush/Helpers/task.md | 6 +++--- LastPush/dropTopFromLineFunction/task.md | 10 +++++----- LastPush/getPatternHeightFunction/task.md | 4 ++-- LastPush/repeatHorizontallyFunction/task.md | 6 +++--- MastermindAdvanced/CompleteTheProject/task.md | 4 ++-- MastermindAdvanced/generateSecretFunction/task.md | 4 ++-- MastermindAdvanced/isCorrectInputFunction/task.md | 6 +++--- MastermindAdvanced/safeUserInputFunction/task.md | 2 +- TheFirstDateWithProgramming/BuiltinFunctions/task.md | 2 +- .../CompleteTheProject/task.md | 6 +++--- .../ProgramEntryPoint/task.md | 2 +- TheFirstDateWithProgramming/ReadUserInput/task.md | 4 ++-- TheFirstDateWithProgramming/Variables/task.md | 2 +- WarmUp/Collections/task.md | 8 ++++---- WarmUp/CollectionsPartTwo/task.md | 10 +++++----- WarmUp/CustomFunctions/task.md | 6 +++--- WarmUp/If/task.md | 2 +- WarmUp/Loops/task.md | 10 +++++----- WarmUp/countPartialMatches/task.md | 4 ++-- WarmUp/isCompleteFunction/task.md | 2 +- WarmUp/isLostFunction/task.md | 2 +- WarmUp/isWinFunction/task.md | 2 +- WarmUp/playGameMain/task.md | 2 +- WarmUp/printRoundResults/task.md | 2 +- 47 files changed, 112 insertions(+), 112 deletions(-) diff --git a/AlmostDone/CompleteTheProject/task.md b/AlmostDone/CompleteTheProject/task.md index 5b950dc1..d7b44de5 100644 --- a/AlmostDone/CompleteTheProject/task.md +++ b/AlmostDone/CompleteTheProject/task.md @@ -5,7 +5,7 @@ This time, without a new theoretical part! Finish the game – implement the `photoshop` function, that combines all functions together. -
+
The signature of the function is: ```kotlin @@ -22,7 +22,7 @@ Finally, call this function in the `main` function. Also, the `main` function will be checked - just uncomment code in the `main` function. -
+
![Console photoshop example](../../utils/src/main/resources/images/part1/almost.done/game.gif "Console photoshop example") @@ -36,7 +36,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
Try expanding this project yourself! For example, add new predefined pictures or filters.
diff --git a/AlmostDone/MultiRowStrings/task.md b/AlmostDone/MultiRowStrings/task.md index 49ef9b9e..64fc84ea 100644 --- a/AlmostDone/MultiRowStrings/task.md +++ b/AlmostDone/MultiRowStrings/task.md @@ -4,7 +4,7 @@ It's time to practice! Implement the `trimPicture` function, which accepts a picture and removes all indents from it. -
+
The signature of the function is: ```kotlin diff --git a/AlmostDone/NullSafety/task.md b/AlmostDone/NullSafety/task.md index 392dccd2..bba76bb6 100644 --- a/AlmostDone/NullSafety/task.md +++ b/AlmostDone/NullSafety/task.md @@ -6,7 +6,7 @@ Implement the `chooseFilter` function, which asks the user to choose a filter (`borders` or `squared`, the full text is `Please choose the filter: 'borders' or 'squared'.`) and returns it. -
+
The signature of the function is: ```kotlin @@ -27,7 +27,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
The when expression allows you to use several values in one branch and define a variable in place: diff --git a/AlmostDone/NullSafetyPartTwo/task.md b/AlmostDone/NullSafetyPartTwo/task.md index b2531d7f..20ac8aca 100644 --- a/AlmostDone/NullSafetyPartTwo/task.md +++ b/AlmostDone/NullSafetyPartTwo/task.md @@ -4,7 +4,7 @@ We need to provide the user to be able to transform their own pictures. Let's do Implement `getPicture` function that asks the user to choose a pre-defined picture or to input a custom picture. -
+
The signature of the function is: ```kotlin @@ -39,7 +39,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
To check the user's answer in the `getPicture` function, it is most convenient to use the `when` expression instead a composite `if`. diff --git a/AlmostDone/StringFunctions/task.md b/AlmostDone/StringFunctions/task.md index cb43b46f..946b5dfd 100644 --- a/AlmostDone/StringFunctions/task.md +++ b/AlmostDone/StringFunctions/task.md @@ -8,7 +8,7 @@ For the border symbol, please use the pre-defined variable `borderSymbol`, it st println(borderSymbol) // # ``` -
+
Here's an example of the function's work:

@@ -28,7 +28,7 @@ In other words, you need to pad the shorter lines with the `separator` to the le To get the width of the picture, you cak use the predefined function `getPictureWidth`, that returns the maximum of width from all lines from the picture. -

+
```kotlin val pictureWidth = getPictureWidth(picture) // calculate the longest line from the picture and returns it's width @@ -57,7 +57,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
First example: Example of the function's work @@ -67,7 +67,7 @@ Second example:
-
+
To check how your function works, you can run it in main by passing one of the pre-defined pictures: @@ -80,14 +80,14 @@ fun main() { ```
-
+
The length of the top and bottom edges of the border will be 4 characters longer than the width of the initial picture, since we add the borderSymbol and the separator on both sides of the image.
-
+
If you want, you can try to implement your own implementation fo the `getPictureWidth` function: split the picture by using `lines` function diff --git a/AlmostDone/StringFunctionsPartTwo/task.md b/AlmostDone/StringFunctionsPartTwo/task.md index 292651c9..d7696ac8 100644 --- a/AlmostDone/StringFunctionsPartTwo/task.md +++ b/AlmostDone/StringFunctionsPartTwo/task.md @@ -8,7 +8,7 @@ For the border symbol, please use the pre-defined variable `borderSymbol`, it st println(borderSymbol) // # ``` -
+
Here's an example of the function's work:

@@ -27,7 +27,7 @@ In other words, you need to pad the shorter lines with the `separator` to the le To get the width of the picture, you cak use the predefined function `getPictureWidth`, that returns the maximum of width from all lines from the picture. -

+
```kotlin val pictureWidth = getPictureWidth(picture) // calculate the longest line from the picture and returns it's width @@ -55,7 +55,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
First example: Example of the function's work @@ -64,7 +64,7 @@ Second example: Example of the function's work
-
+
To check how your function works, you can run it in main by passing one of the pre-defined pictures: @@ -78,14 +78,14 @@ fun main() {
-
+
You can use the `applyBordersFilter` function to add the borders, next create two `StringBuilder`s (one for the top and one for the bottom part), and put them row by row.
-
+
If you want, you can try to implement your own implementation fo the `getPictureWidth` function: split the picture by using `lines` function diff --git a/AlmostDone/When/task.md b/AlmostDone/When/task.md index 41b31632..a257c42c 100644 --- a/AlmostDone/When/task.md +++ b/AlmostDone/When/task.md @@ -7,7 +7,7 @@ and a filter name, applies the `trimPicture` function to the picture and finally applies the given filter, and returns the updated picture. To apply a filter, just call one of the already defined functions `applyBordersFilter` or `applySquaredFilter`. -
+
The signature of the function is: ```kotlin diff --git a/AlmostDone/applyBordersFilterFunction/task.md b/AlmostDone/applyBordersFilterFunction/task.md index 99d850bb..6de4f1d3 100644 --- a/AlmostDone/applyBordersFilterFunction/task.md +++ b/AlmostDone/applyBordersFilterFunction/task.md @@ -10,7 +10,7 @@ Add several functions to the game: function instead of implementation as a temporary solution. We will implement this function during solving next tasks. -
+
The signature of the function is: ```kotlin @@ -18,7 +18,7 @@ fun applyBordersFilter(picture: String): String ```
-
+
An example of this filter:

@@ -33,7 +33,7 @@ An example of this filter: function instead of implementation as a temporary solution. We will implement this function during solving next tasks. -

+
The signature of the function is: ```kotlin @@ -41,7 +41,7 @@ fun applySquaredFilter(picture: String): String ```
-
+
An example of this filter:

diff --git a/AlmostDone/choosePictureFunction/task.md b/AlmostDone/choosePictureFunction/task.md index 3f7e80f0..3e834e61 100644 --- a/AlmostDone/choosePictureFunction/task.md +++ b/AlmostDone/choosePictureFunction/task.md @@ -5,7 +5,7 @@ of the pre-defined pictures they want to change. Implement `choosePicture` picture that chooses one pre-defined picture by its name. -

+
The signature of the function is: ```kotlin diff --git a/AlmostDone/safeReadLineFunction/task.md b/AlmostDone/safeReadLineFunction/task.md index 89c23864..e61ac25f 100644 --- a/AlmostDone/safeReadLineFunction/task.md +++ b/AlmostDone/safeReadLineFunction/task.md @@ -9,7 +9,7 @@ It's time to implement this function by yourself! Implement the `safeReadLine` function, which returns the string the user inputs or throws an error if the `null` value was received. -
+
The signature of the function is: ```kotlin diff --git a/Chat/askFirstQuestion/task.md b/Chat/askFirstQuestion/task.md index c9c7bff9..609d78ee 100644 --- a/Chat/askFirstQuestion/task.md +++ b/Chat/askFirstQuestion/task.md @@ -13,7 +13,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
To print a question, you can use the `println` function from the previous steps. Then, to store the user's input in a variable, you can use the `readlnOrNull` function. diff --git a/Chat/askSecondQuestion/task.md b/Chat/askSecondQuestion/task.md index c048fea4..bb0f60d4 100644 --- a/Chat/askSecondQuestion/task.md +++ b/Chat/askSecondQuestion/task.md @@ -16,14 +16,14 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
To print the answer, you can use the `println` function from the previous steps. Then, to read the user's input into a variable, you can use the `readlnOrNull` function.
-
+
String literals may contain template expressions – pieces of code that are evaluated and whose results are concatenated into the string. diff --git a/Chat/completeTheProject/task.md b/Chat/completeTheProject/task.md index f89c51d9..b9be415c 100644 --- a/Chat/completeTheProject/task.md +++ b/Chat/completeTheProject/task.md @@ -14,7 +14,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
The game should look like this: @@ -22,13 +22,13 @@ The game should look like this:
-
+
To print the answer, you can use the `println` function from the previous steps.
-
+
String literals may contain template expressions – pieces of code that are evaluated and whose results are concatenated into the string. diff --git a/Hangman/Core/task.md b/Hangman/Core/task.md index 5e186159..4171155c 100644 --- a/Hangman/Core/task.md +++ b/Hangman/Core/task.md @@ -6,7 +6,7 @@ Implement the `generateNewUserWord` function, which generates a new sequence of underscores and already guessed letters by means of a string with `secret`, a char with user's `guess`, and a string `currentUserWord`. -
+
The signature of the function is: ```kotlin @@ -25,7 +25,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
Here are several examples of the _currentUserWord_ function's work: @@ -37,7 +37,7 @@ Here are several examples of the _currentUserWord_ function's work: - secret = `"BOOK"`, guess = `'K'`, currentUserWord = `"_ _ _ K"`, result = `"_ _ _ K"`;
-
+
To make a loop check over each char in a string, you can use the `indices` property: ``` @@ -51,7 +51,7 @@ It is the same as: It's a more convenient and shorter way to represent a range of indices.
-
+
The [`removeSuffix`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/remove-suffix.html) function helps to delete a suffix from a string: @@ -62,7 +62,7 @@ println("abcdef".removeSuffix("f")) // abcde It can be helpful if you need to delete some extra separators from the end of the string.
-
+
To implement the `generateNewUserWord` function you can just to check for each letter from the `secret` if this letter equals with the `guess`. diff --git a/Hangman/generateSecretFunction/task.md b/Hangman/generateSecretFunction/task.md index a5491bfe..22e51087 100644 --- a/Hangman/generateSecretFunction/task.md +++ b/Hangman/generateSecretFunction/task.md @@ -4,7 +4,7 @@ The goal of this task is to generate a random word for the game. Implement the `generateSecret` function, that generates a _random_ word from the `words` list. -
+
The signature of the function is: ```kotlin diff --git a/Hangman/getHiddenSecretFunction/task.md b/Hangman/getHiddenSecretFunction/task.md index 0ed27283..ffbc3505 100644 --- a/Hangman/getHiddenSecretFunction/task.md +++ b/Hangman/getHiddenSecretFunction/task.md @@ -5,7 +5,7 @@ In this step we will add a function to generate the initial hidden secret with u Implement the `getHiddenSecret` function, that accepts `wordLength` and generates the initial hidden secret with underscores, e.g. for `wordLength` `4` the result will be `_ _ _ _`. -
+
The signature of the function is: ```kotlin @@ -27,7 +27,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
To join a list of elements into a string, you can use the [`joinToString`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/join-to-string.html) diff --git a/Hangman/getRoundResultsFunction/task.md b/Hangman/getRoundResultsFunction/task.md index bf87b14e..5765dc72 100644 --- a/Hangman/getRoundResultsFunction/task.md +++ b/Hangman/getRoundResultsFunction/task.md @@ -7,7 +7,7 @@ which accepts a string `secret` - the secret of the current of the game, a char `guess` - a current guess from the user, and a string `currentUserWord` - a current state of the game, e.g. `_ _ _ K`. This function should check if the user guessed a char. -
+
The signature of the function is: ```kotlin diff --git a/Hangman/isCompleteFunction/task.md b/Hangman/isCompleteFunction/task.md index 26cf6e97..2d250e4b 100644 --- a/Hangman/isCompleteFunction/task.md +++ b/Hangman/isCompleteFunction/task.md @@ -5,7 +5,7 @@ It's time to practice! Let's start with a simple function. Implement the `isComplete` function, which accepts two string arguments - `secret` and `currentGuess`, and checks if the game is complete. The game is complete only if `secret` and `currentGuess` equal. -
+
The signature of the function is: ```kotlin @@ -28,7 +28,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
Here are several examples of the _isComplete_ function's work: @@ -37,7 +37,7 @@ Here are several examples of the _isComplete_ function's work: - secret = "ABC", currentGuess = "A A A", result = false;
-
+
The easiest way to replace `separator` in `currentGuess` is to use the built-in function [`replace`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/replace.html): ```kotlin diff --git a/Hangman/isCorrectInputFunction/task.md b/Hangman/isCorrectInputFunction/task.md index 81f0f647..54d8ef47 100644 --- a/Hangman/isCorrectInputFunction/task.md +++ b/Hangman/isCorrectInputFunction/task.md @@ -6,7 +6,7 @@ Implement the `isCorrectInput` function, that accepts a string `userInput` and checks if it is correct: 1) the length of the `userInput` is 1 and 2) the `userInput` is an english letter. If `userInput` is correct, the function returns `true`, and `false` otherwise. -
+
The signature of the function is: ```kotlin @@ -35,7 +35,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
You can use `length` to get the number of letters in `userInput`: ```kotlin @@ -44,7 +44,7 @@ val size = userInput.length Then, you need to compare it with `1`.
-
+
The built-in function `isLetter` checks if the passed symbol is an English letter and can be applied only to one letter at once: diff --git a/Hangman/safeUserInputFunction/task.md b/Hangman/safeUserInputFunction/task.md index 4a53979e..30c5666d 100644 --- a/Hangman/safeUserInputFunction/task.md +++ b/Hangman/safeUserInputFunction/task.md @@ -6,7 +6,7 @@ Implement the `safeUserInput` function, which accepts no arguments and returns an uppercase letter that was input by the user. This function has to check the user input with `isCorrectInput` function to avoid incorrect inputs. -
+
The signature of the function is: ```kotlin @@ -38,7 +38,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
The built-in function [`uppercase`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/uppercase.html) converts all letter from a string to uppercase format: diff --git a/LastPush/CanvasGapsGenerator/task.md b/LastPush/CanvasGapsGenerator/task.md index f3c70555..b58162d9 100644 --- a/LastPush/CanvasGapsGenerator/task.md +++ b/LastPush/CanvasGapsGenerator/task.md @@ -5,7 +5,7 @@ This step is not easy, but we believe you will solve it! On this step you need to implement the `canvasWithGapsGenerator` function, which accepts the `pattern`, `width`, and `height` that were inputted by the user. This function should return a new string with a generated canvas-with-gaps picture. -
+
The signature of the function is: ```kotlin @@ -23,7 +23,7 @@ The generator works according to the following algorithm: and in every **even level** - in **odd**; 4) When repeated **vertically**, the pattern remains **unchanged**. -
+
For example, let's take the pattern: ```text @@ -71,7 +71,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
To drop n last symbols from a String, you can use the dropLast function, e.g.: ```kotlin @@ -81,7 +81,7 @@ To drop n last symbols from a String, you can use the If you need to drop n symbols from the beginning of a String, you can use the drop function.
-
+
In industrial programming, duplicate code is commonly avoided and put into functions. However, it is not always possible to immediately write clear and readable code. diff --git a/LastPush/CanvasGenerator/task.md b/LastPush/CanvasGenerator/task.md index 14c9887d..aa9d1e36 100644 --- a/LastPush/CanvasGenerator/task.md +++ b/LastPush/CanvasGenerator/task.md @@ -5,7 +5,7 @@ It's time to implement the first pattern generator! On this step you need to implement the `canvasGenerator` function, which accepts the `pattern`, `width`, and `height` that were inputted by the user. This function should return a new string with a generated canvas picture. -
+
The signature of the function is: ```kotlin @@ -25,7 +25,7 @@ The generator works according to the following algorithm: but only if the pattern has more than one line; 3) When repeated **horizontally**, the pattern remains **unchanged**. -
+
For example, consider the following pattern: ```text diff --git a/LastPush/CompleteTheProject/task.md b/LastPush/CompleteTheProject/task.md index 16767687..736401a8 100644 --- a/LastPush/CompleteTheProject/task.md +++ b/LastPush/CompleteTheProject/task.md @@ -5,7 +5,7 @@ On this step you need to finish the app. Implement the `applyGenerator` function, that accepts `pattern`, `generatorName`, `width` and `height` and trims the `pattern` and finally applies `canvasGenerator` or `canvasWithGapsGenerator` function. -
+
The signature of the function is: ```kotlin @@ -20,7 +20,7 @@ The possible values for the `generatorName` argument: The `applyGenerator` function should inform the user about an unexpected filter name by throwing an error. -
+
![The patterns generator example](../../utils/src/main/resources/images/part1/last.push/app.gif "The patterns generator example") diff --git a/LastPush/Helpers/task.md b/LastPush/Helpers/task.md index 09eff824..92884d72 100644 --- a/LastPush/Helpers/task.md +++ b/LastPush/Helpers/task.md @@ -5,7 +5,7 @@ During the next steps we will implement some helper functions to create the appl Implement the `fillPatternRow` function, which accepts a `patternRow` (one line from the pattern) and `patternWidth` and adds the row `separator` to extend the line to the `patternWidth` size. -
+
The signature of the function is: ```kotlin @@ -26,7 +26,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
To generate a string that consists of some repeated symbols, you can use the repeat function, e.g.: ```kotlin @@ -34,7 +34,7 @@ To generate a string that consists of some repeated symbols, you can use the -
+
To implement the `fillPatternRow` function, you just need to check if the length of the current pattern row is less than the pattern width. diff --git a/LastPush/dropTopFromLineFunction/task.md b/LastPush/dropTopFromLineFunction/task.md index fc0496f8..584486a2 100644 --- a/LastPush/dropTopFromLineFunction/task.md +++ b/LastPush/dropTopFromLineFunction/task.md @@ -18,7 +18,7 @@ e.g. (for `width` = 1): ``` -
+
The signature of the function is: ```kotlin @@ -30,7 +30,7 @@ fun dropTopFromLine(line: String, width: Int, patternHeight: Int, patternWidth: You can implement this function in any possible way, but we _recommend_ to look into the [`removeSuffix`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/remove-suffix.html) and [`drop`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/drop.html) built-in functions. -
+
The [`removeSuffix`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/remove-suffix.html) built-in function helps to delete a string from the end of the current string: @@ -41,7 +41,7 @@ println("abcdefg".removeSuffix("a")) // abcdefg, since the initial string does n ```
-
+
The [`drop`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/drop.html) built-in function helps to delete `n` symbols from the beginning of the current string: @@ -57,7 +57,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
The first examples: ```text @@ -106,7 +106,7 @@ These functions will help us to implement the filters just to repeat vertically
-
+
You need to remove `patternWidth * width + newLineSymbol.length` symbols from the beginning of the line, since you have a line where the pattern is repeated `width` times and `newLineSymbol` in different OS can be more than `1`. diff --git a/LastPush/getPatternHeightFunction/task.md b/LastPush/getPatternHeightFunction/task.md index 1ac4c0fe..8946cab0 100644 --- a/LastPush/getPatternHeightFunction/task.md +++ b/LastPush/getPatternHeightFunction/task.md @@ -4,7 +4,7 @@ Let's start to practice! Implement the `getPatternHeight` function, which accepts a `pattern` and calculates its height. -
+
The signature of the function is: ```kotlin @@ -18,7 +18,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
The pattern height can be calculated as the number of _lines_ in the pattern.
diff --git a/LastPush/repeatHorizontallyFunction/task.md b/LastPush/repeatHorizontallyFunction/task.md index e21cbfe9..10c83133 100644 --- a/LastPush/repeatHorizontallyFunction/task.md +++ b/LastPush/repeatHorizontallyFunction/task.md @@ -6,7 +6,7 @@ to combine them into another one which apply a filter to the pattern. Implement the `repeatHorizontally` function, which accepts a `pattern`, the number of repeats `n`, and `patternWidth` and repeat the `pattern` `n` times horizontally. -
+
The signature of the function is: ```kotlin @@ -39,7 +39,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
The first examples: ```kotlin @@ -87,7 +87,7 @@ Result:
-
+
To check how your function works, you can run it in main by passing one of the pre-defined patterns: diff --git a/MastermindAdvanced/CompleteTheProject/task.md b/MastermindAdvanced/CompleteTheProject/task.md index 5fa645c7..085852c1 100644 --- a/MastermindAdvanced/CompleteTheProject/task.md +++ b/MastermindAdvanced/CompleteTheProject/task.md @@ -7,7 +7,7 @@ in the previous step. Since the `safeUserInput` function requires an `alphabet: String` argument, don't forget to update the signature of the `playGame` function. -
+
The signature of the function is: ```kotlin @@ -19,7 +19,7 @@ Finally, don't forget to use the `alphabet` argument inside the main function wh Good luck! -
+
![The game's example](../../utils/src/main/resources/images/part1/warmup/game.gif "The game's example") diff --git a/MastermindAdvanced/generateSecretFunction/task.md b/MastermindAdvanced/generateSecretFunction/task.md index 15222eb6..30ee006a 100644 --- a/MastermindAdvanced/generateSecretFunction/task.md +++ b/MastermindAdvanced/generateSecretFunction/task.md @@ -5,7 +5,7 @@ Let's make our game more fun! Implement the `generateSecret` function to return a random secret word for the game: - add new arguments: `wordLength` and `alphabet`; -
+
The signature of the function is: ```kotlin @@ -25,7 +25,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
You can create a new list with `wordLength` elements using _random_ letters from `alphabet`. Finally, you can use the `joinToString` function with an empty separator (`""`) to build the final string. diff --git a/MastermindAdvanced/isCorrectInputFunction/task.md b/MastermindAdvanced/isCorrectInputFunction/task.md index 189af087..75054ecb 100644 --- a/MastermindAdvanced/isCorrectInputFunction/task.md +++ b/MastermindAdvanced/isCorrectInputFunction/task.md @@ -6,7 +6,7 @@ Implement the `isCorrectInput` function, which accepts `userInput`, `wordLength`, and `alphabet` and returns `true` if the input is correct, and `false` otherwise. -
+
The signature of the function is: ```kotlin @@ -39,7 +39,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
You can use `length` to get the number of letters in `userInput`: ```kotlin @@ -48,7 +48,7 @@ val size = userInput.length Then, you need to compare it with `wordLength`.
-
+
As we already know, Kotlin has many built-in functions. If you need to check whether a list (or string) is empty, diff --git a/MastermindAdvanced/safeUserInputFunction/task.md b/MastermindAdvanced/safeUserInputFunction/task.md index 2f239855..bc83b67d 100644 --- a/MastermindAdvanced/safeUserInputFunction/task.md +++ b/MastermindAdvanced/safeUserInputFunction/task.md @@ -6,7 +6,7 @@ Implement the `safeUserInput` function, which accepts `wordLength` and `alphabet` and handles incorrect user inputs. -
+
The signature of the function is: ```kotlin diff --git a/TheFirstDateWithProgramming/BuiltinFunctions/task.md b/TheFirstDateWithProgramming/BuiltinFunctions/task.md index 0ebd7ddc..9be54043 100644 --- a/TheFirstDateWithProgramming/BuiltinFunctions/task.md +++ b/TheFirstDateWithProgramming/BuiltinFunctions/task.md @@ -1,6 +1,6 @@ Let's start implementing our **Story twister** project. Let's first print an introduction to the user. -
+
![The game's example](../../utils/src/main/resources/images/part1/first.date/game.gif "The game's example") diff --git a/TheFirstDateWithProgramming/CompleteTheProject/task.md b/TheFirstDateWithProgramming/CompleteTheProject/task.md index 261deba0..ea3aafad 100644 --- a/TheFirstDateWithProgramming/CompleteTheProject/task.md +++ b/TheFirstDateWithProgramming/CompleteTheProject/task.md @@ -17,7 +17,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
To print the first **predefined** question from the `firstQuestion` variable and the user answer, you can use the `println` function from the previous steps: @@ -40,7 +40,7 @@ fun main() {
-
+
The game should look like this: @@ -48,7 +48,7 @@ The game should look like this:
-
+
String literals may contain template expressions – pieces of code that are evaluated and whose results are concatenated into the string. diff --git a/TheFirstDateWithProgramming/ProgramEntryPoint/task.md b/TheFirstDateWithProgramming/ProgramEntryPoint/task.md index 7a8ae606..55a58453 100644 --- a/TheFirstDateWithProgramming/ProgramEntryPoint/task.md +++ b/TheFirstDateWithProgramming/ProgramEntryPoint/task.md @@ -4,7 +4,7 @@ It's time to write your first program in Kotlin! Change the output text into `Hello!` and run the program. -
+
To run your program, you need to open the `Main.kt` file and click on the **green triangle** near the `main` function. Then, the output of the program will be shown in the console: diff --git a/TheFirstDateWithProgramming/ReadUserInput/task.md b/TheFirstDateWithProgramming/ReadUserInput/task.md index d81a9a5c..06ff047a 100644 --- a/TheFirstDateWithProgramming/ReadUserInput/task.md +++ b/TheFirstDateWithProgramming/ReadUserInput/task.md @@ -26,7 +26,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
To print a question, you can use the `println` function from the previous steps. Then, to read the user input, you can use the `readlnOrNull` function: @@ -45,7 +45,7 @@ fun main() {
-
+
As a result, the user's interaction with the game will look like this: diff --git a/TheFirstDateWithProgramming/Variables/task.md b/TheFirstDateWithProgramming/Variables/task.md index 3360edd0..7941786e 100644 --- a/TheFirstDateWithProgramming/Variables/task.md +++ b/TheFirstDateWithProgramming/Variables/task.md @@ -11,7 +11,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
In the current task, it is better to use the `val` keyword, since we will just _save_ values from the user into the variables and will not change them afterwards. diff --git a/WarmUp/Collections/task.md b/WarmUp/Collections/task.md index 9feebc60..81c565e2 100644 --- a/WarmUp/Collections/task.md +++ b/WarmUp/Collections/task.md @@ -8,7 +8,7 @@ of letters that match exactly down to position. You can implement this function in any possible way, but we _recommend_ to look into the `filterIndexed` built-in function. -
+
Kotlin has many built-in functions: e.g., we can filter and manipulate with not only the elements from the list but also list indices. For example, given two words, we need to build a new word, which consists of the characters that occur in both words at the same positions. @@ -40,7 +40,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
Here are several examples of the _countExactMatches_ function's work: @@ -50,14 +50,14 @@ Here are several examples of the _countExactMatches_ function's work: - guess = "BBBB", secret = "BBDH", result = 2.
-
+
The main idea of the algorithm is to keep only those letters that are equal and have the same index. Next, we can just return the number of these letters. To find the number of exact matches, you can consider the filterIndexed function.
-
+
To get the number of characters in the word, you can use length: `"ABCDDD".length` will return `6`, since the string contains `6` letters. diff --git a/WarmUp/CollectionsPartTwo/task.md b/WarmUp/CollectionsPartTwo/task.md index 0cf48b88..3efae2c7 100644 --- a/WarmUp/CollectionsPartTwo/task.md +++ b/WarmUp/CollectionsPartTwo/task.md @@ -6,7 +6,7 @@ a new function `countAllMatches` to calculate all matches Add and implement a new function _countAllMatches_ which has two string arguments (_secret_ and _guess_) and returns the number of matched letters between them that don't depend on the position. -
+
The signature of the function is: ```kotlin @@ -16,7 +16,7 @@ fun countAllMatches(secret: String, guess: String): Int You can implement this function in any possible way, but we _recommend_ to look into the `filter` and `minOf` built-in functions. -
+
You can use the filter function to filter elements from one collection that are in another: @@ -28,7 +28,7 @@ println(list1.filter{ it in list2 }) // [3, 4] ```
-
+
You can use the minOf function to find a minimum values from several ones: @@ -44,7 +44,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
Here are several examples of the _countAllMatches_ function's work: @@ -54,7 +54,7 @@ Here are several examples of the _countAllMatches_ function's work: - guess = "BBBB", secret = "BBDH", result = 2.
-
+
You can just count the number of letters from the guess that are in secret. But in some cases it will prodice an incorrect answer, for example, if the guess has the same letters: diff --git a/WarmUp/CustomFunctions/task.md b/WarmUp/CustomFunctions/task.md index 188db9fb..dd3b1000 100644 --- a/WarmUp/CustomFunctions/task.md +++ b/WarmUp/CustomFunctions/task.md @@ -7,7 +7,7 @@ Add several functions to the game: - _generateSecret_, which should return the hidden word. For the time being, let this function always return `ABCD`. -
+
The signature of the function is: ```kotlin @@ -21,7 +21,7 @@ You don't need to implement this function now, it is enough to use the `TODO` function instead of implementation as a temporary solution. We will implement this function during solving next tasks. -
+
The signature of the function is: ```kotlin @@ -35,7 +35,7 @@ You don't need to implement this function now, it is enough to use the `TODO` function instead of implementation as a temporary solution. We will implement this function during solving next tasks. -
+
The signature of the function is: ```kotlin diff --git a/WarmUp/If/task.md b/WarmUp/If/task.md index afea3db9..d70866f4 100644 --- a/WarmUp/If/task.md +++ b/WarmUp/If/task.md @@ -11,7 +11,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
If you compare two variables to get a `Boolean` result, you can use the short notation. For example, the following code: diff --git a/WarmUp/Loops/task.md b/WarmUp/Loops/task.md index 0c781745..43933a81 100644 --- a/WarmUp/Loops/task.md +++ b/WarmUp/Loops/task.md @@ -5,7 +5,7 @@ It's time to start implementing the `playGame` function to be able to read user Define a new function `playGame`, which accepts `secret`, `wordLength`, and `maxAttemptsCount` and imitates the game process. -
+
The signature of the function is: ```kotlin @@ -41,17 +41,17 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
Use `do-while` loop for imitating the game process.
-
+
The best type for the `complete` variable for the loop condition is `Boolean`, since it indicates only two game states.
-
+
If you use the `do-while` loop with a `Boolean` variable as the condition, you can omit the initialization of the variable before the loop. For example, consider the following code: @@ -71,7 +71,7 @@ do { You can do it only if the value of the variable is changed inside the loop.
-
+
One of the possible ways to solve this task: ```kotlin diff --git a/WarmUp/countPartialMatches/task.md b/WarmUp/countPartialMatches/task.md index 69804942..ff1e91b6 100644 --- a/WarmUp/countPartialMatches/task.md +++ b/WarmUp/countPartialMatches/task.md @@ -15,7 +15,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
Here are several examples of the _countPartialMatches_ function's work: @@ -25,7 +25,7 @@ Here are several examples of the _countPartialMatches_ function's work: - guess = "BBBB", secret = "BBDH", result = 0.
-
+
Since we already have functions that calculate count of all matches and count of exact matches, we can just subtract count of exact matches from count of all matches to get the right value. diff --git a/WarmUp/isCompleteFunction/task.md b/WarmUp/isCompleteFunction/task.md index 6397ed06..35f433af 100644 --- a/WarmUp/isCompleteFunction/task.md +++ b/WarmUp/isCompleteFunction/task.md @@ -5,7 +5,7 @@ In this task we will create a function to check if the game is complete. - Define a function `isComplete`, which accepts `secret` and `guess` and checks if the game is over. For now, let it always return `true`. We will implement the function logic later. -
+
The signature of the function is: ```kotlin diff --git a/WarmUp/isLostFunction/task.md b/WarmUp/isLostFunction/task.md index 1c312885..7b3428fc 100644 --- a/WarmUp/isLostFunction/task.md +++ b/WarmUp/isLostFunction/task.md @@ -5,7 +5,7 @@ Let's implement the second function. Add a function `isLost`, which accepts three arguments: `complete`, `attempts`, and `maxAttemptsCount` and returns `true` only if the user **did not** guess the word (the `complete` variable stores `false`) **and** spent _more_ than `maxAttemptsCount` attempts. -
+
The signature of the function is: ```kotlin diff --git a/WarmUp/isWinFunction/task.md b/WarmUp/isWinFunction/task.md index 65e787fb..426649c5 100644 --- a/WarmUp/isWinFunction/task.md +++ b/WarmUp/isWinFunction/task.md @@ -6,7 +6,7 @@ Add a function `isWon`, which accepts three arguments: `complete`, `attempts`, a and returns `true` only if the user guessed the word (the `complete` variable stores `true`) **and** spent _not more_ than `maxAttemptsCount` attempts. -
+
The signature of the function is: ```kotlin diff --git a/WarmUp/playGameMain/task.md b/WarmUp/playGameMain/task.md index 2953b66d..ce97e4ef 100644 --- a/WarmUp/playGameMain/task.md +++ b/WarmUp/playGameMain/task.md @@ -11,7 +11,7 @@ If you have any difficulties, **hints will help you solve this task**. ### Hints -
+
You can call the `generateSecret` and write the output to a variable, or you can pass the result without creating an extra variable: diff --git a/WarmUp/printRoundResults/task.md b/WarmUp/printRoundResults/task.md index c517c574..244bb0e1 100644 --- a/WarmUp/printRoundResults/task.md +++ b/WarmUp/printRoundResults/task.md @@ -6,7 +6,7 @@ Implement the function `printRoundResults` to print the number of exact matches and the number of partial matches in the current round. It should accept two string arguments - `secret` and `guess`. -
+
The signature of the function is: ```kotlin