Following recommendations on sorts/split_workload.py

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
This commit is contained in:
Margaret 2023-08-02 17:28:08 +03:00 committed by GitHub
parent 5e6590b85c
commit 4277c8c58a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,7 @@ def split_list(timings: List[Union[int, float, str]]) -> Tuple[List[Union[int, f
all_nums_positive = [c >= 0 for c in timings] all_nums_positive = [c >= 0 for c in timings]
for i in range(1, 2**n - 1): for i in range(1, 2**n - 1):
indices = [j for j in range(n) if (i & (1 << j)) != 0] indices = [j for j in range(n) if (i & (1 << j)) != 0]
distributed_timings_1 = [timings[j] for j in indices] indices = [j for j in range(n) if i & (1 << j) != 0]
distributed_timings_2 = [timings[j] for j in range(n) if j not in indices] distributed_timings_2 = [timings[j] for j in range(n) if j not in indices]
diff = abs(sum(distributed_timings_1) - sum(distributed_timings_2)) diff = abs(sum(distributed_timings_1) - sum(distributed_timings_2))
if diff < smallest_diff: if diff < smallest_diff: