Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.118 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.76; '*S*': 0.00; 'wednesday,': 0.07; 'function,': 0.09; 'logic': 0.09; 'returns,': 0.09; 'eckhardt': 0.16; 'loop.': 0.16; 'nonzero': 0.16; 'received:74.208.4.195': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'entered': 0.20; 'solution.': 0.20; 'candidates': 0.23; 'header:User-Agent:1': 0.23; 'url:moin': 0.24; 'excel': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'especially': 0.30; 'code': 0.31; 'comments': 0.31; 'url:wiki': 0.31; 'this.': 0.32; 'url:python': 0.33; 'noticed': 0.34; 'could': 0.34; 'but': 0.35; 'doing': 0.36; 'next': 0.36; 'entry': 0.36; 'url:org': 0.36; 'example,': 0.37; 'so,': 0.37; 'level': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'previous': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'negative': 0.60; 'march': 0.61; "you're": 0.61; 'back': 0.62; "you'll": 0.62; 'more': 0.64; 'levels': 0.65; 'charset:windows-1252': 0.65; 'received:74.208': 0.68; 'hoping': 0.75; 'discover': 0.82; 'aspect.': 0.84; 'vba': 0.84; 'directly.': 0.95; '2013': 0.98 Date: Thu, 28 Mar 2013 00:36:02 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Sudoku References: <9dla2a-kql.ln1@satorlaser.homedns.org> <5ce10a13-be58-4548-85df-e1d865d3304e@googlegroups.com> In-Reply-To: <5ce10a13-be58-4548-85df-e1d865d3304e@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:xDdmEw8A5RZ6RzDik4PipHsfqA+p6ZDNRfGa5sB4ZeQ /0uAlP0WTICo2694LtHOrw0gdPxlJ/vIufpZa9JF/tXz7qWra0 TyQd/GlmrXHKXq45Ftsm6Aj+eP1b55VgiJessmUNw/Ga4tBxjW ymJb0mDucAIgjt6Miqjbnn9nIjxpH+GbIjpjTdkg6QQNBwuCBA rxRgR+PuQUrd+Urqu1L3MTaihNPNiw6UJ0FvEgaJ1lUmYsgqQx KLlqBi6lNulslpbiw5PwMlX7tOQn3S2QNWaKjvCCBqMzOnYC+H FlxgVTgLemqPb8bQw5BnTlw+xi17FOrrdvfL3KU4mYw+Sscjg= = 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: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364445382 news.xs4all.nl 6881 [2001:888:2000:d::a6]:54537 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42095 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: >> > > Thank you for your explanation. > I noticed that in this particular puzzle when it ran out of candidates in a particular cycle, it then changed the last entry to the next one in line in the previous cycle. But I cannot find any code to do this. > I was hoping to understand the logic so that I could re-write it in VBA for excel which would enable any puzzle to be entered directly. > Your comments are a big help especially the double negative aspect. > 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 up of the function, and doing a "backtrack." When the function succeeds, it will be many levels of recursion deep. For example, if the original pattern had 30 nonzero items in it, or 51 zeroes, you'll be 51 levels of recursion when you discover a solution. If you don't already understand recursion at all, then say so, and one or more of us will try to explain it in more depth. -- DaveA