結果

問題 No.227 簡単ポーカー
ユーザー S YS Y
提出日時 2024-10-22 00:47:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,773 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-10-22 00:47:58
合計ジャッジ時間 1,408 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 33 ms
10,880 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 31 ms
11,008 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 WA -
testcase_07 AC 31 ms
10,752 KB
testcase_08 WA -
testcase_09 AC 30 ms
10,880 KB
testcase_10 AC 34 ms
10,752 KB
testcase_11 AC 32 ms
10,880 KB
testcase_12 AC 32 ms
11,008 KB
testcase_13 AC 31 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    a_lst = list(map(int, input().split(' ')))

    if judge_full_house(a_lst):
        print('FULL HOUSE')
    elif judge_3_card(a_lst):
        print('THREE CARD')
    elif judge_2_pair(a_lst):
        print('TWO PAIR')
    elif judge_1_pair(a_lst):
        print('ONE PAIR')
    else:
        print('NO HAND')

def judge_full_house(lst):
    card_dict = {}

    for ele in lst:
        if ele not in card_dict.keys():
            card_dict[ele] = 1
        else:
            card_dict[ele] += 1
    
    isExist3 = False
    isExist2 = False
    for val in card_dict.values():
        if not isExist3 and val == 3:
            isExist3 = True
        elif not isExist2 and val == 2:
            isExist2 = True

    if isExist2 and isExist3:
        return True
    else:
        return False

def judge_3_card(lst):
    card_dict = {}

    for ele in lst:
        if ele not in card_dict.keys():
            card_dict[ele] = 1
        else:
            card_dict[ele] += 1
            if card_dict[ele] == 3:
                return True

    return False

def judge_2_pair(lst):
    card_dict = {}

    for ele in lst:
        if ele not in card_dict.keys():
            card_dict[ele] = 1
        else:
            card_dict[ele] += 1

    isFirst2 = False

    for val in card_dict.values():
        if val == 2 and not isFirst2:
            isFirst2 = True
        elif val == 2 and isFirst2:
            return True

    return False


def judge_1_pair(lst):
    card_dict = {}

    for ele in lst:
        if ele not in card_dict.keys():
            card_dict[ele] = 1
        else:
            card_dict[ele] += 1

    for val in card_dict.values():
        if val == 2:
            return True

    return False

if __name__ == '__main__':
    main()
0