Skip to content
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

Atoms reading #17

Open
wants to merge 14 commits into
base: solutions
Choose a base branch
from
19 changes: 14 additions & 5 deletions exercises/card_counting.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ high = 1
Enter your solution below.

```elixir

low = 1
high = 1
normal = 0
```

## High Card
Expand All @@ -92,7 +94,8 @@ initial_count + high
Enter your solution below.

```elixir

initial_count = 0
initial_count + high
```

## Low Card
Expand All @@ -112,7 +115,8 @@ initial_count + low
Enter your solution below.

```elixir

initial_count = 0
initial_count + low
```

## Multiple Cards
Expand All @@ -134,7 +138,8 @@ You could omit the **normal** cards or allow **high** and **low** cards to balan
Enter your solution below.

```elixir

initial_count = 5
initial_count + 5 * high + 2 * low + 2 * normal
```

## Bonus: Determining Card Values
Expand Down Expand Up @@ -176,7 +181,11 @@ You could omit the **normal** cards or allow **high** and **low** cards to balan
Enter your solution below.

```elixir

random_card_1 = Enum.random(1..13)
random_card_2 = Enum.random(1..13)
random_card_3 = Enum.random(1..13)
initial_count = 0
random_card_1 + random_card_2 + random_card3
```

## Mark As Completed
Expand Down
15 changes: 10 additions & 5 deletions exercises/fun_formulas.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ actual / total
Enter your solution below.

```elixir

10 / 7 * 100
7 / 10 * 100
```

## Rocket Ship
Expand All @@ -81,7 +82,9 @@ mass * acceleration
Enter your solution below.

```elixir

mass = 10
acceleration = 50
mass * acceleration
```

## What Do You Tip?
Expand All @@ -105,7 +108,7 @@ initial_cost * tip_percent
Enter your solution below.

```elixir

tip = 20 * 0.15
```

## Pythagorean Theorum
Expand All @@ -129,7 +132,9 @@ a ** 2 + b ** 2
Enter your solution below.

```elixir

a = 4
b = 10
a ** 2 + b ** 2
```

## Bonus: Square Root
Expand All @@ -149,7 +154,7 @@ c_squared = 116
Enter your solution below.

```elixir

:math.sqrt(116)
```

## Mark As Completed
Expand Down
16 changes: 14 additions & 2 deletions exercises/guessing_games.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ Ensure your solutions works for both an incorrect and correct player guess.
Enter your solution below.

```elixir

guess = "foo"
answer = "bar"
(guess == answer && "Yes!") || "Nope!"
```

## Bonus: Guess the Random Word
Expand Down Expand Up @@ -67,7 +69,10 @@ Armed with this knowledge, you're going to create a word guessing game.
Enter your solution below.

```elixir
guess = Enum.random(["hello", "hi", "howdy"])
answer = Enum.random(["hello", "hi", "howdy"])

(guess == answer && "Yep!") || "Nope!"
```

## Bonus: Guess the Number
Expand Down Expand Up @@ -119,7 +124,14 @@ Now let's build a number guessing game
Enter your solution below.

```elixir

guess = Enum.random(1..10)
answer = 5

cond do
guess == answer -> "Correct!"
guess < answer -> "Too low!"
guess > answer -> "Too high!"
end
```

## Mark As Completed
Expand Down
20 changes: 15 additions & 5 deletions exercises/habit_tracker.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ small = 5
Enter your solution below.

```elixir

large = 30
medium = 20
small = 5
```

## Small, Medium, Large
Expand Down Expand Up @@ -83,7 +85,7 @@ small + medium + large
Enter your answer in the code cell below.

```elixir

small + medium + large
```

## Multiples
Expand All @@ -102,7 +104,7 @@ small * 10 + medium * 5 + large * 3
Enter your answer below.

```elixir

10 * small + 5 * medium + 3 * large
```

## Progress Bar
Expand Down Expand Up @@ -133,7 +135,8 @@ points / goal
Enter your answer below.

```elixir

goal = 40
(small + medium) / goal * 100
```

## Penalties and Rewards
Expand All @@ -160,7 +163,8 @@ small * 1.6 * 3 + medium * 2 + large * 2 * 0.5
Enter your answer below.

```elixir

goal = 40
3 * 1.6 * small + 2 * medium + 2 * 0.5 * large
```

## Bonus: Add Your Own Feature
Expand All @@ -169,7 +173,13 @@ Add your own feature to the habit tracking app. Use comments to describe your fe
how it would affect calculating the total score and/or the total percentage of completed habits.

```elixir
# if the total is > 50% of goal then add 10 point bonus
goal = 40
total = small + medium

if total > 20 do
total + 10
end
```

## Mark As Completed
Expand Down
10 changes: 10 additions & 0 deletions exercises/mad_libs.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ blank3 = "code"
Enter your solution below.

```elixir
blank1 = "person"
blank2 = "coffee"
blank3 = "code"

"A programmer is a " <> blank1 <> " that turns " <> blank2 <> " into " <> blank3

"A programmer is a #{blank1} that turns #{blank2} into #{blank3}"
```

## String Interpolation Madlib
Expand All @@ -65,7 +71,11 @@ blank3 = "foobar"
Enter your solution below.

```elixir
blank1 = "one"
blank2 = "two"
blank3 = "three"

"#{blank1} and #{blank2} combined makes #{blank3}"
```

## Mark As Completed
Expand Down
12 changes: 10 additions & 2 deletions exercises/shopping_list.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ shopping_cart = shopping_cart ++ ["banana", "banana", "banana"]
Enter your solution below.

```elixir

cart = []
cart = cart ++ ["grapes", "walnuts", "apples"]
cart = cart ++ ["blueberries", "chocolate", "pizza"]
cart = cart -- ["grapes", "walnuts"]
cart = cart ++ ["banana", "banana", "banana"]
```

## Text Shopping List With Quantities
Expand Down Expand Up @@ -79,7 +83,11 @@ shopping_cart = shopping_cart ++ [candies: 5]
</details>

```elixir

cart = []
cart = cart ++ [butter: 2, candy: 10]
cart = cart -- [butter: 2]
cart = cart -- [candy: 10]
cart = cart ++ [candy: 5]
```

## Mark As Completed
Expand Down
14 changes: 7 additions & 7 deletions progress.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"agents_and_ets_reading": false,
"protocols_reading": false,
"games_score_tracker_exercise": false,
"habit_tracker_exercise": false,
"habit_tracker_exercise": true,
"reduce_reading": false,
"code_editors_reading": false,
"exdoc_reading": false,
Expand Down Expand Up @@ -64,14 +64,14 @@
"github_engineering_journal_exercise": false,
"mailbox_server_exercise": false,
"blog_posts_exercise": false,
"git_reading": false,
"git_reading": true,
"named_number_lists_exercise": false,
"big_o_notation_reading": false,
"battle_map_exercise": false,
"group_project_blog_presentation_exercise": false,
"timer_exercise": false,
"games_benchmarking_exercise": false,
"guessing_games_exercise": false,
"guessing_games_exercise": true,
"sign_up_form_exercise": false,
"enum_reading": false,
"caesar_cypher_exercise": false,
Expand Down Expand Up @@ -129,7 +129,7 @@
"naming_numbers_exercise": false,
"deployment_exercise": false,
"typespecs_reading": false,
"card_counting_exercise": false,
"card_counting_exercise": true,
"math_with_protocols_exercise": false,
"stack_server_exercise": false,
"pokemon_battle_exercise": false,
Expand All @@ -145,7 +145,7 @@
"task_drills_exercise": false,
"monster_spawner_exercise": false,
"metaprogramming_reading": false,
"start_here_reading": false,
"start_here_reading": true,
"games_supervisor_setup_exercise": false,
"pic_chat_pub_sub_reading": false,
"lists_reading": false,
Expand All @@ -158,7 +158,7 @@
"save_game_exercise": false,
"document_tools_exercise": false,
"factorial_exercise": false,
"livebook_reading": false,
"livebook_reading": true,
"filter_values_by_type_exercise": false,
"book_search_exercise": false,
"guards_reading": false,
Expand Down Expand Up @@ -205,5 +205,5 @@
"fibonacci_exercise": false,
"typespec_drills_exercise": false,
"custom_assertions_exercise": false,
"atoms_reading": false
"atoms_reading": true
}
6 changes: 3 additions & 3 deletions reading/atoms.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ false === :false
In the Elixir cell below, use `===` to check if `nil` is equal to `:nil`.

```elixir

nil === nil
```

Check if `true` is equal to `:true`.

```elixir

true === true
```

Check if `false` is equal to `:false`.

```elixir

false === false
```

## Further Reading
Expand Down
2 changes: 0 additions & 2 deletions reading/iex.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ We can also use [IO.gets/2](https://hexdocs.pm/elixir/IO.html#gets/2) to retriev

<!-- livebook:{"force_markdown":true} -->

<!-- livebook:{"force_markdown":true} -->

```elixir
iex> input = IO.gets("Give me some input: ")
Give me some input: sure!
Expand Down
8 changes: 5 additions & 3 deletions reading/livebook.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ Livebook may change this UI, so if this is instruction is no longer accurate ple

Create an Elixir code cell below. Run some Elixir code such as `1 + 2` in the cell.

<!-- livebook:{"break_markdown":true} -->
```elixir
1 + 2
```

### Livebook Shortcuts

Expand Down Expand Up @@ -210,7 +212,7 @@ Try uncommenting the following code (Remove the `#` character) then press <kbd>A
Notice that the `1 + 1` code moves to the left.

```elixir
# 1 + 1
1 + 1
```

If you have not evaluated any Elixir code cells, you may see a warning.
Expand All @@ -223,7 +225,7 @@ If you cannot format an Elixir cell, you can use this as a clue that you have a
code is invalid. Notice that you cannot use <kbd>ALT</kbd>+<kbd>SHIFT</kbd>+<kbd>F</kbd> to format the code.

```elixir
1 +
1 + 1
```

## Mark As Completed
Expand Down
4 changes: 4 additions & 0 deletions reading/start_here.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ There is a **Commit Your Progress** and a **Mark as Completed** section at the e

However, self-led students can complete these sections if they want to track their progress and get more practice using GitHub. We ask that you don't create pull requests to the DockYard Academy repo, as this spams our PR tracker. If you are not an academy student, we also ask that you refrain from @mentioning the instructor as this spams our notifications, and 1-1 feedback is only available to academy students.

```elixir
2 + 2
```

## Mark As Completed

<!-- livebook:{"attrs":{"source":"file_name = Path.basename(Regex.replace(~r/#.+/, __ENV__.file, \"\"), \".livemd\")\n\nsave_name =\n case Path.basename(__DIR__) do\n \"reading\" -> \"start_here_reading\"\n \"exercises\" -> \"start_here_exercise\"\n end\n\nprogress_path = __DIR__ <> \"/../progress.json\"\nexisting_progress = File.read!(progress_path) |> Jason.decode!()\n\ndefault = Map.get(existing_progress, save_name, false)\n\nform =\n Kino.Control.form(\n [\n completed: input = Kino.Input.checkbox(\"Mark As Completed\", default: default)\n ],\n report_changes: true\n )\n\nTask.async(fn ->\n for %{data: %{completed: completed}} <- Kino.Control.stream(form) do\n File.write!(\n progress_path,\n Jason.encode!(Map.put(existing_progress, save_name, completed), pretty: true)\n )\n end\nend)\n\nform","title":"Track Your Progress"},"chunks":null,"kind":"Elixir.HiddenCell","livebook_object":"smart_cell"} -->
Expand Down