Ad
  • Custom User Avatar

    Can someone please help? I have what I believe to be a solution in Haskell.
    ghci> :l isPP
    [1 of 1] Compiling Codewars.Kata.PP ( isPP.hs, interpreted )
    Ok, one module loaded.
    ghci> isPP 1
    Nothing
    ghci> isPP 4
    Just (2,2)
    ghci> isPP 9
    Just (3,2)
    ghci> isPP 5
    Nothing

    Should work on first few perfect powers:
    Fail.

  • Custom User Avatar

    No worries - I was just a little grumpy and should have walked away, calmed down and not posted and hence troubled you. Figuring out the solution once I realised what was expected was really simple, perhaps so simple being the reason I assumed the intent was to get us to create the classes, structs ow whatever we chose to be appropiate. Since solved.

  • Custom User Avatar

    You do not need to create them, they are already available in preloaded sinppet as:

    struct Point{
      double x;
      double y;
    };
    
    struct Triangle{
      Point a;
      Point b;
      Point c;
    };
    

    There is a sentence in the description which attempts to explain this, but yeah, mignt be not clear enough. You do not need to define anything, or include anything, you just use the existing classes.

  • Custom User Avatar

    I created my own Point and Triangle classes in C++ and approriate class member functions then when I run the test I get an error: "Redefinition of Point, Triangle ... Point preveiously defined here." How do I get to see these existing definitions for Point and Triangle?

  • Custom User Avatar

    Thankyou hobovsky and trash_incel. The addition of << std::flush allowed me to see that to my surpise the program crashed on the very first test with inputs "2" and "3" even though this compiled and ran with correct result locally. From there I deduced I was getting a -1 index. I had been looping using reverse iterator and was trying to compute the index for my vector to store the computation results using std::distance. This is were things were wrong. I guess that I was either lucky locally or my compiler was doing something smart. I had already made one of my own tests with one number as "" and again this compiled fine and gave the correct result for me locally. Anyway - I have now submitted with success. Thanks both.

  • Custom User Avatar

    add << std::flush after the values you print. flushing the standard output ensures you will see it even if the program crashes

  • Custom User Avatar

    This part, and specifically the READ at 0x000000000000, usually means that the error is caused by reading a past-the-end iterator:

    ==1==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 [...]
    ==1==The signal is caused by a READ memory access.
    

    Note that in this kata it is possible to receive "" as an input (don;t ask me why), and it should be treated as "0".

  • Custom User Avatar

    On c++ when running test I get the following STDERR:
    double free or corruption (out)
    UndefinedBehaviorSanitizer:DEADLYSIGNAL
    ==1==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f0db73858e0 bp 0x7ffc65681330 sp 0x7ffc656810e0 T1)
    ==1==The signal is caused by a READ memory access.
    ==1==Hint: address points to the zero page.
    ==1==WARNING: invalid path to external symbolizer!
    ==1==WARNING: Failed to use and restart external symbolizer!
    #0 0x7f0db73858df (/lib/x86_64-linux-gnu/libc.so.6+0x408df)
    #1 0x7f0db73ce836 (/lib/x86_64-linux-gnu/libc.so.6+0x89836)
    #2 0x7f0db73d58b9 (/lib/x86_64-linux-gnu/libc.so.6+0x908b9)
    #3 0x7f0db73dce49 (/lib/x86_64-linux-gnu/libc.so.6+0x97e49)
    #4 0x42574d (/workspace/test+0x42574d)
    #5 0x428475 (/workspace/test+0x428475)
    #6 0x426b2e (/workspace/test+0x426b2e)
    #7 0x426673 (/workspace/test+0x426673)
    #8 0x4262ab (/workspace/test+0x4262ab)
    #9 0x42bb25 (/workspace/test+0x42bb25)
    #10 0x42584d (/workspace/test+0x42584d)
    #11 0x7f0db7366c86 (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
    #12 0x4045a9 (/workspace/test+0x4045a9)

    UndefinedBehaviorSanitizer can not provide additional info.
    ==1==ABORTING

    When I compile my code locally with: $ g++ -ggdb -pedantic-errors -Wall -Weffc++ -Wextra -Wconversion -Wsign-conversion -std=c++17 multiply.cpp -o prog I get no errors. There is a warning about conversion to long unsigned int from int on my variable index which I use to hold a "std::vector<>" result. The program runs with the given tests. I tried using std::cout << "a: " << a << '\n'; and std::cout << "b: " << b << '\n'; to see what inputs the problem might be associated with but this did not work on test. Can someone please advise how I might find th bug?

  • Custom User Avatar

    One of the random tests on C++ is test tX, original Tx, expects true. I think this should be false.
    The description says anagrams are case insensitive. Apply case insensitivity to Tx and tX means they are the same word and not different.

  • Custom User Avatar

    You should print the input lists at the beginning of the function to see where it fails. See https://docs.codewars.com/training/troubleshooting/#print-input

    It's currently failing with some negative numbers in array1.

  • Custom User Avatar

    Hi,
    Thanks for this challenge. However, I encounter a problem, I pass all the tests except one case where I should have True but I have False. Would these come from my code?

    Thanks for your answers :)

  • Custom User Avatar

    How can I be sure about exactly which test I am failing. The output is:
    Time: 3288ms Passed: 1 Failed: 1 Exit code 1
    Test_Results
    Comp_Tests
    Tests_comp
    ! Expected: true
    Actual: false
    Random_tests

    When i print the inputs it seems like the failure is for input (2,2,3) and (4,9,9) but based on a look through the discussions it looks like this might not be the case? For other Kata a test number is given for each test and a pass or fail output against each.

  • Custom User Avatar

    Great answer - it helped a lot. Instructions clear and easy to follow. I solved the problem and passed all tests. Thanks :)

  • Custom User Avatar

    Ideally, failed tests would present the input which made them fail. But if they do not, you can try this: https://docs.codewars.com/training/training-example#debugging-a-kata

  • Custom User Avatar

    how do I find out what the inputs were for a failed test? I have submitted a solution in C++ for 'common denominators' and have failed test 3 with output:
    Expected: equal to "(77033412951888085,14949283383840498)(117787497858828,14949283383840498)(2526695441399712,14949283383840498)" Actual: "(3414707982693751,14949283383840498)(1573009032312,14949283383840498)(1612068318217,14949283383840498)"

  • Loading more items...