An open API service indexing awesome lists of open source software.

https://github.com/umarquez/summing_nums

This code extracts all the combinations of a list of numbers which sums the given total
https://github.com/umarquez/summing_nums

Last synced: about 1 year ago
JSON representation

This code extracts all the combinations of a list of numbers which sums the given total

Awesome Lists containing this project

README

          

# summing_nums
This code extracts all the combinations of a list of numbers which sums the given total

## Problem
Write a function which would take two variables as input

- Variable 1(a list of numbers) - example [1, 2, 4, 7, 9, 11]
- Variable 2(a target number) - example 11
- Output - Return a list of all the combinations of numbers given in input 1 which adds up to target. The result of the above inputs would be [[4,7], [9,2], [11]].

### More examples:

- Input :- Variable 1 = [-1, 2, 5, 6] , Variable 2 = 5; Output = [[-1,6], [5]]
- Input :- Variable 1 = [1,4,5] Variable 2 = [13]; Output = None

## Assumptions:-
For simplicity assume the below :

- The list in input variable 1 contains only integers.