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


Groups > comp.lang.python > #42235

Re: Sudoku

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.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 <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status UNSURE 0.205
X-Spam-Level **
X-Spam-Evidence '*H*': 0.59; '*S*': 0.00; 'calculating': 0.09; 'explanation': 0.09; 'python': 0.11; 'def': 0.12; 'bug': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'helps!': 0.16; 'terminate.': 0.16; 'wrote:': 0.18; 'code.': 0.18; '>>>': 0.22; 'otherwise,': 0.22; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'rest': 0.29; 'am,': 0.29; '(like': 0.30; 'message-id:@mail.gmail.com': 0.30; 'closer': 0.31; 'comparison': 0.31; 'depth': 0.31; 'douglas': 0.31; 'critical': 0.32; 'quite': 0.32; 'fri,': 0.33; 'received:209.85': 0.35; 'case,': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'list.': 0.37; 'received:209': 0.37; 'sometimes': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'eventually': 0.60; 'is.': 0.60; 'simple,': 0.60; 'hope': 0.61; 'numbers': 0.61; 'further': 0.61; 'first': 0.61; 'maximum': 0.63; 'sum': 0.64; 'mar': 0.68; 'answer.': 0.68; 'results': 0.69; 'receive': 0.70; 'anyone.': 0.74; 'obvious': 0.74; 'condition.': 0.84; 'obvious.': 0.84; 'standing': 0.84; 'exceeded': 0.97; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=9qA/zkXjS+TY+VQHUkXxoddN01zPFi3myMpOQ7uyi0I=; b=JK34jhrtJ4WF8oWYxiBYAabMsaMazSj5ki6Y3oLcz0koGOXFuVmbOXMoqg9mfrUtC9 UdhRb+vYJWTGs4CDcFxdBHUJxArB85OS13cpl3/9P79SJMx7J/9YPNnTD9UAKcJJVysV 2fWAj8BMfoYwvVQHQdxLFpSxMR2PJt+DKB2ERI5V+iq0N0n6JbvsntPmHox/1LcaxVxD ruwI4n6JwBYo+EIuu/2JB4XCYrYM11v1Gn+HuWlXcojGsRTs0tw4aXId5AZ7bvxAepbj H6PjTow+JSCCBRntKKbMA5weGiaL+6UbesD72VbaCr+eOTyNM6vIZiQdDZRqgFeIxJ5b OuEQ==
MIME-Version 1.0
X-Received by 10.52.67.164 with SMTP id o4mr324055vdt.42.1364510736142; Thu, 28 Mar 2013 15:45:36 -0700 (PDT)
In-Reply-To <f160e316-e2f6-4314-827e-9d48007f7f70@googlegroups.com>
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>
Date Fri, 29 Mar 2013 09:45:36 +1100
Subject Re: Sudoku
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-Mailman-Approved-At Fri, 29 Mar 2013 12:24:27 +0100
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>
Newsgroups comp.lang.python
Message-ID <mailman.3946.1364556269.2939.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364556269 news.xs4all.nl 6957 [2001:888:2000:d::a6]:45630
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42235

Show key headers only | View raw


On Fri, Mar 29, 2013 at 9:11 AM, Eric Parry <joan4eric@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 the answer.
Otherwise, find someone who is standing closer to Douglas Hofstadter
than you are; then ask him or her what recursion is.

:)

Recursion is a form of self-referential code. Take this simple, and
rather silly, means of calculating the sum of numbers in a list (like
the sum() function):

# The sum of numbers in an empty list is 0.
# Otherwise it is the first number plus the sum of the rest of the list.
def list_sum(lst):
    if not lst: return 0
    return lst[0] + list_sum(lst[1:])

>>> list_sum([1,2,3,4,5,6])
21

Note how the function calls itself - but not always. That's critical
to recursion - a termination condition. In this case, it's quite
obvious that the list will eventually have nothing left in it, so the
function will terminate. Sometimes it's less obvious. Sometimes a bug
results in infinite recursion... and:

RuntimeError: maximum recursion depth exceeded in comparison

Hope that helps!

ChrisA

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