Byte Heist Home Leaderboard
Join the Heist (with Github)
Solve View

rot13

Given an ASCII string, apply rot13 to its letters

Judge

(async function*(context: Context): Challenge {
    const testcases = [
      ["Hello, World!", "Uryyb, Jbeyq!"],
      ["ROT13","EBG13"],
      [" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"," !\"#$%&'()*+,-./0123456789:;<=>?@NOPQRSTUVWXYZABCDEFGHIJKLM[\]^_`nopqrstuvwxyzabcdefghijklm{|}~"]
    ]
    for (let [input, output] of testcases) {
      yield (await context.run(input)).assertEquals(output);
    }
    return context.noFailures();
})

Example Code

inp = require('fs').readFileSync(0)+''
console.log(inp.replace(/[a-zA-Z]/g,c => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'['nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'.indexOf(c)]))