Ad
  • Custom User Avatar

    thanks sensei :)

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks for your post!

  • Custom User Avatar

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

  • Custom User Avatar

    That would lead to [612235,0,2] instead, you can only move one digit.

  • Custom User Avatar

    You should use malloc or calloc for the result.
    Thanks for your post.

  • Custom User Avatar

    I solved it in C. But it only runs the examples succesfully if I comment out the free(act) and free(sact) statements in dotest(), otherwise it crashes with

    *** Error in `/home/codewarrior/solution': free(): invalid pointer: 0x0000000000603200 ***
    

    As said, it runs succesfully when I change the code in the 'Example tests' box but not when I hit attempt. Thanks for the interesting problem, as always.

  • Custom User Avatar

    I vote only 'somewhat' satisfied because the assigment 'Try to do it without if statements' is not enforceable (as witnessed by the C solutions that nearly all use if or switch/case) but this is what makes it a nice little puzzle.