<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://united-coders.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>united-coders.com - python</title>
 <link>http://united-coders.com/taxonomy/term/22/0</link>
 <description></description>
 <language>en</language>
<item>
 <title>facebook Hacker Cup 2012 Qualification - solution for billboards</title>
 <link>http://united-coders.com/christian-harms/facebook-hacker-cup-2012-qualification-solution-for-billboards</link>
 <description>&lt;p&gt;The second problem from this year facebook hackercup sound like the classic &lt;a href=&quot;http://en.wikipedia.org/wiki/Knapsack_problem&quot;&gt;knapsack problem&lt;/a&gt;. But the solution is much easier (words are in fixed sort order). Feel free to find a smarter algorithm or comment my python solution.&lt;/p&gt;
&lt;h2&gt;problem description&lt;/h2&gt;
&lt;p&gt;We are starting preparations for Hacker Cup 2013 really early. Our first step is to prepare billboards to advertise the contest. We have text for hundreds of billboards, but we need your help to design them.&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/facebook-hacker-cup-2012-qualification-solution-for-billboards&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/facebook-hacker-cup-2012-qualification-solution-for-billboards&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/facebook-hacker-cup-2012-qualification-solution-for-billboards&quot; dc:title=&quot;facebook Hacker Cup 2012 Qualification - solution for billboards&quot; trackback:ping=&quot;http://united-coders.com/trackback/119&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-5034&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/facebook-hacker-cup-2012-qualification-solution-for-billboards#comments</comments>
 <category domain="http://united-coders.com/category/tags/code-puzzle">code puzzle</category>
 <category domain="http://united-coders.com/category/tags/facebook-hackercup">facebook hackercup</category>
 <category domain="http://united-coders.com/category/tags/java">java</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <category domain="http://united-coders.com/category/tags/solution">solution</category>
 <pubDate>Wed, 25 Jan 2012 18:50:17 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">119 at http://united-coders.com</guid>
</item>
<item>
 <title>Q*Bert chrismas tree puzzle</title>
 <link>http://united-coders.com/christian-harms/qbert-chrismas-tree-puzzle</link>
 <description>&lt;p&gt;This is a short coding puzzle with q*bert (who is &lt;a href=&quot;http://en.wikipedia.org/wiki/Qbert&quot;&gt;q*bert&lt;/a&gt;?) and an chrismas tree. &lt;/p&gt;
&lt;h2&gt;the qbert question&lt;/h2&gt;
&lt;p&gt;&lt;img alt=&quot;qbert chrismas tree coding puzzle&quot; src=&#039;http://united-coders.com/sites/default/files/imagepicker/4/qtree_tree.jpg&#039; style=&quot;float: right&quot; width=&#039;300&#039; height=&#039;263&#039; /&gt;&lt;br /&gt;
The task: Our 2011 q*bert can only jump down. He start from the top and has to find the path to the bottom of the chrismas tree with collecting the most points available (while jumping left-or-right down). Find the way with the highest sum.&lt;/p&gt;
&lt;p&gt;Input:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;div class=&quot;python geshifilter-python&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;chrismasTree = &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;75&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;95&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;17&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;47&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;82&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;18&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;35&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;87&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;4&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;82&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;47&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;65&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;19&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;23&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;75&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;34&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; qbertRun&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;chrismasTree&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The sum is 465 - try to solve it with a little program. The brute force method will be possible with this small tree.&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/qbert-chrismas-tree-puzzle&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/qbert-chrismas-tree-puzzle&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/qbert-chrismas-tree-puzzle&quot; dc:title=&quot;Q*Bert chrismas tree puzzle&quot; trackback:ping=&quot;http://united-coders.com/trackback/116&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-4390&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/qbert-chrismas-tree-puzzle#comments</comments>
 <category domain="http://united-coders.com/category/tags/code-puzzle">code puzzle</category>
 <category domain="http://united-coders.com/category/tags/pathfinding">pathfinding</category>
 <category domain="http://united-coders.com/category/tags/project-euler">project euler</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <category domain="http://united-coders.com/category/tags/qbert">q*bert</category>
 <pubDate>Mon, 19 Dec 2011 12:28:05 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">116 at http://united-coders.com</guid>
</item>
<item>
 <title>Use compressed data directly - from ZIP files or gzip http response</title>
 <link>http://united-coders.com/christian-harms/use-compressed-data-directly-from-zip-files-or-gzip-http-response</link>
 <description>&lt;p&gt;Did you use compressing while using resources from your scripts and projects? Many data files are compressed to save disc space and compressed requests over the network saves bandwith. &lt;/p&gt;
&lt;p&gt;This article gives some hints to use the “battery included” power of python for the handling of compressed files or use HTTP with gzip compression:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;reading log files as GZIP or uncompressed&lt;/li&gt;
&lt;li&gt;using files directly from ZIP- or RAR compression archive&lt;/li&gt;
&lt;li&gt;use gzip compressing while fetching web sites&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;br/&gt;&lt;/br/&gt;&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/use-compressed-data-directly-from-zip-files-or-gzip-http-response&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/use-compressed-data-directly-from-zip-files-or-gzip-http-response&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/use-compressed-data-directly-from-zip-files-or-gzip-http-response&quot; dc:title=&quot;Use compressed data directly - from ZIP files or gzip http response&quot; trackback:ping=&quot;http://united-coders.com/trackback/108&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-6060&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/use-compressed-data-directly-from-zip-files-or-gzip-http-response#comments</comments>
 <category domain="http://united-coders.com/category/tags/content-encoding">content-encoding</category>
 <category domain="http://united-coders.com/category/tags/gzip">gzip</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <category domain="http://united-coders.com/category/tags/rar">rar</category>
 <category domain="http://united-coders.com/category/tags/zip">zip</category>
 <category domain="http://united-coders.com/category/tags/zlib">zlib</category>
 <pubDate>Mon, 17 Oct 2011 13:02:44 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">108 at http://united-coders.com</guid>
</item>
<item>
 <title>basic rules for code readability and the if statement</title>
 <link>http://united-coders.com/christian-harms/basic-rules-for-code-readability-and-the-if-statement</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;Some reader knows my preference for programming languages like python or javascript. One reason is the readability (yes, this is possible with many languages except &lt;a href=&quot;http://brainfuck.tk/&quot; title=&quot;brainfuck interpreter&quot;&gt;brainfuck&lt;/a&gt; or &lt;a href=&quot;http://compsoc.dur.ac.uk/whitespace/&quot; title=&quot;programming language whitespace&quot;&gt;whitespace&lt;/a&gt;). Once we write some lines of code, but other developer has to read the lines of code several times while code reviews, debugging or refactoring.&lt;/p&gt;
&lt;p&gt;Code should be &lt;b&gt;readable&lt;/b&gt; like your normal language. I will start with a funny condition.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;div class=&quot;javascript geshifilter-javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt;notOk &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; userObj.&lt;span style=&quot;color: #660066;&quot;&gt;ask&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This is only confusing and you will never formulate this expression in a natural language. With several steps this term can be simply resolved:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;( !notOk != false )&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;( !notOk == true )&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;( !notOk)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;now you should rethink the variable name: &lt;code&gt;isOk = !notOk&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And the result is more readable:&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/basic-rules-for-code-readability-and-the-if-statement&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/basic-rules-for-code-readability-and-the-if-statement&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/basic-rules-for-code-readability-and-the-if-statement&quot; dc:title=&quot;basic rules for code readability and the if statement&quot; trackback:ping=&quot;http://united-coders.com/trackback/106&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-1114&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/basic-rules-for-code-readability-and-the-if-statement#comments</comments>
 <category domain="http://united-coders.com/category/tags/javascript">javascript</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <category domain="http://united-coders.com/category/tags/readability">readability</category>
 <pubDate>Mon, 01 Aug 2011 16:55:23 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">106 at http://united-coders.com</guid>
</item>
<item>
 <title>comparing language performance and memory usage</title>
 <link>http://united-coders.com/christian-harms/comparing-language-performance-and-memory-usage</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;With the small &lt;a href=&quot;http://united-coders.com/nico-heid/no-duplicates-please&quot;&gt;coding contest&lt;/a&gt; some weeks ago we got many comments and it’s worth to make a conclusion for the solutions in different languages. What language is easier to write, has better memory usage or better performance?&lt;/p&gt;
&lt;p&gt;To clarify the question:&lt;/p&gt;
&lt;h2&gt;Remove duplicate lines from a file&lt;/h2&gt;
&lt;p&gt;We have a text file with 13 Million entries, all numbers in the range from 1.000.000 to 100.000.000. Each line has only one number. The file is unordered and we have about 1% duplicate entries. Remove the duplicates. &lt;/p&gt;
&lt;p&gt;Be efficient with the memory usage and / or find a performant solution. The script should be started with the filename and linenumber and print the result to stdout.&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/comparing-language-performance-and-memory-usage&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/comparing-language-performance-and-memory-usage&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/comparing-language-performance-and-memory-usage&quot; dc:title=&quot;comparing language performance and memory usage&quot; trackback:ping=&quot;http://united-coders.com/trackback/104&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-7255&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/comparing-language-performance-and-memory-usage#comments</comments>
 <category domain="http://united-coders.com/category/tags/c">c</category>
 <category domain="http://united-coders.com/category/tags/hashmap">hashmap</category>
 <category domain="http://united-coders.com/category/tags/language-memory-usage">language memory usage</category>
 <category domain="http://united-coders.com/category/tags/language-performance">language performance</category>
 <category domain="http://united-coders.com/category/tags/lua">lua</category>
 <category domain="http://united-coders.com/category/tags/perl">perl</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <category domain="http://united-coders.com/category/tags/sort">sort</category>
 <enclosure url="http://united-coders.com/sites/default/files/charts.js.txt" length="12244" type="text/plain" />
 <pubDate>Fri, 10 Jun 2011 08:46:35 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">104 at http://united-coders.com</guid>
</item>
<item>
 <title>Google Code Jam - Minimum Scalar Product</title>
 <link>http://united-coders.com/nico-heid/google-code-jam-minimum-scalar-product</link>
 <description>&lt;p&gt;With the &lt;a href=&quot;http://code.google.com/codejam&quot; target=&quot;_blank&quot;&gt;Google Code Jam 2011&lt;/a&gt; less than four weeks away, it is time for some finger exercises.&lt;/p&gt;
&lt;p&gt;Let&#039;s start with the &lt;a href=&quot;http://code.google.com/codejam/contest/dashboard?c=32016#s=p0&amp;amp;a=0&quot; target=&quot;_blank&quot;&gt;Minimum Scalar Product&lt;/a&gt;, which should only take you a few minutes.&lt;/p&gt;
&lt;p&gt;Here&#039;s the Java version, which will only work for the small input set. I&#039;ll explain later.&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;div class=&quot;java geshifilter-java&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;int&lt;/span&gt; getMinimumScalarProduct2&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; x, &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; y&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003399;&quot;&gt;Arrays&lt;/span&gt;.&lt;span style=&quot;color: #006633;&quot;&gt;sort&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;x&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003399;&quot;&gt;Arrays&lt;/span&gt;.&lt;span style=&quot;color: #006633;&quot;&gt;sort&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;y&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;int&lt;/span&gt; sum&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; x.&lt;span style=&quot;color: #006633;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum &lt;span style=&quot;color: #339933;&quot;&gt;+=&lt;/span&gt; x&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; y&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;x.&lt;span style=&quot;color: #006633;&quot;&gt;length&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: bold; font-style: italic;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;return&lt;/span&gt; sum&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;What we do is sort both arrays, then multiply them. One starting from the beginning, the other from the end. So our biggest numbers are multiplied with the smallest. The math is on Google&#039;s solution page, we&#039;re just looking at coding here.&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/nico-heid/google-code-jam-minimum-scalar-product&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/nico-heid/google-code-jam-minimum-scalar-product&quot; dc:identifier=&quot;http://united-coders.com/nico-heid/google-code-jam-minimum-scalar-product&quot; dc:title=&quot;Google Code Jam - Minimum Scalar Product&quot; trackback:ping=&quot;http://united-coders.com/trackback/101&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-8106&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/nico-heid/google-code-jam-minimum-scalar-product#comments</comments>
 <category domain="http://united-coders.com/category/tags/code-jam">code jam</category>
 <category domain="http://united-coders.com/category/tags/google">google</category>
 <category domain="http://united-coders.com/category/tags/java">java</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <pubDate>Sun, 10 Apr 2011 12:52:54 +0000</pubDate>
 <dc:creator>Nico Heid</dc:creator>
 <guid isPermaLink="false">101 at http://united-coders.com</guid>
</item>
<item>
 <title>10 one-line solutions for project euler</title>
 <link>http://united-coders.com/christian-harms/10-one-line-solutions-for-project-euler</link>
 <description>&lt;h2&gt;What are one-line solutions?&lt;/h2&gt;
&lt;p&gt;Solving an problem from project euler can be a challenge or coding fun. The result of every problem is only one number, calculated by an algorithm. Some algorithms can be written as one expression. You get an one-liner if you can embed it in a function with only one line of code.&lt;/p&gt;
&lt;h2&gt;What is Project Euler?&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#039;http://projecteuler.net/&#039;&gt;Project Euler&lt;/a&gt; is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.&lt;/p&gt;
&lt;p&gt;After solving some project euler problems with python I got some one-line solutions with nice usage of &lt;a href=&#039;http://united-coders.com/christian-harms/functional-programming-with-python&#039;&gt;list comprehensions and functional programming&lt;/a&gt;. These code examples are not clean code but a challenge to find more one-line solutions. This article include my first 10 solutions for project euler as one-line python function. Dont use it to cheating the project - it should be a motivation to find smart coding solutions and participate to project euler. &lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/10-one-line-solutions-for-project-euler&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/10-one-line-solutions-for-project-euler&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/10-one-line-solutions-for-project-euler&quot; dc:title=&quot;10 one-line solutions for project euler&quot; trackback:ping=&quot;http://united-coders.com/trackback/92&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-3798&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/10-one-line-solutions-for-project-euler#comments</comments>
 <category domain="http://united-coders.com/category/tags/euler-prject">euler prject</category>
 <category domain="http://united-coders.com/category/tags/one-liner">one-liner</category>
 <category domain="http://united-coders.com/category/tags/puzzle">puzzle</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <pubDate>Tue, 28 Dec 2010 13:00:16 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">92 at http://united-coders.com</guid>
</item>
<item>
 <title>Google code jam solution for alien language</title>
 <link>http://united-coders.com/christian-harms/google-code-jam-solution-for-alien-language</link>
 <description>&lt;h2&gt;Problem&lt;/h2&gt;
&lt;p&gt;In the &lt;a href=”http://code.google.com/codejam/contest/dashboard?c=90101”&gt;2009 qualification round&lt;/a&gt; there was a simple problem with a nice background story:&lt;/p&gt;
&lt;p&gt;After years of study, scientists at Google Labs have discovered an alien language transmitted from a faraway planet. The alien language is very unique in that every word consists of exactly L lowercase letters. Also, there are exactly D words in this language.&lt;/p&gt;
&lt;p&gt;Once the dictionary of all the words in the alien language was built, the next breakthrough was to discover that the aliens have been transmitting messages to Earth for the past decade. Unfortunately, these signals are weakened due to the distance between our two planets and some of the words may be misinterpreted. In order to help them decipher these messages, the scientists have asked you to devise an algorithm that will determine the number of possible interpretations for a given pattern.&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/google-code-jam-solution-for-alien-language&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/google-code-jam-solution-for-alien-language&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/google-code-jam-solution-for-alien-language&quot; dc:title=&quot;Google code jam solution for alien language&quot; trackback:ping=&quot;http://united-coders.com/trackback/73&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-8127&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/google-code-jam-solution-for-alien-language#comments</comments>
 <category domain="http://united-coders.com/category/tags/contest">contest</category>
 <category domain="http://united-coders.com/category/tags/google">google</category>
 <category domain="http://united-coders.com/category/tags/jam">jam</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <pubDate>Mon, 30 Aug 2010 09:58:16 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">73 at http://united-coders.com</guid>
</item>
<item>
 <title>The rotate google contest in 15 lines</title>
 <link>http://united-coders.com/christian-harms/the-rotate-google-contest-in-15-lines</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;The &lt;a href=&quot;http://united-coders.com/nico-heid/google-code-jam-rotate&quot;&gt;rotate example&lt;/a&gt; nico last week reported was funny to solve: No rotating needed! Read the complete problem description in &lt;a href=&quot;http://united-coders.com/nico-heid/google-code-jam-rotate&quot;&gt;nicos article&lt;/a&gt; or in the google &lt;a href=&quot;http://code.google.com/codejam/contest/dashboard?c=544101#&quot;&gt;code contest&lt;/a&gt; page. Here my complete python solution with file handling and solution printing.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;div class=&quot;python geshifilter-python&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;from&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;re&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; search&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;fp = &lt;span style=&quot;color: #008000;&quot;&gt;file&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; case &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;+&lt;span style=&quot;color: #008000;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;fp.&lt;span style=&quot;color: black;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; n, k = &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;x&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; x &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; fp.&lt;span style=&quot;color: black;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; lines = &lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;fp.&lt;span style=&quot;color: black;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; x &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;n&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#right-gravitation and joining to one line (delim is a line)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: bold; font-style: italic;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; s = &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;#&amp;quot;&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;lambda&lt;/span&gt; x:&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;%%%ds&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt;n&lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;x.&lt;span style=&quot;color: black;&quot;&gt;strip&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;.&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;, lines&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; result = &lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#find one of the 4 variants: horiz, verti, slash, backslash for Blue&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; reB = &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;(B.{%%d}){%d}B&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;k-&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/the-rotate-google-contest-in-15-lines&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/the-rotate-google-contest-in-15-lines&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/the-rotate-google-contest-in-15-lines&quot; dc:title=&quot;The rotate google contest in 15 lines&quot; trackback:ping=&quot;http://united-coders.com/trackback/72&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-8848&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/the-rotate-google-contest-in-15-lines#comments</comments>
 <category domain="http://united-coders.com/category/tags/contest">contest</category>
 <category domain="http://united-coders.com/category/tags/google">google</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <pubDate>Thu, 19 Aug 2010 11:35:38 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">72 at http://united-coders.com</guid>
</item>
<item>
 <title>Image resizing tips general and for python</title>
 <link>http://united-coders.com/christian-harms/image-resizing-tips-general-and-for-python</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;Generating thumbnails from a collection of pictures is an easy task and there are many tools for the job. But I didn&#039;t find a tool who can clip out a centered box of my pictures to get quadratic thumbs of my originals. Because I am a developer and I dont want to try out many tools: I will hack a short python script (with help of the &lt;a href=&quot;http://www.pythonware.com/products/pil/&quot;&gt;PIL&lt;/a&gt;) myself.&lt;/p&gt;
&lt;h1&gt;simple solution&lt;/h1&gt;
&lt;p&gt;The following python script can be find on many webpages. It will take all command line arguments as image filenames and convert it to 200x200 thumbnails with the default extension &quot;_thumb.jpg&quot; (build from the original filename):&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;div class=&quot;python geshifilter-python&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; Image, &lt;span style=&quot;color: #dc143c;&quot;&gt;os&lt;/span&gt;, &lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; filename &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;argv&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;1&lt;/span&gt;:&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; img = Image.&lt;span style=&quot;color: #008000;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;filename&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;resize&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;200&lt;/span&gt;,&lt;span style=&quot;color: #ff4500;&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; out = &lt;span style=&quot;color: #008000;&quot;&gt;file&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;os&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;path&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;splitext&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;filename&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;+&lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;_thumb.jpg&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;w&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; img.&lt;span style=&quot;color: black;&quot;&gt;save&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;out, &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;JPEG&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;finally&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.&lt;span style=&quot;color: black;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/image-resizing-tips-general-and-for-python&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/image-resizing-tips-general-and-for-python&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/image-resizing-tips-general-and-for-python&quot; dc:title=&quot;Image resizing tips general and for python&quot; trackback:ping=&quot;http://united-coders.com/trackback/57&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-3689&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/image-resizing-tips-general-and-for-python#comments</comments>
 <category domain="http://united-coders.com/category/tags/image">image</category>
 <category domain="http://united-coders.com/category/tags/python">python</category>
 <category domain="http://united-coders.com/category/tags/resize">resize</category>
 <category domain="http://united-coders.com/category/tags/thumbnail">thumbnail</category>
 <pubDate>Sun, 21 Mar 2010 23:15:27 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">57 at http://united-coders.com</guid>
</item>
</channel>
</rss>


