How do you solve the multicolor tile puzzle in Undertale?

Quick answer: Learn the color rules Papyrus explains, then walk across on safe tiles. Pink is safe, red blocks you, yellow shocks you and green starts a fight.
Show walkthrough
The rules
Pink is safe. Red cannot be walked on. Yellow shocks you and pushes you back. Green makes you fight a monster, and orange makes you smell like oranges.
Water and soap
Blue tiles are water with piranhas that bite you if you smell like oranges; water next to a yellow tile is electric. Purple tiles are slippery soap that make you smell like lemons, which piranhas do not mind.
Solve it
Papyrus explains the rules at length, then turns the machine on. In Snowdin the result is easy to cross, so just walk on. If the layout ever looks hard, look for a line of pink tiles first.
Second time
You see this puzzle again in Hotland, this time run by Mettaton with a timer. The same rules apply. See the Snowdin walkthrough for the rest of the area.
