a=5,b=7,c=10
print sorted([a,b,c])[0] + sorted([a,b,c])[1] > sorted([a,b,c])[2] and 'YES' or 'NO'
- read more
28.The same number
read moreL=[1,2,2.5,3,4] print "NO" if (len(set(L))==len(L)) else "YES"
27.Gas Station
read morelimit = [1,2,3,4] cost = [4,2,1,3] sum = 0 subsum = 0 ix = 0 for i in range(len(limit)): delta = limit[i] - cost[i] sum += delta subsum += delta if subsum < 0: ix = i + 1 subsum = 0 if sum<0: print -1 else: print ix
26.Sequence to judge
read moreL=[1,2,3,4] print("UP" if L==sorted(L) else "DOWN" if L==sorted(L)[::-1] else "WRONG" )
25.Format the time
read moret={'year':'2013','month':'9','day':'30','hour':'16','minute':'45','second':'2'} print '%04d-%02d-%02d %02d:%02d:%02d' %(int(t['year']), int(t['month']), int(t['day']), int(t['hour']), int(t['minute']), int(t['second']))
24.Horse take the lead
read morem=2 n=1 if m < n: m, n = n, m horse = [(1, 2), (2, 1), (-1, 2), (-2, 1), (-2,-1),(-1,-2),(1, -2), (2, -1)] queue = [(0, 0)] goal = {(0, 0): 0} while queue != []: base = queue.pop(0) for item in horse: arrow = ((item[0] + base[0 ...
23.365 Or 366
read moreyear="2013" print(366 if int(year)%400==0 or int(year)%4==0 and int(year)%100!=0 else 365)
22.Time is money
read morest="00:00:00" et="00:00:10" print abs(int(st.split(':')[0])*3600 + int(st.split(':')[1])*60 + int(st.split(':')[2])-(int(et.split(':')[0])*3600 + int(et.split(':')[1])*60 + int(et.split(':')[2])))
21.Back to the text string
read morea="xabcbai" n=5 print('YES' if [i for i in range(len(a)-n+1) if a[i:(i+n)] == a[i:(i+n)][::-1]] else 'NO')
20.Information encryption
read morea="cagy" b=33 print(''.join([chr((ord(i)-ord('a')+b)%26+ord('a')) for i in a]))