Improve the solution for 1-17.

Reuse the improved functions from 1-16. Add logic for pretty output
formatting.
Replace test value for maximum line length.