The idea for this code golf puzzle is from link: The Bridge and Torch Problem
The inspiration for this code golf puzzle is the Bridge and Torch problem, in which d people at the start of a bridge must all cross it in the least amount of time.
The catch is that at most two people can cross at once, otherwise the bridge will crush under their weight, and the group only has access to one torch, which must be carried to cross the bridge.
Each person in the whole puzzle has a specified time that they take to walk across the bridge. If two people cross together, the pair goes as slow as the slowest person.
For this challenge d=4 and for the input you will get a time t and a list of tuple like:
input = (19,[('A', 1), ('B', 3), ('C', 4), ('D', 5)])
Now the task is to find all possible solution how they can cross the bridge within the time t. Solve the problem in the fewest bytes of code possible.
For example for this input:
input =(19,[('A', 1), ('B', 2), ('C', 5), ('D', 10)])
Your solution should look like:
Solution
['Couple A and B cross the bridge']
[' A goes back']
['Couple D and C cross the bridge']
[' B goes back']
['Couple A and B cross the bridge']
Solution
['Couple A and B cross the bridge']
[' A goes back']
['Couple D and A cross the bridge']
[' A goes back']
['Couple C and A cross the bridge']
Solution
['Couple A and B cross the bridge']
[' A goes back']
['Couple C and A cross the bridge']
[' A goes back']
['Couple D and A cross the bridge']
Solution
['Couple A and C cross the bridge']
[' A goes back']
['Couple D and A cross the bridge']
[' A goes back']
['Couple A and B cross the bridge']
Solution
['Couple A and C cross the bridge']
[' A goes back']
['Couple A and B cross the bridge']
[' A goes back']
['Couple D and A cross the bridge']
Solution
['Couple A and D cross the bridge']
[' A goes back']
['Couple C and A cross the bridge']
[' A goes back']
['Couple A and B cross the bridge']
Solution
['Couple A and D cross the bridge']
[' A goes back']
['Couple A and B cross the bridge']
[' A goes back']
['Couple C and A cross the bridge']
The output don't need to be in a specific format.