Re: codingbat question broken?

2014-07-13 Thread Orochi
On Sunday, 13 July 2014 07:49:18 UTC+5:30, Chris Angelico  wrote:
 On Sun, Jul 13, 2014 at 12:05 PM, Rodrick Brown rodrick.br...@gmail.com 
 wrote:
 
 
 
  Can anyone show me an example where all test are success?
 
 
 
 No, because that's asking for the answer :) What you need to do is
 
 look at the failing test cases, and figure out why your function is
 
 giving the wrong result. Do you see what's true of all the failing
 
 cases and is not true of any others? That might give you a clue as to
 
 what's wrong.
 
 
 
 ChrisA



On Sunday, 13 July 2014 07:49:18 UTC+5:30, Chris Angelico  wrote:
 On Sun, Jul 13, 2014 at 12:05 PM, Rodrick Brown rodrick.br...@gmail.com 
 wrote:
 
 
 
  Can anyone show me an example where all test are success?
 
 
 
 No, because that's asking for the answer :) What you need to do is
 
 look at the failing test cases, and figure out why your function is
 
 giving the wrong result. Do you see what's true of all the failing
 
 cases and is not true of any others? That might give you a clue as to
 
 what's wrong.
 
 
 
 ChrisA

This Is My Code(using Python 2.7)
Its working fine with the given test cases.
#Lucky_Sum
a =[]
def lucky_sum(list):
t = 0
for item in list:
if item == 13:
break
else:
t=t+item
return t

list=[]
type(list)
n = raw_input(Enter Numebr of item in list: )
n = int(n)

for x in range (0,n):
list.append(int(raw_input()))
print List is :,list

print lucky_sum(list)
-- 
https://mail.python.org/mailman/listinfo/python-list


codingbat question broken?

2014-07-12 Thread Rodrick Brown
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) → 015Xlucky_sum(13,
13, 2) → 015X

Can anyone show me an example where all test are success?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: codingbat question broken?

2014-07-12 Thread Chris Angelico
On Sun, Jul 13, 2014 at 12:05 PM, Rodrick Brown rodrick.br...@gmail.com wrote:

 Can anyone show me an example where all test are success?

No, because that's asking for the answer :) What you need to do is
look at the failing test cases, and figure out why your function is
giving the wrong result. Do you see what's true of all the failing
cases and is not true of any others? That might give you a clue as to
what's wrong.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: codingbat question broken?

2014-07-12 Thread Dan Stromberg
This runs on 2.7 or 3.4, unmodified (other than the #!):

#!/usr/local/cpython-2.7/bin/python
#!/usr/local/cpython-3.4/bin/python

def lucky_sum(*list_):
lucky_total = 0
for element in list_:
if element == 13:
break
lucky_total += element
return lucky_total

if __name__ == '__main__':
print('starting tests')
assert lucky_sum(1, 2, 3) == 6
assert lucky_sum(1, 2, 13) == 3
assert lucky_sum(1, 13, 3) == 1
print('ending tests')

On Sat, Jul 12, 2014 at 7:05 PM, Rodrick Brown rodrick.br...@gmail.com
wrote:

 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) → 015Xlucky_sum(13,
 13, 2) → 015X

 Can anyone show me an example where all test are success?


 --
 https://mail.python.org/mailman/listinfo/python-list


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: codingbat question broken?

2014-07-12 Thread Ian Kelly
On Sat, Jul 12, 2014 at 8:05 PM, Rodrick Brown rodrick.br...@gmail.com
wrote:
 if a == 13:
   t = b + c

This looks incorrect. So no, I don't think the problem is with codingbat.
-- 
https://mail.python.org/mailman/listinfo/python-list