結果

問題 No.1129 Rating じゃんけん
ユーザー hogucchogucc
提出日時 2022-05-02 21:13:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 11,416 KB
実行使用メモリ 15,296 KB
最終ジャッジ日時 2023-09-14 18:18:48
合計ジャッジ時間 3,148 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,012 KB
testcase_01 AC 81 ms
15,024 KB
testcase_02 AC 83 ms
15,256 KB
testcase_03 AC 81 ms
15,056 KB
testcase_04 AC 82 ms
15,288 KB
testcase_05 AC 82 ms
15,284 KB
testcase_06 AC 82 ms
15,296 KB
testcase_07 AC 81 ms
15,272 KB
testcase_08 AC 83 ms
15,200 KB
testcase_09 AC 81 ms
15,056 KB
testcase_10 AC 83 ms
15,020 KB
testcase_11 AC 82 ms
15,056 KB
testcase_12 AC 80 ms
15,164 KB
testcase_13 AC 81 ms
15,256 KB
testcase_14 AC 81 ms
15,296 KB
testcase_15 AC 80 ms
15,016 KB
testcase_16 AC 81 ms
15,172 KB
testcase_17 AC 82 ms
15,196 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class RockPaperScissors
  ROCK = 0
  Scissor = 1
  Paper = 2

  COMPATIBLE_TABLE = {ROCK => Scissor, Scissor => Paper, Paper => ROCK}

  def self.win?(player_hand, rival_hand)
    return false if COMPATIBLE_TABLE[player_hand] != rival_hand
    true
  end

  def self.winner
    a, b, c, d = gets.split.map(&:to_i)

    return 'null' if a > c
    return 'tRue' if a < c
    return 'Draw' if b == d
    return 'null' if self.win?(b, d)
    'tRue'
  end
end

puts RockPaperScissors.winner
0