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

  • Default User Avatar

    I'll look at this in depth when at home, I'm very limited on the smartphone.
    possibly test suite is broken , then...
    would you mind posting your attempt?

    edit: think I found the .mistake the namespace problem indeed is in the test suite. unable to solve it immediately ...

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

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

  • Custom User Avatar

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

  • Default User Avatar

    Very nice minimal code although a bit hard for a human to read. Nicely done though!

  • Loading more items...