/////////////////////////////No.227 簡単ポーカー //入力文字読み取り process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function (chunk) { //すべて受け取り改行で区切って格納 var inputall = chunk.split("\n"); //一文字ずつを配列に格納 var cards = inputall[0].split(" ") //カードをソート cards.sort(function (a, b) { if (a < b) return -1; if (a > b) return 1; return 0; }); //カードの役を入れる var winninghands = "NO HAND"; //同じカードが三枚あるか for (var i = 0; i < cards.length-2; i++) { if (cards[i] == cards[i + 1] && cards[i] == cards[i + 2]) { if (cards[i] == cards[i + 3] || cards[i-1] == cards[i+2]) { //フォーカード、ファイブカード winninghands = "NO HAND"; break; } else { cards.splice(i, 3); if (cards[0] == cards[1]) { winninghands = "FULL HOUSE" } else if (cards[0] != cards[1]) { winninghands = "THREE CARD" } } } } //同じカードが二枚あるか if (winninghands == "NO HAND") { for (var i = 0; i < cards.length - 1; i++) { if (cards[i] == cards[i + 2]) { //フォーカード、ファイブカード break; } else { if (cards[i] == cards[i + 1]) { cards.splice(i, 2); if (cards[0] == cards[1] || cards[1] == cards[2]) { winninghands = "TWO PAIR" } else { winninghands = "ONE PAIR" } } } } } console.log(winninghands) });