Created
August 10, 2014 21:53
-
-
Save okoye/d1b59ffd10eaa08c1f38 to your computer and use it in GitHub Desktop.
A pseudocode implementation of the bruteforce approach to a subset-sum problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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