<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Accumulative Effect &#187; Project Euler</title>
	<atom:link href="http://ashleyangell.com/category/project-euler/feed/" rel="self" type="application/rss+xml" />
	<link>http://ashleyangell.com</link>
	<description>The personal blog of Ashley Angell</description>
	<lastBuildDate>Wed, 16 Jun 2010 13:22:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Project Euler Problem 48 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-48-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-48-solution/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 12:53:43 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.meroal.com/?p=111</guid>
		<description><![CDATA[The series, 1^(1) + 2^(2) + 3^(3) + ... + 10^(10) = 10405071317. Find the last ten digits of the series, 1^(1) + 2^(2) + 3^(3) + ... + 1000^(1000). My solution in Ruby: sum = 0 for i in 1..1000 do sum += i**i end str = sum.to_s &#160; puts str&#91;str.length - 10,str.length&#93; UPDATE [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>The series, 1^(1) + 2^(2) + 3^(3) + ... + 10^(10) = 10405071317.</p>
<p>Find the last ten digits of the series, 1^(1) + 2^(2) + 3^(3) + ... + 1000^(1000).</p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby">sum = <span style="color:#006666;">0</span>
<span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">1</span>..<span style="color:#006666;">1000</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  sum += i**i
<span style="color:#9966CC; font-weight:bold;">end</span>
str = sum.<span style="color:#9900CC;">to_s</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> str<span style="color:#006600; font-weight:bold;">&#91;</span>str.<span style="color:#9900CC;">length</span> - <span style="color:#006666;">10</span>,str.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre>
<hr/>
<strong>UPDATE</strong></p>
<pre class="ruby">s = <span style="color:#006666;">0</span>
<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span>..<span style="color:#006666;">1000</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">inject</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |s, x| s + x ** x <span style="color:#006600; font-weight:bold;">&#125;</span> % <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">10</span> ** <span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span>
str = s.<span style="color:#9900CC;">to_s</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> str<span style="color:#006600; font-weight:bold;">&#91;</span>str.<span style="color:#9900CC;">length</span> - <span style="color:#006666;">10</span>,str.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=111</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 25 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-25-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-25-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 14:01:22 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.meroal.com/?p=120</guid>
		<description><![CDATA[The Fibonacci sequence is defined by the recurrence relation: F_(n) = F_(n−1) + F_(n−2), where F_(1) = 1 and F_(2) = 1. Hence the first 12 terms will be: F_(1) = 1 F_(2) = 1 F_(3) = 2 F_(4) = 3 F_(5) = 5 F_(6) = 8 F_(7) = 13 F_(8) = 21 F_(9) = [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>The Fibonacci sequence is defined by the recurrence relation:</p>
<p>    F_(n) = F_(n−1) + F_(n−2), where F_(1) = 1 and F_(2) = 1.</p>
<p>Hence the first 12 terms will be:</p>
<p>    F_(1) = 1<br />
    F_(2) = 1<br />
    F_(3) = 2<br />
    F_(4) = 3<br />
    F_(5) = 5<br />
    F_(6) = 8<br />
    F_(7) = 13<br />
    F_(8) = 21<br />
    F_(9) = 34<br />
    F_(10) = 55<br />
    F_(11) = 89<br />
    F_(12) = 144</p>
<p>The 12th term, F_(12), is the first term to contain three digits.</p>
<p>What is the first term in the Fibonacci sequence to contain 1000 digits?</p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby">t1, t2, term = <span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span>
<span style="color:#CC0066; font-weight:bold;">loop</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  temp = t1 + t2
  t1 = t2
  t2 = temp
  term += <span style="color:#006666;">1</span>
  temp_s = temp.<span style="color:#9900CC;">to_s</span>
  <span style="color:#9966CC; font-weight:bold;">break</span> <span style="color:#9966CC; font-weight:bold;">if</span> temp_s.<span style="color:#9900CC;">length</span> &gt;= <span style="color:#006666;">1000</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> term</pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=120</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 20 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-20-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-20-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 11:45:26 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ashleyangell.com/?p=595</guid>
		<description><![CDATA[n! means n x (n - 1) x ... x 3 x 2 x 1 Find the sum of the digits in the number 100! My solution in Ruby: sum = 0 factorial = 1 for i in 1..100 factorial = factorial * i end str = factorial.to_s y = str.scan&#40;/./&#41; y.each do &#124;c&#124; sum += c.to_i end puts sum]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>n</em>! means <em>n</em> x (<em>n</em> - 1) x ... x 3 x 2 x 1</p>
<p>Find the sum of the digits in the number 100!</p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby">sum = <span style="color:#006666;">0</span>
factorial = <span style="color:#006666;">1</span>
<span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">1</span>..<span style="color:#006666;">100</span>
  factorial = factorial * i
<span style="color:#9966CC; font-weight:bold;">end</span>
str = factorial.<span style="color:#9900CC;">to_s</span>
y = str.<span style="color:#9900CC;">scan</span><span style="color:#006600; font-weight:bold;">&#40;</span>/./<span style="color:#006600; font-weight:bold;">&#41;</span>
y.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |c|
  sum += c.<span style="color:#9900CC;">to_i</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> sum</pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=595</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 17 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-17-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-17-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 11:35:33 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.meroal.com/?p=94</guid>
		<description><![CDATA[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. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be [...]]]></description>
			<content:encoded><![CDATA[<div class="problem_content">
<blockquote><p>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.</p>
<p>If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?</p>
<p class="info"><strong>NOTE:</strong> Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.</p>
</blockquote>
<p>My solution in Ruby:</p></div>
<pre class="ruby">@@words = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006666;">1</span> =&gt; <span style="color:#996600;">&quot;one&quot;</span>,<span style="color:#006666;">2</span> =&gt; <span style="color:#996600;">&quot;two&quot;</span>,<span style="color:#006666;">3</span> =&gt; <span style="color:#996600;">&quot;three&quot;</span>,<span style="color:#006666;">4</span> =&gt; <span style="color:#996600;">&quot;four&quot;</span>,<span style="color:#006666;">5</span> =&gt; <span style="color:#996600;">&quot;five&quot;</span>,<span style="color:#006666;">6</span> =&gt; <span style="color:#996600;">&quot;six&quot;</span>,<span style="color:#006666;">7</span> =&gt; <span style="color:#996600;">&quot;seven&quot;</span>,<span style="color:#006666;">8</span> =&gt; <span style="color:#996600;">&quot;eight&quot;</span>,<span style="color:#006666;">9</span> =&gt; <span style="color:#996600;">&quot;nine&quot;</span>,<span style="color:#006666;">10</span> =&gt; <span style="color:#996600;">&quot;ten&quot;</span>,<span style="color:#006666;">11</span> =&gt; <span style="color:#996600;">&quot;eleven&quot;</span>,<span style="color:#006666;">12</span> =&gt; <span style="color:#996600;">&quot;twelve&quot;</span>,<span style="color:#006666;">13</span> =&gt; <span style="color:#996600;">&quot;thirteen&quot;</span>,<span style="color:#006666;">14</span> =&gt; <span style="color:#996600;">&quot;fourteen&quot;</span>,<span style="color:#006666;">15</span> =&gt; <span style="color:#996600;">&quot;fifteen&quot;</span>,<span style="color:#006666;">16</span> =&gt; <span style="color:#996600;">&quot;sixteen&quot;</span>,<span style="color:#006666;">17</span> =&gt; <span style="color:#996600;">&quot;seventeen&quot;</span>,<span style="color:#006666;">18</span> =&gt; <span style="color:#996600;">&quot;eighteen&quot;</span>,<span style="color:#006666;">19</span> =&gt; <span style="color:#996600;">&quot;nineteen&quot;</span>,<span style="color:#006666;">20</span> =&gt; <span style="color:#996600;">&quot;twenty&quot;</span>,<span style="color:#006666;">30</span> =&gt; <span style="color:#996600;">&quot;thirty&quot;</span>,<span style="color:#006666;">40</span> =&gt; <span style="color:#996600;">&quot;forty&quot;</span>,<span style="color:#006666;">50</span> =&gt; <span style="color:#996600;">&quot;fifty&quot;</span>,<span style="color:#006666;">60</span> =&gt; <span style="color:#996600;">&quot;sixty&quot;</span>,<span style="color:#006666;">70</span> =&gt; <span style="color:#996600;">&quot;seventy&quot;</span>,<span style="color:#006666;">80</span> =&gt; <span style="color:#996600;">&quot;eighty&quot;</span>,<span style="color:#006666;">90</span> =&gt; <span style="color:#996600;">&quot;ninety&quot;</span>,<span style="color:#006666;">100</span> =&gt; <span style="color:#996600;">&quot;hundred&quot;</span>,<span style="color:#006666;">1000</span> =&gt; <span style="color:#996600;">&quot;thousand&quot;</span>,<span style="color:#006666;">0</span> =&gt; <span style="color:#996600;">&quot;&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
count = <span style="color:#006666;">0</span>;
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> one_to_ninetynine<span style="color:#006600; font-weight:bold;">&#40;</span>base<span style="color:#006600; font-weight:bold;">&#41;</span>
  icount = <span style="color:#006666;">0</span>
  <span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">1</span>..<span style="color:#006666;">19</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    icount += base + @@words<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  j = <span style="color:#006666;">10</span>
  <span style="color:#9966CC; font-weight:bold;">until</span> j == <span style="color:#006666;">90</span>
    j += <span style="color:#006666;">10</span>
    icount += base + @@words<span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span>
    <span style="color:#9966CC; font-weight:bold;">for</span> k <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">1</span>..<span style="color:#006666;">9</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      icount += base + @@words<span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span> + @@words<span style="color:#006600; font-weight:bold;">&#91;</span>k<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  icount
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
count += one_to_ninetynine<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">for</span> l <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">1</span>..<span style="color:#006666;">9</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  count += @@words <span style="color:#006600; font-weight:bold;">&#91;</span>l<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span> + <span style="color:#006600; font-weight:bold;">&#40;</span>@@words<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">100</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  count += one_to_ninetynine<span style="color:#006600; font-weight:bold;">&#40;</span>@@words<span style="color:#006600; font-weight:bold;">&#91;</span>l<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span> + <span style="color:#006600; font-weight:bold;">&#40;</span>@@words<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">100</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
count += @@words<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span> + @@words<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1000</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">length</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> count</pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=253</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 16 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-16-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-16-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 10:50:16 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.meroal.com/?p=109</guid>
		<description><![CDATA[2^(15) = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^(1000)? My solution in Ruby: sum, number = 0, 2**1000 str = number.to_s y = str.scan&#40;/./&#41; y.each do &#124;c&#124; sum += c.to_i end puts [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>2^(15) = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.</p>
<p>What is the sum of the digits of the number 2^(1000)?</p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby">sum, number = <span style="color:#006666;">0</span>, <span style="color:#006666;">2</span>**<span style="color:#006666;">1000</span>
str = number.<span style="color:#9900CC;">to_s</span>
y = str.<span style="color:#9900CC;">scan</span><span style="color:#006600; font-weight:bold;">&#40;</span>/./<span style="color:#006600; font-weight:bold;">&#41;</span>
y.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |c|
	sum += c.<span style="color:#9900CC;">to_i</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> sum</pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=109</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 14 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-14-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-14-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 10:42:26 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ashleyangell.com/?p=599</guid>
		<description><![CDATA[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 -> [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>The following iterative sequence is defined for the set of positive integers:</p>
<p>n -> n/2 (n is even)<br />
n -> 3n + 1 (n is odd)</p>
<p>Using the rule above and starting with 13, we generate the following sequence:</p>
<p>13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1<br />
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.</p>
<p>Which starting number, under one million, produces the longest chain?</p>
<p>NOTE: Once the chain starts the terms are allowed to go above one million.</p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby">highchain = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
high = <span style="color:#006666;">0</span>
<span style="color:#006666;">1000000</span>.<span style="color:#9900CC;">downto</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> |i|
  links = <span style="color:#006666;">0</span>
  result = i
  <span style="color:#CC0066; font-weight:bold;">loop</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    links += <span style="color:#006666;">1</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> result.<span style="color:#9900CC;">odd</span>?
      result = <span style="color:#006600; font-weight:bold;">&#40;</span>result * <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#006666;">1</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      result = result / <span style="color:#006666;">2</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">break</span> <span style="color:#9966CC; font-weight:bold;">if</span> result == <span style="color:#006666;">1</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  highchain = <span style="color:#006600; font-weight:bold;">&#123;</span>i, links<span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">if</span> links &gt; high
  high = links <span style="color:#9966CC; font-weight:bold;">if</span> links &gt; high
<span style="color:#9966CC; font-weight:bold;">end</span>
highchain.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |k,v| <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{k} has the longest chain of #{v} links!&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=599</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 13 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-13-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-13-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 10:40:45 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.meroal.com/?p=115</guid>
		<description><![CDATA[Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. (numbers omitted) My solution in Ruby: numbers = &#91; 37107287533902102798797998220837590246510135740250, 46376937677490009712648124896970078050417018260538, 74324986199524741059474233309513058123726617309629, 91942213363574161572522430563301811072406154908250, 23067588207539346171171980310421047513778063246676, 89261670696623633820136378418383684178734361726757, 28112879812849979408065481931592621691275889832738, 44274228917432520321923589422876796487670272189318, 47451445736001306439091167216856844588711603153276, 70386486105843025439939619828917593665686757934951, 62176457141856560629502157223196586755079324193331, 64906352462741904929101432445813822663347944758178, 92575867718337217661963751590579239728245598838407, 58203565325359399008402633568948830189458628227828, 80181199384826282014278194139940567587151170094390, 35398664372827112653829987240784473053190104293586, 86515506006295864861532075273371959191420517255829, 71693888707715466499115593487603532921714970056938, 54370070576826684624621495650076471787294438377604, 53282654108756828443191190634694037855217779295145, 36123272525000296071075082563815656710885258350721, 45876576172410976447339110607218265236877223636045, 17423706905851860660448207621209813287860733969412, 81142660418086830619328460811191061556940512689692, 51934325451728388641918047049293215058642563049483, 62467221648435076201727918039944693004732956340691, 15732444386908125794514089057706229429197107928209, 55037687525678773091862540744969844508330393682126, 18336384825330154686196124348767681297534375946515, 80386287592878490201521685554828717201219257766954, 78182833757993103614740356856449095527097864797581, [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.<br />
<em>(numbers omitted)</em></p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby"> numbers = <span style="color:#006600; font-weight:bold;">&#91;</span>
<span style="color:#006666;">37107287533902102798797998220837590246510135740250</span>,
<span style="color:#006666;">46376937677490009712648124896970078050417018260538</span>,
<span style="color:#006666;">74324986199524741059474233309513058123726617309629</span>,
<span style="color:#006666;">91942213363574161572522430563301811072406154908250</span>,
<span style="color:#006666;">23067588207539346171171980310421047513778063246676</span>,
<span style="color:#006666;">89261670696623633820136378418383684178734361726757</span>,
<span style="color:#006666;">28112879812849979408065481931592621691275889832738</span>,
<span style="color:#006666;">44274228917432520321923589422876796487670272189318</span>,
<span style="color:#006666;">47451445736001306439091167216856844588711603153276</span>,
<span style="color:#006666;">70386486105843025439939619828917593665686757934951</span>,
<span style="color:#006666;">62176457141856560629502157223196586755079324193331</span>,
<span style="color:#006666;">64906352462741904929101432445813822663347944758178</span>,
<span style="color:#006666;">92575867718337217661963751590579239728245598838407</span>,
<span style="color:#006666;">58203565325359399008402633568948830189458628227828</span>,
<span style="color:#006666;">80181199384826282014278194139940567587151170094390</span>,
<span style="color:#006666;">35398664372827112653829987240784473053190104293586</span>,
<span style="color:#006666;">86515506006295864861532075273371959191420517255829</span>,
<span style="color:#006666;">71693888707715466499115593487603532921714970056938</span>,
<span style="color:#006666;">54370070576826684624621495650076471787294438377604</span>,
<span style="color:#006666;">53282654108756828443191190634694037855217779295145</span>,
<span style="color:#006666;">36123272525000296071075082563815656710885258350721</span>,
<span style="color:#006666;">45876576172410976447339110607218265236877223636045</span>,
<span style="color:#006666;">17423706905851860660448207621209813287860733969412</span>,
<span style="color:#006666;">81142660418086830619328460811191061556940512689692</span>,
<span style="color:#006666;">51934325451728388641918047049293215058642563049483</span>,
<span style="color:#006666;">62467221648435076201727918039944693004732956340691</span>,
<span style="color:#006666;">15732444386908125794514089057706229429197107928209</span>,
<span style="color:#006666;">55037687525678773091862540744969844508330393682126</span>,
<span style="color:#006666;">18336384825330154686196124348767681297534375946515</span>,
<span style="color:#006666;">80386287592878490201521685554828717201219257766954</span>,
<span style="color:#006666;">78182833757993103614740356856449095527097864797581</span>,
<span style="color:#006666;">16726320100436897842553539920931837441497806860984</span>,
<span style="color:#006666;">48403098129077791799088218795327364475675590848030</span>,
<span style="color:#006666;">87086987551392711854517078544161852424320693150332</span>,
<span style="color:#006666;">59959406895756536782107074926966537676326235447210</span>,
<span style="color:#006666;">69793950679652694742597709739166693763042633987085</span>,
<span style="color:#006666;">41052684708299085211399427365734116182760315001271</span>,
<span style="color:#006666;">65378607361501080857009149939512557028198746004375</span>,
<span style="color:#006666;">35829035317434717326932123578154982629742552737307</span>,
<span style="color:#006666;">94953759765105305946966067683156574377167401875275</span>,
<span style="color:#006666;">88902802571733229619176668713819931811048770190271</span>,
<span style="color:#006666;">25267680276078003013678680992525463401061632866526</span>,
<span style="color:#006666;">36270218540497705585629946580636237993140746255962</span>,
<span style="color:#006666;">24074486908231174977792365466257246923322810917141</span>,
<span style="color:#006666;">91430288197103288597806669760892938638285025333403</span>,
<span style="color:#006666;">34413065578016127815921815005561868836468420090470</span>,
<span style="color:#006666;">23053081172816430487623791969842487255036638784583</span>,
<span style="color:#006666;">11487696932154902810424020138335124462181441773470</span>,
<span style="color:#006666;">63783299490636259666498587618221225225512486764533</span>,
<span style="color:#006666;">67720186971698544312419572409913959008952310058822</span>,
<span style="color:#006666;">95548255300263520781532296796249481641953868218774</span>,
<span style="color:#006666;">76085327132285723110424803456124867697064507995236</span>,
<span style="color:#006666;">37774242535411291684276865538926205024910326572967</span>,
<span style="color:#006666;">23701913275725675285653248258265463092207058596522</span>,
<span style="color:#006666;">29798860272258331913126375147341994889534765745501</span>,
<span style="color:#006666;">18495701454879288984856827726077713721403798879715</span>,
<span style="color:#006666;">38298203783031473527721580348144513491373226651381</span>,
<span style="color:#006666;">34829543829199918180278916522431027392251122869539</span>,
<span style="color:#006666;">40957953066405232632538044100059654939159879593635</span>,
<span style="color:#006666;">29746152185502371307642255121183693803580388584903</span>,
<span style="color:#006666;">41698116222072977186158236678424689157993532961922</span>,
<span style="color:#006666;">62467957194401269043877107275048102390895523597457</span>,
<span style="color:#006666;">23189706772547915061505504953922979530901129967519</span>,
<span style="color:#006666;">86188088225875314529584099251203829009407770775672</span>,
<span style="color:#006666;">11306739708304724483816533873502340845647058077308</span>,
<span style="color:#006666;">82959174767140363198008187129011875491310547126581</span>,
<span style="color:#006666;">97623331044818386269515456334926366572897563400500</span>,
<span style="color:#006666;">42846280183517070527831839425882145521227251250327</span>,
<span style="color:#006666;">55121603546981200581762165212827652751691296897789</span>,
<span style="color:#006666;">32238195734329339946437501907836945765883352399886</span>,
<span style="color:#006666;">75506164965184775180738168837861091527357929701337</span>,
<span style="color:#006666;">62177842752192623401942399639168044983993173312731</span>,
<span style="color:#006666;">32924185707147349566916674687634660915035914677504</span>,
<span style="color:#006666;">99518671430235219628894890102423325116913619626622</span>,
<span style="color:#006666;">73267460800591547471830798392868535206946944540724</span>,
<span style="color:#006666;">76841822524674417161514036427982273348055556214818</span>,
<span style="color:#006666;">97142617910342598647204516893989422179826088076852</span>,
<span style="color:#006666;">87783646182799346313767754307809363333018982642090</span>,
<span style="color:#006666;">10848802521674670883215120185883543223812876952786</span>,
<span style="color:#006666;">71329612474782464538636993009049310363619763878039</span>,
<span style="color:#006666;">62184073572399794223406235393808339651327408011116</span>,
<span style="color:#006666;">66627891981488087797941876876144230030984490851411</span>,
<span style="color:#006666;">60661826293682836764744779239180335110989069790714</span>,
<span style="color:#006666;">85786944089552990653640447425576083659976645795096</span>,
<span style="color:#006666;">66024396409905389607120198219976047599490197230297</span>,
<span style="color:#006666;">64913982680032973156037120041377903785566085089252</span>,
<span style="color:#006666;">16730939319872750275468906903707539413042652315011</span>,
<span style="color:#006666;">94809377245048795150954100921645863754710598436791</span>,
<span style="color:#006666;">78639167021187492431995700641917969777599028300699</span>,
<span style="color:#006666;">15368713711936614952811305876380278410754449733078</span>,
<span style="color:#006666;">40789923115535562561142322423255033685442488917353</span>,
<span style="color:#006666;">44889911501440648020369068063960672322193204149535</span>,
<span style="color:#006666;">41503128880339536053299340368006977710650566631954</span>,
<span style="color:#006666;">81234880673210146739058568557934581403627822703280</span>,
<span style="color:#006666;">82616570773948327592232845941706525094512325230608</span>,
<span style="color:#006666;">22918802058777319719839450180888072429661980811197</span>,
<span style="color:#006666;">77158542502016545090413245809786882778948721859617</span>,
<span style="color:#006666;">72107838435069186155435662884062257473692284509516</span>,
<span style="color:#006666;">20849603980134001723930671666823555245252804609722</span>,
<span style="color:#006666;">53503534226472524250874054075591789781264330331690</span> <span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
sum = <span style="color:#006666;">0</span>
numbers.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |i|
  sum += i
<span style="color:#9966CC; font-weight:bold;">end</span>
sum_s = sum.<span style="color:#9900CC;">to_s</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> sum_s<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span>,<span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=115</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 11 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-11-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-11-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 10:40:05 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ashleyangell.com/?p=602</guid>
		<description><![CDATA[In the 2020 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>In the 2020 grid below, four numbers along a diagonal line have been marked in red.</p>
<p style="font-family:courier new;font-size:8pt;">
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08<br /> <br />
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00<br /> <br />
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65<br /> <br />
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91<br /> <br />
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80<br /> <br />
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50<br /> <br />
32 98 81 28 64 23 67 10 <span style="color:#ff0000;"><b>26</b></span> 38 40 67 59 54 70 66 18 38 64 70<br /> <br />
67 26 20 68 02 62 12 20 95 <span style="color:#ff0000;"><b>63</b></span> 94 39 63 08 40 91 66 49 94 21<br /> <br />
24 55 58 05 66 73 99 26 97 17 <span style="color:#ff0000;"><b>78</b></span> 78 96 83 14 88 34 89 63 72<br /> <br />
21 36 23 09 75 00 76 44 20 45 35 <span style="color:#ff0000;"><b>14</b></span> 00 61 33 97 34 31 33 95<br /> <br />
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92<br /> <br />
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57<br /> <br />
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58<br /> <br />
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40<br /> <br />
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66<br /> <br />
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69<br /> <br />
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36<br /> <br />
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16<br /> <br />
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54<br /> <br />
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48<br /> 
</p>
<p>The product of these numbers is 26  63  78  14 = 1788696.</p>
<p>What is the greatest product of four adjacent numbers in any direction (up, down, left, right, or diagonally) in the 2020 grid?</p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby">grid = <span style="color:#006600; font-weight:bold;">&#91;</span>
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">8</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">22</span>, <span style="color:#006666;">97</span>, <span style="color:#006666;">38</span>, <span style="color:#006666;">15</span>, <span style="color:#006666;">0</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">0</span>, <span style="color:#006666;">75</span>, <span style="color:#006666;">4</span>, <span style="color:#006666;">5</span>, <span style="color:#006666;">7</span>, <span style="color:#006666;">78</span>, <span style="color:#006666;">52</span>, <span style="color:#006666;">12</span>, <span style="color:#006666;">50</span>, <span style="color:#006666;">77</span>, <span style="color:#006666;">91</span>, <span style="color:#006666;">8</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">49</span>, <span style="color:#006666;">49</span>, <span style="color:#006666;">99</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">17</span>, <span style="color:#006666;">81</span>, <span style="color:#006666;">18</span>, <span style="color:#006666;">57</span>, <span style="color:#006666;">60</span>, <span style="color:#006666;">87</span>, <span style="color:#006666;">17</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">98</span>, <span style="color:#006666;">43</span>, <span style="color:#006666;">69</span>, <span style="color:#006666;">48</span>, <span style="color:#006666;">4</span>, <span style="color:#006666;">56</span>, <span style="color:#006666;">62</span>, <span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">81</span>, <span style="color:#006666;">49</span>, <span style="color:#006666;">31</span>, <span style="color:#006666;">73</span>, <span style="color:#006666;">55</span>, <span style="color:#006666;">79</span>, <span style="color:#006666;">14</span>, <span style="color:#006666;">29</span>, <span style="color:#006666;">93</span>, <span style="color:#006666;">71</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">67</span>, <span style="color:#006666;">53</span>, <span style="color:#006666;">88</span>, <span style="color:#006666;">30</span>, <span style="color:#006666;">3</span>, <span style="color:#006666;">49</span>, <span style="color:#006666;">13</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">65</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">52</span>, <span style="color:#006666;">70</span>, <span style="color:#006666;">95</span>, <span style="color:#006666;">23</span>, <span style="color:#006666;">4</span>, <span style="color:#006666;">60</span>, <span style="color:#006666;">11</span>, <span style="color:#006666;">42</span>, <span style="color:#006666;">69</span>, <span style="color:#006666;">24</span>, <span style="color:#006666;">68</span>, <span style="color:#006666;">56</span>, <span style="color:#006666;">1</span>, <span style="color:#006666;">32</span>, <span style="color:#006666;">56</span>, <span style="color:#006666;">71</span>, <span style="color:#006666;">37</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">91</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">22</span>, <span style="color:#006666;">31</span>, <span style="color:#006666;">16</span>, <span style="color:#006666;">71</span>, <span style="color:#006666;">51</span>, <span style="color:#006666;">67</span>, <span style="color:#006666;">63</span>, <span style="color:#006666;">89</span>, <span style="color:#006666;">41</span>, <span style="color:#006666;">92</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">54</span>, <span style="color:#006666;">22</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">28</span>, <span style="color:#006666;">66</span>, <span style="color:#006666;">33</span>, <span style="color:#006666;">13</span>, <span style="color:#006666;">80</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">24</span>, <span style="color:#006666;">47</span>, <span style="color:#006666;">32</span>, <span style="color:#006666;">60</span>, <span style="color:#006666;">99</span>, <span style="color:#006666;">3</span>, <span style="color:#006666;">45</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">44</span>, <span style="color:#006666;">75</span>, <span style="color:#006666;">33</span>, <span style="color:#006666;">53</span>, <span style="color:#006666;">78</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">84</span>, <span style="color:#006666;">20</span>, <span style="color:#006666;">35</span>, <span style="color:#006666;">17</span>, <span style="color:#006666;">12</span>, <span style="color:#006666;">50</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">32</span>, <span style="color:#006666;">98</span>, <span style="color:#006666;">81</span>, <span style="color:#006666;">28</span>, <span style="color:#006666;">64</span>, <span style="color:#006666;">23</span>, <span style="color:#006666;">67</span>, <span style="color:#006666;">10</span>, <span style="color:#006666;">26</span>, <span style="color:#006666;">38</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">67</span>, <span style="color:#006666;">59</span>, <span style="color:#006666;">54</span>, <span style="color:#006666;">70</span>, <span style="color:#006666;">66</span>, <span style="color:#006666;">18</span>, <span style="color:#006666;">38</span>, <span style="color:#006666;">64</span>, <span style="color:#006666;">70</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">67</span>, <span style="color:#006666;">26</span>, <span style="color:#006666;">20</span>, <span style="color:#006666;">68</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">62</span>, <span style="color:#006666;">12</span>, <span style="color:#006666;">20</span>, <span style="color:#006666;">95</span>, <span style="color:#006666;">63</span>, <span style="color:#006666;">94</span>, <span style="color:#006666;">39</span>, <span style="color:#006666;">63</span>, <span style="color:#006666;">8</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">91</span>, <span style="color:#006666;">66</span>, <span style="color:#006666;">49</span>, <span style="color:#006666;">94</span>, <span style="color:#006666;">21</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">24</span>, <span style="color:#006666;">55</span>, <span style="color:#006666;">58</span>, <span style="color:#006666;">5</span>, <span style="color:#006666;">66</span>, <span style="color:#006666;">73</span>, <span style="color:#006666;">99</span>, <span style="color:#006666;">26</span>, <span style="color:#006666;">97</span>, <span style="color:#006666;">17</span>, <span style="color:#006666;">78</span>, <span style="color:#006666;">78</span>, <span style="color:#006666;">96</span>, <span style="color:#006666;">83</span>, <span style="color:#006666;">14</span>, <span style="color:#006666;">88</span>, <span style="color:#006666;">34</span>, <span style="color:#006666;">89</span>, <span style="color:#006666;">63</span>, <span style="color:#006666;">72</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">21</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">23</span>, <span style="color:#006666;">9</span>, <span style="color:#006666;">75</span>, <span style="color:#006666;">0</span>, <span style="color:#006666;">76</span>, <span style="color:#006666;">44</span>, <span style="color:#006666;">20</span>, <span style="color:#006666;">45</span>, <span style="color:#006666;">35</span>, <span style="color:#006666;">14</span>, <span style="color:#006666;">0</span>, <span style="color:#006666;">61</span>, <span style="color:#006666;">33</span>, <span style="color:#006666;">97</span>, <span style="color:#006666;">34</span>, <span style="color:#006666;">31</span>, <span style="color:#006666;">33</span>, <span style="color:#006666;">95</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">78</span>, <span style="color:#006666;">17</span>, <span style="color:#006666;">53</span>, <span style="color:#006666;">28</span>, <span style="color:#006666;">22</span>, <span style="color:#006666;">75</span>, <span style="color:#006666;">31</span>, <span style="color:#006666;">67</span>, <span style="color:#006666;">15</span>, <span style="color:#006666;">94</span>, <span style="color:#006666;">3</span>, <span style="color:#006666;">80</span>, <span style="color:#006666;">4</span>, <span style="color:#006666;">62</span>, <span style="color:#006666;">16</span>, <span style="color:#006666;">14</span>, <span style="color:#006666;">9</span>, <span style="color:#006666;">53</span>, <span style="color:#006666;">56</span>, <span style="color:#006666;">92</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">16</span>, <span style="color:#006666;">39</span>, <span style="color:#006666;">5</span>, <span style="color:#006666;">42</span>, <span style="color:#006666;">96</span>, <span style="color:#006666;">35</span>, <span style="color:#006666;">31</span>, <span style="color:#006666;">47</span>, <span style="color:#006666;">55</span>, <span style="color:#006666;">58</span>, <span style="color:#006666;">88</span>, <span style="color:#006666;">24</span>, <span style="color:#006666;">0</span>, <span style="color:#006666;">17</span>, <span style="color:#006666;">54</span>, <span style="color:#006666;">24</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">29</span>, <span style="color:#006666;">85</span>, <span style="color:#006666;">57</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">86</span>, <span style="color:#006666;">56</span>, <span style="color:#006666;">0</span>, <span style="color:#006666;">48</span>, <span style="color:#006666;">35</span>, <span style="color:#006666;">71</span>, <span style="color:#006666;">89</span>, <span style="color:#006666;">7</span>, <span style="color:#006666;">5</span>, <span style="color:#006666;">44</span>, <span style="color:#006666;">44</span>, <span style="color:#006666;">37</span>, <span style="color:#006666;">44</span>, <span style="color:#006666;">60</span>, <span style="color:#006666;">21</span>, <span style="color:#006666;">58</span>, <span style="color:#006666;">51</span>, <span style="color:#006666;">54</span>, <span style="color:#006666;">17</span>, <span style="color:#006666;">58</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">19</span>, <span style="color:#006666;">80</span>, <span style="color:#006666;">81</span>, <span style="color:#006666;">68</span>, <span style="color:#006666;">05</span>, <span style="color:#006666;">94</span>, <span style="color:#006666;">47</span>, <span style="color:#006666;">69</span>, <span style="color:#006666;">28</span>, <span style="color:#006666;">73</span>, <span style="color:#006666;">92</span>, <span style="color:#006666;">13</span>, <span style="color:#006666;">86</span>, <span style="color:#006666;">52</span>, <span style="color:#006666;">17</span>, <span style="color:#006666;">77</span>, <span style="color:#006666;">4</span>, <span style="color:#006666;">89</span>, <span style="color:#006666;">55</span>, <span style="color:#006666;">40</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">4</span>, <span style="color:#006666;">52</span>, <span style="color:#006666;">8</span>, <span style="color:#006666;">83</span>, <span style="color:#006666;">97</span>, <span style="color:#006666;">35</span>, <span style="color:#006666;">99</span>, <span style="color:#006666;">16</span>, <span style="color:#006666;">7</span>, <span style="color:#006666;">97</span>, <span style="color:#006666;">57</span>, <span style="color:#006666;">32</span>, <span style="color:#006666;">16</span>, <span style="color:#006666;">26</span>, <span style="color:#006666;">26</span>, <span style="color:#006666;">79</span>, <span style="color:#006666;">33</span>, <span style="color:#006666;">27</span>, <span style="color:#006666;">98</span>, <span style="color:#006666;">66</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">88</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">68</span>, <span style="color:#006666;">87</span>, <span style="color:#006666;">57</span>, <span style="color:#006666;">62</span>, <span style="color:#006666;">20</span>, <span style="color:#006666;">72</span>, <span style="color:#006666;">3</span>, <span style="color:#006666;">46</span>, <span style="color:#006666;">33</span>, <span style="color:#006666;">67</span>, <span style="color:#006666;">46</span>, <span style="color:#006666;">55</span>, <span style="color:#006666;">12</span>, <span style="color:#006666;">32</span>, <span style="color:#006666;">63</span>, <span style="color:#006666;">93</span>, <span style="color:#006666;">53</span>, <span style="color:#006666;">69</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">4</span>, <span style="color:#006666;">42</span>, <span style="color:#006666;">16</span>, <span style="color:#006666;">73</span>, <span style="color:#006666;">38</span>, <span style="color:#006666;">25</span>, <span style="color:#006666;">39</span>, <span style="color:#006666;">11</span>, <span style="color:#006666;">24</span>, <span style="color:#006666;">94</span>, <span style="color:#006666;">72</span>, <span style="color:#006666;">18</span>, <span style="color:#006666;">8</span>, <span style="color:#006666;">46</span>, <span style="color:#006666;">29</span>, <span style="color:#006666;">32</span>, <span style="color:#006666;">40</span>, <span style="color:#006666;">62</span>, <span style="color:#006666;">76</span>, <span style="color:#006666;">36</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">20</span>, <span style="color:#006666;">69</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">41</span>, <span style="color:#006666;">72</span>, <span style="color:#006666;">30</span>, <span style="color:#006666;">23</span>, <span style="color:#006666;">88</span>, <span style="color:#006666;">34</span>, <span style="color:#006666;">62</span>, <span style="color:#006666;">99</span>, <span style="color:#006666;">69</span>, <span style="color:#006666;">82</span>, <span style="color:#006666;">67</span>, <span style="color:#006666;">59</span>, <span style="color:#006666;">85</span>, <span style="color:#006666;">74</span>, <span style="color:#006666;">4</span>, <span style="color:#006666;">36</span>, <span style="color:#006666;">16</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">20</span>, <span style="color:#006666;">73</span>, <span style="color:#006666;">35</span>, <span style="color:#006666;">29</span>, <span style="color:#006666;">78</span>, <span style="color:#006666;">31</span>, <span style="color:#006666;">90</span>, <span style="color:#006666;">1</span>, <span style="color:#006666;">74</span>, <span style="color:#006666;">31</span>, <span style="color:#006666;">49</span>, <span style="color:#006666;">71</span>, <span style="color:#006666;">48</span>, <span style="color:#006666;">86</span>, <span style="color:#006666;">81</span>, <span style="color:#006666;">16</span>, <span style="color:#006666;">23</span>, <span style="color:#006666;">57</span>, <span style="color:#006666;">5</span>, <span style="color:#006666;">54</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">70</span>, <span style="color:#006666;">54</span>, <span style="color:#006666;">71</span>, <span style="color:#006666;">83</span>, <span style="color:#006666;">51</span>, <span style="color:#006666;">54</span>, <span style="color:#006666;">69</span>, <span style="color:#006666;">16</span>, <span style="color:#006666;">92</span>, <span style="color:#006666;">33</span>, <span style="color:#006666;">48</span>, <span style="color:#006666;">61</span>, <span style="color:#006666;">43</span>, <span style="color:#006666;">52</span>, <span style="color:#006666;">1</span>, <span style="color:#006666;">89</span>, <span style="color:#006666;">19</span>, <span style="color:#006666;">67</span>, <span style="color:#006666;">48</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
biggestproduct = <span style="color:#006666;">0</span>
factors = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
direction = <span style="color:#0000FF; font-weight:bold;">nil</span>
<span style="color:#008000; font-style:italic;">#Horizontal</span>
<span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">0</span>..<span style="color:#006666;">19</span>
  <span style="color:#9966CC; font-weight:bold;">for</span> j <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">0</span>..<span style="color:#9900CC;"><span style="color:#006600; font-weight:bold;">&#40;</span></span><span style="color:#006666;">19</span><span style="color:#006666;">-3</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    product = grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    factors = <span style="color:#006600; font-weight:bold;">&#91;</span>grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> product &gt; biggestproduct
    direction = <span style="color:#996600;">&quot;Horizontal&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> product &gt; biggestproduct
    biggestproduct = product <span style="color:#9966CC; font-weight:bold;">if</span>  product &gt; biggestproduct
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#008000; font-style:italic;">#Vertical</span>
<span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">0</span>..<span style="color:#9900CC;"><span style="color:#006600; font-weight:bold;">&#40;</span></span><span style="color:#006666;">19</span><span style="color:#006666;">-3</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">for</span> j <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">0</span>..<span style="color:#006666;">19</span>
    product = grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>
    factors = <span style="color:#006600; font-weight:bold;">&#91;</span>grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> product &gt; biggestproduct
    direction = <span style="color:#996600;">&quot;Vertical&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> product &gt; biggestproduct
    biggestproduct = product <span style="color:#9966CC; font-weight:bold;">if</span>  product &gt; biggestproduct
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#008000; font-style:italic;">#Diagonal \</span>
<span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">0</span>..<span style="color:#9900CC;"><span style="color:#006600; font-weight:bold;">&#40;</span></span><span style="color:#006666;">19</span><span style="color:#006666;">-3</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">for</span> j <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">0</span>..<span style="color:#9900CC;"><span style="color:#006600; font-weight:bold;">&#40;</span></span><span style="color:#006666;">19</span><span style="color:#006666;">-3</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    product = grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    factors = <span style="color:#006600; font-weight:bold;">&#91;</span>grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> product &gt; biggestproduct
    direction = <span style="color:#996600;">&quot;Diagonal <span style="color:#000099;">\\</span>&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> product &gt; biggestproduct
    biggestproduct = product <span style="color:#9966CC; font-weight:bold;">if</span>  product &gt; biggestproduct
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#008000; font-style:italic;">#Diagonal /</span>
<span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">0</span>..<span style="color:#9900CC;"><span style="color:#006600; font-weight:bold;">&#40;</span></span><span style="color:#006666;">19</span><span style="color:#006666;">-3</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">for</span> j <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">0</span><span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#41;</span>..<span style="color:#006666;">19</span>
    product = grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">-1</span><span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">-2</span><span style="color:#006600; font-weight:bold;">&#93;</span> * grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">-3</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    factors = <span style="color:#006600; font-weight:bold;">&#91;</span>grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">-1</span><span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+2</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">-2</span><span style="color:#006600; font-weight:bold;">&#93;</span>, grid<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006666;">+3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>j<span style="color:#006666;">-3</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> product &gt; biggestproduct
    direction = <span style="color:#996600;">&quot;Diagonal /&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> product &gt; biggestproduct
    biggestproduct = product <span style="color:#9966CC; font-weight:bold;">if</span>  product &gt; biggestproduct
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;answer: #{factors[0]} x #{factors[1]} x #{factors[2]} x #{factors[3]} = #{biggestproduct} (#{direction})&quot;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=602</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 10 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-10-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-10-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 10:39:50 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.meroal.com/?p=133</guid>
		<description><![CDATA[The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. My solution in Ruby: def is_prime &#40; p &#41; if p == 2 return true elsif p &#60;= 1 &#124;&#124; p % 2 == 0 return false else [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.</p>
<p>Find the sum of all the primes below two million.</p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> is_prime <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#CC0066; font-weight:bold;">p</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC0066; font-weight:bold;">p</span> == <span style="color:#006666;">2</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">true</span>
  <span style="color:#9966CC; font-weight:bold;">elsif</span> <span style="color:#CC0066; font-weight:bold;">p</span> &lt;= <span style="color:#006666;">1</span> || <span style="color:#CC0066; font-weight:bold;">p</span> % <span style="color:#006666;">2</span> == <span style="color:#006666;">0</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">false</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">3</span> .. <span style="color:#CC00FF; font-weight:bold;">Math</span>.<span style="color:#9900CC;">sqrt</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">p</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">step</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> |i|
      <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC0066; font-weight:bold;">p</span> % i == <span style="color:#006666;">0</span>
        <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">false</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">true</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
sum = <span style="color:#006666;">0</span>
<span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">2</span>..<span style="color:#006666;">2000000</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> is_prime<span style="color:#006600; font-weight:bold;">&#40;</span>i<span style="color:#006600; font-weight:bold;">&#41;</span>
    sum += i
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> sum</pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=133</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler Problem 8 Solution</title>
		<link>http://ashleyangell.com/2009/04/project-euler-problem-8-solution/</link>
		<comments>http://ashleyangell.com/2009/04/project-euler-problem-8-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 10:38:58 +0000</pubDate>
		<dc:creator>Ash</dc:creator>
				<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.meroal.com/?p=144</guid>
		<description><![CDATA[Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450 My solution in Ruby: var = %&#38; 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Find the greatest product of five consecutive digits in the 1000-digit number.</p>
<p>73167176531330624919225119674426574742355349194934<br />
96983520312774506326239578318016984801869478851843<br />
85861560789112949495459501737958331952853208805511<br />
12540698747158523863050715693290963295227443043557<br />
66896648950445244523161731856403098711121722383113<br />
62229893423380308135336276614282806444486645238749<br />
30358907296290491560440772390713810515859307960866<br />
70172427121883998797908792274921901699720888093776<br />
65727333001053367881220235421809751254540594752243<br />
52584907711670556013604839586446706324415722155397<br />
53697817977846174064955149290862569321978468622482<br />
83972241375657056057490261407972968652414535100474<br />
82166370484403199890008895243450658541227588666881<br />
16427171479924442928230863465674813919123162824586<br />
17866458359124566529476545682848912883142607690042<br />
24219022671055626321111109370544217506941658960408<br />
07198403850962455444362981230987879927244284909188<br />
84580156166097919133875499200524063689912560717606<br />
05886116467109405077541002256983155200055935729725<br />
71636269561882670428252483600823257530420752963450</p></blockquote>
<p>My solution in Ruby:</p>
<pre class="ruby">var = %&amp;
<span style="color:#006666;">73167176531330624919225119674426574742355349194934</span>
<span style="color:#006666;">96983520312774506326239578318016984801869478851843</span>
<span style="color:#006666;">85861560789112949495459501737958331952853208805511</span>
<span style="color:#006666;">12540698747158523863050715693290963295227443043557</span>
<span style="color:#006666;">66896648950445244523161731856403098711121722383113</span>
<span style="color:#006666;">62229893423380308135336276614282806444486645238749</span>
<span style="color:#006666;">30358907296290491560440772390713810515859307960866</span>
<span style="color:#006666;">70172427121883998797908792274921901699720888093776</span>
<span style="color:#006666;">65727333001053367881220235421809751254540594752243</span>
<span style="color:#006666;">52584907711670556013604839586446706324415722155397</span>
<span style="color:#006666;">53697817977846174064955149290862569321978468622482</span>
<span style="color:#006666;">83972241375657056057490261407972968652414535100474</span>
<span style="color:#006666;">82166370484403199890008895243450658541227588666881</span>
<span style="color:#006666;">16427171479924442928230863465674813919123162824586</span>
<span style="color:#006666;">17866458359124566529476545682848912883142607690042</span>
<span style="color:#006666;">24219022671055626321111109370544217506941658960408</span>
<span style="color:#006666;">07198403850962455444362981230987879927244284909188</span>
<span style="color:#006666;">84580156166097919133875499200524063689912560717606</span>
<span style="color:#006666;">05886116467109405077541002256983155200055935729725</span>
<span style="color:#006666;">71636269561882670428252483600823257530420752963450</span>&amp;
&nbsp;
arr = var.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span> // <span style="color:#006600; font-weight:bold;">&#41;</span>
arr.<span style="color:#9900CC;">delete</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span>
big = <span style="color:#006666;">0</span>;
<span style="color:#9966CC; font-weight:bold;">for</span> i <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#006666;">0</span>..<span style="color:#9900CC;">arr</span>.<span style="color:#9900CC;">length</span> - <span style="color:#006666;">5</span>
  <span style="color:#9966CC; font-weight:bold;">next</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC0066; font-weight:bold;">Integer</span><span style="color:#006600; font-weight:bold;">&#40;</span>arr<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#006666;">0</span>
  tmp = <span style="color:#CC0066; font-weight:bold;">Integer</span><span style="color:#006600; font-weight:bold;">&#40;</span>arr<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#006666;">1</span>.<span style="color:#9900CC;">upto</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |j| tmp = tmp * <span style="color:#CC0066; font-weight:bold;">Integer</span><span style="color:#006600; font-weight:bold;">&#40;</span>arr<span style="color:#006600; font-weight:bold;">&#91;</span>i + j<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  big = tmp <span style="color:#9966CC; font-weight:bold;">if</span> tmp &gt; big
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> big</pre>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/ashleyangell.com/p=252</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
