Spotify Best在开始之前。我究竟做错了什么?

问题描述:

我想回答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 
+1

*在几分钟之内,您将得到一个答复,指出您的源代码是否解决了问题,如果不是,则表明错误发生了。* - 他们说错了什么? – 2012-04-16 16:27:27

+0

他们只是说这是错的。他们没有指出实际发生了什么问题。 – 2012-04-16 18:50:27

从问题描述:

2000可以给定为 “2000”, “00” 或 “0”

你代码不接受000作为有效年份。