ed wrote: > On Fri, 19 Jan 2007 00:44:39 -0500 > Thomas Hruska <[EMAIL PROTECTED]> wrote: > >> ed wrote: >>> On Sat, 06 Jan 2007 18:56:58 -0000 >>> "vignesh_ahobila" <[EMAIL PROTECTED]> wrote: >>> >>>> Hey did anyone have the code for sudoku. >>>> >>>> [mod - Have you ever heard of Google? >>>> http://www.google.co.uk/search?q=sudoku+C - PJH] >>> >>> i dont know much about sudoku puzzles, but i imagine a 2d array of >>> int's would be what you're after and some brute force to calculate >>> the results. >> You've clearly never written a puzzle solver before. NEVER, EVER >> brute force anything unless you are unable to figure out initial >> patterns. > > never ever, say never ever. > > correct though, i've never been interested in solving puzzles like > this and less interested in sudoku.
To each his own, right? The first thing someone discovers when writing their first solver is that brute forcing a solution causes it to take "forever" except on extremely simple puzzles that take three moves (or less) to solve. A brute force solution for a small 3x3 puzzle on my nice 3GHz PC might take minutes to hours depending on the puzzle (probably more like hours). It was a pretty safe bet you had never written a puzzle solver before. >> In the case of Sudoku, you can deduce many numbers before having to >> guess. And a lot of puzzles are complete enough to never have to >> guess. When you guess in a solver, you squirrel away a copy of the >> board on a stack before the guess without the option of guessing it >> again should you have to backtrack. Then you work with the new board >> and deduce any numbers. Repeat until you have success or failure. >> If you reach a failure scenario, back out until you can continue >> forward again. Upon success, print the solution and exit. Done >> right, it can solve any 3x3 puzzle instantly. > > interesting, i'd never have thought about that. I dunno - that sort of thing just comes naturally for me any more. Guess that shows how long I've been writing puzzle solvers for fun. I've got quite the collection. If you've seen a puzzle, I've probably got a solver for it written in C/C++ (or at least its probably on my "to-do" list). I've got everything from Sudoku to Jumble to the classic "Cracker Barrel" peg-jumping puzzle (you know - those triangles they have sitting out for the "kid in you" to play with). -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* VerifyMyPC 2.0 Change tracking and management tool. Reduce tech. support times from 2 hours to 5 minutes. Free for personal use, $10 otherwise. http://www.CubicleSoft.com/VerifyMyPC/
