@anonymous/

DarkgreyEssentialRoach

Python 2.7

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def ungolfed(h,m):
	toStr=lambda x:"twelve one two three four five six seven eigth nine ten eleven".split()[x%12]
	hour=lambda x:toStr(x)+" o'clock "+["AM","PM"][x>=12]
	minute=lambda x:"twenty"+(toStr(x-20)if x-20else"")if x>19else"thirteen fourteen fifteen sixteen seventeen eighteen nineteen".split()[x-13]
	
	if m:
		s=""
		if m==30:
			s+="half"
		else:
			if m%15==0:
				s+="quarter"
			else:
				z=m if m<30 else 60-m
				if z<13:
					s+=toStr(z)
				else:
					s+=minute(z)
		print s+(" minutes"if m-30and m%15else "")+[" past "+hour(h)," to "+hour(h+1)][m>30]
	else:
		if h in[0,12]:
			print"twelve "+("noon"if h else "night")
		else:
			print hour(h)
			

def g(h,m):
 a=lambda x:"twelve one two three four five six seven eigth nine ten eleven".split()[x%12];b=lambda x:a(x)+" o'clock "+["AM","PM"][x>=12]
 if m:
	z=m if m<30else 60-m;print(a(z)if z<13else("twenty"+(a(z-20)if z-20else"")if z>19else"thirteen fourteen fifteen sixteen seventeen eighteen nineteen".split()[z-13])if m%15else"quarter"if m-30else"half")+(" minutes"if m-30and m%15else"")+[" past "+b(h)," to "+b(h+1)][m>30]
 else:print"twelve "+("noon"if h else "night")if h in[0,12]else b(h)

g(0,0)
g(12,0)
g(6,0)
g(18,0)
g(6,15)
g(18,45)
g(11,30)
g(16,11)
g(8,17)
g(13,22)
g(17,32)
g(22,20)
g(23,40)
g(12,1)

"""
ungolfed(0,0)
ungolfed(12,0)
ungolfed(6,0)
ungolfed(18,0)
ungolfed(6,15)
ungolfed(18,45)
ungolfed(11,30)
ungolfed(16,11)
ungolfed(8,17)
ungolfed(13,22)
ungolfed(17,32)
ungolfed(22,20)
ungolfed(23,40)
"""