[…] Note: This is an improved version of my original solution to this problem. …