This is not the algorithm.

This is close.