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.139 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.138 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.137 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.136 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.135 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.134 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.133 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.132 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.131 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.130 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.129 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.128 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.127 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.126 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.125 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.124 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.123 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.122 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.121 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.120 tracks/elixir/exercises/raindrops/example.exs