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.
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? 😉
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 ^_^