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.
But isn't the check performed at the start of the expression? Array length will always be greater than or equal to zero. If the value of n is negative then the function returns -1 in this solution.
Edit:
Okay, I'm dumb :D
Read about "?" operator in java.
This comment is hidden because it contains spoiler information about the solution
Well yeah, but... I didn't even make any calculations I've just made a check if n < 100 and I saw that it still requires apple as an answer for the greater numbers :D
I can't believe this one! XD
This comment is hidden because it contains spoiler information about the solution
You sure made a small overkill here :P
Well it wouldn't be that odd if the first time I've launched the final tests the solution worked but I had 3 fails and from that time I can't even compile ;> But okay I'll try to improve. Okay I know now the true purpose of a test so last edit is not valid :D
Are the random tests okay? My solution passes through the basic but there is server timeout when I do the final check.
I had to use inner class and some interface to bypass the solution correctly and I don't think those are elements people of 7th kyu would know :D
Has anyone had a runtime error with Java tests? I've checked my solution and there is an error thrown, but I've made the tests in my IDE and they passed.
Everything is not hard after you do it P:
Nice kata, I've somewhat figured out the solution, but the problems were with the floating point in java, which gave me a good headache :D