Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42225

Re: Sudoku

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joan4eric@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'suppose': 0.07; '"r"': 0.09; 'explanation': 0.09; 'friday,': 0.09; 'function,': 0.09; 'parameter': 0.09; 'returns,': 0.09; 'specified,': 0.09; 'term,': 0.09; 'to:addr:comp.lang.python': 0.09; 'val': 0.09; 'way:': 0.09; 'windows,': 0.09; 'translate': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'command.': 0.16; 'definition.': 0.16; 'integer,': 0.16; 'integer.': 0.16; 'loop.': 0.16; 'nonzero': 0.16; 'zero,': 0.16; 'applies': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'all,': 0.19; 'meant': 0.20; 'solution.': 0.20; 'command': 0.22; 'code,': 0.22; 'programming': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'integer': 0.24; 'specify': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'switch': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'bigger': 0.30; 'matching': 0.30; 'closer': 0.31; 'implied': 0.31; 'linux.': 0.31; 'stands': 0.31; 'another': 0.32; 'definition': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'building': 0.35; 'doing': 0.36; 'next': 0.36; 'example,': 0.37; 'so,': 0.37; 'level': 0.37; 'thank': 0.38; 'needed': 0.38; 'files': 0.38; 'pm,': 0.38; 'explain': 0.39; 'does': 0.39; 'itself': 0.39; 'dave': 0.60; 'march': 0.61; 'skip:* 10': 0.61; "you're": 0.61; 'further': 0.61; 'first': 0.61; 'back': 0.62; "you'll": 0.62; 'skip:n 10': 0.64; 'more': 0.64; 'levels': 0.65; 'receive': 0.70; 'anyone.': 0.74; 'discover': 0.82; 'vba': 0.84; 'angel': 0.91; '2013': 0.98
X-Received by 10.50.217.225 with SMTP id pb1mr2376506igc.5.1364533647508; Thu, 28 Mar 2013 22:07:27 -0700 (PDT)
Newsgroups comp.lang.python
Date Thu, 28 Mar 2013 22:07:27 -0700 (PDT)
In-Reply-To <mailman.3924.1364513332.2939.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=122.151.65.43; posting-account=JzVE4wkAAADCSo8EXJLK0dGqAu47aMvq
References <e45b8b75-ff89-4ee1-9ada-bfda3d06d05d@googlegroups.com> <9dla2a-kql.ln1@satorlaser.homedns.org> <5ce10a13-be58-4548-85df-e1d865d3304e@googlegroups.com> <mailman.3857.1364445382.2939.python-list@python.org> <f160e316-e2f6-4314-827e-9d48007f7f70@googlegroups.com> <mailman.3924.1364513332.2939.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 122.151.65.43
MIME-Version 1.0
Subject Re: Sudoku
From Eric Parry <joan4eric@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.3938.1364535726.2939.python-list@python.org> (permalink)
Lines 131
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364535726 news.xs4all.nl 6847 [2001:888:2000:d::a6]:57315
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42225

Show key headers only | View raw


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 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.
> 
> >>
> 
>        <SNIP>
> 
> >
> 
> > 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.
> 
> > Eric.
> 
> >
> 
> 
> 
> Recursion is not limited to Python.  It's a general programming term, 
> 
> and indeed applies in other situations as well.  Suppose you wanted to 
> 
> explain what the -r switch meant in the cp command.  "r" stands for 
> 
> recursion.
> 
> 
> 
> (example is from Linux.  But if you're more familiar with Windows, it's 
> 
> the /s switch in the DIR command.)
> 
> 
> 
> The cp command copies all the matching files in one directory to another 
> 
> one.  If the -r switch is specified, it then does the same thing to each 
> 
> subdirectory.
> 
> 
> 
> Notice we did NOT have to specify sub-subdirectories, since they're 
> 
> recursively implied by the first description.
> 
> 
> 
> 
> 
> Closer to the current problem, suppose you defined factorial in the 
> 
> following way:  factorial(0) is 1, by definition.  And for all n>0, 
> 
> factorial(n) is n*factorial(n-1).
> 
> 
> 
> So to directly translate this definition to code, you write a function 
> 
> factorial() which takes an integer and returns an integer.  If the 
> 
> parameter is zero, return one.  If the parameter is bigger than zero, 
> 
> then the function calls itself with a smaller integer, building up the 
> 
> answer as needed  (untested).
> 
> 
> 
> def  factorial(n):
> 
>      if n==0:
> 
>          return 1
> 
>      val = n *factorial(n-1)
> 
>      return val
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> DaveA

Thank you for that Dave, I've started writing the VBA code.
Eric.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-26 22:44 -0700
  Re: Sudoku Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-03-27 08:58 +0100
    Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-27 20:00 -0700
      Re: Sudoku Dave Angel <davea@davea.name> - 2013-03-28 00:36 -0400
        Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-28 15:11 -0700
          Re: Sudoku Dave Angel <davea@davea.name> - 2013-03-28 19:28 -0400
            Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-28 22:07 -0700
            Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-28 22:07 -0700
          Re: Sudoku Chris Angelico <rosuav@gmail.com> - 2013-03-29 09:45 +1100
            Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-29 14:47 -0700
              Re: Sudoku Dave Angel <davea@davea.name> - 2013-03-29 18:11 -0400
                Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-30 15:06 -0700
                Re: Sudoku Dave Angel <davea@davea.name> - 2013-03-30 19:15 -0400
                Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-31 15:03 -0700
                Re: Sudoku Dave Angel <davea@davea.name> - 2013-03-31 18:34 -0400
                Re: Sudoku Arnaud Delobelle <arnodel@gmail.com> - 2013-03-31 23:59 +0100
                Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-31 15:03 -0700
                Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-31 15:27 -0700
                Re: Sudoku Chris Angelico <rosuav@gmail.com> - 2013-04-01 09:35 +1100
                Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-31 20:58 -0700
                Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-31 15:27 -0700
                Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-30 15:06 -0700
            Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-29 14:47 -0700
        Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-28 15:11 -0700
  Re: Sudoku Damien Wyart <damien.wyart@free.fr> - 2013-03-27 09:49 +0100
  Re: Sudoku Dave Angel <davea@davea.name> - 2013-03-27 05:38 -0400
  Re: Sudoku Eric Parry <joan4eric@gmail.com> - 2013-03-27 19:49 -0700

csiph-web