Ad
  • Default User Avatar

    I'm using C++ and I'm struggling to understand how this is possible for any value of n that is above 20 as 21! can not fit into any C++ variable as far as I know, and as far as I can work out in order to come up with the answer the calculation of 21! and above must be performed when n = 21 or above. Any clues would be much appreciated! Thanks

  • Default User Avatar

    When pressing Attempt it says I passed all tests failed nothing but it won't let me submit final.

    I guess this is because it took too long but there is no timeout message so I'm confused, never seen this before where it says you passed all tests but won't let you submit.

    time taken is anything from 1590ms to 1800ms, however I get the green light from the sample tests even when it takes longer than the actual attempt. Please can someone help me out here?

    Cheers

  • Default User Avatar

    When I run this locally (C++) it works fine, but when I run the sample tests and cout the remainder I get 2 for both cases. Anyone have an idea how this could be if I'm running the exact same code in a different workspace and acheiving the expected result?

  • Default User Avatar

    Hiya, in C++, from the input: 0 , 10 , 0.95 i get "is equal to 1 but expected 2".

    In the description:
    System A : 15 * 3 = 45
    System B : 500 + 15 * 0.90 + (15 * 0.90) * 0.90 + (15 * 0.90 * 0.90) * 0.90

    implies that the discount is applied on the first ticket bought in system B, so the answer in the above case must be 1, right?

  • Default User Avatar

    Ah ok, sorry about that!

  • Default User Avatar

    On C++ version was getting some weird answers so I added a cout statement to see what was happening. It seems that on test 2 and the random test the method is being called multiple times and with various different values being passed.

    here's what I added:

    class IntSqRoot
    {
    public:
    static long long intRac(long long n, long long guess){
    cout << n << "\t" << guess << endl;

    ...
    ...

    And this is the output:

    125348 300
    236 12
    48981764 8000
    6999 700
    16000 400
    16000 100
    2500 60
    250000 600
    125348981764 356243
    835871232077058 1

    So either I'm missing something here or these tests are faulty. Anyone have an idea of what's going on?

    Cheers

  • Default User Avatar

    Hi Tadar, to convert from positive to negative in binary, using two's complement, you invert all bits, and then add 1.

  • Default User Avatar
  • Default User Avatar

    Ah that's great, thanks! Was having trouble working out how to add tests to be honest so it's good to have help on this. I'll add this to the Kata! Cheers :)

  • Default User Avatar

    I'm pretty sure this (C++ version)is faulty, I'm certain I have the right code and it even works with the sample tests, when submitting however it behaves differently, says expecting a value 1 greater than the one returned. I even tried adding 1 to my result just so I could submit the Kata but then it says expecting 1 less! How is that even possible? Please can someone shed some light on what is going on here?