Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed3a.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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Function': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'def': 0.12; 'courses:': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; '"': 0.31; 'url:python': 0.33; 'received:google.com': 0.35; 'choosing': 0.36; 'url:listinfo': 0.36; "didn't": 0.36; 'url:org': 0.36; '12,': 0.39; 'changed': 0.39; 'url:mail': 0.40; 'for:': 0.64; 'to:addr:gmail.com': 0.65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WqRIYTVGau4qfTN5G16NL5Pa7v+vZYn3T6JxN6pHrwg=; b=cx3GyD2fnxnbfrLUouR5H+DEuzM91KlFPQRTb7b6o6rin5A7OB+yogM3uTGA6NCx25 kfU713eSvuay1xHLwmHISB561RShADGbINZH2NpqCthXieoKQP9CmX36aJL/aosIFqGN FULuI+BF2FlrulcG65WQ6JXrsHTFeZx5nXOIVjOO2g14I/mrPTaJRmbXcNGshKjdFQhr PCAKCWySuV0lQa5cexCbCfSpGdK7PZ0i1d/Pdclr+nuP4czVUGdw69yaBjdZQFMijRan dTZ+GlpYpPmcOM1YLnT6TNwRT4VBchBnl9xSqTC5B4BY8ahqu8oO9RI1WqTNptP9QaDC Dv/w== MIME-Version: 1.0 X-Received: by 10.58.133.15 with SMTP id oy15mr32483834veb.19.1392222086398; Wed, 12 Feb 2014 08:21:26 -0800 (PST) In-Reply-To: <11e9f551-f920-428c-895d-a5d19a4d7734@googlegroups.com> References: <11e9f551-f920-428c-895d-a5d19a4d7734@googlegroups.com> Date: Wed, 12 Feb 2014 11:21:26 -0500 Subject: Re: Combination Function Help From: Joel Goldstick To: kjakupak@gmail.com Content-Type: multipart/alternative; boundary=047d7b6d9f82ea417e04f237f675 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: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392222089 news.xs4all.nl 2862 [2001:888:2000:d::a6]:42223 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66051 --047d7b6d9f82ea417e04f237f675 Content-Type: text/plain; charset=UTF-8 Y On Feb 12, 2014 11:00 AM, wrote: > > def choices(n, k): > if k == 1: > return n > if n == k: > return 1 > if k == 0: > return 1 > return choices(n - 1, k) + choices(n - 1, k - 1) Following line never runs > print ("Total number of ways of choosing %d out of %d courses: " % (n, k)) > > n = int(input("Number of courses you like: ")) > k = int(input("Number of courses you can register for: ")) > choices(n, k) > > Changed it like you said, didn't work > -- > https://mail.python.org/mailman/listinfo/python-list --047d7b6d9f82ea417e04f237f675 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Y
On Feb 12, 2014 11:00 AM, <kjakupa= k@gmail.com> wrote:
>
> def choices(n, k):
> =C2=A0 =C2=A0 if k =3D=3D 1:
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return n
> =C2=A0 =C2=A0 if n =3D=3D k:
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1
> =C2=A0 =C2=A0 if k =3D=3D 0:
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1
> =C2=A0 =C2=A0 return choices(n - 1, k) + choices(n - 1, k - 1)
Following line never runs
> =C2=A0 =C2=A0 print ("Total number of ways of choosing %d out of = %d courses: " % (n, k))
>
> n =3D int(input("Number of courses you like: "))
> k =3D int(input("Number of courses you can register for: "))=
> choices(n, k)
>
> Changed it like you said, didn't work
> --
> https= ://mail.python.org/mailman/listinfo/python-list

--047d7b6d9f82ea417e04f237f675--