-
-
Notifications
You must be signed in to change notification settings - Fork 45
[Concept Exercise] Cheese Club #517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
eb92032
[Concept Exercise] Cheese Club
colinleach c49f496
Update concepts in config.json
colinleach 1e31295
Fix wording in customer rating instructions
colinleach f5e58e2
Fix error output formatting in introduction.md
colinleach 50fe8bb
[New Concept] Functional Programming (#501)
colinleach db4d11e
added task 5 for cummean
colinleach b1dad76
[Concept Exercise] Cheese Club
colinleach f4a06d0
Update concepts in config.json
colinleach c3848d4
Fix wording in customer rating instructions
colinleach c630dd3
Fix error output formatting in introduction.md
colinleach 4cb6833
added task 5 for cummean
colinleach 03a4855
cumulative functions bit copied to concept docs
colinleach ec76aa0
Merge remote-tracking branch 'origin/cheese-club' into cheese-club
colinleach c30b2dd
more hints for task 5
colinleach 6ad07ad
map2_dbl correction
colinleach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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`. | ||
|
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 | ||
|
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 | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.