题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
看起来有点蠢
const s = readline() const obj = {a:2,b:2,c:2,d:3,e:3,f:3,g:4,h:4,i:4,j:5,k:5,l:5,m:6,n:6,o:6,p:7,q:7,r:7,s:7,t:8,u:8,v:8,w:9,x:9,y:9,z:9} let res = '' for(let i in s) { if(!isNaN(+s[i])) { // 处理数字 res += s[i] continue } const ascii = s.charCodeAt(i) let newAscii = 0 // A:65 Z:90 a:97 z:122 if(ascii >= 65 && ascii < 90) { newAscii = ascii + 33 } else if(ascii === 90) { newAscii = 97 } if(newAscii) { res += String.fromCharCode(newAscii) } else { res += obj[s[i]] } } console.log(res)