Ad
  • Default User Avatar

    I am using Python and I'm having trouble with minute discrepancies in the returned values. Most test pass, but some fail with these minute differences. For example, for the test expecting this set of results:
    [('A', [-930, -821.968567], -595.5937134000001, -9, -0.633638, 9.8788895, 498.3100783999997, [786, 973]), ('B', [-968, -929, -872.170855, -832.47569], -829.9500422, -520, -8, 3.509747, 98.99999999999997, [111, 398, 529, 716.419035])]

    I get a few values that don't exactly match. All of them (as is the case with the other failing tests AFAICS) are discrepancies in the results of the first and last deciles. Here are the differing values:

         [My value]     instead of    [test value]
      -9.0              instead of   -9
     498.31007840000007 instead of  498.3100783999997
    -829.9500421999999  instead of -829.9500422
      99.0              instead of   98.99999999999997
    

    Curiously, I think my result of 99.0 is probably more 'accurate' than the test's 98.99999999999997.

    I also tried using decimal.Decimal for calculating the deciles and the differences raising the errors are now:

     [My value]  instead of  [test value]
    -595.5937134 instead of -595.5937134000001
     498.3100784 instead of  498.3100783999997
    -520.0       instead of -520
      99.0       instead of   98.99999999999997
    

    Here, I strongly believe the results of my code are actually more accurate than those of the test suite.

    Still, the tests fail. I think this is an issue with the kata. I did not have these errors with the five figures kata of this statistics series.

  • Default User Avatar

    I did finally find out which variant of quantile calculation it is. I'm not sure the point of the kata should be reverse engineering that, though. Otherwise, it would be a nice one.

  • Default User Avatar

    Hey all,

    I have several tests failing. I applied the 'standard' of quartile calculation, i.e. the Tukey method. I had a look at other ways of calculating quartiles, but there are way too many for me to figure out which one was used for the tests. I did not expect this to be a reverse engineering task for quartile calculation. If it is meant to be that, it should say so in the kata. In fact, I even think it would not be really proper as a kata on codewars. But maybe I am missing something?

    Just one example for where I am stuck: The first failing test is test # 3. The test consists of 60 values between 1 and 32. The value I get that's supposed to be wrong is the lower quartile. I get a result of 12.5, but the test is expecting 12.75. According to Tukey, the lower quartile would be (12 + 13) / 2. However, the expected result is 12.75. Looking through various methods of calculating the lower quartile, I don't see how I could get that result at all. I even looked at scientific papers, although I'm not from a field that has to do with math. I didn't find anything that would return this result. Maybe I'm overlooking something obvious?

    Thank you for any pointers.

  • Default User Avatar

    Actually, I just found the test cases. I don't know if it's all of them (they are very few), but it seems like it might be. They are on this very discussion page: At the top you can "show kata test cases". :)

  • Custom User Avatar

    There's no way to look at the tests when you hit attempt, unless you solve it :D (then you can see by clicking 'Show Kata Test Cases' below satisfaction rating)

    With other languages like JS, it will display your logs regardless if your code times out or not, but not with python runner :/

    But to be clear, you shouldn't need to use any external stuff. All you need is to scroll through the logs that codewars runner displays, and find what you need. ( ideally :P ) Best of luck, and if it doesn't work, let us know, we'll find a way to help.

  • Default User Avatar

    The comma means your code should remove one character from the input string provided to the function as a parameter and add it to a tape-like memory. The dot means it gets copied from memory to a variable later to be returned.

  • Default User Avatar

    Exactly. I was hoping I could avoid that by running the test directly on my machine. But if there's no way to look at the tests, I'll have to add a lot of print statements and do it in the browser. Thanks a bunch anyways!

  • Custom User Avatar

    Hmm... with python that can be tricky. The goal is to print just enough stuff to fill the buffer in 12s (easy if there's infinite loop), otherwise it will only display timeout message. You could print some distinct message and then print the input, so then you could use ctrl+F to find it on the left side, which shows console output. (the last one would be the failing test) Alternatively you could just print a lot of stuff in your loop and trying to debug it to see where it gets stuck.

  • Default User Avatar

    Yes,that's true. But if I don't, it falls as well. it seems to keep looping. I'd just like to check the test to pin my error and don't know where I can find it.

  • Custom User Avatar

    It means you're printing too much stuff into console.

  • Default User Avatar

    When I "attempt", the fifth test fails due to "Max Buffer Size Reached (1.5 MiB)". I am wondering where I can look up the test case to understand what is happening. Any pointers?