题解 | #简单密码#
暴力美学
const readline=require('readline') const rl=readline.createInterface({ input:process.stdin, output:process.stdout }) rl.on('line',(line)=>{ effect(line) }) function effect(line){ let map=new Map([ ['1',1], ['abc',2], ['def',3], ['ghi',4], ['jkl',5], ['mno',6], ['pqrs',7], ['tuv',8], ['wxyz',9], ['0',0] ]) let arr=line.split('') for(let i=0;i<arr.length;i++){ if(/[a-z]/.test(arr[i])){ for (const [key,value] of map) { if(key.indexOf(arr[i])>=0){ arr[i]=value } } } if(/[A-Z]/.test(arr[i])){ if(arr[i]!=='Z'){ arr[i]=String.fromCharCode((arr[i].toLocaleLowerCase().charCodeAt(0)+1)) }else{ arr[i]='a' } } } console.log(arr.join('')) }