Sha256: a067e17c0b20c36d0e5a1dd053fcf59bb132139bf3d1368442e61cf7491a9500

Contents?: true

Size: 329 Bytes

Versions: 238

Compression:

Stored size: 329 Bytes

Contents

defmodule Grains do
  use Bitwise, only_operators: true
  def square(number) when number in (1..64), do: { :ok, 1 <<< (number - 1) }
  def square(_), do: { :error, "The requested square must be between 1 and 64 (inclusive)" }
  def total, do: { :ok, Enum.reduce(1..64, 0, fn(n, acc) -> {:ok, sq} = square(n); acc + sq end) }
end

Version data entries

238 entries across 238 versions & 1 rubygems

Version Path
trackler-2.2.1.109 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.108 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.107 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.106 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.105 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.104 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.103 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.102 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.101 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.100 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.99 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.98 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.97 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.96 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.95 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.94 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.93 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.92 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.91 tracks/elixir/exercises/grains/example.exs
trackler-2.2.1.90 tracks/elixir/exercises/grains/example.exs