Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

[ Create a new account ]

Solving Sudoku With dpkg

Journal written by Otter (3800) and posted by timothy on Saturday August 23, @10:38PM
from the after-all-it's-there dept.
Reader Otter points out in his journal a very neat use for the logic contained in Debian's package dependency resolver: solving sudoku puzzles. To me at least, this is much more interesting than the sudoku puzzles themselves. Update: 08/24 02:51 GMT by T : Hackaday just ran a story that might tickle the same parts of your brain on a game played entirely with MySQL database queries.

Related Stories

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Uh-oh (Score:3, Funny)

    by Yvan256 (722131) on Saturday August 23, @10:41PM (#24723565) Homepage Journal

    1. Computers can generate Sudokus
    2. Computers can solve Sudokus
    3. Skynet determines that humans are useless. It then creates what is called "virtual worlds" in a campaign to exterminate the global human population birth rate.

        • Re:Uh-oh (Score:4, Interesting)

          by Koiu Lpoi (632570) <koiulpoi AT gmail DOT com> on Sunday August 24, @12:30AM (#24724017) Homepage

          Then try this on for size: I believe that "sudoku" is a mass noun, much like all nouns in Japanese. In other words, you can't say "two sudokus" any more than you can say "two softwares" or "two mashed potatoes". You need a counter word, such as "two sudoku puzzles", which you'd have to use (something very similar) in Japanese anyways.

          And besides, let's be honest. "Sudokus" sounds retarded.

  • Sudoku isn't a math puzzle, it's a logic puzzle - just one where you're filling in digits instead of the man in the blue house smoking Pall Malls and having a goldfish.

    The digits 1-9 in Sudoku could be replaced with any 9 other symbols without changing the underlying rules. So yeah, logic can be used to solve it.

    • Sodokus are typically solved by using logic and identifying relationships, but the article describes a clumsy brute force method. I will admit that I'm splitting 'mathematical' hairs here, and that it is an amusing thought to readapt Debian's simple dependency resolver, but crude solving functions, that simply guess at every possible solution, are fairly boring when compared to clever logic with elegant methods, that can solve sudokus in a fraction of time.
      • Ultimately this approach simply encodes the rules of sudoku, and the state of an unsolved sudoku puzzle in logic statements, and then passes it off to a reasonably general logic solver, namely the dependency/conflict resolver in apt-get/aptitude. That's not really brute force at all.

        Whether or not the solution is "brute force" depends on the manner in which debian's dependency/conflict resolver operates. There's many approaches to solving this problem, from gross brute force to reasonably complex machine le

        • by Nymz (905908) on Saturday August 23, @11:31PM (#24723775) Journal

          Sudoku doesn't have clever logic and elegant methods.

          Check out the various strategies listed on this Sudoku Solver. [scanraid.com]

          Don't mod me down if you disagree. If you disagree, consider writing a retort instead.

          You must be new here. Only posters that take the time to back up conclusions with reasoned responses are moderated down. Conversely, those that write short, unsupported attacks are moderated up... because in reality most people can only be trusted with 2 tags - I agree or I disagree.

        • Re:Splitting Hairs (Score:5, Interesting)

          by whatnotever (116284) on Saturday August 23, @11:35PM (#24723797)

          Sudoku can be solved by trying values in cells until a conflict is reached and backtracking to try other assignments. That's the brute-force approach.

          Most sudoku puzzles can be solved via implication, however. There is no need to "try" anything. Certain configurations of values in some cells can imply values in other cells. As a very simple example, consider a row that has all cells filled but one. The value of that unfilled cell is implied and can be filled in without having to try any other values. This is a basic example, but clearly more complex ones exist. This is essentially how people solve the puzzles, and I believe it is what the grandparent was describing.

          However, I do not believe that the grandparent is correct in stating that these methods solve sudokus in a fraction of the time of the brute force method if you allow for standard optimizations of the brute force method as developed for constraint processing (CP) or Boolean satisfiability (SAT) solvers. But then again, many of those optimizations are similar to the "clever logic and elegant methods," especially those that perform propagation and follow implications.

          Sudoku doesn't have clever logic and elegant methods. There is only one method for solving sudoku puzzles, and it strongly resembles a computer doing brute force.

          Don't mod me down if you disagree. If you disagree, consider writing a retort instead.

          It would have been nice if you had written something backing up your own claim as well.

        • Elegant methods (Score:5, Insightful)

          by SeanAhern (25764) on Saturday August 23, @11:36PM (#24723811) Journal

          Sudoku doesn't have clever logic and elegant methods. There is only one method for solving sudoku puzzles, and it strongly resembles a computer doing brute force.

          Sure, there are brute force methods. They are often techniques that dive into deep "consequence" trees to find contradictions. Those are, by their very nature, annoying for people to do and thus attractive for computer solutions. Nishio, tables, all of those just make sudoko boring and feel like you're executing a computer program in your limited-RAM brain.

          But those aren't the "clever" or "elegant" methods. Sudoku techniques that I would consider elegant are things like sashimi x-wings, XYZ-wings, the various type of unique rectangles, and such. I enjoy trying to discover patterns like these in really tricky sudoku problems. I expect I'm not the only one, given the popularity of the puzzle over the last few years.

          If you want to get really deep, you can use sudoku puzzles to explore mathematical group theory.

          All of this (and what you said in your post) are true for other puzzles such as the Rubik's cube. Perfectly suitable for machine automation, but still fun for some of us us lowly humans as well.

        • Re: (Score:3, Informative)

          The "Propagating Constraints" section of this article is quite a bit less brute force than the "search" section:

          http://norvig.com/sudoku.html [norvig.com]

  • by Asuranceturix (1265166) on Saturday August 23, @11:17PM (#24723717)

    And he didn't even use Super Cow Powers to do it!

  • by suck_burners_rice (1258684) on Sunday August 24, @12:07AM (#24723951)
    This is very cool! Kind of like implementing the Towers of Hanoi in vim or something. I'm going to test it against some puzzles from this here handy dandy Sudoku book. Now if only someone would make a Chess solver out of dpkg. You choose any out of the huge number of possible mate layouts and it will compute the dependencies from the start of the game to that mate layout! Implementing this should be so obvious that only a total fool won't immediately see how to do it, so it is left as an exercise for the reader.
  • Make (Score:5, Funny)

    by michaelmalak (91262) <malak@acm.org> on Sunday August 24, @01:10AM (#24724139) Homepage
    Probably also could be done using Make, which is really an expert system in disguise. Ant-heads won't know what I'm talking about. (Mod to +5 Flamebait.)