The Time in Words
def main():
time = ["one", "two", "three", "four", "five", "six", "seven", "eight","nine",
"ten", "eleven", "twelve", "thirteen", "fourteen", "quarter", "sixteen",
"seventeen", "eighteen", "nineteen", "twenty", "twenty one",
"twenty two", "twenty three", "twenty four", "twenty five",
"twenty six", "twenty seven", "twenty eight", "twenty nine", "half"] h = int(raw_input())
m = int(raw_input()) msg = "" if h > 12:
h = h - 12 if m == 0:
msg = time[h-1] + " o' clock"
elif m <= 30:
if m == 1:
msg = time[m-1] + ' minute past ' + time[h-1]
elif m == 15 or m == 30:
msg = time[m-1] + ' past ' + time[h-1]
else:
msg = time[m-1] + ' minutes past ' + time[h-1]
else:
m = 60 - m
if m == 15:
msg = time[m-1] + ' to ' + time[h]
else:
msg = time[m-1] + ' minutes to ' + time[h] print msg main()
Link:
https://www.hackerrank.com/challenges/the-time-in-words
学习
预定义
关键
精确的情况分类和判断
随机推荐
- c语言,全局变量,局部变量,外部函数,内部函数,stasic和extern的复习总结
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- S3C2440的GPIO
S3C2440一共有A B C D E F G H J 共九组IO口,一共是130个,每组IO口的个数如下图所示, 其中A组IO口只有输出功能,没有输入功能, 关于GPXCON寄存器,这个寄存器用来配 ...
- iOS开发之Runtime函数
1.可以通过NSObject的一些方法获取运行时信息或动态执行一些消息: 1./*Returns a Boolean value that indicates whether the receivin ...
- zlog使用手册,小靠谱啊
http://hardysimpson.github.io/zlog/UsersGuide-CN.html Chapter 1 zlog是什么? zlog是一个高可靠性.高性能.线程安全.灵活.概念清 ...
- 编译recovery及过程中的部分错误解决
你必须使用32位或64位Ubuntu系统,关于如何建立编译环境和同步源码的指导,请自己查找有关指导的文章. 1, 安装所需要的包 2, 建立编译的环境,并同步CWM所需的源码,CyanogenMod源 ...
- PhoneGap and Titanium
http://mobile.51cto.com/web-338270.htm http://www.udpwork.com/item/6117.html http://blog.cnbang.net/ ...
- cf C. Insertion Sort
http://codeforces.com/contest/362/problem/C #include <cstdio> #include <cstring> #includ ...
- Powershell使用管道
管道并不是什么新事物,以前的Cmd控制台也有重定向的命令,例如Dir | More可以将结果分屏显示.传统的Cmd管道是基于文本的,但是Powershell是基于对象. PS> ls | Sor ...
- [poj 1364]King[差分约束详解(续篇)][超级源点][SPFA][Bellman-Ford]
题意 有n个数的序列, 下标为[1.. N ], 限制条件为: 下标从 si 到 si+ni 的项求和 < 或 > ki. 一共有m个限制条件. 问是否存在满足条件的序列. 思路 转化为差 ...
- c语言结构体5之匿名结构体
注意: 1匿名结构体不会出现重合 重命名的情况 2有名结构体 名称不能相同 也就是不能重名 //匿名结构体不会出现重名的情况 struct //无名结构体 { ]; ]; int num; };//不 ...