All pastes #2096661 Raw Edit

Someone

public python v1 · immutable
#2096661 ·published 2011-12-27 17:00 UTC
rendered paste body
def leap(year) :	if year%4!=0 :		return False	if year%100==0 and year%400!=0 :		return False	else :		return Truedef legal(day,month,year) :	if year < 1000 :		year=year+2000	if day<1 or month<1 :		return False	if day>31 or month>12 or year>2999 :		return False	if (month==4 or month==6 or month==9 or month==11) and (day>30) :		return False	if (month==2 and day==29 and leap(year)==False ):		return False	else :		return True	z=raw_input()x=0while z[x]!='/' :	x=x+1a=int(z[:x])y=x+1while z[y]!='/' :	y=y+1b=int(z[x+1:y])c=int(z[y+1:])d=0tab=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]]temptab=[0,0,0]if legal(a,b,c) :	tab[d][0]=a	tab[d][1]=b	if c < 1000 :		tab[d][2]=c+2000	else :		tab[d][2]=c	d=d+1if legal(a,c,b) :	tab[d][0]=a	tab[d][1]=c	if b < 1000 :		tab[d][2]=b+2000	else :		tab[d][2]=b	d=d+1if legal(b,a,c) :	tab[d][0]=b	tab[d][1]=a	if c < 1000 :		tab[d][2]=c+2000	else :		tab[d][2]=c	d=d+1if legal(b,c,a) :	tab[d][0]=b	tab[d][1]=c	if a < 1000 :		tab[d][2]=a+2000	else :		tab[d][2]=a	d=d+1if legal(c,a,b) :	tab[d][0]=c	tab[d][1]=a	if b < 1000 :		tab[d][2]=b+2000	else :		tab[d][2]=b	d=d+1if legal(c,b,a) :	tab[d][0]=c	tab[d][1]=b	if a < 1000 :		tab[d][2]=a+2000	else :		tab[d][2]=a	d=d+1if d==0 :	print (str(a)+'/'+str(b)+'/'+str(c)+" is illegal")e=0if d!=0 :	while e<6-d :		tab.remove([0,0,0])		e=e+1if d>0 :	#trie par annees	exchange=True	while exchange==True :		exchange=False		for x in range(5-e) :			if tab[x][2]>tab[x+1][2] :				tab[x],tab[x+1] = tab[x+1],tab[x]				exchange=True	f=0	for x in range(5-e) :		if tab[0][2]==tab[x+1][2] :			f=f+1		#trie par mois	exchange=True	while exchange==True :		exchange=False		for x in range(f) :			if tab[x][1]>tab[x+1][1] :				tab[x],tab[x+1] = tab[x+1],tab[x]				exchange=True	year=str(tab[0][2])	if tab[0][1]<10 :		month=str(0)+str(tab[0][1])	else :		month=str(tab[0][1])	if tab[0][0]<10 :		day=str(0)+str(tab[0][0])	else :		day=str(tab[0][0])	print (year+'-'+month+'-'+day)