Implement solution for 1-4 using trim and reduce
Add a test helper function
Implement tests for 1-4 solution