Code Signal_练习题_alphabeticShift
Given a string, replace each its character by the next one in the English alphabet (z
would be replaced by a
).
Example
For inputString = "crazy"
, the output should bealphabeticShift(inputString) = "dsbaz"
.
我的解答:
def alphabeticShift(inputString):
l = []
for x in inputString:
l.append(x)
for i in range(len(inputString)):
if l[i] == 'z':
l[i] = 'a'
else:
l[i] = chr(ord(l[i])+1)
return ''.join(l)
def alphabeticShift(s):
return "".join(chr((ord(i)-96)%26+97) for i in s)
膜拜大佬
Code Signal_练习题_alphabeticShift的更多相关文章
- Code Signal_练习题_digitDegree
Let's define digit degree of some positive integer as the number of times we need to replace this nu ...
- Code Signal_练习题_Knapsack Light
You found two items in a treasure chest! The first item weighs weight1 and is worth value1, and the ...
- Code Signal_练习题_growingPlant
Each day a plant is growing by upSpeed meters. Each night that plant's height decreases by downSpeed ...
- Code Signal_练习题_arrayMaxConsecutiveSum
Given array of integers, find the maximal possible sum of some of its k consecutive elements. Exampl ...
- Code Signal_练习题_differentSymbolsNaive
Given a string, find the number of different characters in it. Example For s = "cabca", th ...
- Code Signal_练习题_firstDigit
Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int&qu ...
- Code Signal_练习题_extractEachKth
Given array of integers, remove each kth element from it. Example For inputArray = [1, 2, 3, 4, 5, 6 ...
- Code Signal_练习题_stringsRearrangement
Given an array of equal-length strings, check if it is possible to rearrange the strings in such a w ...
- Code Signal_练习题_absoluteValuesSumMinimization
Given a sorted array of integers a, find an integer x from a such that the value of abs(a[0] - x) + ...
随机推荐
- 拿pyg 的fastdfs分布式文件系统 存储的位置
http://192.168.25.133/group1/M00/00/00/wKgZhVtW1vqAUpkZAABcxtZsmb0631.png StorageClient1 upload_fil ...
- VBA操作word生成sql语句
项目开始一般都是用word保存下数据库的文档 但是从表单一个一个的建表实在是很困难乏味,查查资料 1.可以生成一个html或者xml,检索结构生成sql.但是这个方式也蛮麻烦 2.查到vba可以操作w ...
- 【转】iOS中属性与成员变量的区别
[转载自并整理 http://blog.csdn.net/itianyi/article/details/8618128] 一.类Class中的属性property 在ios第一版中,我们为输出口同时 ...
- Smart/400开发上手2: COBOL批处理程序处理过程
开发目的:1.建立DB2数据库表:2.建立逻辑视图:3.通过Cobol程序将一个源数据表的数据通过一定公式计算后导出到另一个目的数据库表源数据表:TIM3PF目的数据表:TIM4PF4.在AS400中 ...
- 在MVC3中修改KindEditor实现上传图片到指定文件夹
KindEditor编辑器默认上传的图片文件夹,是根据系统时间自动生成的,图片是自动上传到这些文件夹里面,无法选择.如果要上传图片到指定文件夹,像相册一样管理图片,则需要扩展KindEditor编辑器 ...
- Python中Gradient Boosting Machine(GBM)调参方法详解
原文地址:Complete Guide to Parameter Tuning in Gradient Boosting (GBM) in Python by Aarshay Jain 原文翻译与校对 ...
- Java生成某段时间内的随机时间
上代码: import java.text.SimpleDateFormat; import java.util.Date; public class DateUtil { /** * 生成随机时间 ...
- (转) lsof 一切皆文件
原文:https://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/lsof.html lsof(list open files)是一个查看当前系统文 ...
- java重点知识
一.java基本知识点 java是由SUN公司在1995年推出的,在2009年SUN公司又被甲骨文公司收购,所以甲骨文公司获得java版权.其底层是由C语言写的,java分为三个体系: JavaSE, ...
- OSGI动态加载删除Service bundle
OSGi模块化框架是很早就出来的一个插件化框架,最早Eclipse用它而出名,但这些年也没有大热虽然OSGi已经发布了版本1到版本5.现在用的最多的,也是本文讲述基于的是Equinox的OSGi实现, ...