Ad
  • Default User Avatar

    Language: C#

    "TestFromImage2" expects five attacks with these rooks: 1-3; 1-5; 3-5; 5-3; 5-3
    I think there is something wrong with this test. There is a duplicate rook and the description mentions that there are no duplicate rooks. However, the correct answer should be three and not the expected five.

  • Default User Avatar

    Thank you Chrono79. Now I understood my misinterpretation.

  • Custom User Avatar

    As you have seen the solutions may have a value occurring only once. Enjoy it!

    You have two 1 in the first one and two -1 in the other.

  • Default User Avatar

    Thanks for the clarification. But why are [-2, 1, 1] and [-1, -1, 2] duplicates of elements in the expected solution?

  • Custom User Avatar

    The description fails to mention that the arrays in the solution should only contain unique values.

  • Default User Avatar

    Maybe I missed something.

    For one of the base test we have given:
    arr = [ 1, -1, 2, 3, -2, 4, 5, -3, -3, -1, 2, 1, 4, 5, -3 ]
    and
    n = 3

    This is expected:
    expected = [ [ -3, -2, 5 ]
    , [ -3, -1, 4 ]
    , [ -3, 1, 2 ]
    , [ -2, -1, 3 ] ]

    Why are [-2, 1, 1] and [-1, -1, 2] not expected?

  • Default User Avatar

    Thank you everyone for your help.
    I learned a lot about arrays in C and the ways of allocating memory.
    I also learned about the markup within the comments.

    In the future I will only use the issue tag if I'm really sure that there is no bug in my code. But that probably won't be the case with C. ;-)

  • Default User Avatar

    with this line:

    int *result = malloc(length_in);
    

    you do not allocate enough memory for an array of int of length length_in. the size of an array is not equal to its length, unless the array elements happen to have a size of one byte, which is not the case for int.

    Please use the question tag to ask for help next time

  • Custom User Avatar

    Your allocated buffer is too small.

  • Default User Avatar

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

  • Custom User Avatar

    Would you be so kind to at least post your code, so we could check what is the problem with it? please remember about code blocks and spoiler flag!

  • Default User Avatar

    I think there is something wrong with the C random tests.

    I always passing all tests, except one. And every time I am getting this error


    Test Crashed

    Caught unexpected signal: 6


    Sometimes I also get this error but with an extra log. For example this one:


    input was:
    length : 61
    {65, -60, -22, -15, 45, 34, -31, -43, -63, 96, -15, 66, -37, -62, 19, -29, -54, 24, -43, 96, -68, 87, 3, 61, -8, -44, 53, -6, -87, 14, 54, 78, 54, -68, -37, -2, 67, 32, 56, -97, 28, -60, 70, 92, -22, -11, -38, 25, -88, 19, 20, -55, 5, -78, -94, 98, -21, 59, -9, -7, -28}

    expected:
    length : 16
    {28, -60, 70, 92, -22, -11, -38, 25, -88, 19, 20, -55, 5, -78, -94, 98}

    but got:
    length : 16
    {91, 25, -64, -30, 40, 86, -66, -28, 1, 31, -35, 121, -98, 79, -95, -40}


    After checking manually I think the expected array is wrong.

  • Default User Avatar

    Your fix is correct. Now my attempt worked. Thank you.

  • Default User Avatar

    Dennis, if you got the time and your solution at hand, please try it again. I think the problem is fixed...

  • Default User Avatar

    re-raising DennisCook's issue. cpp test suite is broken

  • Loading more items...