0
我想回答Spotify問題Best Before,我的代碼對於我能想到的每個測試用例都能正常工作。但是,根據他們的服務器,我錯了。Spotify Best在開始之前。我究竟做錯了什麼?
任何人都可以告訴我我的代碼出錯了嗎?
這裏是我的代碼:
from itertools import permutations
import datetime
import fileinput
def checkdate(d,m,y):
"""Gets possible values for day, month and year
and generates valid permutations of dates"""
b = permutations([d,m,y])
for p in b:
try:
yield datetime.date(p[0], p[1], p[2])
except ValueError:
yield None
def validvalue(a):
return a > 0 and a <= 2999
c = raw_input()
d,m,y = c.split('/')
d,m,y = int(d), int(m), int(y)
if validvalue(d) and validvalue(m) and validvalue(y):
valid = [x for x in checkdate(d,m,y) if x is not None]
if valid:
print "2" + str(min(valid))[1:]
else:
print "%s is illegal" % c
else:
print "%s is illegal" % c
*在幾分鐘之內,您將得到一個答覆,指出您的源代碼是否解決了問題,如果不是,則表明錯誤發生了。* - 他們說錯了什麼? – 2012-04-16 16:27:27
他們只是說這是錯的。他們沒有指出實際發生了什麼問題。 – 2012-04-16 18:50:27