I'm trying to find an optimal solution that will work for the bridge crossing problem. In case you don't know it you can check out the Ted Ed video on it. They show how you can do it with 5 people but I'm trying to see if there is a way to do it with n number of people. The same rules apply but the optimal solution should be found regardless of how many people there are or what their individual walking speeds are.
These are the conditions of crossing the bridge:
Only 1 or 2 people can cross the bridge at the same time in the same direction.
The speed of the two people crossing is the same as the slower one.
It is night and there is only one flashlight.
The people passing the bridge must carry the flashlight.
The flashlight cannot be thrown over the bridge so it must be carried back to the other end of the bridge.