Earlier this fall, I attempted my first corn maze. It didn’t work out very well. Early on I unknowingly cut through an area meant to be impassable and thus ended up missing the majority of the maze. Soap, as it turns out, is a much better maze-solver, taking nary a false turn as it heads inexorably to the exit. The secret to soap’s maze-solving prowess is the Marangoni effect.
Soap has a lower surface tension than the milk that makes up the maze, which causes an imbalance in the forces at the surface of the liquid. That imbalance causes a flow in the direction of higher surface tension; in other words, it tends to pull the soap molecules in the direction of the highest milk concentration. But that explains why the soap moves, not how it knows the right path to take. It turns out that there’s another factor at work. Balancing gravitational forces and surface tension forces shows that the soap tends to spread toward the path with the largest surface area ahead. That’s the maze exit, so Marangoni forces pull the soap right to the way out! (Video credit: F. Temprano-Coleto et al.; research credit: F. Peaudecerf et al.)
ETA: Based on the latest research results, gravity may play less of a role than originally thought. Instead, it seems as though the soap chooses its path in part through pre-existing background levels of surfactant. As the dye advances, it compresses the background surfactant, decreasing the local surface tension until it is in equilibrium with dyed area. Because longer paths take longer to reach that equilibrium, the dye spreads preferentially toward the largest surface area.