結果

問題 No.227 簡単ポーカー
ユーザー asatakeasatake
提出日時 2018-08-13 09:26:12
言語 Elixir
(1.16.2)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 1,112 ms
コンパイル使用メモリ 55,112 KB
実行使用メモリ 51,976 KB
最終ジャッジ日時 2023-08-29 22:55:17
合計ジャッジ時間 11,443 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 633 ms
49,384 KB
testcase_02 AC 628 ms
49,280 KB
testcase_03 AC 626 ms
49,336 KB
testcase_04 AC 632 ms
49,812 KB
testcase_05 AC 630 ms
49,292 KB
testcase_06 WA -
testcase_07 AC 639 ms
49,068 KB
testcase_08 WA -
testcase_09 AC 628 ms
49,212 KB
testcase_10 AC 631 ms
48,564 KB
testcase_11 AC 632 ms
48,876 KB
testcase_12 AC 636 ms
47,816 KB
testcase_13 AC 636 ms
49,816 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: Map.size/1 is deprecated. Use Kernel.map_size/1 instead
Invalid call found at 3 locations:
  Main.exs:21: Main.judge/1
  Main.exs:22: Main.judge/1
  Main.exs:23: Main.judge/1

ソースコード

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
    cond do
      Map.size(m) === 2 -> "FULL HOUSE"
      Map.size(m) === 4 -> "ONE PAIR"
      Map.size(m) === 5 -> "NO HAND"
      Map.values(m) |> Enum.sort === [1, 1, 3] -> "THREE CARD"
      true -> "TWO PAIR"
    end
  end

end
0