結果

問題 No.227 簡単ポーカー
ユーザー f Oxf Ox
提出日時 2021-05-19 00:25:42
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 62 ms / 5,000 ms
コード長 1,119 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 38,912 KB
最終ジャッジ日時 2024-04-17 08:44:19
合計ジャッジ時間 2,993 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
38,656 KB
testcase_01 AC 58 ms
38,912 KB
testcase_02 AC 59 ms
38,784 KB
testcase_03 AC 58 ms
38,784 KB
testcase_04 AC 59 ms
38,656 KB
testcase_05 AC 60 ms
38,912 KB
testcase_06 AC 58 ms
38,784 KB
testcase_07 AC 62 ms
38,784 KB
testcase_08 AC 62 ms
38,656 KB
testcase_09 AC 61 ms
38,784 KB
testcase_10 AC 58 ms
38,912 KB
testcase_11 AC 59 ms
38,784 KB
testcase_12 AC 59 ms
38,784 KB
testcase_13 AC 57 ms
38,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
  // let data = input.split("\n");
  let data = input.split(" ");
  let numsData = data.map(Number); // 配列を文字列から数値に変換する。
  // let  = data[0];
  // let  = data[1];
  // let  = Number(data[0]);
  // let  = Number(data[1]);

  let set = new Set(numsData);
  let uniqueArray = Array.from(set); // setのオブジェクトを配列に変換する必要がある:https://www.deep-rain.com/programming/javascript/1125

  let count = 0;
  let pair = 0;
  let threeCard = 0;

  for(i=0; i<uniqueArray.length; i++) {
    count = numsData.filter(item => item === uniqueArray[i]).length; 
    if (count === 2) {
      pair ++;
    } else if (count === 3) {
      threeCard ++;
    } 
  }
  
  if (pair===1 && threeCard===0) {
    console.log('ONE PAIR');
  } else if (pair===2 && threeCard===0) {
    console.log('TWO PAIR');
  } else if (pair===0 && threeCard===1) {
    console.log('THREE CARD');
  } else if (pair===1 && threeCard===1) {
    console.log('FULL HOUSE');
  } else {
    console.log('NO HAND');
  } 
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0