Sha256: 1454a4c10090a4929a553bbcbfaaef4c91e5f513ad456c2d2e7e5736110393c7

Contents?: true

Size: 421 Bytes

Versions: 69

Compression:

Stored size: 421 Bytes

Contents

defmodule Raindrops do
  def convert(number),
    do: output({[sound(number, 3), sound(number, 5), sound(number, 7)], number})

  defp sound(n, 3) when rem(n, 3) == 0, do: "Pling"
  defp sound(n, 5) when rem(n, 5) == 0, do: "Plang"
  defp sound(n, 7) when rem(n, 7) == 0, do: "Plong"
  defp sound(_, _), do: ""

  defp output({["", "", ""], number}), do: "#{number}"
  defp output({sounds, _}), do: Enum.join(sounds)
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.179 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.178 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.177 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.176 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.175 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.174 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.173 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.172 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.171 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.170 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.169 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.167 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.166 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.165 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.164 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.163 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.162 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.161 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.160 tracks/elixir/exercises/raindrops/example.exs