← All series

Series contents

Log in to track your progress

  1. 1. Welcome to Alchemist Camp Episode
  2. 2. Lesson 1: The guessing game Episode
  3. 3. Solution 1: The Greeter Episode
  4. 4. Lesson 2: Word Count Episode
  5. 5. Word Count ULTIMATE EDITION! Episode
  6. 6. Minimal Todo List Part 1 Episode
  7. 7. Elixir lists vs Elixir tuples Article
  8. 8. The Image Snatcher Episode
  9. 9. Minimal Todo List Part 2 Episode
  10. 10. Elixir maps made effortless Article
  11. 11. Fibonacci with tail recursion Episode
  12. 12. Mini Markdown Episode
  13. 13. Extending Mini Markdown Episode
  14. 14. Alchemy Markdown Episode
  15. 15. Using mix to modularize and add tests Episode
  16. 16. Command line applications with escript Episode
  17. 17. Caboose, a simple Unix tail clone Episode
  18. 18. Game board (Tictac Part 1) Episode
  19. 19. Structs: Maps with checks and default values Article
  20. 20. Deck generation, Pythagorean Triplets and more Episode
  21. 21. Whiteboarding the Tictac state machine Episode
  22. 22. Game state machine (Tictac Part 2) Episode
  23. 23. Modelling the memory game Episode
  24. 24. Finishing Tictac and making a CLI Episode
  25. 25. Threatened by rooks, bishops and knights Episode
  26. 26. A worker to log stats from a YouTube’s API Episode
  27. 27. Constructing bitmap files with Elixir Episode
  28. 28. Making bitmaps with color palettes Episode
  29. 29. Flattening lists recursively in Elixir Episode

Lesson 1: The guessing game

Alchemist Camp is where you can learn the Elixir programming language by building projects. We'll get a solid foundation in Elixir and then use the Phoenix framework to build scalable, fault-tolerant web applications.

Welcome to Alchemist Camp!

Let's start at the very beginning. The first thing you'll need to do is install Elixir. Go to elixir-lang.org, click on the install tab and then follow the instructions for your OS. While you're on the site be sure to bookmark the docs. You'll be referring to them often as you learn! Next you'll need a text editor. If you don't already have a favorite editor, I recommend Visual Studio Code. As of early 2018, VS code is the number one project on Github in terms of contributor activity and it shows. The editor is head and shoulders ahead of competitors in terms of configurability, plugin support and in many cases, even speed.

Once you're set up, open your system terminal. VS code also has a handy integrated terminal you can open by pressing ctrl + `. Then type iex in the terminal. This is Elixir's integrated REPL. Try typing in some simple arithmetic expressions, strings, etc... poke around a bit. Try typing i before an expression to get "info" about how Elixir analyzes that expression. Note what happens when you divide an integer by another integer. Try using the div(a, b) and rem(a, b) functions.

At (10:47) of the video, we start writing a simple module. It's a guessing game that will iterative guess what number a user is thinking of, between some maximum value and some minimum value, and efficiently narrow in on an answer as the user responds with "too low" and "too high" feedback.


Source code for this episode


This lesson should get you set up and give you a good start with IO, functions, and modulo arithmetic in Elixir.

Challenge 1

See if you can make a program that asks the user's name and then greets them by name... and has a special response for users who enter your name.

Open standalone page ↗

12 Comments

I'll bet you can!

- alchemist · 6 years ago

thanks, oh and in case i don't see ya good afternoon good evening and goodnight

- Qurbanov · 2 years ago

nice lecture

- abdulrahman · 6 years ago

These lessons are great.  Love it.

- PaulB · 4 years ago

thank you

- NiluE · 4 years ago

Thank You, brother!

- lastgosu · 5 years ago

Nice simple one to review the basics!

- jtoulouse · 6 years ago

I made a version where the number is defined by the game with Enum.random(1..100) and the user guesses the number. Same basic Idea with case statements, etc.

- okcomputer · 1 year ago

Nice one, simple and right to the point

- czio · 6 years ago

thank you

- zinnia · 5 years ago

nice episode

- Neon23 · 1 year ago

I think can use half-interval method and no need to use min and max.

"bigger" -> bigger(middle, high)
"smaller" -> smaller(low, middle)

- manhtranlinh · 6 years ago