Ad
  • Default User Avatar

    the error comes from your code: wrong index calculation, so you access invalid memory

    char *pos = (char*)(pins + (sizeof(char *) * num_pins) + ((cur_idx) * len));
    

    should be:

    char *pos = (char*)pins + sizeof(char *) * num_pins + cur_idx * (len + 1);
    

    (you forgot the + 1 for the nul terminator, and you got the pointer arithmetic wrong: ptr + n will add n * sizeof *ptr to ptr, so you were going out-of-bounds of pins. The cast to char * needs to happen right away, in order to have byte-level memory access.)

  • Default User Avatar

    as already reported here, actual and expected are flipped all over the place in the tests suite

  • Default User Avatar

    this would invalidate all current, valid solutions to a blue kata and require editing of all four languages, just for a cosmetic change. Why should we do that ?

  • Default User Avatar

    the description could mention that it does not matter whether our path is open or closed (a closed tour is one in which the knight can reach the starting position from the final position)

  • Default User Avatar

    at the bottom of the documentation for Order(), it is written:

    Applies to: .NET 9 and other versions: .NET 7, 8, 9

    checking .NET version on Codewars:

    Console.WriteLine(RuntimeInformation.FrameworkDescription); // .NET 6.0.16
    
  • Default User Avatar
  • Default User Avatar

    are you sure that the test cases you print are those you fail ? I suspect that you were printing the island after having mutated it. I tried your code and it always fails the random tests in the same fashion: the starting point contains some gold ($) and it seems like you fail to collect it, so you have an extra step that you should not have:

    start = (0, 0), steps = 2, expected = 0, actual = 9
    
    $..
    ...
    9..
    

    I'm closing as the issue seems to be coming from your code. Feel free to present more information.

  • Default User Avatar

    there was a bug in the random tests, due to careless division that could yield a NaN when the length of the array is 0. can you check if it is good for you know ?

  • Custom User Avatar

    Trying to solve this in C#... Simple brute method worked with sample tests, but timed out on the later test.
    So i've used the Binet formula which works fine up to n = 10 and fails at n = 100.
    I've used double to define phi, psi and sqrt(5), and to do phi^n, and apparently that starts to fail in lesser digits on the number.
    What am I missing here?

  • Default User Avatar

    this issue is not reproducible - the kata is currently solvable. this is likely due to changes in the Node.JS environment / code runner setup for JS on Codewars (perhaps because Babel is no longer used - though I cannot replicate the issue even with the old Node v8.1.3/Babel version. But it would still be solvable even without that specific feature.

  • Default User Avatar

    this issue is not reproducible.

    var helloWorld = function() {}
    

    works fine for this kata

  • Default User Avatar
  • Default User Avatar

    How did you loop different numbers into the array where you added to find the different lengths?

  • Custom User Avatar

    Added in Haskell ( first random test will always be 0 ).

  • Custom User Avatar

    Haskell has the same situation. Less than ideal design, though I would not argue in favour of changing it now.

    Is it useful to keep this open?

  • Loading more items...