I've trying to solve this puzzle and I always get the test cases correct but when I submit the code I get a 50% score saying that I failed on validator 3, 4 and 6.
I don't see where my code could fail. Can somebody have a look a help me maybe finding out what could be causing the fail? I did it in Python 3.
import sys import calendar from datetime import date begin = input() end = input() y1=(int)(begin[6:]) m1=(int)(begin[3:5]) d1=(int)(begin[0:2]) y2=(int)(end[6:]) m2=(int)(end[3:5]) d2=(int)(end[0:2]) D1 = date(y1, m1, d1) D2 = date(y2, m2, d2) total = (D2 - D1).days s='' m=(int)(end[3:5])-(int)(begin[3:5]) y=(int)(end[6:])-(int)(begin[6:]) D1=date(y2, m1, d1) F=(D2 - D1).days if F>30 and F<60: m-=1 d=(int)(end[0:2])-(int)(begin[0:2]) if y>0: s+=(str)(y) if y>1: s+=' years' else: s+=' year' if m>0: if y>0: s+=', ' s+=(str)(m) if m>1: s+=' months' else: s+=' month' if m>0 or y>0: s+=', ' s+='total ' s+=(str)(total) if total==1: s+=' day' else: s+=' days' print(s)
I must have wasted about 4 hours on this puzzle. I’d rather embrace my condition of hopless n00b who can’t even wrap his head around leap years than waste another hour on it.
There is nothing I dislike more than punishing puzzles that slam the validators in your face after a bunch of useless tests lulling you into a false sense of accomplishment.
I would gladly fail the month difference validation since that notion has no clear definition and the OP didn’t bother to explain what he meant by that or provide meaningful tests that could have helped guessing.
I did try a few different methods. 30 days average, count of elapsed months, taking the day of the month into account or not… 4 methods passed the tests, none passed the validation.
Why a validator that supposedly checks only the number of days between two dates would turn down my code will remain forever a sweet mystery to me, but I guess i can live with that.
Is this puzzle really an easy one? Its success rate is currently 49%. Quite a number of Codingamers expressed that all unit tests passed, whereas some evaluation tests failed. Plus, the specification is quite ambiguous (should you write 1 day or 1 days?)
It would be nice that someone audits some submissions that pass all unit tests and fail some evaluation tests. This could let add some unit tests and/or clarifiy the specification.
Same problem here - validators 3,4,6. Is there any example of dates that they may be checking?
Yep, you got it wrong but the tests are not telling it.
You measure year difference by substracting the year which is very wrong.
Between the 31.12.2015 and the 01.0.2016 there’s one day for instance, but you would output 1 year, 1 day.
I added test cases and validators and update existing ones.