Sha256: 541d48fc2f2e43077686002ac8b86b7c6a28cb64cff6f0f7d1af919962e4e62a
Contents?: true
Size: 620 Bytes
Versions: 196
Compression:
Stored size: 620 Bytes
Contents
defmodule Change do @doc """ Determine the least number of coins to be given to the user such that the sum of the coins' value would equal the correct amount of change. It returns {:error, "cannot change"} if it is not possible to compute the right amount of coins. Otherwise returns the tuple {:ok, list_of_coins} ## Examples iex> Change.generate([5, 10, 15], 3) {:error, "cannot change"} iex> Change.generate([1, 5, 10], 18) {:ok, [1, 1, 1, 5, 10]} """ @spec generate(list, integer) :: {:ok, list} | {:error, String.t} def generate(coins, target) do end end
Version data entries
196 entries across 196 versions & 1 rubygems