id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

tmhscs@gmail.com python > logic_allPossibleSums
prev  |  next  |  chance

Given a list of integers, return all of the possible sums you could get by picking any number of integers (or none of them) from the list and adding them together.

For example, given an integer list of [1,2,3] you could sum none of them and get 0, or just sum 1 or 2 or 3 individually, or do 1+2=3 or 1+3=4 or 2+3=5 or 1+2+3=6.

Do not include any duplicate possibilities in your answer.


logic_allPossibleSums([1]) → [0, 1]
logic_allPossibleSums([1, 2]) → [0, 1, 2, 3]
logic_allPossibleSums([1, 2, 3]) → [0, 1, 2, 3, 4, 5, 6]

...Save, Compile, Run (ctrl-enter)

def logic_allPossibleSums(data):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Post-solution available

Copyright Nick Parlante 2017 - privacy