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.159 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.158 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.157 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.156 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.155 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.154 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.153 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.152 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.151 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.150 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.149 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.148 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.147 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.146 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.145 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.144 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.143 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.142 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.141 tracks/elixir/exercises/raindrops/example.exs
trackler-2.2.1.140 tracks/elixir/exercises/raindrops/example.exs