<?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 31</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36758</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Thu, 01 Jan 2009 01:18:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36758</guid>
		<description>&lt;p&gt;&quot;But for Project Euler we want speed...&quot;&lt;/p&gt;
&lt;p&gt;I think different people want different things.  Looking at the comments it seems that a lot of people are keen to write the most elegant or the shortest code they can.  For me the point is to come up with the code that gives the correct answer (within the program run time constraint) in the shortest possible time spent working on it.  In other words if I can reduce the solution time from 59 seconds to 1 microsecond with less than 58 seconds worth of coding, that&#039;s worth doing, otherwise it isn&#039;t and I&#039;ll move onto something else.  The only proviso is that if the code is re-useable (either in Project Euler or elsewhere) then it&#039;s worth spending some time optimising it.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>&#8220;But for Project Euler we want speed&#8230;&#8221;</p>
<p>I think different people want different things.  Looking at the comments it seems that a lot of people are keen to write the most elegant or the shortest code they can.  For me the point is to come up with the code that gives the correct answer (within the program run time constraint) in the shortest possible time spent working on it.  In other words if I can reduce the solution time from 59 seconds to 1 microsecond with less than 58 seconds worth of coding, that&#8217;s worth doing, otherwise it isn&#8217;t and I&#8217;ll move onto something else.  The only proviso is that if the code is re-useable (either in Project Euler or elsewhere) then it&#8217;s worth spending some time optimising it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36756</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Wed, 31 Dec 2008 22:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36756</guid>
		<description>&lt;p&gt;keepITcool:  You might want to try the recursive approach rather than simply concluding that the performance is unacceptable because it is recursive.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>keepITcool:  You might want to try the recursive approach rather than simply concluding that the performance is unacceptable because it is recursive.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald Staff</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36750</link>
		<dc:creator>Harald Staff</dc:creator>
		<pubDate>Wed, 31 Dec 2008 12:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36750</guid>
		<description>&lt;p&gt;Recursion: see Recursion&lt;br&gt;
(don&#039;t remember where I saw this)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Recursion: see Recursion<br />
(don&#8217;t remember where I saw this)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36743</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Wed, 31 Dec 2008 02:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36743</guid>
		<description>&lt;p&gt;One way is big-endian (so to speak) and the other little-endian.  Does is matter?&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>One way is big-endian (so to speak) and the other little-endian.  Does is matter?</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36741</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Wed, 31 Dec 2008 00:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36741</guid>
		<description>&lt;p&gt;I&#039;ve tried a recursive routine which is more elegant &amp; versatile. But for Project Euler we want speed... and recursive routines take too much ticks on the stack.&lt;br&gt;
Thus nesting: start with the largest coin, then try to fill the (declining) remaining balance.&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;Sub&lt;/span&gt; kic31()&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; t!: t = Timer&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; p002&amp;, p005&amp;, p010&amp;, p020&amp;, p050&amp;, p100&amp;, p200&amp;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; n002&amp;, n005&amp;, n010&amp;, n020&amp;, n050&amp;, n100&amp;, n200&amp;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; amnt&amp;, rslt&amp;&lt;br&gt;
&lt;br&gt;
&#160; amnt = 200&lt;br&gt;
&#160; &lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p200 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; amnt &lt;span class=&quot;kw1&quot;&gt;Step&lt;/span&gt; 200: n200 = amnt - p200&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p100 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; n200 &lt;span class=&quot;kw1&quot;&gt;Step&lt;/span&gt; 100: n100 = n200 - p100&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p050 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; n100 &lt;span class=&quot;kw1&quot;&gt;Step&lt;/span&gt; 50: &#160;n050 = n100 - p050&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p020 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; n050 &lt;span class=&quot;kw1&quot;&gt;Step&lt;/span&gt; 20: &#160;n020 = n050 - p020&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p010 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; n020 &lt;span class=&quot;kw1&quot;&gt;Step&lt;/span&gt; 10: &#160;n010 = n020 - p010&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p005 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; n010 &lt;span class=&quot;kw1&quot;&gt;Step&lt;/span&gt; 5: &#160; n005 = n010 - p005&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p002 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; n005 &lt;span class=&quot;kw1&quot;&gt;Step&lt;/span&gt; 2: &#160; rslt = rslt + 1&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;: &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; Debug.&lt;span class=&quot;kw1&quot;&gt;Print&lt;/span&gt; amnt; rslt; Timer - t&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;ve tried a recursive routine which is more elegant &amp; versatile. But for Project Euler we want speed&#8230; and recursive routines take too much ticks on the stack.<br />
Thus nesting: start with the largest coin, then try to fill the (declining) remaining balance.</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Sub</span> kic31()<br />
&nbsp; <span class="kw1">Dim</span> t!: t = Timer<br />
&nbsp; <span class="kw1">Dim</span> p002&amp;amp;, p005&amp;amp;, p010&amp;amp;, p020&amp;amp;, p050&amp;amp;, p100&amp;amp;, p200&amp;amp;<br />
&nbsp; <span class="kw1">Dim</span> n002&amp;amp;, n005&amp;amp;, n010&amp;amp;, n020&amp;amp;, n050&amp;amp;, n100&amp;amp;, n200&amp;amp;<br />
&nbsp; <span class="kw1">Dim</span> amnt&amp;amp;, rslt&amp;amp;</p>
<p>&nbsp; amnt = 200<br />
&nbsp; <br />
&nbsp; <span class="kw1">For</span> p200 = 0 <span class="kw1">To</span> amnt <span class="kw1">Step</span> 200: n200 = amnt &#8211; p200<br />
&nbsp; <span class="kw1">For</span> p100 = 0 <span class="kw1">To</span> n200 <span class="kw1">Step</span> 100: n100 = n200 &#8211; p100<br />
&nbsp; <span class="kw1">For</span> p050 = 0 <span class="kw1">To</span> n100 <span class="kw1">Step</span> 50: &nbsp;n050 = n100 &#8211; p050<br />
&nbsp; <span class="kw1">For</span> p020 = 0 <span class="kw1">To</span> n050 <span class="kw1">Step</span> 20: &nbsp;n020 = n050 &#8211; p020<br />
&nbsp; <span class="kw1">For</span> p010 = 0 <span class="kw1">To</span> n020 <span class="kw1">Step</span> 10: &nbsp;n010 = n020 &#8211; p010<br />
&nbsp; <span class="kw1">For</span> p005 = 0 <span class="kw1">To</span> n010 <span class="kw1">Step</span> 5: &nbsp; n005 = n010 &#8211; p005<br />
&nbsp; <span class="kw1">For</span> p002 = 0 <span class="kw1">To</span> n005 <span class="kw1">Step</span> 2: &nbsp; rslt = rslt + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; <span class="kw1">Next</span>: <span class="kw1">Next</span>: <span class="kw1">Next</span>: <span class="kw1">Next</span>: <span class="kw1">Next</span>: <span class="kw1">Next</span>: <span class="kw1">Next</span></p>
<p>&nbsp; Debug.<span class="kw1">Print</span> amnt; rslt; Timer &#8211; t<br />
<span class="kw1">End</span> <span class="kw1">Sub</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36728</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Mon, 29 Dec 2008 21:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36728</guid>
		<description>&lt;p&gt;OK.  The recursive solution to Euler 31 based on the template I&#039;d mentioned in my last comment is now on my website.  Visit &lt;a href=&quot;http://www.tushar-mehta.com/misc_tutorials/project_euler/euler031.html&quot; rel=&quot;nofollow&quot;&gt;http://www.tushar-mehta.com/misc_tutorials/project_euler/euler031.html&lt;/a&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>OK.  The recursive solution to Euler 31 based on the template I&#8217;d mentioned in my last comment is now on my website.  Visit <a href="http://www.tushar-mehta.com/misc_tutorials/project_euler/euler031.html" rel="nofollow">http://www.tushar-mehta.com/misc_tutorials/project_euler/euler031.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36726</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 29 Dec 2008 15:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36726</guid>
		<description>&lt;p&gt;Hi Dick -&lt;/p&gt;
&lt;p&gt;Email on it&#039;s way from my work address.  dbb may be right.&lt;/p&gt;
&lt;p&gt;...mrt (Happy New Year to all!)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Dick -</p>
<p>Email on it&#8217;s way from my work address.  dbb may be right.</p>
<p>&#8230;mrt (Happy New Year to all!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36721</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Mon, 29 Dec 2008 09:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36721</guid>
		<description>&lt;p&gt;Use a recursive approach for both Euler 31 and Euler 76 -- they are nearly the same problem!&lt;/p&gt;
&lt;p&gt;A recursive approach can be easily generalized to search for a target T with N possible &#039;buckets&#039; whereas a nested loops approach requires a code change whenever N changes.  For example, how many ways can you come up with $250 using bills / coins of denomination 100, 50, 20, 10, 5, 2, 1, 50c, 25, 10, 5, and 1?  With a recursive approach, only the input data set would change.&lt;/p&gt;
&lt;p&gt;The recursive code for 31 should be easily adaptable to 76!  Just use 99 buckets, 1, 2, ..., 99.  The big difference is that we must use at least 2 buckets in 76 whereas in 31 a single bucket is acceptable.  &lt;/p&gt;
&lt;p&gt;It should not be very difficult to generalize the VBA code at&lt;br&gt;
Find a set of amounts that match a target value&lt;br&gt;
&lt;a href=&quot;http://www.tushar-mehta.com/excel/templates/match_values/index.html&quot; rel=&quot;nofollow&quot;&gt;http://www.tushar-mehta.com/excel/templates/match_values/index.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The only difference between the code on that page and the requirement for 31 is that the code imposes an implicit restriction that each bucket (value) be used only once.  For 31 each value can be used as often as required.  But, that should be a trivial change to the code.  I&#039;ll try it tomorrow and share the results. Adapting the code for 31 to 76 will require some additional work.  But that too should not be too difficult.   Hopefully, I will not have to eat my claim that the recursive approach requires a trivial change. {grin}&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Use a recursive approach for both Euler 31 and Euler 76 &#8212; they are nearly the same problem!</p>
<p>A recursive approach can be easily generalized to search for a target T with N possible &#8216;buckets&#8217; whereas a nested loops approach requires a code change whenever N changes.  For example, how many ways can you come up with $250 using bills / coins of denomination 100, 50, 20, 10, 5, 2, 1, 50c, 25, 10, 5, and 1?  With a recursive approach, only the input data set would change.</p>
<p>The recursive code for 31 should be easily adaptable to 76!  Just use 99 buckets, 1, 2, &#8230;, 99.  The big difference is that we must use at least 2 buckets in 76 whereas in 31 a single bucket is acceptable.  </p>
<p>It should not be very difficult to generalize the VBA code at<br />
Find a set of amounts that match a target value<br />
<a href="http://www.tushar-mehta.com/excel/templates/match_values/index.html" rel="nofollow">http://www.tushar-mehta.com/excel/templates/match_values/index.html</a></p>
<p>The only difference between the code on that page and the requirement for 31 is that the code imposes an implicit restriction that each bucket (value) be used only once.  For 31 each value can be used as often as required.  But, that should be a trivial change to the code.  I&#8217;ll try it tomorrow and share the results. Adapting the code for 31 to 76 will require some additional work.  But that too should not be too difficult.   Hopefully, I will not have to eat my claim that the recursive approach requires a trivial change. {grin}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick Kusleika</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36720</link>
		<dc:creator>Dick Kusleika</dc:creator>
		<pubDate>Mon, 29 Dec 2008 03:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36720</guid>
		<description>&lt;p&gt;No limit, as far as I know.  I can&#039;t imagine what&#039;s cutting it off.  Can you send me the text of the post in an email?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>No limit, as far as I know.  I can&#8217;t imagine what&#8217;s cutting it off.  Can you send me the text of the post in an email?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dbb</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/12/28/euler-problem-31/#comment-36719</link>
		<dc:creator>dbb</dc:creator>
		<pubDate>Mon, 29 Dec 2008 02:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1926#comment-36719</guid>
		<description>&lt;p&gt;aha, I think I figured out the problem both Michael and I are having. The comment editor truncates everything after a &quot;less than&quot; symbol because it thinks it&#039;s an HTML tag&lt;/p&gt;
&lt;p&gt;Here is my full code with a text substitute for the &quot;less than&quot; sign&lt;/p&gt;
&lt;p&gt;Sub P76()&lt;/p&gt;
&lt;p&gt;Dim m As Long&lt;br&gt;
Dim t As Single&lt;br&gt;
t = Timer&lt;br&gt;
fP76 100, 0, m&lt;br&gt;
Debug.Print m - 1, (Timer - t) / 60&lt;/p&gt;
&lt;p&gt;End Sub&lt;/p&gt;
&lt;p&gt;Sub fP76(ByVal n As Long, ByVal S As Long, ByRef m As Long)&lt;br&gt;
  Dim i As Long&lt;br&gt;
  Dim t As Long&lt;br&gt;
  For i = n To 1 Step -1&lt;br&gt;
    t = S + i&lt;br&gt;
    If S = 0 Then Debug.Print i; m&lt;br&gt;
    Select Case t&lt;br&gt;
    Case Is LESSTHAN 100&lt;br&gt;
      fP76 i, t, m&lt;br&gt;
    Case 100&lt;br&gt;
      m = m + 1&lt;br&gt;
    End Select&lt;br&gt;
  Next i&lt;br&gt;
End Sub&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>aha, I think I figured out the problem both Michael and I are having. The comment editor truncates everything after a &#8220;less than&#8221; symbol because it thinks it&#8217;s an HTML tag</p>
<p>Here is my full code with a text substitute for the &#8220;less than&#8221; sign</p>
<p>Sub P76()</p>
<p>Dim m As Long<br />
Dim t As Single<br />
t = Timer<br />
fP76 100, 0, m<br />
Debug.Print m &#8211; 1, (Timer &#8211; t) / 60</p>
<p>End Sub</p>
<p>Sub fP76(ByVal n As Long, ByVal S As Long, ByRef m As Long)<br />
  Dim i As Long<br />
  Dim t As Long<br />
  For i = n To 1 Step -1<br />
    t = S + i<br />
    If S = 0 Then Debug.Print i; m<br />
    Select Case t<br />
    Case Is LESSTHAN 100<br />
      fP76 i, t, m<br />
    Case 100<br />
      m = m + 1<br />
    End Select<br />
  Next i<br />
End Sub</p>
]]></content:encoded>
	</item>
</channel>
</rss>

