Skip to content Skip to sidebar Skip to footer

Why Is This Brute Force Algorithm Producing The Incorrect Result?

I'm trying to write a brute-force algorithm that minimises the number of journeys of a herd of cows, subject to the conditions in the docstring. def brute_force_cow_transport(cows,

Solution 1:

The question here is:

How do I find the shortest sublist in a nested list?

To do this, change the last line to:

min(valid_trips, key=len)

Post a Comment for "Why Is This Brute Force Algorithm Producing The Incorrect Result?"