You know the problems of crossing rivers . Here is a description of the genus:
Once, three cannibals sent three missionaries through the jungle. They were heading to the nearest mission station. After some time, they arrived on a wide river filled with deadly snakes and fish. It is impossible to cross the river without a boat. Fortunately, after a short search, they found a boat with two oars. Unfortunately, the boat was too small to carry anything. He could barely carry two people at a time. Worse, because of the width of the river, it was not possible to return the boat, in addition to turning it back. Since the missionaries could not trust the cannibals, they needed to make a plan so that all six of them cross the river safely. The problem was that these cannibals would kill and eat missionaries as soon as there were more cannibals in some places than missionaries. In this way,our missionary programmer had to develop a plan to ensure that there were never missionaries in the minority on either side of the river. However, cannibals can be trusted otherwise. In particular, they will not give up any potential food, just as missionaries will not give up any potential converts.
My question is part of this problem. I am trying to create a function that returns a list of possible boat loads (for example, if the hull boat is 3, then [(3mis, 0can), (2mis, 1can), (1mis, 1can), ...] ). I have num (number of missionaries or cannibals) and boat capacity as inputs of my function.
How do you develop your function and algorithm?
source
share