solution to Problem B. Manage your Energy