Fixes
This commit is contained in:
@@ -2,12 +2,12 @@ import itertools
|
||||
|
||||
def combinations(target, size, exclude):
|
||||
result = []
|
||||
possible = [i for i in range(1, target) if i not in exclude]
|
||||
if size == 1:
|
||||
return [[target]]
|
||||
else:
|
||||
for i in range(len(possible), 0, -1):
|
||||
for seq in itertools.combinations(possible, i):
|
||||
possible = [index for index in range(1, int((target ** 2 / size) ** 0.6)) if index not in exclude]
|
||||
for index in range(len(possible), 0, -1):
|
||||
for seq in itertools.combinations(possible, index):
|
||||
if sum(seq) == target and len(seq) == size:
|
||||
result.append(list(seq))
|
||||
return result
|
||||
|
||||
@@ -1,13 +1,2 @@
|
||||
import itertools
|
||||
|
||||
def combinations(target, size, exclude):
|
||||
result = []
|
||||
if size == 1:
|
||||
return [[target]]
|
||||
else:
|
||||
possible = [index for index in range(1, int((target ** 2 / size) ** 0.6)) if index not in exclude]
|
||||
for index in range(len(possible), 0, -1):
|
||||
for seq in itertools.combinations(possible, index):
|
||||
if sum(seq) == target and len(seq) == size:
|
||||
result.append(list(seq))
|
||||
return result
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user