Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    No special coding skill needed here, but some mathematic knowledge.

  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Custom User Avatar

    Please use spoiler

  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I don't know what O(1) time means.

    Constant time. No loops, or recursive function calls that are dependent of some variable. Look for Big-O-Notation.

    I am sort of storing the temps?

    Probably, but that's a little bit hard to answer without code.

    ? I have created an object …. Is this method too inefficient for the time requirement?

    It is fine, although the lookup in objects is O(log n) not O(1). Still fast enough for the kata. However, I think that your getMean isn't O(1), but O(k), where k 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 up getMean a little bit.

  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution