結果

問題 No.18 うーさー暗号
ユーザー korogykorogy
提出日時 2017-09-08 04:37:01
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 572 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 11,384 KB
実行使用メモリ 15,280 KB
最終ジャッジ日時 2023-09-21 12:49:54
合計ジャッジ時間 1,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,236 KB
testcase_01 AC 77 ms
15,092 KB
testcase_02 AC 76 ms
15,152 KB
testcase_03 AC 79 ms
15,232 KB
testcase_04 AC 78 ms
15,224 KB
testcase_05 AC 83 ms
15,052 KB
testcase_06 AC 80 ms
14,984 KB
testcase_07 AC 82 ms
15,032 KB
testcase_08 AC 80 ms
15,124 KB
testcase_09 AC 79 ms
14,992 KB
testcase_10 AC 77 ms
15,176 KB
testcase_11 AC 78 ms
15,088 KB
testcase_12 AC 79 ms
15,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class WowCode
    attr_reader :s

    def initialize(s: "")
        @s = s
        @alphabet = ('A'..'Z').to_a
    end

    def cause
        begin
            @s = gets.chomp
        rescue
            
        end
    end

    def decoding(str)
        str = str.split("")
        r = str.each_with_index.map do |c, i|
            @alphabet[((c.ord-(i+1))-("A".ord)) % @alphabet.size]
        end
        r.join("")
    end

    def result
        puts decoding(@s)
    end

    def run
        cause
        result
    end
end

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