• Hi Kevin,

    I really enjoyed reading your script, it was good to see TSQL used in a completely different way than usual. I would never have thought of using the bitwise operator to solve this problem.

    I like to see something different because seeing how other people approach a problem and write code is the best way of learning how to improve your own skills.

    Could you explain a bit about why you chose to work with the numbers in binary? was it your first choice or did you experiment with other ways first?

    The problem with sudoku is that for some of the puzzles you can only get so far by counting the numbers, eventually you may be forced to take a best guess at the content of a square. This is something that is missing from your script, do you intend to extend it in the future?

    I had a go by using recursion, but there is probably a better way, I modified the script to return 3 states: complete, Fail, Try Again. When the Try again state was reached the code would generate a new value for @t with one of the 0's replaced with a guess to see if that would lead to the completion of the puzzle.

    I identifed a square that had the minimum number of possible values and then created a new @t values for each of the possible values. I limited this to two levels of guesses.

    Here are the results I got for this sudoku:

    080700000902000000300090020060800200750109043009004070040050009000000706000007030

    _C1C2C3C4C5C6C7C8C9

    R1_8_7329__

    R29_2___3__

    R33___9__2_

    R4_6_87_29_

    R5758129643

    R6__9_64_7_

    R7_47_5___9

    R8______756

    R9_____7432

    _C1C2C3C4C5C6C7C8C9

    R1_8_73291_

    R29_2___36_

    R33___9__2_

    R4_6_87_29_

    R5758129643

    R6__9_64_7_

    R7_47_5_189

    R8______756

    R9_____7432

    _C1C2C3C4C5C6C7C8C9

    R1586732914

    R2972481365

    R3314596827

    R4463875291

    R5758129643

    R6129364578

    R7647253189

    R8231948756

    R9895617432

    I would be very interested to see how you would solve this problem.

    Thanks.

    Ian.