Beta
Twice Their Age
7 of 9tachyonlabs
Loading description...
Puzzles
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Reference solution and fixed tests also ignore any situation where both person have
0yo
in age (which would be twice the age of the other, since0 * 2 = 0
):Reference solution is demonstrably wrong:
These two range will sum up to
365
as none of the ranges hit leap years.Well, I spent some times on this, and I'm sorry to agree with gopherati, the reference code is buggy. After guessing a lot, I assumed my code is OK and so I passed the tests in force (trying until random being in my favor). The problem with your code is that when oldest birthday is before youngest in the year (see spoiler comment below).
Also, while trying another way to do this, I got this error:
ValueError: day is out of range for month
To me, this can happen only with one of birthday being "02/29/Y".Finally, the fact I passed the test in force means there isn't enough edge cases tests. There should be at least every combinations of: oldest_birthday < or == or > youngest_birthday, "02/28" equal to one of, or before, or between, or after birthdays, more or less than 365 days between births.
This comment has been hidden.
... tentatively niling this as subsequent poking makes me think it is just my code after all.
Thanks! I'm off at a conference right now, but will look into this this weekend after I ger back. I certainly used date objects myself.
you responded just as I was nil'ing that comment, after poking at some other fail cases I'm thinking the problem might be my code after all. By the time you get back I'll know for sure :)
:edit: aand I can't un-nil it now because it has responses, lol
original comment seems correct.
random test gave:
Test case so simulate in python:
age difference is 102 stepping through:
In testing a second cases, I made a math mistake and had to go back and re-check the first to make sure I hadn't done the same there.
Here's another case, with the opposite problem (expects 365 when shoudl be 366)
random test gave:
Test case to simulate in python:
stepping through: