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

学习

  预定义

  关键

    精确的情况分类和判断

随机推荐

  1. Centos common software install

    1.本地安装soft yum localinstall xxx.rpm 2.kolourpaintyum install kolourpaint

  2. 本原串(HDU 2197 快速幂)

    本原串 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  3. 官方recovery签名验证的破解教程

    下面讲如何破解官方recovery签名验证(这个方法应该是通用的,其他手机可以参考,recovery签名验证破解了,也不用费力编译第三方recovery) 1.从官方ROM里提取recovery.im ...

  4. [SQL注入2]FROM SQL INJECTION TO SHELL: POSTGRESQL EDITION

    FROM SQL INJECTION TO SHELL: POSTGRESQL EDITION 这里先介绍一下POSTGRESQL.这是一款数据库管理系统,与oracle是同类型软件.08年左右的市场 ...

  5. iOS设备后台播放音乐方法

    iOS设备后台播放音乐方法 1 在设置Capabliites中打开Background Modes,选择Audio And AirPlay 2 在控制viewDidLoad中添加下面代码 AVAudi ...

  6. Log4j MDC Tomcat下报异常org.apache.log4j.helpers.ThreadLocalMap

    严重: The web application [/qdgswx] created a ThreadLocal with key of type [org.apache.log4j.helpers.T ...

  7. LeetCode_3 sum

    Given an array S of n integers, are there elements a, b, c ? Find all unique triplets in the array w ...

  8. windows批处理命令教程

      批处理文件是无格式的文本文件,它包含一条或多条命令.它的文件扩展名为 .bat 或 .cmd.在命令提示下键入批处理文件的名称,或者双击该批处理文件,系统就会调用Cmd.exe按照该文件中各个命令 ...

  9. 关于Windows高DPI的一些简单总结(Window上一般默认是96 dpi 作为100% 的缩放比率)

    我们知道,关于高DPI的支持, Windows XP时代就开始有了, 那时关于高DPI的支持比较简单, 但是从Vista/Win7 到现在Win8 /Win8.1, Windows关于高DPI的支持已 ...

  10. Permutations 解答

    Question Given a collection of numbers, return all possible permutations. For example,[1,2,3] have t ...