Skip to content

Commit 2f2f012

Browse files
Update variable names
1 parent 48edf46 commit 2f2f012

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

genetic_algorithm/knapsack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def run_ga(
318318

319319
if __name__ == "__main__":
320320
result = run_ga(items, capacity)
321-
best_items = [items[i] for i, bit in enumerate(result["best_genome"]) if bit == 1]
321+
best_items = [items[idx] for idx, bit in enumerate(result["best_genome"]) if bit == 1]
322322

323323
print(f"Knapsack capacity: {result['capacity']}")
324324
print(

0 commit comments

Comments
 (0)