FUN only, solving a Puzzle.

  • ben.brugman

    SSChampion

    Points: 13340

    /*

    For FUN.

    I like puzzles, I like T-SQL coding, I like to show off :-), so why not combine these.

    This project was for FUN only, but I did learn new things.

    Goal:

    Build a Sudoku solver with the minimum amount of script. (Minimum number of lines or characters).

    It does have to solve any normal Sudoku, speed is not a requirement (but would be nice).

    Elegance of the coding is not a requirement (but would be nice).

    Preferable with the minimum of RBAR (Row By Agonizing Row).

    Solution:

    When given a puzzle, I like to solve the puzzle before a solution is presented.

    Not to rob you of attempting this puzzle, I will post my solution later, with a description.

    I have used previous versions of the 'solution' and other puzzles , to show that set based solutions can be a powerful method to solve 'problems'.

    Ben

    */

  • ChrisM@Work

    SSC Guru

    Points: 186074

    ben.brugman wrote:

    /*

    For FUN.

    I like puzzles, I like T-SQL coding, I like to show off :-), so why not combine these.

    This project was for FUN only, but I did learn new things.

    Goal:

    Build a Sudoku solver with the minimum amount of script. (Minimum number of lines or characters).

    It does have to solve any normal Sudoku, speed is not a requirement (but would be nice).

    Elegance of the coding is not a requirement (but would be nice).

    Preferable with the minimum of RBAR (Row By Agonizing Row).

    Solution:

    When given a puzzle, I like to solve the puzzle before a solution is presented.

    Not to rob you of attempting this puzzle, I will post my solution later, with a description.

    I have used previous versions of the 'solution' and other puzzles , to show that set based solutions can be a powerful method to solve 'problems'.

    Ben

    */

     

    Ben, I'm sure this has already been done here, and the final solution is as skimpy as Taylor Swift's bikini.

     

    Edited to add link: https://jasonbrimhall.info/2011/08/23/tsql-sudoku-ii/

     

    • This reply was modified 2 days, 13 hours ago by  ChrisM@Work.

    [font="Arial"]“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw[/font]


    For fast, accurate and documented assistance in answering your questions, please read this article[/url].
    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]
    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
    [url

  • ben.brugman

    SSChampion

    Points: 13340

    ChrisM@Work wrote:

    Ben, I'm sure this has already been done here, and the final solution is as skimpy as Taylor Swift's bikini.

    Edited to add link: https://jasonbrimhall.info/2011/08/23/tsql-sudoku-ii/

    Thank you Chris,

    Especially for the link, had not seen that one before. But as puzzle's go, there is bound to be people who have solved the puzzle before. As for Sudoku's, the solve is in the next issue of the paper or magazine, or sometimes in the same one. So there is no problem in that the puzzle has been solved before.

    The link to the solution, looks a bit like my solution. It contains 1591 characters, after removing (most) of the white space and comments it contains something like just below a 1000 characters. (I got to 998 for this script but did not spend to much time on it).

    I also took the solution and did run it. And tried the same Sudoku (starting with '53') and tried that on  my script. I was surprised that the published script ran in just over 1.5 secs on my machine and my script ran in 0.16 on my machine. My solution was totally geared to the minimum script and not to performance. So in performance (for this puzzle) I did beat the published solution. (Do not know why).

    The length of the published script (just below 1000 chars), but can be trimmed down a bit, my solution does contain less lines if formatted logically. And does contain less characters. It is less than the skimpy, probably only a swimming trunk. (Correct word ? English is not my native language). (It is not more, but more skimpy, is that a contradiction).

    Still working on trimming my script down, still figuring out to remove some length, have some idea's but some of them didn't work out. The length at the moment is significant below a 1000 chars.

    Still the same goes: So I do not want to spoil the puzzle and will be posting the script and a description later.

    Thanks for the link, I enjoyed that,

    Ben

     

     

     

     

    • This reply was modified 1 day, 8 hours ago by  ben.brugman. Reason: typo

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply