You're right, I had a bug in my code.
fmt --width=14 <gettysburg.txt
The copy of the Gettysburg address I grabbed off Wikipedia has "mdashes" in it (unicode characters). That messes up my wrapping too because fmt counts them as two bytes even though they are one character. diff y z
101,104c101,103
< us—that
< from these
< honored dead
< we take
---
> us-that from
> these honored
> dead we take
(the others were not material).Ensuring quality of data counts as time required to complete the project. Also, fmt does not produce an optimally short solution for an 8" long bookmark. For example, using your fmt statement on http://pastebin.com/RxWd11bU produces:
on a great
battle-field
of that
war. We
have come to
dedicate a
portion of
Versus hand-written: on a great
battle-field
of that war.
We have come
to dedicate a
portion of
You'll have to do better than 128 lines, I think, to fit the length requirement. And this was really the author's point. Had you estimated a solution that'd take a few seconds to code using fmt, your estimate would be blown away by reality. Not only would have gone down a rabbit hole (which actually happens quite a lot in software development), but you'd still not have a working solution.
lynx --dump http://morphadorner.northwestern.edu/morphadorner/techtalk/s... | fmt --width=13
This fails due to sub-optimal formatting:
Remember the physical constraint of 1.5" x 8". The fmt output exceeds the bookmark's physical length. Those three lines can be written as two: fmt produces a much lengthier script than would fit on the physical bookmark.