O(n^2) solution to 'What Goes Up'
Cleanup/refactoring.