Ad
  • Custom User Avatar

    C Translation
    ready for review.

  • Custom User Avatar

    Is there anything else needed for approval?

  • Custom User Avatar

    Yes. This is the fork to approve. I have just finished adding the suggestion you made with the not null assert, so it should be ready.

  • Custom User Avatar

    That does seem cleaner. I was unaware of this assert before, so thanks for pointing it out.

  • Custom User Avatar

    So if no one else has any comments/additions, will this be approved?

  • Custom User Avatar

    @nomennescio I swapped out slightly ugly syntax in favor of a typedef typedef int (*SudokuBoard_t)[ 9 ].

    In addition, the relabeling now permutates 1-9, instead of only swapping 3 pairs of integers.

  • Custom User Avatar

    @hobovsky the translation now applies some random relabelling like so

    for( int j = 0; j < 3; ++j ){
      a = rand();
      b = rand();
      if( a != b ){
        relabel( puzzle, a, b ); // change all a->b, and b->a
        relabel( answer, a, b );
      }
    }
    

    The relabeling occurs before every transformation that was there before. So effectively the steps are:

    1. grab a pre-written puzzle and solution
    2. relabel puzzle and solution the same way
    3. transform puzzle and solution the same way

    Is this a sufficient relabeling/randomization strategy?

    @nomennescio What would be the standard format? I'm willing to modify the code to comply with the standard.

  • Custom User Avatar

    @nomennescio I decided to convert to a contiguous 2D array. It was a fun little learning experience for me. Everything should be converted over now.

  • Custom User Avatar

    @hobovsky Thanks for the info on forking. Also, random test are implemented as a simple swapping of triples like you suggested.

    @nomennescio If I were to convert back to a 2D array[9][9] (but keeping the allocation contiguous), would you prefer the use of a results parameter like hobovsky suggested?

  • Custom User Avatar
    • Included #include <stdlib.h> in tests.
    • Helper functions are now static.
    • Array now expects a contiguous buffer of 81 values. Considering suggestion for an output argument instead.

    Random test aren't implemented yet. I will need to spend some time determining how to create them.

  • Default User Avatar

    Oops. Looks like I get a little delete happy with the headers. I believe I have corrected that mistake now.
    The assertion messages have been improved as suggested.

  • Default User Avatar
    • Tests now only print when wrong using the assert.
    • Helper function is now static.
    • Removed unnecesary comments.
    • Removed unnecesary includes.
      Let me know if any further changes are needed.