Note: This file contains an alternative solution. It does not use the apply family functions.