Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74393
| 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 | <rodrick.brown@gmail.com> |
| 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 <rodrick.brown@gmail.com> |
| Date | Sat, 12 Jul 2014 22:05:34 -0400 |
| Subject | codingbat question broken? |
| To | "python-list@python.org" <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 <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11781.1405217673.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
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) → 6
lucky_sum(1, 2, 13) → 3
lucky_sum(1, 13, 3) → 1
The solution I came up with was -
def lucky_sum(a, b, c):
t = 0
for ints in (a, b, c):
if a == 13:
t = b + c
elif b == 13:
t = a
elif c == 13:
t = a + b
else:
t = a + b + c
return t
However the following tests fail
lucky_sum(13, 2, 3) → 05X lucky_sum(13, 2, 13) → 015X lucky_sum(13,
13, 2) → 015X
Can anyone show me an example where all test are success?
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
codingbat question broken? Rodrick Brown <rodrick.brown@gmail.com> - 2014-07-12 22:05 -0400
csiph-web