Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/General-FizzBuzz/Elixir/general-fizzbuzz.elixir
Normal file
19
Task/General-FizzBuzz/Elixir/general-fizzbuzz.elixir
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
defmodule General do
|
||||
def fizzbuzz(input) do
|
||||
[num | nwords] = String.split(input)
|
||||
max = String.to_integer(num)
|
||||
dict = Enum.chunk(nwords, 2) |> Enum.map(fn[n,word] -> {String.to_integer(n),word} end)
|
||||
Enum.each(1..max, fn i ->
|
||||
str = Enum.map_join(dict, fn {n,word} -> if rem(i,n)==0, do: word end)
|
||||
IO.puts if str=="", do: i, else: str
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
input = """
|
||||
105
|
||||
3 Fizz
|
||||
5 Buzz
|
||||
7 Baxx
|
||||
"""
|
||||
General.fizzbuzz(input)
|
||||
Loading…
Add table
Add a link
Reference in a new issue