Re: Sudoku solver

2015-04-10 Thread Albert van der Horst
In article 87iodoakft@elektro.pacujo.net, Marko Rauhamaa ma...@pacujo.net wrote: Ian Kelly ian.g.ke...@gmail.com: The test puzzle that you posted has 23 values already filled in. How does it perform on harder puzzles with only 17 clues (the proven minimum)? One would expect it to be

Re: Sudoku solver

2015-03-30 Thread Ian Kelly
On Sun, Mar 29, 2015 at 12:03 PM, Marko Rauhamaa ma...@pacujo.net wrote: BartC b...@freeuk.com: As Chris mentioned, when I say 'faster than C', I mean X running my algorithm was faster then C running Marko's algoritim (on Ian's data). This was just an illustration of algorithm being more

Re: Sudoku solver

2015-03-30 Thread Christian Gollwitzer
Am 30.03.15 um 08:50 schrieb Ian Kelly: On Sun, Mar 29, 2015 at 12:03 PM, Marko Rauhamaa ma...@pacujo.net wrote: Be careful with the benchmark comparisons. Ian's example can be solved with the identical algorithm in eight different ways (four corners, left or right). I ran the example with my

Re: Sudoku solver

2015-03-30 Thread Ian Kelly
On Mon, Mar 30, 2015 at 1:13 AM, Christian Gollwitzer aurio...@gmx.de wrote: Am 30.03.15 um 08:50 schrieb Ian Kelly: On Sun, Mar 29, 2015 at 12:03 PM, Marko Rauhamaa ma...@pacujo.net wrote: Be careful with the benchmark comparisons. Ian's example can be solved with the identical algorithm in

Re: Sudoku solver

2015-03-30 Thread Chris Angelico
On Mon, Mar 30, 2015 at 7:57 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Mar 30, 2015 at 2:16 AM, Dave Angel da...@davea.name wrote: The relationship between row, column and box can be rearranged. Some of these are already covered by the rotations proposed earlier, where for a 90

Re: Sudoku solver

2015-03-30 Thread Ian Kelly
On Mon, Mar 30, 2015 at 2:16 AM, Dave Angel da...@davea.name wrote: The relationship between row, column and box can be rearranged. Some of these are already covered by the rotations proposed earlier, where for a 90 degree rotate, row becomes column and column becomes row. But in a similar

Re: Sudoku solver

2015-03-30 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: On Mon, Mar 30, 2015 at 1:13 AM, Christian Gollwitzer aurio...@gmx.de wrote: Am 30.03.15 um 08:50 schrieb Ian Kelly: On Sun, Mar 29, 2015 at 12:03 PM, Marko Rauhamaa ma...@pacujo.net wrote: Be careful with the benchmark comparisons. Ian's example can be

Re: Sudoku solver

2015-03-30 Thread Marko Rauhamaa
mr.smit...@gmail.com: You say neater implementation I'll send you to the code-golf site: http://codegolf.stackexchange.com/a/446/38632 this is brute force. There are some really good implementations in other languages that arent brute force. It ain't neater if it don't fit in your posting

Re: Sudoku solver

2015-03-30 Thread Dave Angel
On 03/30/2015 03:29 AM, Ian Kelly wrote: On Mon, Mar 30, 2015 at 1:13 AM, Christian Gollwitzer aurio...@gmx.de wrote: Am 30.03.15 um 08:50 schrieb Ian Kelly: On Sun, Mar 29, 2015 at 12:03 PM, Marko Rauhamaa ma...@pacujo.net wrote: Be careful with the benchmark comparisons. Ian's example can

Re: Sudoku solver

2015-03-30 Thread BartC
On 29/03/2015 08:57, Christian Gollwitzer wrote: Am 29.03.15 um 05:06 schrieb Steven D'Aprano: [OT: Competing with compiled C code] I'm not one of those people who think that C is by definition the fastest language conceivable. (People who believe this sometimes make an exception for

Re: Sudoku solver

2015-03-29 Thread Seymore4Head
On Sun, 29 Mar 2015 23:17:23 +0100, BartC b...@freeuk.com wrote: On 29/03/2015 22:21, Mark Lawrence wrote: On 28/03/2015 23:50, BartC wrote: On 28/03/2015 03:39, Sayth wrote: Good test for pypy to see where it's speed sits between C and Python. Python 3.1: 1700 seconds (normal Python

Re: Sudoku solver

2015-03-29 Thread Steven D'Aprano
On Sun, 29 Mar 2015 03:10 pm, Chris Angelico wrote: On Sun, Mar 29, 2015 at 2:06 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 29 Mar 2015 10:50 am, BartC wrote: (X is my own interpreted language, which is where my interest in this is. This had been generally

Re: Sudoku solver

2015-03-29 Thread BartC
On 29/03/2015 13:01, BartC wrote: On 29/03/2015 11:35, Steven D'Aprano wrote: Anyway, we don't really know where the confusion lies. Perhaps the description is misleading, or I'm just confused, or Bart's idea of brute force is not the same as my idea of brute force, or perhaps he really is a

Re: Sudoku solver

2015-03-29 Thread BartC
On 29/03/2015 11:35, Steven D'Aprano wrote: That's why I can't help but feel that, *given the description we've seen*, perhaps Bart's brute force code doesn't actually solve the problem, and that's why it is so fast. I'm reminded of the recent thread where somebody claimed to have a significant

Re: Sudoku solver

2015-03-29 Thread Marko Rauhamaa
Mark Lawrence breamore...@yahoo.co.uk: One thing I have come to rely on over the years is never, ever trust your gut instincts about Python performance, you're almost inevitably wrong. When I first came across the Norvig solver I made a change, purely for fun, to replace two calls to len()

Re: Sudoku solver

2015-03-29 Thread Marko Rauhamaa
BartC b...@freeuk.com: As Chris mentioned, when I say 'faster than C', I mean X running my algorithm was faster then C running Marko's algoritim (on Ian's data). This was just an illustration of algorithm being more important than language. Be careful with the benchmark comparisons. Ian's

Re: Sudoku solver

2015-03-29 Thread Mark Lawrence
On 29/03/2015 19:03, Marko Rauhamaa wrote: BartC b...@freeuk.com: As Chris mentioned, when I say 'faster than C', I mean X running my algorithm was faster then C running Marko's algoritim (on Ian's data). This was just an illustration of algorithm being more important than language. Be

Re: Sudoku solver

2015-03-29 Thread Christian Gollwitzer
Am 29.03.15 um 05:06 schrieb Steven D'Aprano: I'm not one of those people who think that C is by definition the fastest language conceivable. (People who believe this sometimes make an exception for hand-crafted assembly, which is ironic since these days the best C optimizing compilers can

Re: Sudoku solver

2015-03-29 Thread Chris Angelico
On Sun, Mar 29, 2015 at 9:35 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Anyway, we don't really know where the confusion lies. Perhaps the description is misleading, or I'm just confused, or Bart's idea of brute force is not the same as my idea of brute force, or perhaps he

Re: Sudoku solver

2015-03-29 Thread BartC
On 29/03/2015 04:06, Steven D'Aprano wrote: On Sun, 29 Mar 2015 10:50 am, BartC wrote: But using X *and* my own brute-force algorithm, the same puzzle took 2 seconds to solve - faster than C! But, when you tell me that your very own personal interpreted language, which I assume nobody else

Re: Sudoku solver

2015-03-29 Thread BartC
On 29/03/2015 00:12, Chris Angelico wrote: On Sun, Mar 29, 2015 at 10:50 AM, BartC b...@freeuk.com wrote: Using the OP's algorithm, and testing with the 'hard' puzzle posted by Ian Kelly, I got these approximate results: Python 3.1: 1700 seconds (normal Python interpreter) PyPy:

Re: Sudoku solver

2015-03-29 Thread BartC
On 29/03/2015 19:03, Marko Rauhamaa wrote: BartC b...@freeuk.com: As Chris mentioned, when I say 'faster than C', I mean X running my algorithm was faster then C running Marko's algoritim (on Ian's data). This was just an illustration of algorithm being more important than language. Be

Re: Sudoku solver

2015-03-29 Thread Mark Lawrence
On 29/03/2015 21:59, BartC wrote: On 29/03/2015 00:12, Chris Angelico wrote: On Sun, Mar 29, 2015 at 10:50 AM, BartC b...@freeuk.com wrote: Using the OP's algorithm, and testing with the 'hard' puzzle posted by Ian Kelly, I got these approximate results: Python 3.1: 1700 seconds

Re: Sudoku solver

2015-03-29 Thread Mark Lawrence
On 28/03/2015 23:50, BartC wrote: On 28/03/2015 03:39, Sayth wrote: Good test for pypy to see where it's speed sits between C and Python. I've spent the last hour or so doing such tests. Using the OP's algorithm, and testing with the 'hard' puzzle posted by Ian Kelly, I got these approximate

Re: Sudoku solver

2015-03-29 Thread BartC
On 29/03/2015 22:19, Mark Lawrence wrote: On 29/03/2015 21:59, BartC wrote: On 29/03/2015 00:12, Chris Angelico wrote: On Sun, Mar 29, 2015 at 10:50 AM, BartC b...@freeuk.com wrote: Using the OP's algorithm, and testing with the 'hard' puzzle posted by Ian Kelly, I got these approximate

Re: Sudoku solver

2015-03-29 Thread BartC
On 29/03/2015 22:21, Mark Lawrence wrote: On 28/03/2015 23:50, BartC wrote: On 28/03/2015 03:39, Sayth wrote: Good test for pypy to see where it's speed sits between C and Python. Python 3.1: 1700 seconds (normal Python interpreter) PyPy: 93 seconds C unoptimised: 17

Re: Sudoku solver

2015-03-29 Thread mr . smittye
On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: A lot of discussion was generated by the good, old fibonacci sequence. I have yet to find practical use for fibonacci numbers. However, the technique behind a sudoku solver come up every now and again in practical

Re: Sudoku solver

2015-03-28 Thread Chris Angelico
On Sun, Mar 29, 2015 at 10:50 AM, BartC b...@freeuk.com wrote: Using the OP's algorithm, and testing with the 'hard' puzzle posted by Ian Kelly, I got these approximate results: Python 3.1: 1700 seconds (normal Python interpreter) PyPy: 93 seconds C unoptimised: 17 seconds

Re: Sudoku solver

2015-03-28 Thread Virgil Stokes
On 27-Mar-2015 15:09, Dave Angel wrote: On 03/27/2015 09:56 AM, Marko Rauhamaa wrote: Frank Millman fr...@chagford.com: So what I am talking about is called a satisfactory puzzle, which is a subset of a proper puzzle. That is impossible to define, though, because some people are mental

Re: Sudoku solver

2015-03-28 Thread BartC
On 28/03/2015 03:39, Sayth wrote: Good test for pypy to see where it's speed sits between C and Python. I've spent the last hour or so doing such tests. Using the OP's algorithm, and testing with the 'hard' puzzle posted by Ian Kelly, I got these approximate results: Python 3.1: 1700

Re: Sudoku solver

2015-03-28 Thread Steven D'Aprano
On Sun, 29 Mar 2015 10:50 am, BartC wrote: (X is my own interpreted language, which is where my interest in this is. This had been generally faster than Python until PyPy came along. It does however use a pure byte-code interpreter, so the result is not too bad. But using X *and* my own

Re: Sudoku solver

2015-03-28 Thread Chris Angelico
On Sun, Mar 29, 2015 at 2:06 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 29 Mar 2015 10:50 am, BartC wrote: (X is my own interpreted language, which is where my interest in this is. This had been generally faster than Python until PyPy came along. It does however

Re: Sudoku solver

2015-03-28 Thread Ian Kelly
On Fri, Mar 27, 2015 at 7:40 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Excluding that, the consensus seems to be that Perl's regexes are stronger than Chomsky regular expressions, but nobody quite knows how much stronger. It's likely that they are at least as powerful as

Re: Sudoku solver

2015-03-27 Thread Christian Gollwitzer
Am 26.03.15 um 00:04 schrieb Mark Lawrence: On 25/03/2015 22:50, Steven D'Aprano wrote: On Wed, 25 Mar 2015 10:39 pm, Marko Rauhamaa wrote: I have yet to find practical use for fibonacci numbers. Many people have failed to find practical uses for many things from mathematics. Doesn't mean

Re: Sudoku solver

2015-03-27 Thread Chris Angelico
On Fri, Mar 27, 2015 at 8:07 PM, Frank Millman fr...@chagford.com wrote: There seems to be disagreement over the use of the term 'trial and error'. How about this for a revised wording - It should be possible to reach that solution by a sequence of logical deductions. Each step in the

Re: Sudoku solver

2015-03-27 Thread Frank Millman
Marko Rauhamaa ma...@pacujo.net wrote in message news:87fv8sndw1@elektro.pacujo.net... Frank Millman fr...@chagford.com: Here is another python-based sudoku solver - http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py From its docstring - A proper Sudoku puzzle must have a unique

Re: Sudoku solver

2015-03-27 Thread Dave Angel
On 03/27/2015 09:35 AM, Frank Millman wrote: Dave Angel da...@davea.name wrote in message news:551557b3.5090...@davea.name... But now I have to disagree about true Sudoku puzzle. As we said earlier, it might make sense to say that puzzles that cannot be solved that way are not reasonable

Re: Sudoku solver

2015-03-27 Thread Dave Angel
On 03/27/2015 05:25 AM, Chris Angelico wrote: On Fri, Mar 27, 2015 at 8:07 PM, Frank Millman fr...@chagford.com wrote: There seems to be disagreement over the use of the term 'trial and error'. How about this for a revised wording - It should be possible to reach that solution by a sequence of

Re: Sudoku solver

2015-03-27 Thread Chris Angelico
On Sat, Mar 28, 2015 at 12:14 AM, Dave Angel da...@davea.name wrote: But now I have to disagree about true Sudoku puzzle. As we said earlier, it might make sense to say that puzzles that cannot be solved that way are not reasonable ones to put in a human Sudoku book. But why isn't it a true

Re: Sudoku solver

2015-03-27 Thread Frank Millman
Dave Angel da...@davea.name wrote in message news:551557b3.5090...@davea.name... But now I have to disagree about true Sudoku puzzle. As we said earlier, it might make sense to say that puzzles that cannot be solved that way are not reasonable ones to put in a human Sudoku book. But why

Re: Sudoku solver

2015-03-27 Thread Dave Angel
On 03/27/2015 09:25 AM, Chris Angelico wrote: On Sat, Mar 28, 2015 at 12:14 AM, Dave Angel da...@davea.name wrote: But now I have to disagree about true Sudoku puzzle. As we said earlier, it might make sense to say that puzzles that cannot be solved that way are not reasonable ones to put in a

Re: Sudoku solver

2015-03-27 Thread Marko Rauhamaa
Frank Millman fr...@chagford.com: So what I am talking about is called a satisfactory puzzle, which is a subset of a proper puzzle. That is impossible to define, though, because some people are mental acrobats and can do a lot of deep analysis in their heads. What's satisfactory to you may not

Re: Sudoku solver

2015-03-27 Thread Chris Angelico
On Sat, Mar 28, 2015 at 12:48 AM, Dave Angel da...@davea.name wrote: On the other hand, I play some games which I can only solve with the aid of a computer. Is that cheating? Not for some games. I have some challenges for which I need/prefer to use a wrench, or a screwdriver, or a

Re: Sudoku solver

2015-03-27 Thread Chris Angelico
On Sat, Mar 28, 2015 at 1:09 AM, Dave Angel da...@davea.name wrote: On 03/27/2015 09:56 AM, Marko Rauhamaa wrote: Frank Millman fr...@chagford.com: So what I am talking about is called a satisfactory puzzle, which is a subset of a proper puzzle. That is impossible to define, though,

Re: Sudoku solver

2015-03-27 Thread Chris Angelico
On Sat, Mar 28, 2015 at 12:56 AM, Marko Rauhamaa ma...@pacujo.net wrote: Frank Millman fr...@chagford.com: So what I am talking about is called a satisfactory puzzle, which is a subset of a proper puzzle. That is impossible to define, though, because some people are mental acrobats and can

Re: Sudoku solver

2015-03-27 Thread Dave Angel
On 03/27/2015 09:56 AM, Marko Rauhamaa wrote: Frank Millman fr...@chagford.com: So what I am talking about is called a satisfactory puzzle, which is a subset of a proper puzzle. That is impossible to define, though, because some people are mental acrobats and can do a lot of deep analysis in

Re: Sudoku solver

2015-03-27 Thread Mark Lawrence
On 27/03/2015 14:09, Dave Angel wrote: On 03/27/2015 09:56 AM, Marko Rauhamaa wrote: Frank Millman fr...@chagford.com: So what I am talking about is called a satisfactory puzzle, which is a subset of a proper puzzle. That is impossible to define, though, because some people are mental

Re: Sudoku solver

2015-03-27 Thread BartC
On 26/03/2015 00:07, Ian Kelly wrote: On Wed, Mar 25, 2015 at 2:31 PM, Marko Rauhamaa ma...@pacujo.net wrote: It takes about 2 seconds for my Python program to find the answer but it spends a total of 110 seconds to exhaust the problem space. The analogous C program finished the whole thing

Re: Sudoku solver

2015-03-27 Thread sohcahtoa82
On Friday, March 27, 2015 at 7:10:54 AM UTC-7, Dave Angel wrote: On 03/27/2015 09:56 AM, Marko Rauhamaa wrote: Frank Millman fr...@chagford.com: So what I am talking about is called a satisfactory puzzle, which is a subset of a proper puzzle. That is impossible to define, though,

Re: Sudoku solver

2015-03-27 Thread Larry Hudson
On 03/27/2015 07:09 AM, Dave Angel wrote: [snip] I know, let's use regular expressions g This is totally OT, but... There was a recent (2015-03-23) item on The Daily WTF web site concerning regular expressions. Take a look at http://thedailywtf.com/articles/regularly-expressing-hate

Re: Sudoku solver

2015-03-27 Thread Sayth
Good test for pypy to see where it's speed sits between C and Python. -- https://mail.python.org/mailman/listinfo/python-list

Re: Sudoku solver

2015-03-27 Thread Gregory Ewing
Chris Angelico wrote: Part of me is quaking in fear... the other part looking on in morbid fascination. Can you build a regexp that proves a Sudoku grid solvable? Well, it's *theoretically* possible, since there are a finite number of possible sudoku puzzles, so if nothing else you could just

Re: Sudoku solver

2015-03-27 Thread Steven D'Aprano
On Sat, 28 Mar 2015 01:19 am, Chris Angelico wrote: Part of me is quaking in fear... the other part looking on in morbid fascination. Can you build a regexp that proves a Sudoku grid solvable? Perl's regular expressions can run arbitrary code using ?{...} which technically makes them Turing

Re: Sudoku solver

2015-03-27 Thread Steven D'Aprano
On Sat, 28 Mar 2015 05:18 am, sohcahto...@gmail.com wrote: On Friday, March 27, 2015 at 7:10:54 AM UTC-7, Dave Angel wrote: I know, let's use regular expressions g -- DaveA You jest, but... http://www.perlmonks.org/?node_id=471168 I'm not a Perl expert, but I call that cheating,

Re: Sudoku solver

2015-03-26 Thread Frank Millman
Marko Rauhamaa ma...@pacujo.net wrote in message news:87r3sdnw5t@elektro.pacujo.net... I post below a sudoku solver. I eagerly await neater implementations (as well as bug reports). Here is another python-based sudoku solver - http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py From its

Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Abhiram R abhi.darkn...@gmail.com: On Thu, Mar 26, 2015 at 8:54 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, Mar 25, 2015 at 8:56 PM, Abhiram R abhi.darkn...@gmail.com wrote: On Mar 26, 2015 5:39 AM, Ian Kelly ian.g.ke...@gmail.com wrote: $ cat sudoku2.dat . . . 7 . . . . . 1 . . . .

Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Frank Millman fr...@chagford.com: Here is another python-based sudoku solver - http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py From its docstring - A proper Sudoku puzzle must have a unique solution, and it should be possible to reach that solution by a sequence of logical deductions

Re: Sudoku solver

2015-03-26 Thread Chris Angelico
On Thu, Mar 26, 2015 at 11:26 PM, Marko Rauhamaa ma...@pacujo.net wrote: Frank Millman fr...@chagford.com: Here is another python-based sudoku solver - http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py From its docstring - A proper Sudoku puzzle must have a unique solution, and it should be

Re: Sudoku solver

2015-03-26 Thread Ian Kelly
On Mar 26, 2015 6:31 AM, Marko Rauhamaa ma...@pacujo.net wrote: Frank Millman fr...@chagford.com: Here is another python-based sudoku solver - http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py From its docstring - A proper Sudoku puzzle must have a unique solution, and it should be

Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: On Thu, Mar 26, 2015 at 9:48 AM, Marko Rauhamaa ma...@pacujo.net wrote: In fact, the trial-and-error technique is used in automated theorem proving: Lean provers are generally implemented in Prolog, and make proficient use of the backtracking engine and

Re: Sudoku solver

2015-03-26 Thread Ian Kelly
On Thu, Mar 26, 2015 at 9:48 AM, Marko Rauhamaa ma...@pacujo.net wrote: Ian Kelly ian.g.ke...@gmail.com: On Thu, Mar 26, 2015 at 8:23 AM, Marko Rauhamaa ma...@pacujo.net wrote: That's trial and error, aka, reductio ad absurdum. Okay, I've probably used single-lookahead trial and error in my

Re: Sudoku solver

2015-03-26 Thread Pete Forman
Here's my Python sudoku solver which I wrote about 10 years ago. http://petef.22web.org/sudoku/ It works by applying the solving techniques I came up with. No trial and error or backtracking is used, so it is not up to cracking the very hardest puzzles. Run time is 15 ms to 45 ms on a 2009

Re: Sudoku solver

2015-03-26 Thread Chris Angelico
On Fri, Mar 27, 2015 at 1:14 AM, Dave Angel da...@davea.name wrote: On 03/26/2015 08:37 AM, Chris Angelico wrote: Nothing. And solving a Sudoku puzzle - or any other puzzle - should require no guessing. It should be possible to solve purely by logic. Same goes for every other kind of puzzle

Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Dave Angel da...@davea.name: When in a playful mood, I wonder if all the Sudoku puzzles out there are just permutations of a few hundred written by Will Shortz. A sudoku solver can be trivially turned into a puzzle generator:

Re: Sudoku solver

2015-03-26 Thread Dave Angel
On 03/26/2015 10:41 AM, Chris Angelico wrote: that's already been proven. So, that's why I would avoid guessing. I've written a lot of solvers for various puzzles. Minesweeper, Sudoku, a binary Sudoku-like puzzle that I don't really have a good name for, several others. Every time, I've tried

Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Marko Rauhamaa ma...@pacujo.net: I have optimized my solution slightly: 1. precalculated integer division operations (big savings) 2. interned integers (little savings) The example above now finishes in 41 minutes on my computer. (The C version finishes in 13 seconds). Any considered

Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: On Thu, Mar 26, 2015 at 8:23 AM, Marko Rauhamaa ma...@pacujo.net wrote: That's trial and error, aka, reductio ad absurdum. Okay, I've probably used single-lookahead trial and error in my reasoning at some point. But the example you give is equivalent to the

Re: Sudoku solver

2015-03-26 Thread Dave Angel
On 03/26/2015 08:37 AM, Chris Angelico wrote: On Thu, Mar 26, 2015 at 11:26 PM, Marko Rauhamaa ma...@pacujo.net wrote: Frank Millman fr...@chagford.com: Here is another python-based sudoku solver - http://www.ics.uci.edu/~eppstein/PADS/Sudoku.py From its docstring - A proper Sudoku puzzle

Re: Sudoku solver

2015-03-26 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: I don't think that I have used trial and error, in my head or otherwise, in any sudoku I have ever solved. Of course you have. This here can't be a 2 because if it were a 2, that there would have to be a 5, which is impossible. Thus, the only remaining

Re: Sudoku solver

2015-03-26 Thread Chris Angelico
On Fri, Mar 27, 2015 at 2:03 AM, Dave Angel da...@davea.name wrote: On 03/26/2015 10:41 AM, Chris Angelico wrote: that's already been proven. So, that's why I would avoid guessing. I've written a lot of solvers for various puzzles. Minesweeper, Sudoku, a binary Sudoku-like puzzle that I

Re: Sudoku solver

2015-03-26 Thread Ian Kelly
On Thu, Mar 26, 2015 at 8:23 AM, Marko Rauhamaa ma...@pacujo.net wrote: Ian Kelly ian.g.ke...@gmail.com: I don't think that I have used trial and error, in my head or otherwise, in any sudoku I have ever solved. Of course you have. This here can't be a 2 because if it were a 2, that there

Re: Sudoku solver

2015-03-25 Thread Marko Rauhamaa
John Ladasky john_lada...@sbcglobal.net: On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: I post below a sudoku solver. I eagerly await neater implementations (as well as bug reports). So, it's a brute-force, recursive solver? The code is nice and short. But I bet it

Re: Sudoku solver

2015-03-25 Thread John Ladasky
On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: I post below a sudoku solver. I eagerly await neater implementations (as well as bug reports). So, it's a brute-force, recursive solver? The code is nice and short. But I bet it takes a long time to run. I and a

Re: Sudoku solver

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 12:44 PM, John Ladasky john_lada...@sbcglobal.net wrote: On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: I post below a sudoku solver. I eagerly await neater implementations (as well as bug reports). So, it's a brute-force, recursive solver?

Re: Sudoku solver

2015-03-25 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: The test puzzle that you posted has 23 values already filled in. How does it perform on harder puzzles with only 17 clues (the proven minimum)? One would expect it to be around a million times slower. Just try it. The example had a minimum of clues (drop one

Re: Sudoku solver

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 1:37 PM, Marko Rauhamaa ma...@pacujo.net wrote: John Ladasky john_lada...@sbcglobal.net: On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote: I post below a sudoku solver. I eagerly await neater implementations (as well as bug reports). So, it's a

Re: Sudoku solver

2015-03-25 Thread Chris Angelico
On Thu, Mar 26, 2015 at 7:31 AM, Marko Rauhamaa ma...@pacujo.net wrote: Ian Kelly ian.g.ke...@gmail.com: The test puzzle that you posted has 23 values already filled in. How does it perform on harder puzzles with only 17 clues (the proven minimum)? One would expect it to be around a million

Re: Sudoku solver

2015-03-25 Thread Steven D'Aprano
On Wed, 25 Mar 2015 10:39 pm, Marko Rauhamaa wrote: I have yet to find practical use for fibonacci numbers. Many people have failed to find practical uses for many things from mathematics. Doesn't mean they don't exist: http://en.wikipedia.org/wiki/Fibonacci_number#Applications -- Steven

Re: Sudoku solver

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 2:31 PM, Marko Rauhamaa ma...@pacujo.net wrote: Ian Kelly ian.g.ke...@gmail.com: The test puzzle that you posted has 23 values already filled in. How does it perform on harder puzzles with only 17 clues (the proven minimum)? One would expect it to be around a million

Re: Sudoku solver

2015-03-25 Thread Mark Lawrence
On 25/03/2015 22:50, Steven D'Aprano wrote: On Wed, 25 Mar 2015 10:39 pm, Marko Rauhamaa wrote: I have yet to find practical use for fibonacci numbers. Many people have failed to find practical uses for many things from mathematics. Doesn't mean they don't exist:

Re: Sudoku solver

2015-03-25 Thread Abhiram R
On Mar 26, 2015 5:39 AM, Ian Kelly ian.g.ke...@gmail.com wrote: Hard for a human doesn't necessarily mean hard for a programmatic solver in this case. Try your solver on this one: $ cat sudoku2.dat . . . 7 . . . . . 1 . . . . . . . . . . . 4 3 . 2 . . . . . . . . . . 6 . . . 5 . 9 . . .

Re: Sudoku solver

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 8:56 PM, Abhiram R abhi.darkn...@gmail.com wrote: On Mar 26, 2015 5:39 AM, Ian Kelly ian.g.ke...@gmail.com wrote: Hard for a human doesn't necessarily mean hard for a programmatic solver in this case. Try your solver on this one: $ cat sudoku2.dat . . . 7 . . . . .

Re: Sudoku solver

2015-03-25 Thread Abhiram R
On Thu, Mar 26, 2015 at 8:54 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, Mar 25, 2015 at 8:56 PM, Abhiram R abhi.darkn...@gmail.com wrote: On Mar 26, 2015 5:39 AM, Ian Kelly ian.g.ke...@gmail.com wrote: Hard for a human doesn't necessarily mean hard for a programmatic solver in this

Re: Sudoku

2013-03-31 Thread Eric Parry
On Sunday, March 31, 2013 9:45:36 AM UTC+10:30, Dave Angel wrote: On 03/30/2013 06:06 PM, Eric Parry wrote: On Saturday, March 30, 2013 8:41:08 AM UTC+10:30, Dave Angel wrote: On 03/29/2013 05:47 PM, Eric Parry wrote: SNIP Sometimes a bug in such a function will cause it

Re: Sudoku

2013-03-31 Thread Eric Parry
On Monday, April 1, 2013 8:33:47 AM UTC+10:30, Eric Parry wrote: On Sunday, March 31, 2013 9:45:36 AM UTC+10:30, Dave Angel wrote: On 03/30/2013 06:06 PM, Eric Parry wrote: On Saturday, March 30, 2013 8:41:08 AM UTC+10:30, Dave Angel wrote: On 03/29/2013 05:47 PM, Eric

Re: Sudoku

2013-03-31 Thread Dave Angel
On 03/31/2013 06:03 PM, Eric Parry wrote: SNIP I think in the original it was exit(a). That did not work either. There you go again. Did not work tells us very little. With my Python 2.7.2, exit(something) with something being a string prints the string and then exits. Nowhere have

Re: Sudoku

2013-03-31 Thread Chris Angelico
On Mon, Apr 1, 2013 at 9:27 AM, Eric Parry joan4e...@gmail.com wrote: [ chomp 128 lines of quoted text ] I tried all those things. The program keeps running after the solution in every case. Never mind. It won't do that in VBA when I finish it. Eric. You have just spammed us with, and I

Re: Sudoku

2013-03-31 Thread Arnaud Delobelle
On 31 March 2013 23:34, Dave Angel da...@davea.name wrote: [...] With my Python 2.7.2, exit(something) with something being a string prints the string and then exits. Nowhere have I seen that documented, and I thought it either took an int or nothing. It is documented, just not exactly where

Re: Sudoku

2013-03-31 Thread Eric Parry
Sorry. Won't happen again. signing off this topic. Eric. -- http://mail.python.org/mailman/listinfo/python-list

Re: Sudoku

2013-03-30 Thread Eric Parry
On Saturday, March 30, 2013 8:41:08 AM UTC+10:30, Dave Angel wrote: On 03/29/2013 05:47 PM, Eric Parry wrote: SNIP That explains why the program keeps running after a solution is found. A recursive function can be designed to find all solutions, in which case it would

Re: Sudoku

2013-03-30 Thread Dave Angel
On 03/30/2013 06:06 PM, Eric Parry wrote: On Saturday, March 30, 2013 8:41:08 AM UTC+10:30, Dave Angel wrote: On 03/29/2013 05:47 PM, Eric Parry wrote: SNIP Sometimes a bug in such a function will cause it to run indefinitely, and/or to overflow the stack. I don't see such a bug in this

Re: Sudoku

2013-03-29 Thread Chris Angelico
On Fri, Mar 29, 2013 at 9:11 AM, Eric Parry joan4e...@gmail.com wrote: Thank you for that explanation. No, I do not understand recursion. It is missing from my Python manual. I would be pleased to receive further explanation from anyone. If you already know what recursion is, just remember

Re: Sudoku

2013-03-29 Thread Eric Parry
On Friday, March 29, 2013 9:15:36 AM UTC+10:30, Chris Angelico wrote: On Fri, Mar 29, 2013 at 9:11 AM, Eric Parry joan4e...@gmail.com wrote: Thank you for that explanation. No, I do not understand recursion. It is missing from my Python manual. I would be pleased to receive further

Re: Sudoku

2013-03-29 Thread Dave Angel
On 03/29/2013 05:47 PM, Eric Parry wrote: SNIP That explains why the program keeps running after a solution is found. A recursive function can be designed to find all solutions, in which case it would (as you say) keep running. The function you posted in the first place uses exit() to

Re: Sudoku

2013-03-28 Thread Eric Parry
On Thursday, March 28, 2013 3:06:02 PM UTC+10:30, Dave Angel wrote: On 03/27/2013 11:00 PM, Eric Parry wrote: On Wednesday, March 27, 2013 6:28:01 PM UTC+10:30, Ulrich Eckhardt wrote: SNIP the double-spaced garbage that GoogleGroups put in - see

Re: Sudoku

2013-03-28 Thread Dave Angel
On 03/28/2013 06:11 PM, Eric Parry wrote: On Thursday, March 28, 2013 3:06:02 PM UTC+10:30, Dave Angel wrote: SNIP Are you familiar with recursion? Notice the last line in the function r() calls the function r() inside a for loop. So when r() returns, you're back inside the next level

Re: Sudoku

2013-03-28 Thread Eric Parry
On Friday, March 29, 2013 9:58:27 AM UTC+10:30, Dave Angel wrote: On 03/28/2013 06:11 PM, Eric Parry wrote: On Thursday, March 28, 2013 3:06:02 PM UTC+10:30, Dave Angel wrote: SNIP Are you familiar with recursion? Notice the last line in the function r() calls

Re: Sudoku

2013-03-27 Thread Ulrich Eckhardt
Am 27.03.2013 06:44, schrieb Eric Parry: I downloaded the following program from somewhere using a link from Wikipedia and inserted the “most difficult Sudoku puzzle ever” string into it and ran it. It worked fine and solved the puzzle in about 4 seconds. However I cannot understand how it

Re: Sudoku

2013-03-27 Thread Damien Wyart
* Eric Parry joan4e...@gmail.com in comp.lang.python: I downloaded the following program from somewhere using a link from Wikipedia and inserted the “most difficult Sudoku puzzle ever” string into it and ran it. It worked fine and solved the puzzle in about 4 seconds. However I cannot

Re: Sudoku

2013-03-27 Thread Dave Angel
On 03/27/2013 01:44 AM, Eric Parry wrote: I downloaded the following program from somewhere It'd be good to show where you found it, and credit the apparent author. Bill Barksdale posted this in 2008 at:

  1   2   >