<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0" xml:base="http://scrollingtext.org">
<channel>
 <title>ScrollingText</title>
 <link>http://scrollingtext.org</link>
 <description />
 <language>en</language>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Scrollingtext" /><feedburner:info uri="scrollingtext" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
 <title>Project Euler - Problem 17</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/uAuTvHWr7EM/project-euler-problem-17</link>
 <description>&lt;p&gt;It's been to long since I posted a solution to one of these challenges. How time flies when you're having fun.&lt;/p&gt;
&lt;p&gt;Here's the problem:&lt;br /&gt;
&lt;code&gt;If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.&lt;/p&gt;
&lt;p&gt;If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Here is the python code:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;#!/usr/bin/env python&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;ones &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'1'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'one'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'2'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'two'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'3'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'three'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'4'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'four'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'5'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'five'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #483d8b;"&gt;'6'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'six'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'7'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'seven'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'8'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'eight'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'9'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'nine'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'0'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;''&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;tens &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'2'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'twenty'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'3'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'thirty'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'4'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'forty'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'5'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'fifty'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #483d8b;"&gt;'6'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'sixty'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'7'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'seventy'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'8'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'eighty'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'9'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'ninety'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;teens &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'10'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'ten'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'11'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'eleven'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'12'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'twelve'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'13'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'thriteen'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;         &lt;span style="color: #483d8b;"&gt;'14'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'fourteen'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'15'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'fifteen'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'16'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'sixteen'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'17'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'seventeen'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;         &lt;span style="color: #483d8b;"&gt;'18'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'eighteen'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'19'&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;'nineteen'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;hundreds &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;: &lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;onehundredand&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;2&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;twohundredand&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff4500;"&gt;3&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;threehundredand&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;4&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;fourhundredand&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff4500;"&gt;5&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;fivehundredand&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;6&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;sixhundredand&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff4500;"&gt;7&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;sevenhundredand&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;8&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;eighthundredand&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff4500;"&gt;9&lt;/span&gt;: &lt;span style="color: #483d8b;"&gt;&amp;quot;ninehundredand&amp;quot;&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    tot &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; h &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;xrange&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;10&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; y &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;xrange&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;100&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                t&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;o &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #008000;"&gt;tuple&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;y&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; t &lt;span style="color: #ff7700;font-weight:bold;"&gt;is&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'1'&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    tot +&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;{h}{t}&amp;quot;&lt;/span&gt;.&lt;span style="color: black;"&gt;format&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;h&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;hundreds&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;h&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; t&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;teens&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;t + o&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    tot +&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;{h}{t}{o}&amp;quot;&lt;/span&gt;.&lt;span style="color: black;"&gt;format&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;h&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;hundreds&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;h&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; t&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;tens&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;t&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                                                  o&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;ones&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;o&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;ValueError&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    tot +&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;{h}{o}&amp;quot;&lt;/span&gt;.&lt;span style="color: black;"&gt;format&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;h&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;hundreds&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;h&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; o&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;ones&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;y&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    tot +&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #008000;"&gt;len&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'onethousand'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt; tot&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Even though I wrote it, I still look at it and think "that's not mine." It's been a long time since I wrote a for loop within a for loop. There isn't anything wrong with it, it's just not my style. This time however I wasn't really able to come up with a solution that would allow me to break out of the two for loops.&lt;/p&gt;
&lt;p&gt;The one part of the code that I was surprised "worked" war breaking up the digits by turning the number to a string then a tuple. This allowed me to easily test an exception. This exception will only be thrown 10% of the time. While exceptions might be expensive, the other 90% of the time the code hums along without using a conditional. Everything has costs, but I think that the cost of throwing an exception 10% of the time as opposed to testing a conditional 100% of the time is a cost I'm willing to accept.&lt;/p&gt;
&lt;p&gt;I will admit that I did not code up another solution in a different programming language. While part of that is due to being lazy - it's good for the soul once and a while - I'm also not sure how I can code this up in a functional language. I'm sure it can be done, I just don't know how  (If anyone has a link or idea please share it.) But because I do like to compare things I tweaked the code to run within python 3.3.0. The differences in time are so minimal that I'm not even going to post it. If you're really inspired you can read the python 3 code &lt;a href=https://github.com/btv/project_euler/blob/master/problem_17/python/problem17.py3"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Questions and comments welcomed. One quick side note to my readers: I'm getting married this year (Yay!) and a lot of my free time is spent juggling and planning. So I might not be blogging as frequently as usual. Thanks for your patience. &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=uAuTvHWr7EM:g43Tp0o6Vdw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=uAuTvHWr7EM:g43Tp0o6Vdw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=uAuTvHWr7EM:g43Tp0o6Vdw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=uAuTvHWr7EM:g43Tp0o6Vdw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=uAuTvHWr7EM:g43Tp0o6Vdw:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=uAuTvHWr7EM:g43Tp0o6Vdw:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=uAuTvHWr7EM:g43Tp0o6Vdw:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/uAuTvHWr7EM" height="1" width="1"/&gt;</description>
 <category domain="http://scrollingtext.org/category/catagories/project-euler">Project Euler</category>
 <category domain="http://scrollingtext.org/category/catagories/python">Python</category>
 <pubDate>Tue, 19 Mar 2013 16:59:13 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">91 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/project-euler-problem-17</feedburner:origLink></item>
<item>
 <title>My First Yesod App</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/Z23oiHuulcY/my-first-yesod-app</link>
 <description>&lt;p&gt;First off, I just wanted to say that I hope everyone had a relaxing and enjoyable holiday season and that you enjoyed your New Year's celebration. Whatever you did that day or night, don't name it after me.&lt;/p&gt;
&lt;p&gt;In my last &lt;a href=http://scrollingtext.org/first-flask-web-app"&gt;post&lt;/a&gt;, I showed you how to create a simple web service that responded to three different URLs and interacted with a database using Python and the Flask framework. Now I'm going to show you how to program the same thing in Haskell using the Yesod framework. For those of you too “efficient” to look them up on the previous page HERE, I'm going to repost the requirements:&lt;br /&gt;
&lt;code&gt;Using python with &lt;a href="http://gevent.org"&gt;gevent&lt;/a&gt; 0.13.x and your choice of additional libraries and/or frameworks, implement a single HTTP server with API endpoints that provide the following functionalities:&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt; A Fibonacci endpoint that accepts a number and returns the Fibonacci calculation for that number, and returns result in JSON format. example:&lt;/p&gt;
&lt;li&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #660033;"&gt;-s&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/fib/13'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt;: &lt;span style="color: #000000;"&gt;233&lt;/span&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #660033;"&gt;-s&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/fib/12'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt;: &lt;span style="color: #000000;"&gt;144&lt;/span&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt; An endpoint that fetches the Google homepage and returns the sha1 of the response message-body (HTTP body data).example:&lt;/p&gt;
&lt;li&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #660033;"&gt;-s&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/google-body'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt;: &lt;span style="color: #ff0000;"&gt;&amp;quot;272cca559ffe719d20ac90adb9fc4e5716479e96&amp;quot;&lt;/span&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
    Using some external storage of your choice (can be redis, memcache, sqlite, mysql, etc), provide a means to store and then retrieve a value.Example:&lt;/p&gt;
&lt;li&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #660033;"&gt;-d&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'value=something'&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/store'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/store'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt;: &lt;span style="color: #ff0000;"&gt;&amp;quot;something&amp;quot;&lt;/span&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/&lt;/span&gt;li&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;
    &lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Like the last post, I'm going to talk about the individual functions first, then post the whole code at the end. Let's start with the first requirement, creating a good old Fibonacci sequence:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;handleFibR &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; Handler RepJson&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;handleFibR num &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; jsonToRepJson &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; object &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.=&lt;/span&gt; show&lt;span style="color: #339933; font-weight: bold;"&gt;_&lt;/span&gt;fib&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    show&lt;span style="color: #339933; font-weight: bold;"&gt;_&lt;/span&gt;fib &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; fib num&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    fib &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    fib &lt;span style="color: red;"&gt;0&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    fib &lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    fib n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; fib &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n &lt;span style="color: #339933; font-weight: bold;"&gt;-&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt; fib &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n – &lt;span style="color: red;"&gt;2&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;I'm going to go ahead and describe the code from the bottom up - it's a little weird but it's a lot easier to explain that way, trust me. The show_fib function is just a simple function to sum the values created from the Fibonacci sequence. The result of that function is used as the “value” component of a Pair type that is created with the “.=” operator and the “response” string, and is contained within a list. The object function takes a list of Pairs as its input and creates a &lt;a href="http://hackage.haskell.org/packages/archive/yesod-json/1.1.2/doc/html/Yesod-Json.html#t:Value"&gt;Value&lt;/a&gt; type, which is described in the documentation as “A JSON value represented as a Haskell value.” This Value is then passed as the input into the jsonToRepJson function. All of these functions come together beautifully so that when you point your browser to &lt;a href="http://localhost:3000/fib/24" title="http://localhost:3000/fib/24"&gt;http://localhost:3000/fib/24&lt;/a&gt;, you get this response:&lt;br /&gt;
&lt;code&gt;{"response":"46368"}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For my next trick, I'm going to pull a SHA1 hash out from the Google homepage source code.&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;gGoogR &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; Handler RepJson&lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt;                   &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;getGoogR &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt;                                 &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     body &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; try &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;simpleHttp &lt;span style="background-color: #3cb371;"&gt;&amp;quot;http://www.google.com”) &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="background-color: #3cb371;"&gt;     case body of$                              &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="background-color: #3cb371;"&gt;         Left (SomeException ex) -&amp;gt; jsonToRepJson $ object [“response” .= (“ERROR:  “ ++ (show ex))]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="background-color: #3cb371;"&gt;         Right val -&amp;gt; jsonToRepJson $ object [“response” .= (showDigest $ sha1 val)]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Much like the last function, this function will return a Handler containing a RepJson . First I use the simpleHttp function to travel to the interwebs and pull the Google homepage. Because simpleHttp will throw an HttpException with any non 200 status code, I have the function called within a try function, putting the result into “body”. Body is of the Either type, which means it can have one of two possible values (like Schrodinger's cat). If something went wrong, the value would be in the “Left” side of the Either type. If that's what happened, I don't really care what went wrong so I just return a generic error message. If everything flowed smoothly like all code does (snicker), the data would be on the “Right” side of Either, allowing me to pull the data out using the Right function and named val. The code after this point is extremely similar to the previous example, the difference being the output. The website source code is used as input for the sha1 function, creating a Digest type, then I carry that over to showDigest, which returns a string 160 characters long. All of this is bubbled up to the handler and the user sees:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{"response":"ddd27a244477532f7be5207582afca72b9f74224"}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Your results will differ! For dealing with the database, we need functions that can handle both GET and POST requests.  Before I explain those functions, I want to take a quick moment to share the database schema and the “runDB” function:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;share &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;mkPersist sqlSettings&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; mkMigrate &lt;span style="background-color: #3cb371;"&gt;&amp;quot;migrateAll&amp;quot;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;persist&lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;Stuff&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    value Text&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;deriving&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Show"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Show&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;runDB action &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        Challenge pool &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; getYesod&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        runSqlPool action pool&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;If you are a little confused by these two things, don't fear. I will do my best to describe them in a moment. If that still doesn't help then maybe viewing the entire code base below will. The first code block above is responsible for creating the Stuff database which holds a single column, called “value”. It reminds me of user defined datatypes created with the “data” Haskell keyword.&lt;/p&gt;
&lt;p&gt;The second block is really me &lt;a href="http://en.wikipedia.org/wiki/Cargo_cult_programming"&gt;cargo cult programming&lt;/a&gt;. I've seen this technique used in a lot of the examples of the Yesod book, so I copied it while I was writing this project. The best way I can describe it is as a wrapper function for using an item from a pool of database connectors, and using some of those connectors to to run the query.&lt;/p&gt;
&lt;p&gt;Now that you know what the database looks like and how we access it, we can move onto the functions that interact with it. Here is the code for the POST request:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;postStoreR &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; Handler &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;postStoreR &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    mvalue &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; runInputPost &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; ireq textField &lt;span style="background-color: #3cb371;"&gt;&amp;quot;value&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    runDB &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; insert &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; Stuff mvalue&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    sendResponseStatus status200 &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This function just returns a Handler unit. Using the ireq function, we look through the POST request for the expected input keyed as “value”. The output of that function goes through the runInputPost, and deposits the contents into mvalue. We take mvalue, change it to become a Stuff type, pass that to the insert function which, when it runs, returns an automatically created key. and then moving that along to runDB, which inserts our data into the database. The last line returns the 200 status back to the client, using the sendResponseStatus.&lt;/p&gt;
&lt;p&gt;Finally, for the GET request we have:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;getStoreR &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; Handler RepJson&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;getStoreR &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    mvalue &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; runDB &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; selectFirst &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;Desc StuffValue&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; LimitTo &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;case&lt;/span&gt; mvalue &lt;span style="color: #06c; font-weight: bold;"&gt;of&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        Nothing &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; jsonToRepJson &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; object &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="background-color: #3cb371;"&gt;&amp;quot;NO DATA IN DATABASE&amp;quot;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        Just mvalue' &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; jsonToRepJson &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; object &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; stuffValue &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; entityVal mvalue'&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The result of the selectFirst function provides the input for runDB.  The first argument for selectFirst is an empty list, this argument is for filtering on some kind of value( greater than, less than, not equal to, etc). I have left it blank because I really don't care what the value of “value” is; I just want it. The second list is telling the database to put the column values in descending order. The first line is the Haskell equivalent of the following SQL code:&lt;/p&gt;
&lt;p&gt;&lt;span class="geshifilter"&gt;&lt;code class="sql geshifilter-sql"&gt;&lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;*&lt;/span&gt; &lt;span style="color: #993333; font-weight: bold;"&gt;FROM&lt;/span&gt; Stuff &lt;span style="color: #993333; font-weight: bold;"&gt;GROUP&lt;/span&gt; &lt;span style="color: #993333; font-weight: bold;"&gt;BY&lt;/span&gt; &lt;span style="color: #993333; font-weight: bold;"&gt;VALUE&lt;/span&gt; &lt;span style="color: #993333; font-weight: bold;"&gt;DESC&lt;/span&gt; &lt;span style="color: #993333; font-weight: bold;"&gt;LIMIT&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The results of which are named mvalue. Since it's possible to have nothing in the response, I use the case statement to dig inside mvalue and look around. If “Nothing” was returned, I send back a little json blurb letting the user know that nothing was found, most likely because there isn't data in the database. If something was returned, pull that value out, and mix it all in the with json recipe you've seen me using thus far, and then send the data on its way.&lt;/p&gt;
&lt;p&gt;As the title says, this was my first Yesod web app. I know that I have only scratched the surface of what this framework can do and I'm really interested in creating more with it. I will admit that I initially found the interaction with the database a little cumbersome when compared to Django or Flask. That doesn't mean I don't like it, it's just a little awkward when I was first trying to understand how to work with it. Once I got over those differences, I realized that it mentally translates to SQL better than the other frameworks. Again, I really like Yesod and look forward to using it in the future.&lt;/p&gt;
&lt;p&gt;As always, I and my code welcome questions, comments, and the occasional funny and creative insult.&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #5d478b; font-style: italic;"&gt;{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell #-}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #5d478b; font-style: italic;"&gt;{-# LANGUAGE GADTs,OverloadedStrings,FlexibleContexts, FlexibleInstances #-}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Yesod &lt;span style="color: #06c; font-weight: bold;"&gt;as&lt;/span&gt; Y&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Text &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;pack&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; Text&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Network&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;HTTP&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Conduit &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;simpleHttp&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Network&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;HTTP&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Types &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;status200&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Digest&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Pure&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;SHA &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;showDigest&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; sha1&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Database&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Persist&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Sqlite&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Maybe"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Maybe&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Control&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Exception&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Lifted &lt;span style="color: #06c; font-weight: bold;"&gt;hiding&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;Handler&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;ByteString&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Lazy&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Internal &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;ByteString&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;share &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;mkPersist sqlSettings&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; mkMigrate &lt;span style="background-color: #3cb371;"&gt;&amp;quot;migrateAll&amp;quot;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;persist&lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;Stuff&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    value Text&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;deriving&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Show"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Show&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;data&lt;/span&gt; Challenge &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; Challenge ConnectionPool&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;mkYesod &lt;span style="background-color: #3cb371;"&gt;&amp;quot;Challenge&amp;quot;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;parseRoutes&lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;/&lt;/span&gt;fib&lt;span style="color: #339933; font-weight: bold;"&gt;/&lt;/span&gt;#Int FibR&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;/&lt;/span&gt;google&lt;span style="color: #339933; font-weight: bold;"&gt;-&lt;/span&gt;body GoogR GET&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;/&lt;/span&gt;store StoreR POST GET&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;instance&lt;/span&gt; Yesod Challenge&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;instance&lt;/span&gt; RenderMessage Challenge FormMessage &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     renderMessage &lt;span style="color: #339933; font-weight: bold;"&gt;_&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;_&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; defaultFormMessage &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;instance&lt;/span&gt; YesodPersist Challenge &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;type&lt;/span&gt; YesodPersistBackend Challenge &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; SqlPersist&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    runDB action &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        Challenge pool &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; getYesod&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        runSqlPool action pool&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;handleFibR &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; Handler RepJson&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;handleFibR num &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; jsonToRepJson &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; object &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.=&lt;/span&gt; show&lt;span style="color: #339933; font-weight: bold;"&gt;_&lt;/span&gt;fib&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    show&lt;span style="color: #339933; font-weight: bold;"&gt;_&lt;/span&gt;fib &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; fib num&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    fib &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    fib &lt;span style="color: red;"&gt;0&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    fib &lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    fib n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; fib &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n &lt;span style="color: #339933; font-weight: bold;"&gt;-&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt; fib &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n &lt;span style="color: #339933; font-weight: bold;"&gt;-&lt;/span&gt; &lt;span style="color: red;"&gt;2&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;getGoogR &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; Handler RepJson&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;getGoogR &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    body &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; try &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;simpleHttp &lt;span style="background-color: #3cb371;"&gt;&amp;quot;http://www.google.com&amp;quot;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;case&lt;/span&gt; body &lt;span style="color: #06c; font-weight: bold;"&gt;of&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        Left &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;SomeException ex&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; jsonToRepJson &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; object &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;ERROR: &amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;++&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; ex&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        Right val &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; jsonToRepJson &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; object &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;showDigest &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; sha1 val&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;postStoreR &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; Handler &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;postStoreR &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    mvalue &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; runInputPost &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; ireq textField &lt;span style="background-color: #3cb371;"&gt;&amp;quot;value&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    runDB &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; Y&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;insert &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; Stuff mvalue&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    sendResponseStatus status200 &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;getStoreR &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; Handler RepJson&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;getStoreR &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    mvalue &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; runDB &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; Y&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;selectFirst &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;Y&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Desc StuffValue&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; Y&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;LimitTo &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;case&lt;/span&gt; mvalue &lt;span style="color: #06c; font-weight: bold;"&gt;of&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        Nothing &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; jsonToRepJson &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; object &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="background-color: #3cb371;"&gt;&amp;quot;NO DATA IN DATABASE&amp;quot;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        Just mvalue' &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; jsonToRepJson &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; object &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="background-color: #3cb371;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; stuffValue &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; Y&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;entityVal mvalue'&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; withSqlitePool &lt;span style="background-color: #3cb371;"&gt;&amp;quot;:memory:&amp;quot;&lt;/span&gt; &lt;span style="color: red;"&gt;10&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; \pool &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    runSqlPool &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;runMigration migrateAll&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; pool&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    warpDebug &lt;span style="color: red;"&gt;3000&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; Challenge pool&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=Z23oiHuulcY:kkfXROUOHwU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=Z23oiHuulcY:kkfXROUOHwU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=Z23oiHuulcY:kkfXROUOHwU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=Z23oiHuulcY:kkfXROUOHwU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=Z23oiHuulcY:kkfXROUOHwU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=Z23oiHuulcY:kkfXROUOHwU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=Z23oiHuulcY:kkfXROUOHwU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/Z23oiHuulcY" height="1" width="1"/&gt;</description>
 <category domain="http://scrollingtext.org/category/catagories/haskell">Haskell</category>
 <category domain="http://scrollingtext.org/category/catagories/yesod">Yesod</category>
 <pubDate>Fri, 01 Feb 2013 05:54:36 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">90 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/my-first-yesod-app</feedburner:origLink></item>
<item>
 <title>First Flask web app</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/od8wsJJ3OIs/first-flask-web-app</link>
 <description>&lt;p&gt;As everyone should know by now, I love coding challenges. A while ago I came across this one, which is rather long:&lt;br /&gt;
&lt;code&gt;Using python with &lt;a href="http://gevent.org"&gt;gevent&lt;/a&gt; 0.13.x and your choice of additional libraries and/or frameworks, implement a single HTTP server with API endpoints that provide the following functionalities:&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt; A Fibonacci endpoint that accepts a number and returns the Fibonacci calculation for that number, and returns result in JSON format. example:&lt;/p&gt;
&lt;li&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #660033;"&gt;-s&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/fib/13'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt;: &lt;span style="color: #000000;"&gt;233&lt;/span&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #660033;"&gt;-s&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/fib/12'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt;: &lt;span style="color: #000000;"&gt;144&lt;/span&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt; An endpoint that fetches the Google homepage and returns the sha1 of the response message-body (HTTP body data).example:&lt;/p&gt;
&lt;li&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #660033;"&gt;-s&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/google-body'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt;: &lt;span style="color: #ff0000;"&gt;&amp;quot;272cca559ffe719d20ac90adb9fc4e5716479e96&amp;quot;&lt;/span&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
    Using some external storage of your choice (can be redis, memcache, sqlite, mysql, etc), provide a means to store and then retrieve a value.Example:&lt;/p&gt;
&lt;li&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #660033;"&gt;-d&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'value=something'&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/store'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;$ curl &lt;span style="color: #ff0000;"&gt;'http://127.0.0.1:8080/store'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt;: &lt;span style="color: #ff0000;"&gt;&amp;quot;something&amp;quot;&lt;/span&gt;&lt;span style="color: #7a0874; font-weight: bold;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/&lt;/span&gt;li&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;
    &lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;At one point in my past a coworker talked about his love of the Flask micro framework. Since this is just a simple web API, I figured I'd give it a shot. This is a bit of a complicated task with many pieces, so let's set a game plan for the rest of this post. I'm going to share the specific functions related to each piece of functionality, then at the very end I will share the entire code base so everyone can see how it all fits together.  One last note - to test out the run, you need to call the run.py script, which will also be included below. Ready … BREAK!&lt;/p&gt;
&lt;p&gt;Let's tackle the google-body endpoint first:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;route&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'/google-body'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; google_body&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        sh &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;sha&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;urlopen&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'http://www.google.com'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: black;"&gt;read&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : sh.&lt;span style="color: black;"&gt;hexdigest&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;Exception&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;as&lt;/span&gt; e:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;'ERROR: %s'&lt;/span&gt; % &lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;e&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;While this code block is very compact, it's not difficult to understand. Go out to the internet, get the source code for google's home page and insert that into the sha object. Wrap up the hexdigest results into a dictionary object, throw that into the jsonify function, and send it on its way. Don't forget to package it all in a nice try/except block for safety.&lt;/p&gt;
&lt;p&gt;Onto the Fibonacci API call:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;route&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'/fib/&amp;lt;number&amp;gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;int&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;ValueError&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;'ERROR: Input not a number'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;lru_cache&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;n&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #483d8b;"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;        This code was modified from the fib code in the python3 functools &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;        documentation.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;    &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; n &lt;span style="color: #66cc66;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;2&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; n&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;n-&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; + real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;n-&lt;span style="color: #ff4500;"&gt;2&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;During PyCon US 2012, I became aware of the lru_cache decorator in python3.3. I also learned that Raymond Hettinger wrote code that would allow it work in &lt;a href="http://code.activestate.com/recipes/578078-py26-and-py30-backport-of-python-33s-lru-cache/?in=user-178123"&gt;python2&lt;/a&gt;, which allowed me to copy the code from the python3 documentation with little modification.  Knowing about the lru_cache allowed me to write a nice and concise Fibonacci function reminiscent of something I might write in Haskell or some other functional language.&lt;/p&gt;
&lt;p&gt;Now the last part of this challenge, and the longest. Before we get to the python, I feel that it might help your understanding if you know what kind of database schema we're working with. So I'm going to post that first, then the python code.&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="text geshifilter-text" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;drop table if exists entries;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;create table entries (&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    id integer primary key autoincrement,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    value string not null&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;);&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;route&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'/store'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; methods&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'GET'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'POST'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; store&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; request.&lt;span style="color: black;"&gt;method&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'POST'&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            g.&lt;span style="color: black;"&gt;db&lt;/span&gt;.&lt;span style="color: black;"&gt;execute&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'insert into entries (value) values (?)'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                         &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;request.&lt;span style="color: black;"&gt;form&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'value'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            g.&lt;span style="color: black;"&gt;db&lt;/span&gt;.&lt;span style="color: black;"&gt;commit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            resp &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            resp.&lt;span style="color: black;"&gt;status_code&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;200&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; resp&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;Exception&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;as&lt;/span&gt; e:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;&amp;quot;ERROR: %s&amp;quot;&lt;/span&gt; % &lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;e&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            cur &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; g.&lt;span style="color: black;"&gt;db&lt;/span&gt;.&lt;span style="color: black;"&gt;execute&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'select value from entries order by id desc'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #808080; font-style: italic;"&gt;#fetchone returns a list. To better meet the requirements,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #808080; font-style: italic;"&gt;#just slicing the head of the list and output that.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : cur.&lt;span style="color: black;"&gt;fetchone&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;IndexError&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;'NOTHING IN THE DATABASE'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This step is obviously a little more complex - the function has to process both the GET and the POST HTTP methods, while using an outside database to store and retrieve the information. I believe the code here is simple enough for you to understand, so I won't explain every line. For the POST method I had to do some juggling to get the desired return results. In the example above a POST method works, but does not receive an actual response. I was able to create this by using the jsonify object to create an empty &lt;a href="http://flask.pocoo.org/docs/api/#flask.Response"&gt;Flask.Response&lt;/a&gt; object, and then set the status code of that response.&lt;/p&gt;
&lt;p&gt;At the end of the day I'm pretty happy with this. It wasn't a hard challenge, but certainly allowed me to learn a bit about Flask. If I did over again, I might improve things by creating my own decorator to abstract all the try/except blocks. The errors would have to become more generic and maybe less helpful, but that is a worthwhile cost for being able to live the “Don't Repeat Yourself” mentality.  The decorator would look something like this (the code below has not been tested - caveat emptor):&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; try_block&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;f&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;wraps&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; wrapper&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;*args&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; **kwds&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; f&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;*args&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;**kwds&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;       &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;ValueError&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;'ERROR: Input not a number'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;As more functions start to use this decorator it'll most likely get uglier as it has to juggle more and more exceptions. While that is certainly a cost of having all of the error checking wrapped up in one location, the benefit that I can see is if another programmer were to add a new piece of functionality, he would know exactly where to go to add in the exceptions if it wasn't there already.&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;route&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'/fib/&amp;lt;number&amp;gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;try_block&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;int&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
I think this would clean up the function quite a bit.&lt;/p&gt;
&lt;p&gt;Next time I'm going to show how to do this in Haskell using the Yesod web framework. As always, questions, and comments are welcomed.&lt;/p&gt;
&lt;p&gt;run.py&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; gevent.&lt;span style="color: black;"&gt;wsgi&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; WSGIServer&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; playhaven &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; app&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; init_db&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;init_db&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;http_server &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; WSGIServer&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'0.0.0.0'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;8080&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; app&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;http_server.&lt;span style="color: black;"&gt;serve_forever&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;challenge.py&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;__future__&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; with_statement&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;urllib2&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; urlopen&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; contextlib &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; closing&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; flask &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; Flask&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; request&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; g&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; jsonify&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; lru_cache &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; lru_cache&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; sqlite3&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;sha&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;DATABASE &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'/tmp/challenge.db'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;DEBUG &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #008000;"&gt;True&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;SECRET_KEY &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'c29tZXRoaW5nY2xldmVyaGVyZQ==&lt;span style="color: #000099; font-weight: bold;"&gt;\n&lt;/span&gt;'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;USERNAME &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'challenge'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;PASSWORD &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'chang3m3'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;app &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; Flask&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;__name__&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;app.&lt;span style="color: black;"&gt;config&lt;/span&gt;.&lt;span style="color: black;"&gt;from_object&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;__name__&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;app.&lt;span style="color: black;"&gt;config&lt;/span&gt;.&lt;span style="color: black;"&gt;from_envvar&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'CHALLENGE_SETTINGS'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; silent&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #008000;"&gt;True&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; connect_db&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; sqlite3.&lt;span style="color: black;"&gt;connect&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;app.&lt;span style="color: black;"&gt;config&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'DATABASE'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; init_db&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;with&lt;/span&gt; closing&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;connect_db&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;as&lt;/span&gt; db:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;with&lt;/span&gt; app.&lt;span style="color: black;"&gt;open_resource&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'schema.sql'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;as&lt;/span&gt; f:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            db.&lt;span style="color: black;"&gt;cursor&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: black;"&gt;executescript&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;f.&lt;span style="color: black;"&gt;read&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        db.&lt;span style="color: black;"&gt;commit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;before_request&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; before_request&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    g.&lt;span style="color: black;"&gt;db&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; connect_db&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;teardown_request&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; teardown_request&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;exception&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    g.&lt;span style="color: black;"&gt;db&lt;/span&gt;.&lt;span style="color: black;"&gt;close&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;route&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'/fib/&amp;lt;number&amp;gt;'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;int&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;ValueError&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;'ERROR: Input not a number'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;lru_cache&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;n&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #483d8b;"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;        This code was modified from the fib code in the python3 functools &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;        documentation.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;    &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; n &lt;span style="color: #66cc66;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;2&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; n&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;n-&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; + real_fib&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;n-&lt;span style="color: #ff4500;"&gt;2&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;route&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'/google-body'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; google_body&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        sh &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;sha&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;new&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;urlopen&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'http://www.google.com'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: black;"&gt;read&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : sh.&lt;span style="color: black;"&gt;hexdigest&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;Exception&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;as&lt;/span&gt; e:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;'ERROR: %s'&lt;/span&gt; % &lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;e&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;@&lt;/span&gt;app.&lt;span style="color: black;"&gt;route&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'/store'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; methods&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'GET'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'POST'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; store&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; request.&lt;span style="color: black;"&gt;method&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'POST'&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            g.&lt;span style="color: black;"&gt;db&lt;/span&gt;.&lt;span style="color: black;"&gt;execute&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'insert into entries (value) values (?)'&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                         &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;request.&lt;span style="color: black;"&gt;form&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'value'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            g.&lt;span style="color: black;"&gt;db&lt;/span&gt;.&lt;span style="color: black;"&gt;commit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            resp &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            resp.&lt;span style="color: black;"&gt;status_code&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;200&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; resp&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;Exception&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;as&lt;/span&gt; e:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;response&amp;quot;&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;&amp;quot;ERROR: %s&amp;quot;&lt;/span&gt; % &lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;e&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            cur &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; g.&lt;span style="color: black;"&gt;db&lt;/span&gt;.&lt;span style="color: black;"&gt;execute&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'select value from entries order by id desc'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #808080; font-style: italic;"&gt;#fetchone returns a list. To better meet the requirements,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #808080; font-style: italic;"&gt;#just slicing the head of the list and output that.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : cur.&lt;span style="color: black;"&gt;fetchone&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;IndexError&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; jsonify&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;'response'&lt;/span&gt; : &lt;span style="color: #483d8b;"&gt;'NOTHING IN THE DATABASE'&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'__main__'&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    app.&lt;span style="color: black;"&gt;run&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=od8wsJJ3OIs:Orv-fkzGmM4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=od8wsJJ3OIs:Orv-fkzGmM4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=od8wsJJ3OIs:Orv-fkzGmM4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=od8wsJJ3OIs:Orv-fkzGmM4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=od8wsJJ3OIs:Orv-fkzGmM4:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=od8wsJJ3OIs:Orv-fkzGmM4:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=od8wsJJ3OIs:Orv-fkzGmM4:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/od8wsJJ3OIs" height="1" width="1"/&gt;</description>
 <category domain="http://scrollingtext.org/category/catagories/flask">Flask</category>
 <category domain="http://scrollingtext.org/category/catagories/python">Python</category>
 <pubDate>Wed, 28 Nov 2012 21:54:09 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">89 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/first-flask-web-app</feedburner:origLink></item>
<item>
 <title>Project Euler: Problem 16</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/MhTtTF68UpE/project-euler-problem-16</link>
 <description>&lt;p&gt;I'm not dead yet! I've just been insanely busy the last month or two with changing jobs and preparing my first programming presentation for &lt;a href="http://baypiggies.net"&gt;BayPiggies&lt;/a&gt; and &lt;a href="http://www.siliconvalley-codecamp.com/"&gt;Silicon Valley Code Camp&lt;/a&gt; (which is a post for the near future). Both of these have kept me away from my blog. Let me make it up to you with a solution to project Euler problem #16. &lt;/p&gt;
&lt;p&gt;The challenge is:&lt;br /&gt;
&lt;quote&gt;&lt;br /&gt;
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.&lt;br /&gt;
What is the sum of the digits of the number 21000?&lt;/quote&gt;&lt;/p&gt;
&lt;p&gt;Let's start with some Python code:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;#!/usr/bin/python&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt; &lt;span style="color: #008000;"&gt;sum&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #008000;"&gt;int&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;i&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;2&lt;/span&gt; ** &lt;span style="color: #ff4500;"&gt;1000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;For this solution, using a more functional approach definitely reduced the code base. But one thing I was a little surprised about is that having a list comprehension within the sum function is actually faster than a generator expression. Usually one hears how generator expressions are preferred over list comprehensions because they are more efficient with memory, among other reasons. However, it's actually faster to give sum a list. One quick caveat, this whole sum and list comprehension thing applies to Python 2. The same seems to be also be true for Python 3, at least from the interpreter:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;sum(int(x) for x in str(2 ** 1000))&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; number&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;1000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff4500;"&gt;0.11109958100132644&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;sum([int(x) for x in str(2 ** 1000)])&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; number&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;1000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff4500;"&gt;0.09597363900684286&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;sum(int(x) for x in str(2 ** 1000))&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; number&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;10000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff4500;"&gt;1.051396899012616&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;sum([int(x) for x in str(2 ** 1000)])&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; number&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;10000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff4500;"&gt;0.9054670640034601&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;sum(int(x) for x in str(2 ** 1000))&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; number&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;100000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff4500;"&gt;10.498383879996254&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #66cc66;"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;.&lt;span style="color: #dc143c;"&gt;timeit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;sum([int(x) for x in str(2 ** 1000)])&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; number&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;100000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff4500;"&gt;8.992312036993098&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;On to the Haskell code:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;module&lt;/span&gt; Main &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Char"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Char&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;main &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"&gt;&lt;span style="font-weight: bold;"&gt;sum&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; digitToInt &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;span style="color: red;"&gt;2&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;^&lt;/span&gt; &lt;span style="color: red;"&gt;1000&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Maybe it's just me and my Haskell/Python-centric brain, but I think the algorithm is simple enough to easily see the similarities and differences between the two languages.  If I wanted to write the Haskell code to better match the Python code (syntactic differences aside), it would look like this: (inside the Haskell interpreter)&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;Prelude&lt;/span&gt;&lt;/a&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Char&lt;span style="color: #339933; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"&gt;&lt;span style="font-weight: bold;"&gt;sum&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt; digitToInt x &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; x &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: red;"&gt;2&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;^&lt;/span&gt; &lt;span style="color: red;"&gt;1000&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Even though this code may be easier to read for a Python programmer, it's not “good” Haskell code. It'll get the job done, but the map is obfuscated by the list comprehension. We can also adjust the Python code to make it resemble Haskell by using map:&lt;/p&gt;
&lt;p&gt;&lt;span class="geshifilter"&gt;&lt;code class="python geshifilter-python"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt; &lt;span style="color: #008000;"&gt;sum&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;map&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;int&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;2&lt;/span&gt; ** &lt;span style="color: #ff4500;"&gt;1000&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;But that might get you “dinged” because some people think that using map is “too functional” or “not Pythonic”, even if the code might be faster. &lt;sigh&gt; I don't subscribe to that line of thinking...but that's a discussion for another time.&lt;/p&gt;
&lt;p&gt;Times:&lt;br /&gt;
python – list comprehension : .032s&lt;br /&gt;
python – map		           : .030s&lt;br /&gt;
haskell – list ( interpreted)    : .155s&lt;br /&gt;
haskell – map (interpreted)   : .155s&lt;br /&gt;
haskell – list (compiled)       : .006s&lt;br /&gt;
haskell – map (compiled)     : .006s&lt;/p&gt;
&lt;p&gt;As always, questions, comments, and complaints are encouraged.  I hope everyone will forgive me for not posting for so long... sometimes life happens.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=MhTtTF68UpE:BN63bQirwgo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=MhTtTF68UpE:BN63bQirwgo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=MhTtTF68UpE:BN63bQirwgo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=MhTtTF68UpE:BN63bQirwgo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=MhTtTF68UpE:BN63bQirwgo:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=MhTtTF68UpE:BN63bQirwgo:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=MhTtTF68UpE:BN63bQirwgo:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/MhTtTF68UpE" height="1" width="1"/&gt;</description>
 <category domain="http://scrollingtext.org/category/catagories/haskell">Haskell</category>
 <category domain="http://scrollingtext.org/category/catagories/project-euler">Project Euler</category>
 <category domain="http://scrollingtext.org/category/catagories/python">Python</category>
 <pubDate>Thu, 25 Oct 2012 16:12:48 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">88 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/project-euler-problem-16</feedburner:origLink></item>
<item>
 <title>Book Review - Coders At Work</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/nY2vpaUrX5s/book-review-coders-work</link>
 <description>&lt;p&gt;&lt;center&gt;&lt;img src="http://scrollingtext.org/sites/default/files/cow.png"&gt;&lt;/center&gt;&lt;br /&gt;
I just finished reading the book &lt;a href="https://en.wikipedia.org/wiki/Coders_at_work"&gt;&lt;i&gt;Coders at Work&lt;/i&gt;&lt;/a&gt; by &lt;a href="https://twitter.com/#!/peterseibel"&gt;Peter Seibel&lt;/a&gt;. This wonderful book is filled with interviews with prominent programmers: Joe Armstrong, Simon Peyton Jones, Donald Knuth, among others. My review isn't going to be the standard book review. Instead I'm going to talk about some of the specific ideas I picked up while reading the book and discuss those ideas, rather than the book itself. For those of you who are looking for more of a standard review, all I can really say is that Coders at Work is well worth the time for  a programmer or a computer historian/hobbyist. Unfortunately for the casual non-computer-field reader, the interview topics (and the interviewees) assume a certain level of prior knowledge. What makes this book so good is that different people will be able to walk away from it with different ideas, depending on their areas of expertise and interest. As the industry grows and changes, we definitely do things based on what the people before us have already discovered - Seibel’s interview subjects are the fascinating programmers whose ideas and hard work make possible all the cool things we get to play with today.&lt;/p&gt;
&lt;p&gt;Code Readings:&lt;/p&gt;
&lt;p&gt;In the interview with &lt;a href="http://en.wikipedia.org/wiki/Douglas_Crockford"&gt;Douglas Crockford&lt;/a&gt; there was a lot of talk about code readings. If you’re not sure what those are (I wasn’t), from the way Douglas describes it they are regular meetings where programmers read the code base together.  In my mind it sounds like someone is giving a presentation but instead of it being PowerPoint slides, it’s code. I picture the presenter going line by line and describing what is going on and why he or she decided to do things a particular way. These sound like an excellent idea to me. In my experience so far, the code review process seems to have been relegated to using &lt;a href="http://www.reviewboard.org/"&gt;Reviewboard&lt;/a&gt; or other similar website-based tools. I'm not trying to insult these tools, but they remove the human factor of the code review and hinder the discussion that can happen over a particular piece of code. I understand that programmer time is expensive and managers should be careful how much of that time is spent in meetings. But I think these meetings could benefit everyone and will have a return on investment (that is the time spent) in ways that cannot be quickly seen. One benefit is that everyone who attends will come out with a basic idea of what the code looks like within a given project, even if they’re not working on that project directly. So if things shift around (as they inevitably do) and a new person is moved into that project, he or she won’t be starting from scratch. Even just a little bit of knowledge might help a programmer get over the initial shock of having to dive into a new project.&lt;/p&gt;
&lt;p&gt;Programmers need Empathy:&lt;/p&gt;
&lt;p&gt;In the interview with &lt;a href="http://en.wikipedia.org/wiki/Joshua_Bloch"&gt;Joshua Bloch&lt;/a&gt; there was a quick chat about programmer personalities. There were a couple of choice quotes regarding programmer empathy for the users, like, “...intelligence is not a scalar quantity; it’s a vector quantity. And if you lack empathy or emotional intelligence, then you shouldn’t be designing APIs or GUIs or languages.” and “What we’re doing is an aesthetic pursuit. It involves craftsmanship as well as mathematics and it involves people skills and prose skills—all of these things that we don’t necessarily think of as engineering but without which I don’t think you’ll ever be a really good engineer.”&lt;/p&gt;
&lt;p&gt;I bring these quotes up because I agree with them, and because they speak of issues that are largely ignored in the engineering community (again, in my experience). I've sure we’ve all run into programmers that only care about the technical aspects of the project or the correctness of their code and do not concern themselves for how the user might interact with the system. For example, the company I work for designed a web-app that included separate “Kill” and “Terminate” buttons.  This was a complete UI fail that could have been avoided, had the programmer (we’ll call him/her “Terry”) had empathy for the user.  As a programmer, I understand the difference between &lt;a href="https://en.wikipedia.org/wiki/SIGKILL"&gt;SIGKILL&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/SIGTERM"&gt;SIGTERM&lt;/a&gt;, but those buttons would be confusing to even the more-advanced-than-average user (and go far beyond failing &lt;a href="http://www.urbandictionary.com/define.php?term=Grandma+Test"&gt;the grandmother test&lt;/a&gt;).  When this was brought up as a ticket for “Terry” to fix, “Terry” argued that there was nothing technically incorrect about the problem and closed the ticket “Won't Fix.”&lt;/p&gt;
&lt;p&gt;Hiring:&lt;/p&gt;
&lt;p&gt;One thing I noticed in a lot of the interviews was that Peter asked the interviewee what he or she looked for in a potential new hire. What I found fascinating is that none of them said, “I like to ask really hard questions.” or “I ask really obscure questions about the programming language they use to see how well they know it.” They mostly talked about looking for someone who had passion for the craft.&lt;/p&gt;
&lt;p&gt;As someone who is frequently on both sides of the hiring table, I know that the current hiring process in Silicon Valley doesn't normally ask questions about WHO is being hired. Questions about hobbies or interests are rare. It's mostly just technical questions, as if the person who is applying for the job is another computer whose sole purpose is to solve a company's problems. All the emphasis seems to be focused on the technical skills of the interviewee. While it's important to know if someone can “do the job,” tech skills alone do not make a person a great programmer - a good one, yes, but I don’t get the impression that companies are settling for “good” anymore. Passion is what gives someone the tenacity to work through the obstacles and become a great programmer, and if we as interviewers insist on focusing only on hard skills, we risk cheating ourselves out of the truly great engineers.&lt;/p&gt;
&lt;p&gt;Donald Knuth:&lt;/p&gt;
&lt;p&gt;Peter also asked every single interviewee about Donald Knuth's books and his “literate programming”&lt;br /&gt;
&lt;link:w3&gt; style of writing code. I will admit that I have not read his books, but I want to. I'm not sure what this literate programming style is, but I'm curious enough about it to learn, and see if there are some aspects of it I can incorporate into my own coding and documentation style. Next step, pick up an electronic version of the book, &lt;a href="https://en.wikipedia.org/wiki/Literate_programming"&gt;“Literate Programming”&lt;/a&gt; and give it a good read.&lt;/p&gt;
&lt;p&gt;I fully enjoyed Coders at Work. I took away much more from the interviews than I talked about here, and I’m sure there’s even more to learn.  I'm planning on rereading it again in a couple of years; as I grow as a programmer I will have a different perspective on the craft, and might find a whole new or different set of lessons from what I got this time. If not, at the very least I’ll have the pleasure of reading it again. &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=nY2vpaUrX5s:aq98eh1gEGY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=nY2vpaUrX5s:aq98eh1gEGY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=nY2vpaUrX5s:aq98eh1gEGY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=nY2vpaUrX5s:aq98eh1gEGY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=nY2vpaUrX5s:aq98eh1gEGY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=nY2vpaUrX5s:aq98eh1gEGY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=nY2vpaUrX5s:aq98eh1gEGY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/nY2vpaUrX5s" height="1" width="1"/&gt;</description>
 <category domain="http://scrollingtext.org/category/catagories/book-reviews">Book Reviews</category>
 <pubDate>Tue, 28 Aug 2012 17:01:00 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">87 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/book-review-coders-work</feedburner:origLink></item>
<item>
 <title>Project Euler: Problem 14</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/S-fLtjionZs/project-euler-problem-14</link>
 <description>&lt;p&gt;“The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd).  Using the rule above and starting with 13, we generate the following sequence: 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1.  It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms.  Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.  Which starting number, under one million, produces the longest chain?  NOTE: Once the chain starts the terms are allowed to go above one million.”&lt;/p&gt;
&lt;p&gt;&lt;shamlessPlug&gt;Not many of you may be aware of this, but about a year ago I wrote up a blog post that discussed Collatz chains in Haskell.  You can find that post here: &lt;http://scrollingtext.org/devil-details-part-2&gt;.&lt;/shamelessPlug&gt; Having some of the code already written made coming up with the solution easier.  However, just because I had one function doesn't mean I had the whole problem licked.  I still had a fair amount of work in front of me.  Below is my code from the first attempt at a solution:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;module&lt;/span&gt; Main &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;List&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' &lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' n&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: red;"&gt;0&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:even"&gt;&lt;span style="font-weight: bold;"&gt;even&lt;/span&gt;&lt;/a&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; n : chain' &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n `&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:div"&gt;&lt;span style="font-weight: bold;"&gt;div&lt;/span&gt;&lt;/a&gt;` &lt;span style="color: red;"&gt;2&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:odd"&gt;&lt;span style="font-weight: bold;"&gt;odd&lt;/span&gt;&lt;/a&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; n : chain' &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n &lt;span style="color: #339933; font-weight: bold;"&gt;*&lt;/span&gt; &lt;span style="color: red;"&gt;3&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; main &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; seqx &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; chain' &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;3&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;..&lt;/span&gt;&lt;span style="color: red;"&gt;1000000&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; lengthx &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:length"&gt;&lt;span style="font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt; seqx&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:maximum"&gt;&lt;span style="font-weight: bold;"&gt;maximum&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zip"&gt;&lt;span style="font-weight: bold;"&gt;zip&lt;/span&gt;&lt;/a&gt; lengthx seqx&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
This code appears to be logically correct but was incredibly slow - so slow that after over 2 minutes it still hadn’t completed.  I admit I can be a little impatient with these things from time to time, but in this case something was obviously wrong.&lt;/p&gt;
&lt;p&gt;I devised two optimizations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; Reverse the order of the list. I will be more likely to find the number with the longest chain near 1,000,000 than 3.&lt;/li&gt;
&lt;li&gt; Use odd numbers only. This is based on the fact that in the chain' function an odd number gets multiplied right off the bat, whereas an even number is instantly divided by 2, and also on the assumption that a higher number will be more likely to have a longer chain.  (I admit this was a complete experiment - I had no proof that it would work ahead of time, and knew it gave me the right answer only after the fact.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The code then morphed into:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;module&lt;/span&gt; Main &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;List&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' &lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' n&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: red;"&gt;0&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:even"&gt;&lt;span style="font-weight: bold;"&gt;even&lt;/span&gt;&lt;/a&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; n : chain' &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n `&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:div"&gt;&lt;span style="font-weight: bold;"&gt;div&lt;/span&gt;&lt;/a&gt;` &lt;span style="color: red;"&gt;2&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:odd"&gt;&lt;span style="font-weight: bold;"&gt;odd&lt;/span&gt;&lt;/a&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; n : chain' &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n &lt;span style="color: #339933; font-weight: bold;"&gt;*&lt;/span&gt; &lt;span style="color: red;"&gt;3&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; main &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; seqx &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; chain' &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;999999&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;&lt;span style="color: red;"&gt;999997&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;..&lt;/span&gt;&lt;span style="color: red;"&gt;3&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; lengthx &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:length"&gt;&lt;span style="font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt; seqx&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:maximum"&gt;&lt;span style="font-weight: bold;"&gt;maximum&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zip"&gt;&lt;span style="font-weight: bold;"&gt;zip&lt;/span&gt;&lt;/a&gt; lengthx seqx&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The problem I ran into with this code was that I received stack overflow errors; my list of tuples holding another long list of int’s was taking up to much memory.  I fixed this problem by computing the length of the list immediately after generating it.  The new code looked like this:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;List&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' &lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;chain' n&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: red;"&gt;0&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:even"&gt;&lt;span style="font-weight: bold;"&gt;even&lt;/span&gt;&lt;/a&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; n : chain' &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n `&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:div"&gt;&lt;span style="font-weight: bold;"&gt;div&lt;/span&gt;&lt;/a&gt;` &lt;span style="color: red;"&gt;2&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:odd"&gt;&lt;span style="font-weight: bold;"&gt;odd&lt;/span&gt;&lt;/a&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; n : chain' &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n &lt;span style="color: #339933; font-weight: bold;"&gt;*&lt;/span&gt; &lt;span style="color: red;"&gt;3&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; main &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; seqx &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;\x → &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;x&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:length"&gt;&lt;span style="font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; chain' x&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;999999&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;&lt;span style="color: red;"&gt;999997&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;..&lt;/span&gt;&lt;span style="color: red;"&gt;3&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:maximum"&gt;&lt;span style="font-weight: bold;"&gt;maximum&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; seqx&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This got me a result within the one minute time frame, but it still wasn't the right answer.  Can you figure out why?  Using &lt;a href="http://scrollingtext.org/apache-log-ip-counting#comment-384"&gt;the great code Jedai posted in the comments of my Apache log post&lt;/a&gt;, I was able to get my answer and finally complete the problem:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;module&lt;/span&gt; Main &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;                                                                             &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Tuple&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;List &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;sortBy&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Function &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;on&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  chain' &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  chain' &lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  chain' n&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: red;"&gt;0&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:even"&gt;&lt;span style="font-weight: bold;"&gt;even&lt;/span&gt;&lt;/a&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; n : chain' &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n `&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:div"&gt;&lt;span style="font-weight: bold;"&gt;div&lt;/span&gt;&lt;/a&gt;` &lt;span style="color: red;"&gt;2&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:odd"&gt;&lt;span style="font-weight: bold;"&gt;odd&lt;/span&gt;&lt;/a&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; n : chain' &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;n &lt;span style="color: #339933; font-weight: bold;"&gt;*&lt;/span&gt; &lt;span style="color: red;"&gt;3&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  main &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;      &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; seqx &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;\x &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;x&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:length"&gt;&lt;span style="font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; chain' x&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;999999&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;&lt;span style="color: red;"&gt;999997&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;..&lt;/span&gt;&lt;span style="color: red;"&gt;3&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;      &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:fst"&gt;&lt;span style="font-weight: bold;"&gt;fst&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"&gt;&lt;span style="font-weight: bold;"&gt;head&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; sortBy &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:flip"&gt;&lt;span style="font-weight: bold;"&gt;flip&lt;/span&gt;&lt;/a&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:compare"&gt;&lt;span style="font-weight: bold;"&gt;compare&lt;/span&gt;&lt;/a&gt; `on` &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:snd"&gt;&lt;span style="font-weight: bold;"&gt;snd&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; seqx&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://scrollingtext.org/sites/default/files/bingo_computer_programming_languages.png"&gt;&lt;/p&gt;
&lt;p&gt;After figuring that out, getting the python answer was a breeze:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;#!/usr/bin/python&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;&amp;quot;&amp;quot;Python solution for Project Euler problem #14.&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;itertools&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; imap&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; sequence&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    t_num &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; number&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    count &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;while&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;t_num &lt;span style="color: #66cc66;"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; t_num % &lt;span style="color: #ff4500;"&gt;2&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            t_num /&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;2&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            t_num &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;t_num * &lt;span style="color: #ff4500;"&gt;3&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        count +&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;return&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;count&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt; &lt;span style="color: #008000;"&gt;max&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;imap&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;sequence&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #008000;"&gt;xrange&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;999999&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;3&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;-&lt;span style="color: #ff4500;"&gt;2&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Here are the speed numbers:&lt;br /&gt;
Haskell (complied) : 14.758s&lt;br /&gt;
Python : 18.537s&lt;br /&gt;
Haskell (runghc): 15.217s&lt;/p&gt;
&lt;p&gt;I think the use of recursion in my Haskell code is affecting its speed of computation.  As I learned from problem 12, I can use the State Monad again to speed things up.  But I also learned from the comments of &lt;a href="http://scrollingtext.org/project-euler-problem-12"&gt;problem 12&lt;/a&gt; that some people were able to substitute a scan or fold in the State Monad’s place.  So I decided to shoot for one more solution.  After studying up on scan and fold, and finding that neither was really what I wanted, I found iterate. Using iterate I was able to change the program to this:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;module&lt;/span&gt; Main &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Tuple&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;List &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;sortBy&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:iterate"&gt;&lt;span style="font-weight: bold;"&gt;iterate&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Function &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;on&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; chain' &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Integer"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Integer&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; chain' n  &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; n &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:otherwise"&gt;&lt;span style="font-weight: bold;"&gt;otherwise&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:length"&gt;&lt;span style="font-weight: bold;"&gt;length&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;takeWhile &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:iterate"&gt;&lt;span style="font-weight: bold;"&gt;iterate&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;\x &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;if&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:even"&gt;&lt;span style="font-weight: bold;"&gt;even&lt;/span&gt;&lt;/a&gt; x &lt;span style="color: #06c; font-weight: bold;"&gt;then&lt;/span&gt; x `&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:div"&gt;&lt;span style="font-weight: bold;"&gt;div&lt;/span&gt;&lt;/a&gt;` &lt;span style="color: red;"&gt;2&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;else&lt;/span&gt; x &lt;span style="color: #339933; font-weight: bold;"&gt;*&lt;/span&gt; &lt;span style="color: red;"&gt;3&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;1&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; n&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; main &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt; main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; seqx &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;\x &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;x&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; chain' x&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: red;"&gt;999999&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;&lt;span style="color: red;"&gt;999997&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;..&lt;/span&gt;&lt;span style="color: red;"&gt;3&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;     &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:fst"&gt;&lt;span style="font-weight: bold;"&gt;fst&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"&gt;&lt;span style="font-weight: bold;"&gt;head&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; sortBy &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:flip"&gt;&lt;span style="font-weight: bold;"&gt;flip&lt;/span&gt;&lt;/a&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:compare"&gt;&lt;span style="font-weight: bold;"&gt;compare&lt;/span&gt;&lt;/a&gt; `on` &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:snd"&gt;&lt;span style="font-weight: bold;"&gt;snd&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; seqx&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The new chain' function doesn't read as cleanly as the old one, but it does remove the recursion I was talking about earlier.  The computer gods rewarded my efforts by reducing the run times to these:&lt;/p&gt;
&lt;p&gt;Haskell (complied) : 10.933s&lt;br /&gt;
Haskell (runghc): 11.744s&lt;/p&gt;
&lt;p&gt;From 14.758 to 10.933 - almost 4 seconds taken off the clock!  I think a speed up like that calls for some celebrating.  Which is exactly what I'm going to do before I start on problem 15.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=S-fLtjionZs:PDh6K5wGjX4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=S-fLtjionZs:PDh6K5wGjX4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=S-fLtjionZs:PDh6K5wGjX4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=S-fLtjionZs:PDh6K5wGjX4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=S-fLtjionZs:PDh6K5wGjX4:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=S-fLtjionZs:PDh6K5wGjX4:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=S-fLtjionZs:PDh6K5wGjX4:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/S-fLtjionZs" height="1" width="1"/&gt;</description>
 <comments>http://scrollingtext.org/project-euler-problem-14#comments</comments>
 <category domain="http://scrollingtext.org/category/catagories/haskell">Haskell</category>
 <category domain="http://scrollingtext.org/category/catagories/project-euler">Project Euler</category>
 <category domain="http://scrollingtext.org/category/catagories/python">Python</category>
 <pubDate>Wed, 25 Jul 2012 16:45:37 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">86 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/project-euler-problem-14</feedburner:origLink></item>
<item>
 <title>More than 1095 days of existence!!  Or...Happy third birthday to Scrollingtext!!!</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/24oFAvDQC9g/more-1095-days-existence-orhappy-third-birthday-scrollingtext</link>
 <description>&lt;p&gt;&lt;img src="http://scrollingtext.org/sites/default/files/3_lenses.jpeg"&gt;&lt;br /&gt;
Another 365 have come and gone since the last time I've written one of these birthday posts, and like last time I'm still surprised and still proud that this blog and my creative juices have survived this long.&lt;/p&gt;
&lt;p&gt;I will be the first to admit that I'm totally amazed over 17 THOUSAND people from all over the world have dropped by my site and read my writing. Who know what I had to say was that interesting?  Knowing that interest is growing really makes me want to continue improving my writing and finding more interesting projects to explore.  Last year Scrollingtext saw a little more than 10 thousand people - there’s been an amazing amount of growth over the last year, and I think I'm going to make it a personal goal to continue this trend.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;The five most popular posts for the year are:&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://scrollingtext.org/pxe-network-boot-virtualbox-pt-2"&gt;PXE Network Boot VirtualBox, PT 2&lt;/a&gt; – This one has been up here for a long time. Seeing this in the top 5 makes me think I should think about doing follow-up posts on VirtualBox. Apparently people find this helpful.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://scrollingtext.org/using-curl-and-user-agent-string-web-scraping-pt-2-now-php"&gt;Using curl and a user agent string for web scraping&lt;/a&gt; – I had no idea that web scraping would be so popular. Maybe I should write a follow-up article for this one too.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://scrollingtext.org/project-euler-problem-5"&gt;Project Euler: Problem 5&lt;/a&gt; – The biggest thing for me about this post was learning about lcm's. As has been pointed out to me in the comments for Problem 12, and as a statement about programming in general, understanding the problem and knowing the right algorithm (or two) that solve it is more than half the battle.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://scrollingtext.org/project-euler-problem-4"&gt;Project Euler: Problem 4&lt;/a&gt; – I think this one takes the cake for most comments on a single post. Oh and OJ, I was just reading over those comments and I think I picked up on your subtle optimization. Nice little trick! &lt;/li&gt;
&lt;li&gt;&lt;a href="http://scrollingtext.org/project-euler-problem-12"&gt;Project Euler: Problem 12&lt;/a&gt; – I was really proud of this post. I spent a lot of time and energy learning how to use the State Monad to get the problem to run and the result was totally worth the effort.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;b&gt;Things I've learned:&lt;/b&gt;&lt;br /&gt;
For the last year I've had an actual programming job, and within that job I've learned a lot of python programming tricks and idioms - some of which I know have carried over into my personal style. My playing around with Haskell as also affected my style of programming. My boss can identify my code on sight because I use fewer variables than my co-workers. So in a way I've learned that everything I do, both at work and on my own, are connected. The time spent thinking about Project Euler problems and writing that code may not directly translate to what I do at work, but it definitely has an effect on the code I end up writing at work (and the quality of that code).&lt;/p&gt;
&lt;p&gt;No retrospective post would not be complete without the “Thank yous.” First, thank you to my girlfriend , Kelsey. If it wasn't for her I wouldn't be able to properly articulate my thoughts to the world. And secondly thank you to the 17 thousand people who visited the site last year, all the people who visited in the previous two, and everyone who keeps coming back. Having a place where I can post what I'm currently working on in my spare time is a nifty thing. But having people actually read it makes it so much cooler! So thank you to everyone who's ever read something on my site, where ever you are now.&lt;/p&gt;
&lt;p&gt;On that note, Happy 3rd birthday Scrollingtext. Here’s to another year and hopefully many more.&lt;/p&gt;
&lt;p&gt;** Photo copied from here: &lt;a href="http://www.flickr.com/photos/ebelbeb/5244753318/"&gt;http://www.flickr.com/photos/ebelbeb/5244753318/&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=24oFAvDQC9g:jhcoM8Hfi7c:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=24oFAvDQC9g:jhcoM8Hfi7c:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=24oFAvDQC9g:jhcoM8Hfi7c:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=24oFAvDQC9g:jhcoM8Hfi7c:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=24oFAvDQC9g:jhcoM8Hfi7c:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=24oFAvDQC9g:jhcoM8Hfi7c:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=24oFAvDQC9g:jhcoM8Hfi7c:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/24oFAvDQC9g" height="1" width="1"/&gt;</description>
 <comments>http://scrollingtext.org/more-1095-days-existence-orhappy-third-birthday-scrollingtext#comments</comments>
 <category domain="http://scrollingtext.org/category/catagories/personal">Personal</category>
 <pubDate>Fri, 29 Jun 2012 16:30:28 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">85 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/more-1095-days-existence-orhappy-third-birthday-scrollingtext</feedburner:origLink></item>
<item>
 <title>Project Euler: Problem 13</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/rixIgvj3Hok/project-euler-problem-13</link>
 <description>&lt;p&gt;Problem thirteen from Project Euler is one of those problems that's so simple, I don't understand why it's in the double digits section. The problem reads: “Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.”&lt;br /&gt;
It then proceeds to list 100 long numbers. I'm not going to paste them here because they are in the code solutions below and I don't want to clog up the &lt;a href="http://lolcats.icanhascheezburger.com/2011/04/05/funny-pictures-the-internet-is-a-series-of-tubes/"&gt;“tubez”&lt;/a&gt; with more redundant information than I'm about to.&lt;/p&gt;
&lt;p&gt;Enough of my jibber-jabber.  Here is my Haskell solution first (trying to change things up here):&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;module&lt;/span&gt; Main &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;main &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"&gt;&lt;span style="font-weight: bold;"&gt;take&lt;/span&gt;&lt;/a&gt; &lt;span style="color: red;"&gt;10&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"&gt;&lt;span style="font-weight: bold;"&gt;sum&lt;/span&gt;&lt;/a&gt; big&lt;span style="color: #339933; font-weight: bold;"&gt;_&lt;/span&gt;number&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt; big&lt;span style="color: #339933; font-weight: bold;"&gt;_&lt;/span&gt;number &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt; &lt;span style="color: red;"&gt;37107287533902102798797998220837590246510135740250&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;46376937677490009712648124896970078050417018260538&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;74324986199524741059474233309513058123726617309629&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;91942213363574161572522430563301811072406154908250&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;23067588207539346171171980310421047513778063246676&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;89261670696623633820136378418383684178734361726757&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;28112879812849979408065481931592621691275889832738&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;44274228917432520321923589422876796487670272189318&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;47451445736001306439091167216856844588711603153276&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;70386486105843025439939619828917593665686757934951&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;62176457141856560629502157223196586755079324193331&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;64906352462741904929101432445813822663347944758178&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;92575867718337217661963751590579239728245598838407&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;58203565325359399008402633568948830189458628227828&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;80181199384826282014278194139940567587151170094390&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;35398664372827112653829987240784473053190104293586&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;86515506006295864861532075273371959191420517255829&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;71693888707715466499115593487603532921714970056938&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;54370070576826684624621495650076471787294438377604&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;53282654108756828443191190634694037855217779295145&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;36123272525000296071075082563815656710885258350721&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;45876576172410976447339110607218265236877223636045&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;17423706905851860660448207621209813287860733969412&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;81142660418086830619328460811191061556940512689692&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;51934325451728388641918047049293215058642563049483&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;62467221648435076201727918039944693004732956340691&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;15732444386908125794514089057706229429197107928209&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;55037687525678773091862540744969844508330393682126&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;18336384825330154686196124348767681297534375946515&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;80386287592878490201521685554828717201219257766954&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;78182833757993103614740356856449095527097864797581&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;16726320100436897842553539920931837441497806860984&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;48403098129077791799088218795327364475675590848030&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;87086987551392711854517078544161852424320693150332&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;59959406895756536782107074926966537676326235447210&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;69793950679652694742597709739166693763042633987085&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;41052684708299085211399427365734116182760315001271&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;65378607361501080857009149939512557028198746004375&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;35829035317434717326932123578154982629742552737307&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;94953759765105305946966067683156574377167401875275&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;88902802571733229619176668713819931811048770190271&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;25267680276078003013678680992525463401061632866526&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;36270218540497705585629946580636237993140746255962&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;24074486908231174977792365466257246923322810917141&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;91430288197103288597806669760892938638285025333403&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;34413065578016127815921815005561868836468420090470&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;23053081172816430487623791969842487255036638784583&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;11487696932154902810424020138335124462181441773470&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;63783299490636259666498587618221225225512486764533&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;67720186971698544312419572409913959008952310058822&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;95548255300263520781532296796249481641953868218774&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;76085327132285723110424803456124867697064507995236&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;37774242535411291684276865538926205024910326572967&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;23701913275725675285653248258265463092207058596522&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;29798860272258331913126375147341994889534765745501&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;18495701454879288984856827726077713721403798879715&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;38298203783031473527721580348144513491373226651381&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;34829543829199918180278916522431027392251122869539&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;40957953066405232632538044100059654939159879593635&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;29746152185502371307642255121183693803580388584903&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;41698116222072977186158236678424689157993532961922&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;62467957194401269043877107275048102390895523597457&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;23189706772547915061505504953922979530901129967519&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;86188088225875314529584099251203829009407770775672&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;11306739708304724483816533873502340845647058077308&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;82959174767140363198008187129011875491310547126581&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;97623331044818386269515456334926366572897563400500&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;42846280183517070527831839425882145521227251250327&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;55121603546981200581762165212827652751691296897789&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;32238195734329339946437501907836945765883352399886&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;75506164965184775180738168837861091527357929701337&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;62177842752192623401942399639168044983993173312731&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;32924185707147349566916674687634660915035914677504&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;99518671430235219628894890102423325116913619626622&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;73267460800591547471830798392868535206946944540724&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;76841822524674417161514036427982273348055556214818&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;97142617910342598647204516893989422179826088076852&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;87783646182799346313767754307809363333018982642090&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;10848802521674670883215120185883543223812876952786&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;71329612474782464538636993009049310363619763878039&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;62184073572399794223406235393808339651327408011116&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;66627891981488087797941876876144230030984490851411&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;60661826293682836764744779239180335110989069790714&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;85786944089552990653640447425576083659976645795096&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;66024396409905389607120198219976047599490197230297&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;64913982680032973156037120041377903785566085089252&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;16730939319872750275468906903707539413042652315011&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;94809377245048795150954100921645863754710598436791&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;78639167021187492431995700641917969777599028300699&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;15368713711936614952811305876380278410754449733078&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;40789923115535562561142322423255033685442488917353&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;44889911501440648020369068063960672322193204149535&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;41503128880339536053299340368006977710650566631954&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;81234880673210146739058568557934581403627822703280&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;82616570773948327592232845941706525094512325230608&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;22918802058777319719839450180888072429661980811197&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;77158542502016545090413245809786882778948721859617&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;72107838435069186155435662884062257473692284509516&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;20849603980134001723930671666823555245252804609722&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                       &lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;53503534226472524250874054075591789781264330331690&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;followed by my Python solution:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;#!/usr/bin/python&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;code solution for project euler's problem #13 in python.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;__future__&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; print_function&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; print_10&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;str&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;:&lt;span style="color: #ff4500;"&gt;10&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    big_number &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;37107287533902102798797998220837590246510135740250&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;46376937677490009712648124896970078050417018260538&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;74324986199524741059474233309513058123726617309629&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;91942213363574161572522430563301811072406154908250&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;23067588207539346171171980310421047513778063246676&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;89261670696623633820136378418383684178734361726757&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;28112879812849979408065481931592621691275889832738&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;44274228917432520321923589422876796487670272189318&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;47451445736001306439091167216856844588711603153276&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;70386486105843025439939619828917593665686757934951&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;62176457141856560629502157223196586755079324193331&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;64906352462741904929101432445813822663347944758178&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;92575867718337217661963751590579239728245598838407&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;58203565325359399008402633568948830189458628227828&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;80181199384826282014278194139940567587151170094390&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;35398664372827112653829987240784473053190104293586&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;86515506006295864861532075273371959191420517255829&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;71693888707715466499115593487603532921714970056938&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;54370070576826684624621495650076471787294438377604&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;53282654108756828443191190634694037855217779295145&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;36123272525000296071075082563815656710885258350721&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;45876576172410976447339110607218265236877223636045&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;17423706905851860660448207621209813287860733969412&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;81142660418086830619328460811191061556940512689692&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;51934325451728388641918047049293215058642563049483&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;62467221648435076201727918039944693004732956340691&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;15732444386908125794514089057706229429197107928209&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;55037687525678773091862540744969844508330393682126&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;18336384825330154686196124348767681297534375946515&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;80386287592878490201521685554828717201219257766954&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;78182833757993103614740356856449095527097864797581&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;16726320100436897842553539920931837441497806860984&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;48403098129077791799088218795327364475675590848030&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;87086987551392711854517078544161852424320693150332&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;59959406895756536782107074926966537676326235447210&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;69793950679652694742597709739166693763042633987085&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;41052684708299085211399427365734116182760315001271&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;65378607361501080857009149939512557028198746004375&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;35829035317434717326932123578154982629742552737307&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;94953759765105305946966067683156574377167401875275&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;88902802571733229619176668713819931811048770190271&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;25267680276078003013678680992525463401061632866526&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;36270218540497705585629946580636237993140746255962&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;24074486908231174977792365466257246923322810917141&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;91430288197103288597806669760892938638285025333403&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;34413065578016127815921815005561868836468420090470&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;23053081172816430487623791969842487255036638784583&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;11487696932154902810424020138335124462181441773470&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;63783299490636259666498587618221225225512486764533&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;67720186971698544312419572409913959008952310058822&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;95548255300263520781532296796249481641953868218774&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;76085327132285723110424803456124867697064507995236&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;37774242535411291684276865538926205024910326572967&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;23701913275725675285653248258265463092207058596522&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;29798860272258331913126375147341994889534765745501&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;18495701454879288984856827726077713721403798879715&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;38298203783031473527721580348144513491373226651381&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;34829543829199918180278916522431027392251122869539&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;40957953066405232632538044100059654939159879593635&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;29746152185502371307642255121183693803580388584903&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;41698116222072977186158236678424689157993532961922&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;62467957194401269043877107275048102390895523597457&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;23189706772547915061505504953922979530901129967519&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;86188088225875314529584099251203829009407770775672&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;11306739708304724483816533873502340845647058077308&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;82959174767140363198008187129011875491310547126581&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;97623331044818386269515456334926366572897563400500&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;42846280183517070527831839425882145521227251250327&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;55121603546981200581762165212827652751691296897789&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;32238195734329339946437501907836945765883352399886&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;75506164965184775180738168837861091527357929701337&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;62177842752192623401942399639168044983993173312731&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;32924185707147349566916674687634660915035914677504&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;99518671430235219628894890102423325116913619626622&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;73267460800591547471830798392868535206946944540724&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;76841822524674417161514036427982273348055556214818&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;97142617910342598647204516893989422179826088076852&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;87783646182799346313767754307809363333018982642090&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;10848802521674670883215120185883543223812876952786&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;71329612474782464538636993009049310363619763878039&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;62184073572399794223406235393808339651327408011116&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;66627891981488087797941876876144230030984490851411&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;60661826293682836764744779239180335110989069790714&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;85786944089552990653640447425576083659976645795096&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;66024396409905389607120198219976047599490197230297&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;64913982680032973156037120041377903785566085089252&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;16730939319872750275468906903707539413042652315011&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;94809377245048795150954100921645863754710598436791&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;78639167021187492431995700641917969777599028300699&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;15368713711936614952811305876380278410754449733078&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;40789923115535562561142322423255033685442488917353&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;44889911501440648020369068063960672322193204149535&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;41503128880339536053299340368006977710650566631954&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;81234880673210146739058568557934581403627822703280&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;82616570773948327592232845941706525094512325230608&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;22918802058777319719839450180888072429661980811197&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;77158542502016545090413245809786882778948721859617&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;72107838435069186155435662884062257473692284509516&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;20849603980134001723930671666823555245252804609722&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                   &lt;span style="color: #ff4500;"&gt;53503534226472524250874054075591789781264330331690&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    print_10&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #008000;"&gt;sum&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;big_number&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;and to continue adding in the spice, I have included a solution in Scala:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="scala geshifilter-scala" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;a href="http://scala-lang.org"&gt;&lt;span style="color: #0000ff; font-weight: bold;"&gt;import&lt;/span&gt;&lt;/a&gt; BigInt.&lt;span style="color: #000080;"&gt;_&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;a href="http://scala-lang.org"&gt;&lt;span style="color: #0000ff; font-weight: bold;"&gt;object&lt;/span&gt;&lt;/a&gt; problem&lt;span style="color: #000080;"&gt;_&lt;/span&gt;13 &lt;span style="color: #F78811;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;a href="http://scala-lang.org"&gt;&lt;span style="color: #0000ff; font-weight: bold;"&gt;def&lt;/span&gt;&lt;/a&gt; main &lt;span style="color: #F78811;"&gt;&amp;#40;&lt;/span&gt;args &lt;span style="color: #000080;"&gt;:&lt;/span&gt; Array&lt;span style="color: #F78811;"&gt;&amp;#91;&lt;/span&gt;String&lt;span style="color: #F78811;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #F78811;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #F78811;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;a href="http://scala-lang.org"&gt;&lt;span style="color: #0000ff; font-weight: bold;"&gt;val&lt;/span&gt;&lt;/a&gt; big&lt;span style="color: #000080;"&gt;_&lt;/span&gt;number &lt;span style="color: #000080;"&gt;=&lt;/span&gt; List&lt;span style="color: #F78811;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #6666FF;"&gt;&amp;quot;37107287533902102798797998220837590246510135740250&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;46376937677490009712648124896970078050417018260538&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;74324986199524741059474233309513058123726617309629&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;91942213363574161572522430563301811072406154908250&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;23067588207539346171171980310421047513778063246676&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;89261670696623633820136378418383684178734361726757&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;28112879812849979408065481931592621691275889832738&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;44274228917432520321923589422876796487670272189318&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;47451445736001306439091167216856844588711603153276&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;70386486105843025439939619828917593665686757934951&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;62176457141856560629502157223196586755079324193331&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;64906352462741904929101432445813822663347944758178&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;92575867718337217661963751590579239728245598838407&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;58203565325359399008402633568948830189458628227828&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;80181199384826282014278194139940567587151170094390&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;35398664372827112653829987240784473053190104293586&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;86515506006295864861532075273371959191420517255829&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;71693888707715466499115593487603532921714970056938&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;54370070576826684624621495650076471787294438377604&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;53282654108756828443191190634694037855217779295145&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;36123272525000296071075082563815656710885258350721&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;45876576172410976447339110607218265236877223636045&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;17423706905851860660448207621209813287860733969412&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;81142660418086830619328460811191061556940512689692&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;51934325451728388641918047049293215058642563049483&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;62467221648435076201727918039944693004732956340691&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;15732444386908125794514089057706229429197107928209&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;55037687525678773091862540744969844508330393682126&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;18336384825330154686196124348767681297534375946515&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;80386287592878490201521685554828717201219257766954&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;78182833757993103614740356856449095527097864797581&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;16726320100436897842553539920931837441497806860984&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;48403098129077791799088218795327364475675590848030&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;87086987551392711854517078544161852424320693150332&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;59959406895756536782107074926966537676326235447210&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;69793950679652694742597709739166693763042633987085&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;41052684708299085211399427365734116182760315001271&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;65378607361501080857009149939512557028198746004375&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;35829035317434717326932123578154982629742552737307&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;94953759765105305946966067683156574377167401875275&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;88902802571733229619176668713819931811048770190271&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;25267680276078003013678680992525463401061632866526&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;36270218540497705585629946580636237993140746255962&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;24074486908231174977792365466257246923322810917141&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;91430288197103288597806669760892938638285025333403&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;34413065578016127815921815005561868836468420090470&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;23053081172816430487623791969842487255036638784583&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;11487696932154902810424020138335124462181441773470&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;63783299490636259666498587618221225225512486764533&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;67720186971698544312419572409913959008952310058822&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;95548255300263520781532296796249481641953868218774&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;76085327132285723110424803456124867697064507995236&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;37774242535411291684276865538926205024910326572967&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;23701913275725675285653248258265463092207058596522&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;29798860272258331913126375147341994889534765745501&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;18495701454879288984856827726077713721403798879715&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;38298203783031473527721580348144513491373226651381&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;34829543829199918180278916522431027392251122869539&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;40957953066405232632538044100059654939159879593635&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;29746152185502371307642255121183693803580388584903&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;41698116222072977186158236678424689157993532961922&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;62467957194401269043877107275048102390895523597457&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;23189706772547915061505504953922979530901129967519&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;86188088225875314529584099251203829009407770775672&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;11306739708304724483816533873502340845647058077308&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;82959174767140363198008187129011875491310547126581&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;97623331044818386269515456334926366572897563400500&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;42846280183517070527831839425882145521227251250327&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;55121603546981200581762165212827652751691296897789&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;32238195734329339946437501907836945765883352399886&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;75506164965184775180738168837861091527357929701337&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;62177842752192623401942399639168044983993173312731&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;32924185707147349566916674687634660915035914677504&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;99518671430235219628894890102423325116913619626622&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;73267460800591547471830798392868535206946944540724&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;76841822524674417161514036427982273348055556214818&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;97142617910342598647204516893989422179826088076852&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;87783646182799346313767754307809363333018982642090&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;10848802521674670883215120185883543223812876952786&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;71329612474782464538636993009049310363619763878039&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;62184073572399794223406235393808339651327408011116&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;66627891981488087797941876876144230030984490851411&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;60661826293682836764744779239180335110989069790714&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;85786944089552990653640447425576083659976645795096&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;66024396409905389607120198219976047599490197230297&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;64913982680032973156037120041377903785566085089252&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;16730939319872750275468906903707539413042652315011&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;94809377245048795150954100921645863754710598436791&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;78639167021187492431995700641917969777599028300699&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;15368713711936614952811305876380278410754449733078&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;40789923115535562561142322423255033685442488917353&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;44889911501440648020369068063960672322193204149535&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;41503128880339536053299340368006977710650566631954&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;81234880673210146739058568557934581403627822703280&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;82616570773948327592232845941706525094512325230608&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;22918802058777319719839450180888072429661980811197&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;77158542502016545090413245809786882778948721859617&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;72107838435069186155435662884062257473692284509516&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;20849603980134001723930671666823555245252804609722&amp;quot;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                              &lt;span style="color: #6666FF;"&gt;&amp;quot;53503534226472524250874054075591789781264330331690&amp;quot;&lt;/span&gt;&lt;span style="color: #F78811;"&gt;&amp;#41;&lt;/span&gt; map &lt;span style="color: #F78811;"&gt;&amp;#123;&lt;/span&gt;BigInt&lt;span style="color: #F78811;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #000080;"&gt;_&lt;/span&gt;&lt;span style="color: #F78811;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #F78811;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;a href="http://scala-lang.org"&gt;&lt;span style="color: #0000ff; font-weight: bold;"&gt;val&lt;/span&gt;&lt;/a&gt; sums &lt;span style="color: #000080;"&gt;=&lt;/span&gt; big&lt;span style="color: #000080;"&gt;_&lt;/span&gt;number sum&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;a href="http://scala-lang.org"&gt;&lt;span style="color: #0000ff; font-weight: bold;"&gt;val&lt;/span&gt;&lt;/a&gt; su &lt;span style="color: #000080;"&gt;=&lt;/span&gt; sums toString&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;a href="http://scala-lang.org"&gt;&lt;span style="color: #0000ff; font-weight: bold;"&gt;val&lt;/span&gt;&lt;/a&gt; su10 &lt;span style="color: #000080;"&gt;=&lt;/span&gt; su take &lt;span style="color: #F78811;"&gt;10&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        println&lt;span style="color: #F78811;"&gt;&amp;#40;&lt;/span&gt;su10&lt;span style="color: #F78811;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #F78811;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #F78811;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
Some of you may be wondering, “Why a Scala solution?”  To which I respond, “Why not?”  Because that's a little short, I'll add that it has something to do with Scala starting to gain traction in the industry and me seeing if I would like to get paid to program in it.&lt;/p&gt;
&lt;p&gt;The solution, in all three languages, is pretty simple. The recipe essentially says, “Put all numbers into a list.  Get the sum of that list, turn that number into a string, and get the first 10 characters of that string.”&lt;/p&gt;
&lt;p&gt;Times:&lt;br /&gt;
Haskell (compiled)   : real	0m0.004s&lt;br /&gt;
Haskell (runghc)     : real	0m0.314s&lt;br /&gt;
Python               : real	0m0.059s&lt;br /&gt;
Scala   (compiled)   : real	0m0.757s&lt;/p&gt;
&lt;p&gt;For the most part it's pretty standard in these tests to see performance times such that Haskell (compiled) &lt; Python &lt; Haskell (runghc). Java and Perl usually fall somewhere between the Haskell (compiled) and Python, in that order. To see Scala be 2x slower than Haskell (runghc) was a shocker.  The only thing that makes sense to me for the slowdown is having to use the BigInt library. That is probably the biggest thing I took away from these time tests - if I want to do REALLY large number crunching and performance DOES matter, JVM-based languages might not be the best option. &lt;/p&gt;
&lt;p&gt;A few thoughts on Scala:&lt;br /&gt;
If I haven't stated it already in this blog, I should now give the disclaimer that I'm not a Java fan.  I know it still has its loyal followers, but I'm not one of them.  Moving on.  This was my first time working with Scala, and I'd like to finally welcome Java to the 21st century.  While doing some research on the Scala language itself I read that “the industry” was moving to replace Java with Scala.  I welcome that change.  Does that mean I “like” Scala?  The honest answer is, to butcher the quote the appliances from the Flintstones, “Eh, it's a language.” Scala is definitely an improvement over Java – not really that hard to do in my opinion – but, the language still feels unpolished.  One quick way to kill the interpreter in Scala is to type “Int” then hit the enter key.  Instead of error-ing out, the interpreter does a great job of interpreting a crash test car hitting a cement wall (I had to restart the whole thing.)  When I tried the same “technique” in the Python interpreter, I got &lt;type 'int'&gt; as a response and for Haskell's interpreter I received “Not in scope: data constructor `Int'”.  I also found Scala's function composition to be a little lacking when compared to Haskell.  I wasn't able to cleanly change the BigInt data type to String, and then only print out ten characters without requiring three separate val's.  Yes, I could have used one var instead, but that's beside the point. I will admit it could be my inexperience with the language showing, so if anyone knows a smoother way to do this in Scala please share it in the comments.&lt;/p&gt;
&lt;p&gt;All that being said, I do like the way Scala is trying to handle the reducing of Java's dot notation, and I think it's starting to make strides in the right direction in other areas.  I'm open to working with Scala more, and look forward to seeing how it evolves over the next few years.  &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=rixIgvj3Hok:x79nWfdzsvA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=rixIgvj3Hok:x79nWfdzsvA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=rixIgvj3Hok:x79nWfdzsvA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=rixIgvj3Hok:x79nWfdzsvA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=rixIgvj3Hok:x79nWfdzsvA:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=rixIgvj3Hok:x79nWfdzsvA:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=rixIgvj3Hok:x79nWfdzsvA:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/rixIgvj3Hok" height="1" width="1"/&gt;</description>
 <comments>http://scrollingtext.org/project-euler-problem-13#comments</comments>
 <category domain="http://scrollingtext.org/category/catagories/haskell">Haskell</category>
 <category domain="http://scrollingtext.org/category/catagories/project-euler">Project Euler</category>
 <category domain="http://scrollingtext.org/category/catagories/python">Python</category>
 <category domain="http://scrollingtext.org/category/catagories/scala">Scala</category>
 <pubDate>Tue, 22 May 2012 16:48:04 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">84 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/project-euler-problem-13</feedburner:origLink></item>
<item>
 <title>Apache Log IP Counting</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/j9LxYKBKQxI/apache-log-ip-counting</link>
 <description>&lt;p&gt;It all started with a simple question: “Which single IP shows up the most in an apache log file?”  To which I ultimately came up with an answer using a string of Bash commands:&lt;/p&gt;
&lt;p&gt;&lt;span class="geshifilter"&gt;&lt;code class="bash geshifilter-bash"&gt;&amp;nbsp;&lt;span style="color: #c20cb9; font-weight: bold;"&gt;less&lt;/span&gt; apache_log &lt;span style="color: #000000; font-weight: bold;"&gt;|&lt;/span&gt; &lt;span style="color: #c20cb9; font-weight: bold;"&gt;cut&lt;/span&gt; &lt;span style="color: #660033;"&gt;-d&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'-'&lt;/span&gt; &lt;span style="color: #660033;"&gt;-f&lt;/span&gt; &lt;span style="color: #000000;"&gt;1&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;|&lt;/span&gt; &lt;span style="color: #c20cb9; font-weight: bold;"&gt;sort&lt;/span&gt; &lt;span style="color: #660033;"&gt;-r&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;|&lt;/span&gt; &lt;span style="color: #c20cb9; font-weight: bold;"&gt;uniq&lt;/span&gt; &lt;span style="color: #660033;"&gt;-c&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This produced some text displaying how many times various IP addresses made requests from an apache web server.  After seeing the results and thinking for a moment, I remembered that there is a “new” data type – as of Python 2.7 and new to me at least – called &lt;a href="http://docs.python.org/library/collections.html?highlight=counter#collections.Counter"&gt;“Counter”&lt;/a&gt; within the collections module in the standard library that would allow me to recreate this in Python.  So I quickly whipped up the code below:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;#!/usr/bin/env python&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;sys&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; argv&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;collections&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; Counter&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;with&lt;/span&gt; &lt;span style="color: #008000;"&gt;open&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;argv&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;as&lt;/span&gt; f:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        c &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; Counter&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;i.&lt;span style="color: black;"&gt;partition&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; i &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; f&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; k&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;v &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; c.&lt;span style="color: black;"&gt;most_common&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;'{:&amp;gt;4} {}'&lt;/span&gt;.&lt;span style="color: black;"&gt;format&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;v&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;k&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;VIOLA!  I get the same results as if I'd done it in Bash. Of course, like the madman I am, I wasn't happy to just stop at Python; I had to write this up in Haskell too.  So I said “damn the torpedoes,” fired up my favorite text editor, and started to hack and slash my way toward a third version.  After much documentation reading, internet searching, and trial and error I can proudly proclaim, “MISSION ACCOMPLISHED”:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="haskell geshifilter-haskell" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;module&lt;/span&gt; Main &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; System&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Environment &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;getArgs&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;qualified&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Text &lt;span style="color: #06c; font-weight: bold;"&gt;as&lt;/span&gt; T &lt;span style="color: #06c; font-weight: bold;"&gt;hiding&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"&gt;&lt;span style="font-weight: bold;"&gt;head&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zip"&gt;&lt;span style="font-weight: bold;"&gt;zip&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;qualified&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Text&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;as&lt;/span&gt; TI &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:readFile"&gt;&lt;span style="font-weight: bold;"&gt;readFile&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;import&lt;/span&gt; Data&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Map &lt;span style="color: #06c; font-weight: bold;"&gt;hiding&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #06c; font-weight: bold;"&gt;type&lt;/span&gt; Counter &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Text&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;mapUnpack &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; Counter &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;String&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;mapUnpack &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;k&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;v&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"&gt;&lt;span style="font-weight: bold;"&gt;show&lt;/span&gt;&lt;/a&gt; v &lt;span style="color: #339933; font-weight: bold;"&gt;++&lt;/span&gt; &lt;span style="background-color: #3cb371;"&gt;&amp;quot; &amp;quot;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;++&lt;/span&gt; T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;unpack k&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;sortMapByValue &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; Map T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;Text &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;Counter&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;sortMapByValue &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; rqsort &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; toList&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #5d478b; font-style: italic;"&gt;-- copied &amp;amp; modified by LYHGG in the recusion chapter&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #5d478b; font-style: italic;"&gt;-- doing in reverse order as to better suit the output&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;rqsort &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;Counter&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;Counter&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;rqsort &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;rqsort &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;k&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;v&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;:xs&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; smallerSorted &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; rqsort &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;k'&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;v'&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;k'&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;v'&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; xs&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; v' &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;=&lt;/span&gt; v&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        biggerSorted  &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; rqsort &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;k'&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;v'&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;|&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;k'&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;v'&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; xs&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt; v' &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt; v&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;in&lt;/span&gt; biggerSorted &lt;span style="color: #339933; font-weight: bold;"&gt;++&lt;/span&gt; &lt;span style="color: green;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;k&lt;span style="color: #339933; font-weight: bold;"&gt;,&lt;/span&gt;v&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;++&lt;/span&gt; smallerSorted&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;main &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;IO&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;main &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;span style="color: #06c; font-weight: bold;"&gt;do&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    results &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;lt;-&lt;/span&gt; getArgs &lt;span style="color: #339933; font-weight: bold;"&gt;&amp;gt;&amp;gt;=&lt;/span&gt; TI&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:readFile"&gt;&lt;span style="font-weight: bold;"&gt;readFile&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"&gt;&lt;span style="font-weight: bold;"&gt;head&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; results' &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"&gt;&lt;span style="font-weight: bold;"&gt;map&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;\x &lt;span style="color: #339933; font-weight: bold;"&gt;-&amp;gt;&lt;/span&gt; T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;replace space nothing &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"&gt;&lt;span style="font-weight: bold;"&gt;head&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;splitOn dash x&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:lines"&gt;&lt;span style="font-weight: bold;"&gt;lines&lt;/span&gt;&lt;/a&gt; results&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;let&lt;/span&gt; results'' &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; fromListWith &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #339933; font-weight: bold;"&gt;+&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zip"&gt;&lt;span style="font-weight: bold;"&gt;zip&lt;/span&gt;&lt;/a&gt; results' &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:repeat"&gt;&lt;span style="font-weight: bold;"&gt;repeat&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: red;"&gt;1&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;::&lt;/span&gt; &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"&gt;&lt;span style="color: #cccc00; font-weight: bold;"&gt;Int&lt;/span&gt;&lt;/a&gt;&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:mapM_"&gt;&lt;span style="font-weight: bold;"&gt;mapM_&lt;/span&gt;&lt;/a&gt; &lt;span style="color: green;"&gt;&amp;#40;&lt;/span&gt;&lt;a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:print"&gt;&lt;span style="font-weight: bold;"&gt;print&lt;/span&gt;&lt;/a&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt; mapUnpack&lt;span style="color: green;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #339933; font-weight: bold;"&gt;$&lt;/span&gt; sortMapByValue results''&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #06c; font-weight: bold;"&gt;where&lt;/span&gt; dash    &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;pack &lt;span style="background-color: #3cb371;"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;          space   &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;pack &lt;span style="background-color: #3cb371;"&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;          nothing &lt;span style="color: #339933; font-weight: bold;"&gt;=&lt;/span&gt; T&lt;span style="color: #339933; font-weight: bold;"&gt;.&lt;/span&gt;pack &lt;span style="background-color: #3cb371;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The Haskell implementation took me longer than I expected as there were a couple of challenges to figure out:&lt;br /&gt;
    1) Learning the Data.Map datatype and figuring out how to build that datatype from a list of IP addresses.&lt;br /&gt;
    2) Sorting the Map by value and not by key.&lt;br /&gt;
    3) Unpacking the Map to be printed. &lt;/p&gt;
&lt;p&gt;The first problem was solved by a lucky internet search that showed me an example of how to use the &lt;a href=" http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Map.html#v:fromListWith"&gt;'fromListWith'&lt;/a&gt; function.  This function performed the heavy lifting of sorting and counting the IP addresses in the log file.  For the sorting by value instead of by key problem I was able to construct my own solution by tweaking the quicksort example from &lt;i&gt;&lt;a href="http://learnyouahaskell.com/recursion"&gt;Learn You a Haskell&lt;/a&gt;&lt;/i&gt;.  The changes I made expanded the tuple, allowing it to compare values and sort them in descending order.  For the text holding and manipulation involved in Map unpacking, I've been told by other Haskellers that &lt;a href="http://hackage.haskell.org/packages/archive/text/0.11.2.0/doc/html/Data-Text.html"&gt;Data.Text&lt;/a&gt; is “the way to go” (as the default String implementation is a little slow and lacking features).  While Data.Text did provide me an easy way to split the string and grab the IP addresses, it also required translating the IP addresses back into a String data type before Haskell would print it.  Thus my need for a specific function to create a string based on each item in the Map.  In the grand scheme of things having to write the mapUnpack function wasn't horrible...it was just one more hoop that I had to jump through before I could call this project complete.  After these modifications I was able to put this program together without TOO much hassle, and in the end got the exact same results as both the Bash string and the Python program.&lt;/p&gt;
&lt;p&gt;Would I recommend writing these scripts for work instead of using the string of Bash commands?  No, especially if you're asked this question in a high-stress situation.  However, these little personal challenges were a great way to expand my programming skills, particularly in learning about new libraries like the collections module in Python and the Data.Map module in Haskell.  Having this random new knowledge might not seem worthwhile upfront, but might come in handy in the future if I ever encounter a problem that simple strings of Bash commands can't handle.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=j9LxYKBKQxI:v0Kia7b4-y0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=j9LxYKBKQxI:v0Kia7b4-y0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=j9LxYKBKQxI:v0Kia7b4-y0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=j9LxYKBKQxI:v0Kia7b4-y0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=j9LxYKBKQxI:v0Kia7b4-y0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=j9LxYKBKQxI:v0Kia7b4-y0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=j9LxYKBKQxI:v0Kia7b4-y0:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/j9LxYKBKQxI" height="1" width="1"/&gt;</description>
 <comments>http://scrollingtext.org/apache-log-ip-counting#comments</comments>
 <category domain="http://scrollingtext.org/category/catagories/bash">Bash</category>
 <category domain="http://scrollingtext.org/category/catagories/haskell">Haskell</category>
 <category domain="http://scrollingtext.org/category/catagories/python">Python</category>
 <pubDate>Tue, 08 May 2012 15:55:38 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">83 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/apache-log-ip-counting</feedburner:origLink></item>
<item>
 <title>Connect 4</title>
 <link>http://feedproxy.google.com/~r/Scrollingtext/~3/NZ1rJgzqhio/connect-4</link>
 <description>&lt;p&gt;A couple of weeks ago I was lucky enough to have my employer send me to PyCon.  If you weren't at PyCon you missed out on a lot of things...like the invading squirrel hordes.  Thankfully, all of the talks are viewable &lt;a href="http://pyvideo.org/category/17/pycon-us-2012"&gt;here&lt;/a&gt;.  But PyCon is not the focus of this post, just a starting point. At PyCon, in the vendor area, there was the Thumbtack booth.  The guys at this book weren't doing the “normal” conference thing (passing out schwag to every being, living or dead, that passed them); they actually made people work for their swag.  Thumbtack had a programming challenge that you had to submit a solution to before they would give you either a large shot glass or a glass beer stein.&lt;br /&gt;
The challenge was to accept a list of lists from standard input, and parse it looking for a winner in a game of Connect 4.  I believe this could be a great interview question, and will be using it for the upcoming interviews where I work.  One of the reasons for this is that it's deceptively difficult.  While we as humans have been conditioned to recognize patterns since birth, computers need to be taught every step from the beginning.  How do I go about teaching something that I don't remember learning?  But enough of my babbling - let's look at my solution:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="python geshifilter-python" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #808080; font-style: italic;"&gt;#!/usr/bin/env python&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;from&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;__future__&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; print_function&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;import&lt;/span&gt; &lt;span style="color: #dc143c;"&gt;sys&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;def&lt;/span&gt; char_check&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; char&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; prev_row&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; prev_col&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; count&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; direction&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    direction_dict &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#123;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;: &lt;span style="color: #008000;"&gt;None&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                      &lt;span style="color: #ff4500;"&gt;2&lt;/span&gt;: &lt;span style="color: #008000;"&gt;None&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                      &lt;span style="color: #ff4500;"&gt;3&lt;/span&gt;: &lt;span style="color: #008000;"&gt;None&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                      &lt;span style="color: #ff4500;"&gt;4&lt;/span&gt;: &lt;span style="color: #ff7700;font-weight:bold;"&gt;lambda&lt;/span&gt;: char_check&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col - &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; char&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; row&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; count + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;4&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                      &lt;span style="color: #ff4500;"&gt;5&lt;/span&gt;: &lt;span style="color: #008000;"&gt;None&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                      &lt;span style="color: #ff4500;"&gt;6&lt;/span&gt;: &lt;span style="color: #ff7700;font-weight:bold;"&gt;lambda&lt;/span&gt;: char_check&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; char&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; row&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; count + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;6&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                      &lt;span style="color: #ff4500;"&gt;7&lt;/span&gt;: &lt;span style="color: #ff7700;font-weight:bold;"&gt;lambda&lt;/span&gt;: char_check&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col - &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; char&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; row&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; count + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;7&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                      &lt;span style="color: #ff4500;"&gt;8&lt;/span&gt;: &lt;span style="color: #ff7700;font-weight:bold;"&gt;lambda&lt;/span&gt;: char_check&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; char&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; row&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; count + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;8&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                      &lt;span style="color: #ff4500;"&gt;9&lt;/span&gt;: &lt;span style="color: #ff7700;font-weight:bold;"&gt;lambda&lt;/span&gt;: char_check&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; char&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; row&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; count + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;9&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; count &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #ff4500;"&gt;3&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;Winner: %s&amp;quot;&lt;/span&gt; % char&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #dc143c;"&gt;sys&lt;/span&gt;.&lt;span style="color: black;"&gt;exit&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    direction_list &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    direction_list_append &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; direction_list.&lt;span style="color: black;"&gt;append&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;four_list&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;row&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;col - &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; char &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_row &lt;span style="color: #ff7700;font-weight:bold;"&gt;or&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;col - &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_col&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            direction &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;4&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;: &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            direction_list_append&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;4&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;elif&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;four_list&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;row&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;col + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; char &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_row &lt;span style="color: #ff7700;font-weight:bold;"&gt;or&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;col + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_col&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              direction &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;6&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              direction_list_append&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;6&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;elif&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;four_list&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;col - &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; char &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_row &lt;span style="color: #ff7700;font-weight:bold;"&gt;or&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;col - &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_col&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              direction &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;7&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              direction_list_append&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;7&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;elif&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;four_list&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;col&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; char &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_row &lt;span style="color: #ff7700;font-weight:bold;"&gt;or&lt;/span&gt; col &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_col&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              direction &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;8&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              direction_list_append&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;8&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;elif&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;four_list&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;col + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; char &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;row + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_row &lt;span style="color: #ff7700;font-weight:bold;"&gt;or&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;col + &lt;span style="color: #ff4500;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; prev_col&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;and&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              direction &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;9&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;              direction_list_append&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #ff4500;"&gt;9&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; d &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; direction_list:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            direction_dict&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;d&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;IndexError&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;pass&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; __name__ &lt;span style="color: #66cc66;"&gt;==&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        four_list &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: #008000;"&gt;eval&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #dc143c;"&gt;sys&lt;/span&gt;.&lt;span style="color: black;"&gt;stdin&lt;/span&gt;.&lt;span style="color: black;"&gt;read&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;except&lt;/span&gt; &lt;span style="color: #008000;"&gt;SyntaxError&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;Error getting list from the web, using preprogrammed backup.&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        four_list &lt;span style="color: #66cc66;"&gt;=&lt;/span&gt; &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;O&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;O&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;O&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;O&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;O&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;O&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;X&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    &lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: bold; font-style: italic;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #ff7700;font-weight:bold;"&gt;finally&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; r&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;_ &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;enumerate&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;four_list&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;char_check&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;r&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt; four_list&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;r&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;col&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;for&lt;/span&gt; col&lt;span style="color: #66cc66;"&gt;,&lt;/span&gt;_ &lt;span style="color: #ff7700;font-weight:bold;"&gt;in&lt;/span&gt; &lt;span style="color: #008000;"&gt;enumerate&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;four_list&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;r&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #ff7700;font-weight:bold;"&gt;if&lt;/span&gt; four_list&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;r&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#91;&lt;/span&gt;col&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;!=&lt;/span&gt; &lt;span style="color: #483d8b;"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #ff7700;font-weight:bold;"&gt;print&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #483d8b;"&gt;&amp;quot;No Winner&amp;quot;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Maybe it's my preference for functional programming coming out, but when I looked at this problem I thought “recursion,” remembering from college how much easier it is to solve the &lt;a href="https://en.wikipedia.org/wiki/Tower_of_Hanoi"&gt;Tower of Hanoi&lt;/a&gt; problem with recursion than without.  The problem became a little more complicated when I went from solving the original example to generating and testing a different board.&lt;/p&gt;
&lt;p&gt;At the moment I'm trying to figure out a Haskell version of this solution. Hopefully I'll have one soon and I'll update this page when I do. &lt;/p&gt;
&lt;p&gt;Before I posted this, I wrote a quick email to the person I spoke to at the Thumbtack booth and sent him my solution.  He thanked me for the solution and requested my address to mail a mug to me, which showed up in the mail couple of days ago.  (Below is a pic of the mug filled with a beautiful amber beer.)  He also sent me a link to the company's blog post about their experiences using a coding challenge to earn schwag.  Here is the &lt;a href="http://www.thumbtack.com/engineering/how-we-got-people-to-earn-our-schwag/"&gt;link&lt;/a&gt;.  There are also some pretty impressive solutions to the challenge there, including one done in regular expressions, which deserves a tip of the hat in my book.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://scrollingtext.org/sites/default/files/IMG_20120419_161121.jpg"&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=NZ1rJgzqhio:DR03vx7n8UI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=NZ1rJgzqhio:DR03vx7n8UI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=NZ1rJgzqhio:DR03vx7n8UI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=NZ1rJgzqhio:DR03vx7n8UI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=NZ1rJgzqhio:DR03vx7n8UI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?i=NZ1rJgzqhio:DR03vx7n8UI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Scrollingtext?a=NZ1rJgzqhio:DR03vx7n8UI:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Scrollingtext?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Scrollingtext/~4/NZ1rJgzqhio" height="1" width="1"/&gt;</description>
 <comments>http://scrollingtext.org/connect-4#comments</comments>
 <category domain="http://scrollingtext.org/category/catagories/python">Python</category>
 <pubDate>Thu, 19 Apr 2012 23:58:45 +0000</pubDate>
 <dc:creator>Bryce</dc:creator>
 <guid isPermaLink="false">82 at http://scrollingtext.org</guid>
<feedburner:origLink>http://scrollingtext.org/connect-4</feedburner:origLink></item>
</channel>
</rss>
