defmodule Main do def main() do l = IO.gets("") |> String.trim |> String.to_integer n = IO.gets("") |> String.trim |> String.to_integer w = IO.gets("") |> String.trim |> String.split |> Enum.map(fn x -> String.to_integer(x) end) |> Enum.sort IO.inspect n - calc(0, w, l) end defp calc(c, [], l) do 0 end defp calc(c, w, l) do IO.inspect [c, w, l] [h | t] = w cond do c + h <= l -> calc(c + h, t, l) true -> Enum.count(t) + 1 end end end