mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
Compare commits
No commits in common. "48e0f356769056089caf19584f67762b961cc04b" and "885e8db94a3c7cd85f491da0393bf503bebc56d0" have entirely different histories.
48e0f35676
...
885e8db94a
@ -27,8 +27,8 @@ def split_list(
|
||||
ValueError: Timings must be a list of numbers
|
||||
|
||||
"""
|
||||
valid_timings: list[int | float] = []
|
||||
for current_element in timings:
|
||||
valid_timings = list[int | float]
|
||||
for current_element in enumerate(timings):
|
||||
if (
|
||||
isinstance(current_element, str)
|
||||
and current_element.replace(".", "", 1).isdigit()
|
||||
@ -41,7 +41,6 @@ def split_list(
|
||||
elif isinstance(current_element, (int, float)):
|
||||
valid_timings.append(abs(current_element))
|
||||
else:
|
||||
print(type(current_element))
|
||||
raise ValueError("Timings must be a list of numbers")
|
||||
|
||||
if len(valid_timings) == 0:
|
||||
@ -56,8 +55,7 @@ def split_list(
|
||||
indices = [j for j in range(n) if i & (1 << j) != 0]
|
||||
distributed_timings_1 = [valid_timings[j] for j in indices]
|
||||
distributed_timings_2 = [valid_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:
|
||||
smallest_diff = diff
|
||||
result = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user