Solution:
The key to solving this problem is to realize that the slower person sets the pace for the pair. So, if two people with different crossing times cross together, the time taken will be equal to the slower person's crossing time.
Step 1: Alex and Bob cross the bridge together, taking 7 minutes (because Bob is the slower one).
AB ----> (7 minutes)
Step 2: Alex goes back alone with the flashlight, taking 4 minutes.
A <---- (4 minutes)
Step 3: Carol and Daniel cross the bridge together, taking 31 minutes (because Daniel is the slower one).
CD ----> (31 minutes)
Step 4: Bob goes back alone with the flashlight, taking 7 minutes.
B <---- (7 minutes)
Step 5: Alex and Bob cross the bridge together, taking 7 minutes (because Bob is the slower one).
AB ----> (7 minutes)
Total time taken = 7 + 4 + 31 + 7 + 7 = 56 minutes.
Therefore, they cross the bridge in 56 minutes.
Notations: A, B, C, and D represent Alex, Bob, Carol, and Daniel, respectively. The arrow (---->) indicates crossing the bridge from one side to the other, and the less than symbol (<) indicates coming back with the flashlight.