21 lines
988 B
Plaintext
21 lines
988 B
Plaintext
Even today, with proportional fonts and complex layouts, there are still [[Template:Lines_too_long|cases]] where you need to wrap text at a specified column.
|
|
|
|
|
|
;Basic task:
|
|
The basic task is to wrap a paragraph of text in a simple way in your language.
|
|
|
|
If there is a way to do this that is built-in, trivial, or provided in a standard library, show that. Otherwise implement the [http://en.wikipedia.org/wiki/Word_wrap#Minimum_length minimum length greedy algorithm from Wikipedia.]
|
|
|
|
Show your routine working on a sample of text at two different wrap columns.
|
|
|
|
|
|
;Extra credit:
|
|
Wrap text using a more sophisticated algorithm such as the Knuth and Plass TeX algorithm.
|
|
If your language provides this, you get easy extra credit,
|
|
but you ''must reference documentation'' indicating that the algorithm
|
|
is something better than a simple minimimum length algorithm.
|
|
|
|
If you have both basic and extra credit solutions, show an example where
|
|
the two algorithms give different results.
|
|
<br><br>
|