Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@
],
"status": "wip"
},
{
"slug": "cheese-club",
"name": "Cheese Club",
"uuid": "c9b29ac8-cb91-4808-89ce-81b2358bd586",
"concepts": [
"dataframes"
Comment thread
colinleach marked this conversation as resolved.
Outdated
],
"prerequisites": [
"lists",
"loops",
"functions"
],
"status": "wip"
},
{
"slug": "captains-log",
"name": "Captains Log",
Expand Down
26 changes: 26 additions & 0 deletions exercises/concept/cheese-club/.docs/hints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Hints

## 1. Classify customers

- Using [`every()`][ref-every] with an anonymous function may be convenient.

## 2. Name customers

- Processing two inputs in parallel: think about [`map2()`][ref-map2] as a possible approach.

## 3. Separate out emphatic customers

- Earlier tasks will help you.
- Which customers do you want to [`keep`][ref-keep] in the output list?

## 4. Change ratings to binary

- There are several ways to solve this, but [`if_else()`][ref-if_else] from the `dplyr` library may be simplest. This was discussed in the [Switch Concept][concept-switch].
- Within `purrr`, another possibility is [`map_int()`][ref-map_int].

[ref-every]: https://purrr.tidyverse.org/reference/every.html
[ref-map2]: https://purrr.tidyverse.org/reference/map2.html
[ref-keep]: https://purrr.tidyverse.org/reference/keep.html
[ref-if_else]: https://dplyr.tidyverse.org/reference/if_else.html
[ref-map_int]: https://purrr.tidyverse.org/reference/map.html
[concept-switch]: https://exercism.org/tracks/r/concepts/switch
85 changes: 85 additions & 0 deletions exercises/concept/cheese-club/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Instructions

We are starting up a cheese club, which will use ML to select new cheeses to offer our cheese-loving customers based on their histories and tastes.

New members are required to fill out an initial survey so we can gather some basic data to start with.
Through this, it's been found that there is a subset of emphatic clients who lack nuance in their critiques.
As this can end up irrevocably biasing a more nuanced algorithm, there is a separate algorithm set up to handle their needs.
You are asked to provide some helper functions to wrangle their data.

~~~~exercism/note
While there may be different ways to solve the following tasks, each can be solved with no more than two higher order functions.
~~~~

## 1. Classify customers

The rating system has a five star basis, which is simply consists of integers `1:5`.
Comment thread
colinleach marked this conversation as resolved.
Outdated
The emphatic customers will only give ratings of `1` or `5`, and we want to know if a customer exhibits this behavior.

Implement `all_15()` which takes a vector of ratings and returns `true` if all ratings are either `1` or `5`, and false otherwise.

```R
all_15(c(2, 3, 4, 4, 1))
#> [1] FALSE

all_15(c(1, 5, 5, 1, 5))
#> [1] TRUE
```

## 2. Name customers

We need to associate the customer name (or ID) with their ratings.

Implement `name_customers()`, which takes a vector of names and a list of ratings, and "zips" them into a list of lists.

Inner list elements should have names `name` and `rating`.

```R
names <- c("c1", "c2")
ratings <- list(c(2, 3, 5), c(1, 1, 5))
name_customers(names, ratings)
#> [[1]]
#> [[1]]$name
#> [1] "c1"

#> [[1]]$rating
#> [1] 2 3 5

#> [[2]]
#> [[2]]$name
#> [1] "c2"

#> [[2]]$rating
#> [1] 1 1 5
Comment thread
depial marked this conversation as resolved.
```

## 3. Separate out emphatic customers

We need to separate the more emphatic customers from the others.

Implement `emphatics()` which takes customers and ratings.
Returns a list restricted to those who only use only `1` or `5` star ratings.`

```R
# names and ratings as in the task 2 example

emphatics(names, ratings)
#> [[1]]
#> [[1]]$name
#> [1] "c2"

#> [[1]]$rating
#> [1] 1 1 5
```

## 4. Change ratings to binary

Since the emphatic customers only use `1` and `5` ratings, it will more computationally convenient if these are changed these to `0` and `1`.

Implement `to_binary()` which takes vector of emphatic ratings.
Returns binary ratings, where `1` has been changed to `0` and `5` has been changed to `1`.

```R
to_binary(c(1, 1, 5, 5, 1))
#> [1] 0 0 1 1 0
```
Loading