結果

問題 No.227 簡単ポーカー
ユーザー mesh1nek0x0mesh1nek0x0
提出日時 2018-07-03 23:25:24
言語 Ruby
(3.3.0)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 606 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 11,200 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-09-13 17:21:12
合計ジャッジ時間 2,784 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,164 KB
testcase_01 AC 77 ms
15,044 KB
testcase_02 AC 77 ms
15,152 KB
testcase_03 AC 81 ms
15,140 KB
testcase_04 AC 77 ms
15,216 KB
testcase_05 AC 80 ms
15,280 KB
testcase_06 AC 79 ms
15,160 KB
testcase_07 AC 82 ms
15,184 KB
testcase_08 AC 76 ms
15,216 KB
testcase_09 AC 77 ms
15,316 KB
testcase_10 AC 76 ms
15,328 KB
testcase_11 AC 77 ms
15,316 KB
testcase_12 AC 77 ms
15,272 KB
testcase_13 AC 78 ms
15,116 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/bin/ruby
cards = {
  "1" => 0,
  "2" => 0,
  "3" => 0,
  "4" => 0,
  "5" => 0,
  "6" => 0,
  "7" => 0,
  "8" => 0,
  "9" => 0,
  "10" => 0,
  "11" => 0,
  "12" => 0,
  "13" => 0
}

A = gets.chomp.split(' ')

5.times do |num|
  cards[A[num]] += 1
end

## 大きい順に[[k,v], [k,v], [k,v]...]という配列が返る
sorted = cards.sort { |(k1, v1), (k2, v2)| v2 <=> v1 }

if sorted[0][1] === 3
  if sorted[1][1] == 1
    puts "THREE CARD"
  else
    puts "FULL HOUSE"
  end
elsif sorted[0][1] === 2
  if sorted[1][1] == 1
    puts "ONE PAIR"
  else
    puts "TWO PAIR"
  end
else
  puts "NO HAND"
end
0