結果

問題 No.227 簡単ポーカー
ユーザー asatakeasatake
提出日時 2018-08-13 09:29:58
言語 Elixir
(1.16.2)
結果
AC  
実行時間 630 ms / 5,000 ms
コード長 569 bytes
コンパイル時間 1,495 ms
コンパイル使用メモリ 53,728 KB
実行使用メモリ 49,388 KB
最終ジャッジ日時 2023-08-29 22:52:47
合計ジャッジ時間 11,389 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 617 ms
49,132 KB
testcase_01 AC 626 ms
49,204 KB
testcase_02 AC 626 ms
49,020 KB
testcase_03 AC 615 ms
49,244 KB
testcase_04 AC 607 ms
49,088 KB
testcase_05 AC 625 ms
49,240 KB
testcase_06 AC 620 ms
49,368 KB
testcase_07 AC 610 ms
49,220 KB
testcase_08 AC 630 ms
49,212 KB
testcase_09 AC 617 ms
49,080 KB
testcase_10 AC 627 ms
49,108 KB
testcase_11 AC 620 ms
48,992 KB
testcase_12 AC 613 ms
49,088 KB
testcase_13 AC 620 ms
49,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main() do
    a = IO.gets("") |> String.trim |> String.split
    IO.puts judge(count(%{}, a))
  end

  def count(m, []) do
    m
  end

  def count(m, [h | t]) do
    new_m = case Map.has_key?(m, h) do
      false -> Map.put_new(m, h, 1)
      true -> Map.update!(m, h, fn x -> x + 1 end)
    end
    count(new_m, t)
  end

  def judge(m) do
    case Map.values(m) |> Enum.sort do
      [2, 3] -> "FULL HOUSE"
      [1, 1, 3] -> "THREE CARD"
      [1, 2, 2] -> "TWO PAIR"
      [1, 1, 1, 2] -> "ONE PAIR"
      _ -> "NO HAND"
    end
  end

end
0