結果

問題 No.227 簡単ポーカー
ユーザー neko_the_shadowneko_the_shadow
提出日時 2016-12-18 15:00:39
言語 Bash
(Bash 5.1.16)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 742 bytes
コンパイル時間 48 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 20:29:41
合計ジャッジ時間 1,084 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,376 KB
testcase_01 AC 9 ms
4,380 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 10 ms
4,376 KB
testcase_06 AC 9 ms
4,376 KB
testcase_07 AC 10 ms
4,376 KB
testcase_08 AC 10 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 9 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/bin/bash

# カードの一覧と手の中のカードの種類の一覧を保持しておく。
cards=$(cat /dev/stdin)
types=$(for card in $cards; do echo $card; done | sort -g | uniq)

# 2枚組と3枚組のカードの種類を数える。
double=0
triple=0

for type in $types; do
	cnt=0
	for card in $cards; do
		[ $card -eq $type ] && cnt=$((cnt + 1))
	done
	
	[ $cnt -eq 2 ] && double=$((double + 1))
	[ $cnt -eq 3 ] && triple=$((triple + 1))
done

# 2枚組と3枚組の数から役を判定する。
if [ $triple -eq 1 -a $double -eq 1 ]; then
	echo "FULL HOUSE"
elif [ $triple -eq 1 ]; then
	echo "THREE CARD"
elif [ $double -eq 2 ]; then
	echo "TWO PAIR"
elif [ $double -eq 1 ]; then
	echo "ONE PAIR"
else 
	echo "NO HAND"
fi

0