[Solved] Elixir Coin Change [closed]


try this

defmodule MejorCambio do

    def darcambio(abono, adeudo) do
      td = abono - adeudo
      IO.inspect("Tu cambio es de #{td}")

      Enum.reduce([200,100,50,20,10, 5, 2, 1], %{abono: abono, adeudo: adeudo} , fn divisa, acc ->

        cambio = acc.abono - acc.adeudo

          repeat =  div(cambio, divisa)

          acc2 =  rem(cambio, divisa)

      %{deno: divisa , val: repeat} |> IO.inspect()

          %{acc | adeudo: acc2 * -1, abono: 0 }

      end)|> IO.inspect()


      end


    end

0

solved Elixir Coin Change [closed]