For an explanation, refer to the solution submitted by Steve Herman in this location.
Steve Herman has also submitted a generalization in this location.
blackjack
flooble's webmaster puzzle