forked from DockYard-Academy/curriculum
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add exercises for protocols and touch up content
- Loading branch information
1 parent
370ac90
commit d9b5f44
Showing
19 changed files
with
709 additions
and
119 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
/todo |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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,95 @@ | ||
# Bottles Of Soda | ||
|
||
## Bottles of Soda | ||
|
||
In the Elixir cell below create a module `BottlesOfSoda` with a function `on_the_wall/0`. | ||
See further instructions below, you should implement each step one by one on the `BottlesOfSoda` module | ||
|
||
```elixir | ||
|
||
``` | ||
|
||
### Step 1 | ||
|
||
`on_the_wall/0` should | ||
|
||
* From 99 to 1 return a list with the string | ||
|
||
```elixir | ||
" | ||
X bottles of soda on the wall. | ||
X bottles of soda. | ||
Take one down, pass it around. | ||
X - 1 bottles of soda on the wall. | ||
" | ||
``` | ||
|
||
Where the `X` is the number of bottles of soda remaining. | ||
|
||
### Step 2 | ||
|
||
* when X is 1, use the correct grammar: | ||
|
||
```elixir | ||
" | ||
1 bottle of soda on the wall. | ||
1 bottle of soda. | ||
Take one down, pass it around. | ||
0 bottles of soda on the wall. | ||
" | ||
``` | ||
|
||
### Step 3 | ||
|
||
* When X is 0, use the following phrase: | ||
|
||
```elixir | ||
" | ||
No more bottles of soda on the wall, no more bottles of soda. | ||
Go to the store and buy some more, 99 bottles of soda on the wall. | ||
" | ||
``` | ||
|
||
### Step 4 | ||
|
||
* Create an `on_the_wall/1` function which takes in a positive **integer** for the `number_of_bottles` of soda on the wall. | ||
* From `number_of_bottles` to `0`, repeat the expected song lyrics. | ||
|
||
### Step 5 | ||
|
||
* Allow the `on_the_wall/1` function to also accept a descending **range** to perform the rhyme from. | ||
i.e. `BottlesOfSoda.on_the_wall(99..50)`. | ||
|
||
### Step 6 | ||
|
||
* Create an `on_the_wall/2` function which accepts an **integer** or a **range** for the first parameter. | ||
* For the second parameter, the function should accept a "string" for the type of beverage. | ||
|
||
For example `BottlesOfSoda.on_the_wall(99, "pop")` would start with: | ||
|
||
```elixir | ||
" | ||
99 bottles of pop on the wall. | ||
99 bottles of pop. | ||
Take one down, pass it around. | ||
98 bottles of pop on the wall. | ||
" | ||
``` | ||
|
||
### Step 7 | ||
|
||
* Create an `on_the_wall/3` function which accepts an **integer** or a **range** for the first parameter. | ||
* For the second parameter, the function should accept a **string** for the type of beverage. | ||
* For the third parameter, the function should accept a **string** for the beverage container. | ||
* Ensure that `on_the_wall/3` function remains gramatically correct for `0` and `1` beverage container. | ||
|
||
For example `BottlesOfSoda.on_the_wall(99, "pop", "can")` would start with: | ||
|
||
```elixir | ||
" | ||
99 cans of pop on the wall. | ||
99 cans of pop. | ||
Take one down, pass it around. | ||
98 cans of pop on the wall. | ||
" | ||
``` |
This file contains 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,31 @@ | ||
# Chess Moves | ||
|
||
## Overview | ||
|
||
You're going to a simplified chess game with a 9 X 9 board. | ||
|
||
<!-- livebook:{"force_markdown":true} --> | ||
|
||
```elixir | ||
[ | ||
[nil, nil, nil], | ||
[nil, nil, nil], | ||
[nil, nil, nil] | ||
] | ||
``` | ||
|
||
You need to create a `Piece` protocol and `can_move?` function | ||
|
||
### Create a Checkers Board | ||
|
||
* Create a `Checkers` module with a `new` function that returns a fresh checkers board like so,. | ||
|
||
<!-- livebook:{"force_markdown":true} --> | ||
|
||
```elixir | ||
[ | ||
[nil, nil, nil], | ||
[nil, nil, nil], | ||
[nil, nil, nil] | ||
] | ||
``` |
This file contains 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,27 @@ | ||
# Rock Paper Scissors | ||
|
||
## Custom Rock Paper Scissors | ||
|
||
You're going to create a rock paper scissors game where users can create their own choices. | ||
|
||
* Create a `CustomGame` struct. | ||
* Create required keys for `:rock`, `:paper`, `:scissors`. | ||
* Create a `CustomGame.new/3` function that allows users to enter alternate atoms for `:rock`, `:paper`, and `:scissors`. | ||
* Create a `CustomGame.play/3` which expects the return value of `CustomGame.create_game/3` as a parameter. | ||
The second and third parameter should expect custom atoms the user previously defined. | ||
|
||
For example, | ||
|
||
```elixir | ||
game = CustomGame.new(:grass, :fire, :water) | ||
|
||
CustomGame.play(game, :fire, :water) | ||
"water beats fire" | ||
|
||
CustomGame.play(game, :water, :water) | ||
"draw" | ||
``` | ||
|
||
```elixir | ||
|
||
``` |
Oops, something went wrong.