From f7c17ac0f833aa663395fcee3fa2dd46ff8ed8eb Mon Sep 17 00:00:00 2001 From: quentinlee Date: Wed, 25 Jan 2023 16:36:11 +0100 Subject: [PATCH 1/3] feat: implement livebook for exercises --- README.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3520d2d..155394b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Simple diagrams and resources to help learning Elixir, Phoenix, Ecto and other u - [10 tips for new elixir developpers](#10-tips-for-new-elixir-developpers) - [Elixir cheat sheet](#elixir-cheat-sheet) - [Elixir learning path](#elixir-learning-path) - - [Level 1 (Elixir)](#level-1-elixir) + - [Section 1 (Elixir)](#section-1-elixir) - [Installing Elixir and Running IEx](#installing-elixir-and-running-iex) - [Elixir guide styles (non exhaustive)](#elixir-guide-styles-non-exhaustive) - [Basics (Getting started with Elixir)](#basics-getting-started-with-elixir) @@ -24,7 +24,8 @@ Simple diagrams and resources to help learning Elixir, Phoenix, Ecto and other u - [Controls Structures (cond, with, case, if)](#controls-structures-cond-with-case-if) - [IO and files](#io-and-files) - [Debugging with Elixir](#debugging-with-elixir) - - [Level 2 (Phoenix, Ecto and OTP basics)](#level-2-phoenix-ecto-and-otp-basics) +- [👣 Get your feet wet](#-get-your-feet-wet) + - [Section 2 (Phoenix, Ecto and OTP basics)](#section-2-phoenix-ecto-and-otp-basics) - [Mix](#mix) - [Errors and Exceptions](#errors-and-exceptions) - [Testing your code](#testing-your-code) @@ -33,7 +34,7 @@ Simple diagrams and resources to help learning Elixir, Phoenix, Ecto and other u - [OTP Basics](#otp-basics) - [Phoenix](#phoenix) - [Ecto](#ecto) - - [Level 3 (OTP, MetaProgramming)](#level-3-otp-metaprogramming) + - [Section 3 (OTP, MetaProgramming)](#section-3-otp-metaprogramming) - [Processes (Spawn, Links, Tasks, etc.)](#processes-spawn-links-tasks-etc) - [Supervisors](#supervisors) - [AST](#ast) @@ -95,7 +96,7 @@ Anyone can contribute, add resources, links and update mermaid diagrams :) Feel # Elixir learning path -## Level 1 (Elixir) +## Section 1 (Elixir) → At this level, you can practice coding with Elixir using the [Exercism’s Elixir track](https://exercism.org/tracks/elixir), a website where you can find puzzles and exercises for every Elixir concepts. Plus, their [Sylabus](https://exercism.org/tracks/elixir/concepts) is great! @@ -211,7 +212,16 @@ Doc[Documentation and Typespecs] - [Three Ways to Debug Code in Elixir by Pulkit Goyal](https://blog.appsignal.com/2021/11/30/three-ways-to-debug-code-in-elixir.html) -## Level 2 (Phoenix, Ecto and OTP basics) +# 👣 Get your feet wet + +After reading through all these documentations for the first section, you must have gathered some basic knowledge about Elixir. +Now, let's do a series of exercises covering different concepts we mentioned above, and get yourself more familiar with the language. +The exercises were written in Livebook. To access the website, you need this password: 7ieocxmigw3pyruhnxzp5v66jdgiatw5 + +- [Section 1 exercises](https://elixir-learning-path.fly.dev/sessions/xgcbllf6pzsuj7nyhv2qdjock36exfvtv4qydeav) + + +## Section 2 (Phoenix, Ecto and OTP basics) ```mermaid graph TD @@ -313,7 +323,7 @@ graph TD - [Ecto.Multi hexdoc](https://hexdocs.pm/ecto/Ecto.Multi.html) - [Dynamic queries](https://hexdocs.pm/ecto/dynamic-queries.html) -## Level 3 (OTP, MetaProgramming) +## Section 3 (OTP, MetaProgramming) ```mermaid graph TD From a1d5a7798df089595cf79ec980a57e31bbe1b489 Mon Sep 17 00:00:00 2001 From: quentinlee Date: Thu, 26 Jan 2023 09:57:54 +0100 Subject: [PATCH 2/3] chore: use livebook badge --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 155394b..804a5e2 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Simple diagrams and resources to help learning Elixir, Phoenix, Ecto and other u - [IO and files](#io-and-files) - [Debugging with Elixir](#debugging-with-elixir) - [👣 Get your feet wet](#-get-your-feet-wet) + - [Section 1 exercises](#section-1-exercises) - [Section 2 (Phoenix, Ecto and OTP basics)](#section-2-phoenix-ecto-and-otp-basics) - [Mix](#mix) - [Errors and Exceptions](#errors-and-exceptions) @@ -216,10 +217,10 @@ Doc[Documentation and Typespecs] After reading through all these documentations for the first section, you must have gathered some basic knowledge about Elixir. Now, let's do a series of exercises covering different concepts we mentioned above, and get yourself more familiar with the language. -The exercises were written in Livebook. To access the website, you need this password: 7ieocxmigw3pyruhnxzp5v66jdgiatw5 - -- [Section 1 exercises](https://elixir-learning-path.fly.dev/sessions/xgcbllf6pzsuj7nyhv2qdjock36exfvtv4qydeav) +The exercises were written in Livebook. +### Section 1 exercises +[![Run in Livebook](https://livebook.dev/badge/v1/black.svg)](https://livebook.dev/run?url=https%3A%2F%2Felixir-learning-path.fly.dev%2Fsessions%2Fxgcbllf6pzsuj7nyhv2qdjock36exfvtv4qydeav) ## Section 2 (Phoenix, Ecto and OTP basics) From ff8063949e64ca226f68e344b057ce0a7752117b Mon Sep 17 00:00:00 2001 From: quentinlee Date: Thu, 26 Jan 2023 10:17:38 +0100 Subject: [PATCH 3/3] chore: add exercises in a livemd file --- exercises/section_1.livemd | 80 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 exercises/section_1.livemd diff --git a/exercises/section_1.livemd b/exercises/section_1.livemd new file mode 100644 index 0000000..b47363a --- /dev/null +++ b/exercises/section_1.livemd @@ -0,0 +1,80 @@ +# Elixir Learning Path + +## Section 1 exercises + +Get your hands dirty on Elixir with the series of exercises below. The idea is to write a function that returns expected output, with unit tests implemented. + + + +### String length + +Given a string, you need to return the number of characters. + +```elixir +defmodule String.Length do + def string_length(string) do + ## Your solution here + end +end +``` + +```elixir +ExUnit.start(auto_run: false) + +defmodule String.LengthTest do + use ExUnit.Case, async: false + alias String.Length + + describe "string_length/1" do + test "the length of hello is 5" do + assert Length.string_length("hello") == 5 + end + + test "the length of wikipedia is 9" do + assert Length.string_length("wikipedia") == 9 + end + + test "the length of dsqsqdqsdeqdfqfaezaezeqsdsqrerdsqdqsdqdqdqs is 43" do + assert Length.string_length("dsqsqdqsdeqdfqfaezaezeqsdsqrerdsqdqsdqdqdqs") == 43 + end + end +end + +ExUnit.run() +``` + +### Addition + +Write a function that returns the addition of a and b. + +```elixir +defmodule Addition do + def add(a, b) when is_integer(a) and is_integer(b) do + ## Your solution here + end +end +``` + +```elixir +ExUnit.start(auto_run: false) + +defmodule AdditionTest do + use ExUnit.Case, async: false + + describe "add/2" do + test "2 add 1 equals 3" do + assert Addition.add(2, 1) == 3 + end + + test "532323132 add 2423242424 equals" do + assert Addition.add(532_323_132, 2_423_242_424) == 2_955_565_556 + end + + test "if one of the element is not integer should transform it and perform addition" do + assert Addition.add("2", 1) == 3 + end + end +end + +ExUnit.run() +```