Skip to content

Commit

Permalink
Add Fizz Buzz implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sambostock committed Apr 9, 2017
1 parent 7a996dc commit 1875ddf
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FizzBadd

**TODO: Add description**
A shitty Fizz Buzz implementation generator.

## Installation

Expand Down
13 changes: 0 additions & 13 deletions lib/fizz_badd.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,4 @@ defmodule FizzBadd do
@moduledoc """
Documentation for FizzBadd.
"""

@doc """
Hello world.
## Examples
iex> FizzBadd.hello
:world
"""
def hello do
:world
end
end
28 changes: 28 additions & 0 deletions lib/fizz_badd/fizz_buzz.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule FizzBadd.FizzBuzz do
@moduledoc """
Fizz Buzz implementation for internal use.
"""

@doc """
Produce the n-th value in the Fizz Buzz sequence.
## Examples
iex> FizzBadd.FizzBuzz.fizz_buzz(1)
"1"
iex> FizzBadd.FizzBuzz.fizz_buzz(3)
"Fizz"
iex> FizzBadd.FizzBuzz.fizz_buzz(5)
"Buzz"
iex> FizzBadd.FizzBuzz.fizz_buzz(15)
"Fizz Buzz"
"""
def fizz_buzz(n) when rem(n, 15) == 0, do: "Fizz Buzz"
def fizz_buzz(n) when rem(n, 5) == 0, do: "Buzz"
def fizz_buzz(n) when rem(n, 3) == 0, do: "Fizz"
def fizz_buzz(n), do: Integer.to_string(n)
end
7 changes: 7 additions & 0 deletions test/fizz_badd/fizz_buzz_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule FizzBaddTest.FizzBuzzTest do
use ExUnit.Case

alias FizzBadd.FizzBuzz, as: FizzBuzz

doctest FizzBuzz
end
4 changes: 0 additions & 4 deletions test/fizz_badd_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
defmodule FizzBaddTest do
use ExUnit.Case
doctest FizzBadd

test "the truth" do
assert 1 + 1 == 2
end
end

0 comments on commit 1875ddf

Please sign in to comment.