Skip to content

Instantly share code, notes, and snippets.

@okoye
Created August 10, 2014 21:53
Show Gist options
  • Save okoye/d1b59ffd10eaa08c1f38 to your computer and use it in GitHub Desktop.
Save okoye/d1b59ffd10eaa08c1f38 to your computer and use it in GitHub Desktop.
A pseudocode implementation of the bruteforce approach to a subset-sum problem
Input: List numbers, Integer target
Output: List solution
ofSize = 1 #size of combination to generate
while ofSize <= numbers.size:
for each combination in possibleCombinations(numbers, ofSize):
if sum(combination) == target:
return combination
ofSize++
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment