<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Euler Problem 203</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2009/09/26/euler-problem-203/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2009/09/26/euler-problem-203/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:28:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: gruff999</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/09/26/euler-problem-203/#comment-41311</link>
		<dc:creator>gruff999</dc:creator>
		<pubDate>Tue, 29 Sep 2009 12:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2998#comment-41311</guid>
		<description>&lt;p&gt;fzz&lt;/p&gt;
&lt;p&gt;I&#039;m a &#039;hit it until it works&#039; coder, rarely using subtleties of variable types - other than arrays. I wouldn&#039;t, for example, think to use dictionaries or collections, though obviously it looks like I should.&lt;/p&gt;
&lt;p&gt;So when someone ReDims something other than an array it confuses me. Can you shed light on the internals of:&lt;/p&gt;
&lt;p&gt;Dim pt As Variant&lt;br&gt;
ReDim pt(1 To 51) As Double&lt;/p&gt;
&lt;p&gt;gruff999&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>fzz</p>
<p>I&#8217;m a &#8216;hit it until it works&#8217; coder, rarely using subtleties of variable types &#8211; other than arrays. I wouldn&#8217;t, for example, think to use dictionaries or collections, though obviously it looks like I should.</p>
<p>So when someone ReDims something other than an array it confuses me. Can you shed light on the internals of:</p>
<p>Dim pt As Variant<br />
ReDim pt(1 To 51) As Double</p>
<p>gruff999</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JoshG</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/09/26/euler-problem-203/#comment-41286</link>
		<dc:creator>JoshG</dc:creator>
		<pubDate>Mon, 28 Sep 2009 16:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2998#comment-41286</guid>
		<description>&lt;p&gt;You guys and your collections / dictionaries.  It makes things so...easy.  My idea was to build the triangle, add each number to a list, sort the list, and then pull out the unique values for testing.  It runs in a blink, but it&#039;s not nearly so neat and clean as fzz&#039;s.  Well done.&lt;/p&gt;
&lt;p&gt;-Josh&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You guys and your collections / dictionaries.  It makes things so&#8230;easy.  My idea was to build the triangle, add each number to a list, sort the list, and then pull out the unique values for testing.  It runs in a blink, but it&#8217;s not nearly so neat and clean as fzz&#8217;s.  Well done.</p>
<p>-Josh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/09/26/euler-problem-203/#comment-41281</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 28 Sep 2009 14:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2998#comment-41281</guid>
		<description>&lt;p&gt;fzz -&lt;/p&gt;
&lt;p&gt;Very nice.  I particularly like doing the &quot;heavy-lifting&quot; in the dictionary keys, and having the item be a tiny boolean.  That&#039;s a neat trick, and all that&#039;s required..&lt;/p&gt;
&lt;p&gt;For those scoring at home, to use a dictionary object, you need to set a reference (via the Tools menu) to the Microsoft Scripting Runtime.  One advantage of a dictionary over a collection is that a dictionary has an &quot;exists&quot; method (as fzz used).  Takes the place of my IsIn(collection,key) function.  Dictionaries are slower than collections, but you can&#039;t improve on fzz&#039;s zero seconds.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;...mrt&lt;/i&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>fzz -</p>
<p>Very nice.  I particularly like doing the &#8220;heavy-lifting&#8221; in the dictionary keys, and having the item be a tiny boolean.  That&#8217;s a neat trick, and all that&#8217;s required..</p>
<p>For those scoring at home, to use a dictionary object, you need to set a reference (via the Tools menu) to the Microsoft Scripting Runtime.  One advantage of a dictionary over a collection is that a dictionary has an &#8220;exists&#8221; method (as fzz used).  Takes the place of my IsIn(collection,key) function.  Dictionaries are slower than collections, but you can&#8217;t improve on fzz&#8217;s zero seconds.</p>
<p><i>&#8230;mrt</i></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/09/26/euler-problem-203/#comment-41268</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Sun, 27 Sep 2009 07:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2998#comment-41268</guid>
		<description>&lt;p&gt;Use the symmetry of Pascal&#039;s triangle (PT). If you index the 0th through 50th order rows 0..50 for rows and -50..50 for columns using the convention that even order rows use even column indices and odd order rows use odd column indices, PT(row, -col) = PT(row, col) for all row and col. You only need to fill out PT for nonnegative col.&lt;/p&gt;
&lt;p&gt;Also, with only 4 squared primes to check, the Sieve of Eratosthenes is too much overhead.&lt;/p&gt;
&lt;p&gt;The following runs a bit more than 10 times faster than your code, and it&#039;s all in one procedure (which is one of the reasons it&#039;s faster).&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt; euler203fb()&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; dn &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;New&lt;/span&gt; Dictionary&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; pt &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;, p &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Double&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; i &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, j &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; pt(1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 51) &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Double&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; pt(1) = 1&lt;br&gt;
&#160; pt(2) = 1&lt;br&gt;
&lt;br&gt;
&#160; dn.Add Key:=1, Item:=&lt;span class=&quot;kw1&quot;&gt;False&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;use the symmetry of the triangle and don&#039;t do more than necessary&lt;br&gt;
&lt;/span&gt; &#160;&lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i = 2 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 50&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; j = i + 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; i  2 + 1 &lt;span class=&quot;kw1&quot;&gt;Step&lt;/span&gt; -1&lt;br&gt;
&#160; &#160; &#160; pt(j) = pt(j) + pt(j - 1)&lt;br&gt;
&#160; &#160; &#160; p = pt(j)&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039;check if divisible by squared primes 2, 3, 5 or 7&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; p / 4 - Int(p / 4) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; _&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; p / 9 - Int(p / 9) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; _&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; p / 25 - Int(p / 25) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; _&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; p / 49 - Int(p / 49) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; _&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Not&lt;/span&gt; dn.Exists(p) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; dn.Add Key:=p, Item:=&lt;span class=&quot;kw1&quot;&gt;False&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; j&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; i &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 2 = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; pt(j) = pt(j + 2)&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; i&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Erase&lt;/span&gt; pt&lt;br&gt;
&#160; pt = dn.Keys&lt;br&gt;
&#160; dn.RemoveAll&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i = &lt;span class=&quot;kw1&quot;&gt;LBound&lt;/span&gt;(pt) &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(pt)&lt;br&gt;
&#160; &#160; euler203fb = euler203fb + pt(i)&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; i&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Erase&lt;/span&gt; pt&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>Use the symmetry of Pascal&#8217;s triangle (PT). If you index the 0th through 50th order rows 0..50 for rows and -50..50 for columns using the convention that even order rows use even column indices and odd order rows use odd column indices, PT(row, -col) = PT(row, col) for all row and col. You only need to fill out PT for nonnegative col.</p>
<p>Also, with only 4 squared primes to check, the Sieve of Eratosthenes is too much overhead.</p>
<p>The following runs a bit more than 10 times faster than your code, and it&#8217;s all in one procedure (which is one of the reasons it&#8217;s faster).</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Function</span> euler203fb()<br />
&nbsp; <span class="kw1">Dim</span> dn <span class="kw1">As</span> <span class="kw1">New</span> Dictionary<br />
&nbsp; <span class="kw1">Dim</span> pt <span class="kw1">As</span> <span class="kw1">Variant</span>, p <span class="kw1">As</span> <span class="kw1">Double</span><br />
&nbsp; <span class="kw1">Dim</span> i <span class="kw1">As</span> <span class="kw1">Long</span>, j <span class="kw1">As</span> <span class="kw1">Long</span></p>
<p>&nbsp; <span class="kw1">ReDim</span> pt(1 <span class="kw1">To</span> 51) <span class="kw1">As</span> <span class="kw1">Double</span></p>
<p>&nbsp; pt(1) = 1<br />
&nbsp; pt(2) = 1</p>
<p>&nbsp; dn.Add Key:=1, Item:=<span class="kw1">False</span></p>
<p>&nbsp; <span class="co1">&#8216;use the symmetry of the triangle and don&#8217;t do more than necessary<br />
</span> &nbsp;<span class="kw1">For</span> i = 2 <span class="kw1">To</span> 50<br />
&nbsp; &nbsp; <span class="kw1">For</span> j = i + 1 <span class="kw1">To</span> i  2 + 1 <span class="kw1">Step</span> -1<br />
&nbsp; &nbsp; &nbsp; pt(j) = pt(j) + pt(j &#8211; 1)<br />
&nbsp; &nbsp; &nbsp; p = pt(j)<br />
&nbsp; &nbsp; &nbsp; <span class="co1">&#8216;check if divisible by squared primes 2, 3, 5 or 7<br />
</span> &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> p / 4 &#8211; Int(p / 4) <span class="kw1">Then</span> _<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> p / 9 &#8211; Int(p / 9) <span class="kw1">Then</span> _<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> p / 25 &#8211; Int(p / 25) <span class="kw1">Then</span> _<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> p / 49 &#8211; Int(p / 49) <span class="kw1">Then</span> _<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> <span class="kw1">Not</span> dn.Exists(p) <span class="kw1">Then</span> dn.Add Key:=p, Item:=<span class="kw1">False</span><br />
&nbsp; &nbsp; <span class="kw1">Next</span> j<br />
&nbsp; &nbsp; <span class="kw1">If</span> i <span class="kw1">Mod</span> 2 = 0 <span class="kw1">Then</span> pt(j) = pt(j + 2)<br />
&nbsp; <span class="kw1">Next</span> i</p>
<p>&nbsp; <span class="kw1">Erase</span> pt<br />
&nbsp; pt = dn.Keys<br />
&nbsp; dn.RemoveAll</p>
<p>&nbsp; <span class="kw1">For</span> i = <span class="kw1">LBound</span>(pt) <span class="kw1">To</span> <span class="kw1">UBound</span>(pt)<br />
&nbsp; &nbsp; euler203fb = euler203fb + pt(i)<br />
&nbsp; <span class="kw1">Next</span> i</p>
<p>&nbsp; <span class="kw1">Erase</span> pt</p>
<p><span class="kw1">End</span> <span class="kw1">Function</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: MaryP</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/09/26/euler-problem-203/#comment-41264</link>
		<dc:creator>MaryP</dc:creator>
		<pubDate>Sat, 26 Sep 2009 21:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2998#comment-41264</guid>
		<description>&lt;p&gt;Whew; math.  Nice job...I think.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Whew; math.  Nice job&#8230;I think.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

