Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
get_sets_of_sum
import copy def get_sets_of_sum(numbers, k, possible_set, result): if k == 0: if sorted(possible_set) not in result : result.append( sorted(possible_set)) elif k < 0: return else: for n in numbers: new_set = copy.copy(possible_set) new_set.append(n) new_numbers = copy.copy(numbers) new_numbers.remove(n) get_sets_of_sum(new_numbers, k-n, new_set, result) k = 10 possible_set = [] numbers = list(range(1,10)) result = [] get_sets_of_sum(numbers, k, possible_set, result) print(result)
run
|
edit
|
history
|
help
0
double
E
1
abc
if else
gj4
gj
Temp
E
shuru15