Sha256: 2e8fa120317f6d837d8a9ea88f9624d5cf96dbbe1722565223efe38fa83e45dc
Contents?: true
Size: 621 Bytes
Versions: 69
Compression:
Stored size: 621 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
69 entries across 69 versions & 1 rubygems