Skip to content

Commit

Permalink
Update task.md
Browse files Browse the repository at this point in the history
language checked
  • Loading branch information
stephen-hero authored Sep 26, 2023
1 parent 281508c commit 50b31e0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions duckShopServer/duckShopServerPartition/task.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
In this task you need to implement a function to be able to
divide ducks in the Duck Shop into two categories - with any Kotlin stuff and without it - and reorder them according to this condition.
In this task, you need to implement a function to be able to
divide ducks in the Duck Shop into two categories — those with some Kotlin-related stuff and those without it and reorder them according to this condition.

### Task

Implement the `divideDucksIntoKotlinAndNonKotlin` function from the `GameActionFunctionsService` class in
the `org.jetbrains.kotlin.course.duck.shop.functions.action` package.
This function should divide ducks into two groups - with any Kotlin attribute (the field `hasKotlinAttribute` is `true`) and without - and returns these two collections.
This function should divide ducks into two groups — those with some Kotlin attribute (the field `hasKotlinAttribute` is `true`) and those without it — and return these two collections.

We have only one function, since the function `fun Collection<Duck>.divideDucksIntoKotlinAndNonKotlin()` works for both collections - for `List` and for `Set`.
We have only one function, since the function `fun Collection<Duck>.divideDucksIntoKotlinAndNonKotlin()` works for both collections for `List` and for `Set`.
The map collection does not have this function.

After implementing this task the `Partition` button in `list` and `set` modes becomes alive:
After implementing this task, the `Partition` button in `list` and `set` modes becomes alive:

![Current state](../../utils/src/main/resources/images/duck/shop/states/state_7.gif)

Expand All @@ -22,7 +22,7 @@ If you have any difficulties, **hints will help you solve this task**.

<div class="hint" title="How can I divide a collection by condition?">

You can do it in several ways, but the easiest one is to use the [`partition`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/partition.html) built-in function.
You can do it in several ways, but the easiest one is to use the built-in [`partition`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/partition.html) function.
It accepts a predicate (condition) to divide a collection into two parts according to this condition:

```kotlin
Expand Down

0 comments on commit 50b31e0

Please sign in to comment.