The Love-Letter Mystery
def numOperations(testStr):
num = 0
n = len(testStr)
for i in range(n / 2):
num += abs(ord(testStr[i]) - ord(testStr[n - i - 1]))
return num def main():
t = int(raw_input())
for _ in range(t):
testStr = raw_input().strip()
print numOperations(testStr) main()
Link:
https://www.hackerrank.com/challenges/the-love-letter-mystery
学习
利用Asckii码来解决问题
strip()去除结尾
错误
一定注意数组和list的下标,这个是很容易出错的坑
The Love-Letter Mystery的更多相关文章
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 17. Letter Combinations of a Phone Number
题目: Given a digit string, return all possible letter combinations that the number could represent. A ...
- 什么是Unicode letter
起因:从一段代码说起 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...
- LeetCode——Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- No.017:Letter Combinations of a Phone Number
问题: Given a digit string, return all possible letter combinations that the number could represent.A ...
- SCI/EI期刊投稿 Reply Letter 常用格式总结
SCI/EI期刊投稿Reply Letter常用格式总结 整个论文投稿的过程中,会遇到各种问题,需要我们向主编询问或是回复.下面主要总结了responses to the comme ...
- 【leetcode】 Letter Combinations of a Phone Number(middle)
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- [LeetCode] Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- [LintCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 69. Letter Combinations of a Phone Number
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations ...
随机推荐
- [Python 3.x 官方文档翻译]Whetting Your Appetite 欢迎您的使用
If you do much work on computers, eventually you find that there’s some task you’d like to automate. ...
- laravel跟jquery之间传输json数据
laravel代码: public function test(){ $arr = ["test1"=>"1","test2"=> ...
- nginx+uwsgi+flask搭建python-web应用程序
Flask本身就可以直接启动HTTP服务器,但是受限于管理.部署.性能等问题,在生产环境中,我们一般不会使用Flask自身所带的HTTP服务器. 从现在已有的实践来看,对于Flask,比较好的部署方式 ...
- Android WebView简介
Android的网络功能特别强大,WebView(网络视图)组件支持加载网页,可以理解为使用Webkit内核的浏览器,而它的实现方式有两种: 第一种具体实现步骤如下: (1)在布局文件中先生命WebV ...
- ACM2136
/* Problem Description Everybody knows any number can be combined by the prime number. Now, your tas ...
- Codeforces Round #272 (Div. 1) Problem C. Dreamoon and Strings
C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Linux文件io--one简述
什么是文件IO IO就是input/output,输入/输出.文件IO的意思就是读写文件. 文件操作的主要接口API 什么是操作系统API (1)API是一些函数,这些函数是由linux系统提供支持的 ...
- Map的内容按字母顺序排序
map有自带的排序功能,但需要重写排序方法,代码如下: package coreJava.com.shindo.corejava.map; import java.util.ArrayList; im ...
- kendo ui中grid页面参数问题
kendo ui 中grid 算是最长用的控件之一,当使用分页效果时,我们要传递分页参数与自己定义的参数如: var dataSource = new kendo.data.DataSource({ ...
- python 之 Paramiko学习
paramiko模块,基于SSH用于连接远程服务器并执行相关操作. 一.安装 pip3 install paramiko 二.使用 SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码 ...