Ad
  • Custom 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.

  • Custom User Avatar

    Thank you Chrono79. Now I understood my misinterpretation.

  • Custom 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

    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?

  • Custom 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. ;-)

  • Custom User Avatar

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

  • Custom 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.

  • Custom User Avatar

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

  • Custom User Avatar

    I'm not using round. Which namespace shoud I use?

  • Custom User Avatar

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

  • Custom User Avatar

    Thank you. After writing down the question, it hit me. ^^

  • Custom User Avatar

    Question solved by myself.