This article is all about coding the implicit conditions in FizzBuzz. This makes you to walk over lines of code that gives similar output with different syntax.
To whom ?
This is for complete beginners in Elixir. But, this gonna be more informative at the end.
What is Fizz-Buzz ?
When you google, you will find the following phrases about the FizzBuzz.
FizzBuzz is a very simple programming task, used in software developer job interviews, to determine whether the job candidate can actually write code.
Fizz buzz is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any number divisible by three with the word “fizz”, and any number divisible by five with the word “buzz” and if divisible by both three and five with the word FizzBuzz or else just printing the number itself.
That’s all about the FizzBuzz. Oh.. you finally know what FizzBuzz is . Keep Rocking…
What are we gonna code here?
We simply print the numbers in a range replacing them with words Fizz, Buzz, and FizzBuzz using game protocol.
Time to code…
Here, I named the module with
FizzBuzz of course everybody does the same and wrote a
At first we just print the numbers in the range and see how it works.
defmodule FizzBuzz do
def play(min, max) do
Enum.each(min..max, fn(num)-> IO.puts num end )
This function takes two numbers as input technically minimum and maximum values in a range. So, we can create a range via
You can check the implemented protocols with the help of