Compare commits

..

No commits in common. "d053352d957992081733a3aafb60fae8d2f2551d" and "d7437a22b6e7fa397af7b90eec6cc9ea76502536" have entirely different histories.

View File

@ -28,20 +28,22 @@ def split_list(timings: list) -> tuple:
def split_workload(arr: list) -> tuple:
if len(arr) == 0:
return ([], [], 0)
if len(arr) == 1:
return ([arr[0]], [], 1)
result = ([], [], 0)
elif len(arr) == 1:
result = ([arr[0]], [], 1)
else:
n = len(arr)
smallest_diff = float("inf")
if any(c < 0 for c in arr):
raise ValueError("Numbers can only be non-negative")
all_nums_positive = [c >= 0 for c in arr]
if False in all_nums_positive:
raise ValueError("numbers can only be positive")
for i in range(1, 2**n - 1):
indices = [j for j in range(n) if (i & (1 << j)) != 0]
distributed_timings_1 = [arr[j] for j in indices]
distributed_timings_2 = [arr[j] for j in range(n) if j not in indices]
diff = abs(sum(distributed_timings_1) - sum(distributed_timings_2))
smallest_diff = min(smallest_diff, diff)
if diff < smallest_diff:
smallest_diff = diff
result = (
distributed_timings_1,
distributed_timings_2,