Ad
  • Default User Avatar

    Of course I can't find an example of failure, your interpretation of the conditions was very correct.

    It's great, I think it's fantastic that you work at bit level.

    I used detection of zero as a shortcut to get out of the routine, but you saved lines.

    On the other hand I had to check that << -1 actually works, I always expected that offset would have to be a positive quantity. I learned something new for me.

  • Custom User Avatar

    can give me sample of test case where this return wrong result? thanks

    (hint 1: board[i][j] is uint. what is the value of board[i][j]-1 ? is it equal to -1, or is it equal to something else?)

    (hint 2: try to run this code first, edit it and try to print the value of x |= 1 << (board[i][j]-1) to stdout);

  • Custom User Avatar

    board is unsigned int. what happened when unsigned int 0 minus by one?

    hint: x|=1 << (board[row][col] -1); is not shifting left by -1. it's something else

  • Default User Avatar

    Interesting board[i][j] = 0

    x |= 1 << (board[i][j] - 1);
    x |= 1 << ( - 1);
    x |= 0

    so nothing happen, 0 is ignored. It's great, maybe unplanned but great. The board fails due any digit missing