結果

問題 No.264 じゃんけん
ユーザー korogykorogy
提出日時 2017-09-03 12:24:31
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 892 bytes
コンパイル時間 35 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-24 12:09:16
合計ジャッジ時間 1,265 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
12,032 KB
testcase_01 AC 83 ms
12,288 KB
testcase_02 AC 80 ms
12,032 KB
testcase_03 AC 74 ms
12,288 KB
testcase_04 AC 79 ms
12,160 KB
testcase_05 AC 75 ms
12,288 KB
testcase_06 AC 77 ms
12,288 KB
testcase_07 AC 79 ms
12,288 KB
testcase_08 AC 74 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Janken
    attr_reader :n, :k

    def initialize(n: 0, k: 0)
        @n, @k = n, k
    end

    def datainput
        begin
            @n, @k = gets.chomp.split.map { |v| Integer(v) }
        rescue
            
        end
    end

    # 0: ぐー
    # 1: ちょき
    # 2: ぱー
    def janken(myself, opponent)
        if myself == opponent
            return "Drew"
        end
        case myself
        when 0
            return "Won" if opponent == 1
            return "Lost" if opponent == 2
        when 1
            return "Won" if opponent == 2
            return "Lost" if opponent == 0
        when 2
            return "Won" if opponent == 0
            return "Lost" if opponent == 1
        end
    end

    def dataoutput
        puts janken(@n, @k)
    end

    def run
        datainput
        dataoutput
    end
end

if $0 == __FILE__
    Janken.new.run
end
0