当前位置:网站首页>HJ21 简单密码
HJ21 简单密码
2022-06-28 07:36:00 【有勇气的牛排】
知识点:字符串
模拟
描述
现在有一种密码变换算法。
九键手机键盘上的数字与字母的对应: 1–1, abc–2, def–3, ghi–4, jkl–5, mno–6, pqrs–7, tuv–8 wxyz–9, 0–0,把密码中出现的小写字母都变成九键键盘对应的数字,如:a 变成 2,x 变成 9.
而密码中出现的大写字母则变成小写之后往后移一位,如:X ,先变成小写,再往后移一位,变成了 y ,例外:Z 往后移是 a 。
数字和其它的符号都不做变换。
数据范围: 输入的字符串长度满足1≤n≤100
输入描述:
输入一组密码,长度不超过100个字符。
输出描述:
输出密码变换后的字符串
示例1
输入:YUANzhi1987
输出:zvbo9441987
牛客 HJ Python
# 运行时间42ms 占用内存4700KB
# a:97 z:122 0: 49 9:57
s = input()
for i in s:
if ord(i) >= 97 and ord(i) <= 122:
if i in "abc":
print("2",end="")
if i in "def":
print("3",end="")
if i in "ghi":
print("4",end="")
if i in "jkl":
print("5",end="")
if i in "mno":
print("6",end="")
if i in "pqrs":
print("7",end="")
if i in "tuv":
print("8",end="")
if i in "wxyz":
print("9",end="")
elif ord(i) >= 65 and ord(i) < 90:
print(chr(ord(i.lower())+1),end="")
elif ord(i) == 90:
print("a",end="")
else:
print(i,end="")
边栏推荐
- ES6 use of return in arrow function
- R 语言 ggmap 可视化集群
- 腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者
- 力扣515.在每棵树行中找最大值
- R language Kolmogorov Smirnov tests whether the two samples follow the same distribution.
- kubelet驱逐机制的源码分析
- What is EC blower fan?
- R and RGL draw 3D knots
- Face to face experience --- test engineer web side automation --- interview questions for large factories
- hack the box:RouterSpace题解
猜你喜欢
推荐系统系列精讲(第五讲): 排序模型的调优实践
Sword finger offer|: linked list (simple)
Analyze 5 indicators of NFT project
SQL statement optimization steps (1)
网传互联网公司加班表,排名第一的没悬念
Design and practice of vivo sensitive word matching system
ACM notes
腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者
The practice of event driven architecture in vivo content platform
MySQL installation steps - Linux configuration file JDK installation (II)
随机推荐
Kubernetes deploys a secret pit where thanos ruler sends repeated alarms
7-2 芬兰木棋 结构体排序
网传互联网公司加班表,排名第一的没悬念
BACnet/IP網關如何采集樓宇集中控制系統數據
扩展Prometheus的解决方案thanos的简介和几个月使用心得
Application of XOR. (extract the rightmost 1 in the number, which is often used in interviews)
Dbeaver 22.1.1 release, visual database management platform
What is the lifecycle of automated testing?
Unity UI shadow component
Uninstall and reinstall the latest version of MySQL database. The test is valid
Leetcode learning records
Implementation of commit message standardized control in large projects
自动化测试的生命周期是什么?
分析 NFT 项目的 5 个指标
okcc呼叫中心没有电脑的坐席能不能开展工作?
R language ggmap
Leetcode+ 51 - 55 retrospective and dynamic planning topics
LLVM 与 Clang
东方财富上开户是安全的吗
SQL statement optimization steps (1)