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 the kata itself shows numbers being returned by themselves and even states the function should return a number at one point. Not an object that is coerced to be equal to a number. It can really lead people astray when the description lies to us.
Thanks for writing this. I was passing the test but when i submitted i got "expected: but was:" on the true part, had no idea why. But this was the reason.
Would be good if this was made clear in the description.
No special coding skill needed here, but some mathematic knowledge.
Could have clarified that numbers being the same counts as ascending order, also in the submitting portion it was saying
Expected: false, instead got: true when my code was submitting false and the answer expected was true. Would have been able to figure out what you actually wanted a lot faster if this was corrected.
This comment is hidden because it contains spoiler information about the solution
Yours works because you returned nil if you had falsy input so when it was tested w/ the nil case the input of nil was evaluated as false so !input was true so it returned nil. It's the same idea and will also work if they pass in false I guess just slightly less clear what is being tested.
This comment is hidden because it contains spoiler information about the solution
see bootstrap
Please use spoiler
Any hint or advice for dealing w/ the 20th test of the biggest integer? I don't believe we can use any libraries here to deal w/ large numbers? I saw one blog post say something about strings but I don't know how you could add to something when it's a string which we sitll need to do here.
The original code was fairly simple to set up but I am still quite new to programming.
This comment is hidden because it contains spoiler information about the solution
Constant time. No loops, or recursive function calls that are dependent of some variable. Look for Big-O-Notation.
Probably, but that's a little bit hard to answer without code.
It is fine, although the lookup in objects is
O(log n)
notO(1)
. Still fast enough for the kata. However, I think that yourgetMean
isn'tO(1)
, butO(k)
, wherek
is the number of different temperatures that have been encountered so far (by the way, this also called linear time complexity). So you probably need to speed upgetMean
a little bit.Class passes timed test
40,000 get functions completed in 328ms. Shoot for less than 15ms.
Your get functions should take O(1) time! Are you storing all the temperatures?
boo urns
I'm doing this in javascript and only started teaching myself programming ~3 weeks ago so I don't know what 0(1) time means. I am sort of storing the temps? I have created an object that lists every temperature that has occurred as a property and increase the count of that property by 1 for each time the temperature occurs. If that temperature hasn't occurred it will create a new property w/ that temperature name. Is this method too inefficient for the time requirement? I can't imagine a very different method to get a reliable mode happening other than possibly something similar w/ an array but I am quite new as I said.
Class passes timed test
40,000 get functions completed in 108ms. Shoot for less than 15ms.
Your get functions should take O(1) time! Are you storing all the temperatures?
realized my min and max were done really stupidly. also looked up what O(1) means so that happened. Still don't know how you'd do mode like that though
EDIT: nvm guys I figured out a way. I also didn't realize the stress test was ONLY testing on the get functions and not putting it all together.
This comment is hidden because it contains spoiler information about the solution