solution to accumulate exercise