Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'stops': 0.07; 'overflow': 0.09; 'stack.': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'bug': 0.12; 'posted': 0.15; 'entries.': 0.16; 'exit()': 0.16; 'parameter.': 0.16; 'say)': 0.16; 'supplied': 0.16; 'wrote:': 0.18; 'stack': 0.19; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'entries': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'pass': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'work.': 0.31; 'code': 0.31; 'crash': 0.31; 'depth': 0.31; 'run': 0.32; 'running': 0.33; 'problem': 0.35; 'received:google.com': 0.35; 'described': 0.36; 'explains': 0.36; 'found.': 0.36; 'example,': 0.37; 'too': 0.37; 'sometimes': 0.38; 'filled': 0.38; 'pm,': 0.38; 'does': 0.39; 'even': 0.60; 'dave': 0.60; 'tell': 0.60; 'march': 0.61; 'first': 0.61; 'such': 0.63; 'soon': 0.63; 'maximum': 0.63; 'more': 0.64; '2000': 0.65; '30,': 0.65; 'angel': 0.91; '2013': 0.98 X-Received: by 10.50.140.65 with SMTP id re1mr207534igb.13.1364681179999; Sat, 30 Mar 2013 15:06:19 -0700 (PDT) Newsgroups: comp.lang.python Date: Sat, 30 Mar 2013 15:06:19 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=122.151.124.22; posting-account=JzVE4wkAAADCSo8EXJLK0dGqAu47aMvq References: <9dla2a-kql.ln1@satorlaser.homedns.org> <5ce10a13-be58-4548-85df-e1d865d3304e@googlegroups.com> <17da5afc-7a9b-40ea-a544-6012dfeef3ce@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 122.151.124.22 MIME-Version: 1.0 Subject: Re: Sudoku From: Eric Parry To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 60 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364681188 news.xs4all.nl 6930 [2001:888:2000:d::a6]:57691 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42352 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: > > > > > >> > > >> > > > 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 avoid keeping > > running. It stops as soon as a solution is found. > > > > Sometimes a problem cannot be solved in the number of stack entries > > supplied by Python. So even though such a function will terminate, it > > may crash first if the problem is too big. Example, the factorial > > problem I described earlier, if you pass it 2000 as a parameter. If > > this is a problem, one can tell the Python to give you more stack entries. > > > > Given a 9x9 matrix, and at least some of them filled in, the maximum > > depth your code can use is less than 81. So it won't get a stack > > overflow in any implementation of Python I've seen. Perhaps in an 8051. > > > > 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 function. > > > > > > -- > > DaveA The exit() did not work. I replaced it with return = 0, and that does work. Eric.