Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'subject:question': 0.10; 'def': 0.12; '8bit%:32': 0.16; 'c):': 0.16; 'count.': 0.16; 'subject:broken': 0.16; 'example': 0.22; 'tests': 0.22; 'to:name:python-list@python.org': 0.22; 'values': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'towards': 0.31; '13,': 0.31; 'anyone': 0.31; 'problem': 0.35; 'test': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'example,': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'show': 0.63; 'sum': 0.64; '13)': 0.84; '13:': 0.84; 'sum.': 0.84; '-\xc2\xa0': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=BNNPFpLGIks6ejgNsRgqZVMcWCEGNukI2P8C55QGk1U=; b=1AQgoh9a2zStBSQTtxgynJCYFR1L/PtVxFS+exo21q6QcK/c6pjjmZ/x1ikGRc9MSa 99zI5zw/73PV5ldUPSk9+CDvAjrA6CSpDa+tNaex8HFgqv4zoR3/paEsVBgjoM6zOHn9 wuYR0YuT5/K8XQChdmPYzDDUvnZrTjrjhsqpX3hpjdItWHAbxB+Nhi5Zzb1+I9CkwnNn AMcHp4pFXIvVR4qywgtjwjpRBU1neb9FscRIaZfcM8MgcQ6eIWr35l77LdxDoYhOF8ov 53LUsKENPk31fhywAlkbif7QXPVwrUUl3RtcEccyrnvA7Mt4e+Ed46sL8faArVuXGEHl IZ2Q== X-Received: by 10.182.60.225 with SMTP id k1mr9078330obr.48.1405217165800; Sat, 12 Jul 2014 19:06:05 -0700 (PDT) MIME-Version: 1.0 From: Rodrick Brown Date: Sat, 12 Jul 2014 22:05:34 -0400 Subject: codingbat question broken? To: "python-list@python.org" Content-Type: multipart/alternative; boundary=089e0158c97efff98004fe099d6f 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: 125 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405217673 news.xs4all.nl 2896 [2001:888:2000:d::a6]:43910 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74393 --089e0158c97efff98004fe099d6f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I'm working on the following problem set from codingbat.com http://codingbat.com/prob/p107863 Given 3 int values, a b c, return their sum. However, if one of the values is 13 then it does not count towards the sum and values to its right do not count. So for example, if b is 13, then both b and c do not count. lucky_sum(1, 2, 3) =E2=86=92 6 lucky_sum(1, 2, 13) =E2=86=92 3 lucky_sum(1, 13, 3) =E2=86=92 1 The solution I came up with was - def lucky_sum(a, b, c): t =3D 0 for ints in (a, b, c): if a =3D=3D 13: t =3D b + c elif b =3D=3D 13: t =3D a elif c =3D=3D 13: t =3D a + b else: t =3D a + b + c return t However the following tests fail lucky_sum(13, 2, 3) =E2=86=92 05X lucky_sum(13, 2, 13) =E2=86=92 015X = lucky_sum(13, 13, 2) =E2=86=92 015X Can anyone show me an example where all test are success? --089e0158c97efff98004fe099d6f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm working on the following problem set fro= m codingbat.com=C2=A0

Given 3 int values, a b c, return their sum. However, if = one of the values is 13 then it does not count towards the sum and values t= o its right do not count. So for example, if b is 13, then both b and c do = not count.=C2=A0

lucky_sum(1, 2, 3) =E2=86=92 6
lucky_sum(1, 2, 13) =E2=86=92 3
lucky_sum(1, 13, 3) =E2= =86=92 1

The solution I came up with was -=C2= =A0

def lucky_sum(a, b, c):
=
=C2= =A0 t =3D 0
=C2=A0 for ints in (a, b, c):
=C2=A0 =C2=A0 if a =3D=3D 13:
=C2=A0 =C2=A0 =C2=A0 t =3D b + c
=C2=A0 =C2=A0 e= lif b =3D=3D 13:
=C2= =A0 =C2=A0 =C2=A0 t =3D a=C2=A0
=C2=A0 =C2=A0 elif c =3D= =3D 13:=C2=A0
=C2=A0 =C2=A0 =C2=A0 t =3D a + b
=C2=A0 =C2=A0 else:
=C2=A0 =C2=A0 =C2=A0 t =3D a = + b + c
=C2= =A0 return t=C2=A0

How= ever the following tests fail=C2=A0

lucky_sum= (13, 2, 3) =E2=86=92 05X=C2=A0= =C2=A0=C2=A0=C2=A0
lucky_sum(13, 2, 13) =E2=86=92 015X=C2=A0=C2=A0=C2=A0=C2=A0
lucky_sum(13, 13, 2) =E2= =86=92 015X=C2=A0 =C2=A0

Can anyone show me an example wh= ere all test are success?=C2=A0

--089e0158c97efff98004fe099d6f--