結果

問題 No.227 簡単ポーカー
ユーザー gemmarogemmaro
提出日時 2019-08-05 20:05:13
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 1,614 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 11,396 KB
実行使用メモリ 15,396 KB
最終ジャッジ日時 2023-09-25 17:26:19
合計ジャッジ時間 2,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,128 KB
testcase_01 AC 84 ms
15,184 KB
testcase_02 AC 79 ms
15,164 KB
testcase_03 AC 83 ms
15,252 KB
testcase_04 AC 85 ms
15,320 KB
testcase_05 AC 81 ms
15,060 KB
testcase_06 AC 85 ms
15,352 KB
testcase_07 AC 80 ms
15,252 KB
testcase_08 AC 82 ms
15,164 KB
testcase_09 AC 82 ms
15,148 KB
testcase_10 AC 82 ms
15,368 KB
testcase_11 AC 81 ms
15,396 KB
testcase_12 AC 79 ms
15,300 KB
testcase_13 AC 81 ms
15,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

a = gets.chomp.split.map(&:to_i)

def full_house a
    for i in 1..a.size
        b = a.rotate i
        if ( ( b[0] == b[1] && b[2] == b[3] && b[3] == b[4] ) ||
             ( b[0] == b[2] && b[1] == b[3] && b[3] == b[4] ) ) &&
           b[0] != b[3]
            return true 
        end
    end
    return false
end

def three_card a
    for i in 1..a.size
        b = a.rotate i
        if ( ( b[0] == b[1] && b[1] == b[2] ) &&
             ( b[0] != b[3] && b[0] != b[4] ) ) ||
           ( ( b[0] == b[1] && b[0] == b[3] ) &&
             ( b[0] != b[2] && b[0] != b[4] ) )
            return true
        end
    end
    return false
end

def two_pair a
    for i in 1..a.size
        b = a.rotate i
        if ( ( b[0] == b[1] && b[2] == b[3] ) &&
             ( b[0] != b[2] && b[2] != b[4] && b[4] != b[0] ) ) ||
           ( ( b[0] == b[2] && b[1] == b[3] ) &&
             ( b[0] != b[1] && b[1] != b[4] && b[4] != b[0] ) ) ||
           ( ( b[0] == b[3] && b[1] == b[2] ) &&
             ( b[0] != b[1] && b[1] != b[4] && b[4] != b[0] ) )
            return true
        end
    end
    return false
end

def one_pair a
    for i in 1..a.size
        b = a.rotate i
        if ( b[0] == b[1] &&
             ( b[0] != b[2] && b[0] != b[3] && b[0] != b[4] ) ) ||
           ( b[0] == b[2] &&
             ( b[0] != b[1] && b[0] != b[3] && b[0] != b[4] ) )
            return true
        end
    end
    return false
end

if full_house a
    puts "FULL HOUSE"
elsif three_card a
    puts "THREE CARD"
elsif two_pair a
    puts "TWO PAIR"
elsif one_pair a
    puts "ONE PAIR"
else
    puts "NO HAND"
end
0