defmodule Main do #入力 def main do num = IO.gets("") |> String.trim |> String.split |>Enum.map(&String.to_integer/1) check(num, 0) end # 大 小 中 def check([a, b, c], cun) when a > b and a > c do if (a-c) < (c-b) do check([a-1, b, c], cun+1) else check([a, b, c-1], cun+1) end end # 中 小 大 def check([a, b, c], cun) when a > b and a < c do if (c-a) < (a-b) do check([a, b, c-1], cun+1) else check([a-1, b, c], cun+1) end end # 中 大 小 def check([a, b, c], cun) when a > c and a < b do if (b-a) < (a-c) do check([a, b-1, c], cun+1) else check([a-1, b, c], cun+1) end end # 小 大 中 def check([a, b, c], cun) when a < c and c < b do if (c-a) < (b-c) do check([a, b, c-1], cun+1) else check([a, b-1, c], cun+1) end end def check([a, b, c], cun) when a == b or a == c or b == c do IO.inspect cun end end