Rework part 1 to match the sample input and output.