<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Wojno: Tag science</title>
    <link>http://christopher.wojno.com/articles/tag/science</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Exploration through Code</description>
    <item>
      <title>Algorithms: Pretty Printing</title>
      <description>&lt;p&gt;I&amp;#8217;ve been up and down the Internet looking for a good solution to the &amp;#8220;Pretty Printing&amp;#8221; problem. I was dismayed by the lack of readily indexed solutions. So! If you&amp;#8217;re looking to solve this one, I&amp;#8217;m here to point you in the right direction.&lt;/p&gt;


	&lt;h2&gt;Problem Description&lt;/h2&gt;


	&lt;p&gt;Given a set of W words, form a list of lines such that the sum of the slack of the characters in a line L (column s- character count = Slack) squared (some implementations cube this, the algorithm is the same), is minimized.&lt;/p&gt;


	&lt;p&gt;Most problems include that there must be 1 space between every word (except those which do not share the same line) and those spaces must be included in that slack value calculation. Regardless:&lt;/p&gt;


	&lt;h2&gt;The Problem Type&lt;/h2&gt;


	&lt;p&gt;This problem a subset of Dynamic Programming problems known as &amp;#8220;Mutli-way Choices.&amp;#8221; A similar, but less sophisticated version of this problem is the &amp;#8220;Segmented Least Squares&amp;#8221; problem.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m not going to attempt to solve the problem for fear I will make myself the fool. Maybe I&amp;#8217;ll do it later and post it here again when I&amp;#8217;m confident in my answer. The important part is you now know how to look for answers. Admittedly, even armed with this information, you&amp;#8217;ll still get some pretty shady results. But I found some decent material with this &lt;a href="http://www.google.com/search?hl=en&amp;#38;client=firefox-a&amp;#38;rls=org.mozilla%3Aen-US%3Aofficial&amp;#38;hs=NLN&amp;#38;q=segmented+least+squares+problem+dynamic+programming&amp;#38;btnG=Search"&gt;google query&lt;/a&gt; . You should be able to construct a cogent answer with a Least Squares example.&lt;/p&gt;


	&lt;p&gt;Good luck! Happy algorithms!&lt;/p&gt;</description>
      <pubDate>Thu, 08 Nov 2007 22:21:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:fa69de5a-cb1d-4308-adfd-921bdd656d75</guid>
      <author>Christopher Wojno</author>
      <link>http://christopher.wojno.com/articles/2007/11/08/algorithms-pretty-printing</link>
      <category>Theory</category>
      <category>programming</category>
      <category>computer</category>
      <category>math</category>
      <category>algorithm</category>
      <category>science</category>
      <category>dynamic</category>
      <category>pretty</category>
      <category>print</category>
      <category>problem</category>
      <category>multi</category>
      <category>way</category>
      <category>choice</category>
      <category>segmented</category>
      <category>least</category>
      <category>square</category>
    </item>
  </channel>
</rss>
