結果

問題 No.18 うーさー暗号
ユーザー hashimotohashimoto
提出日時 2015-05-20 17:31:32
言語 Ruby
(3.2.2)
結果
AC  
実行時間 91 ms / 5,000 ms
コード長 364 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 11,416 KB
実行使用メモリ 15,472 KB
最終ジャッジ日時 2023-09-21 11:47:09
合計ジャッジ時間 2,063 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,120 KB
testcase_01 AC 79 ms
15,104 KB
testcase_02 AC 79 ms
15,268 KB
testcase_03 AC 91 ms
15,400 KB
testcase_04 AC 83 ms
15,188 KB
testcase_05 AC 83 ms
15,316 KB
testcase_06 AC 87 ms
15,472 KB
testcase_07 AC 87 ms
15,424 KB
testcase_08 AC 88 ms
15,380 KB
testcase_09 AC 85 ms
15,392 KB
testcase_10 AC 77 ms
15,028 KB
testcase_11 AC 77 ms
15,260 KB
testcase_12 AC 85 ms
15,440 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def int_to_alphabet(n)
    ('A'..'Z').to_a[n]
end

def alphabet_to_int(n)
    /#{n}/ =~ ('A'..'Z').to_a.join
end


before = gets.chomp.split("")

count = 1
after = []
before.each do |n|
    after_num = alphabet_to_int(n) - count
    while after_num < 0
        after_num += 26
    end
    count += 1
    after.push(int_to_alphabet(after_num))
end

puts after.join
0