defmodule Main do def judgePoker(cards) do grouped_cards = cards |> Enum.group_by(&(&1)) three_cards = length(for {k, v} <- grouped_cards, length(v) == 3, do: k) two_cards = length(for {k, v} <- grouped_cards, length(v) == 2, do: k) case {three_cards, two_cards} do {1, 1} -> "FULL HOUSE" {1, 0} -> "THREE CARD" {0, 2} -> "TWO PAIR" {0, 1} -> "ONE PAIR" _ -> "NO HAND" end end def main do inputs = IO.binread(:all) |> String.split as = inputs |> Enum.map(&String.to_integer/1) IO.puts judgePoker(as) end end