Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
The test constraints work perfectly. Thats why solutions without those unnecessary checks pass.
What on earth are you talking about?
Yeah. It passed all the tests, therefore it's incorrect. Solid logic.
Well I got that one wrong for sure.
Yeah I misunderstood the requirements.
You read too much into it. When it says "input constraints" it doesn't mean you need to verify the inputs fall into that range. It means that all test case inputs to the function you create will fall into those ranges.
I don't need to verify that h hours will be greater than or equal to 0 and less than or equal to 23 when the contraints tell me the input will be 0 <= h <= 23.
I just wanted to say that building applications that are resistant to unexpected user use requires writing more code.
You're telling me that undefined behaviour in a system is... undefined? Shocking.
How many fewer lines of code would we have if users typed what we wanted? 😉
That makes sense. They should make that clear, however.
Actually, you do not need to implement these constraints yourself.
Rather, the constraints are there to tell you the limits of the tested inputs, so you do not need to worry about / handle cases outside these limits.
For example, this tells you that
h
as an input will always be a number between0
to23
, not-10
/12345
/"ABCDEF"
/[1]
...Example discussions
Still, your solution is a valid approach to this kata, since the behaviour is not defined for values outside of these limit.
These are all equally valid approaches depending on the use case, so you may implement whichever you see fit outside these bounds.
Happy coding ^_^
Probably doesn't require the brackets. I also reasoned that if this code were to end up in production it helps to have the steps laid out even if it's obvious.
If any of the constraints fail then the whole solution should return None.
This is the first correct answer I've seen! The test constraints on this Kata are obviously broken.
This is the third incorrect solution at the top of this page. This kata is not very good.
This is also incorrect. Needs to take constraints into account.
Loading more items...