<?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 52</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/</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: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37032</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Fri, 09 Jan 2009 19:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37032</guid>
		<description>&lt;p&gt;Actually, using VBA with numbers converted to strings is pretty efficient (for VBA). The following took less than a second runtime.&lt;/p&gt;
&lt;p&gt;[FORTRAN-like comparison operators]&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; euler52()&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;, k &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, n &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, p &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;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; s &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Double&lt;/span&gt;, ns &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, ts &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, dt &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; dt = Timer&lt;br&gt;
&#160; s = Log(1# + 2# / 3#) / Log(10#)&lt;br&gt;
&#160; n = 100&lt;br&gt;
&#160; k = 3&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt;&lt;br&gt;
&#160; &#160; n = n + 1&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Log(n) / Log(10#) &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 1# .GT. s &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; k = k + 1&lt;br&gt;
&#160; &#160; &#160; n = 10 ^ k + 1&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&#160; &#160; ns = &lt;span class=&quot;kw1&quot;&gt;CStr&lt;/span&gt;(n)&lt;br&gt;
&#160; &#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; 6&lt;br&gt;
&#160; &#160; &#160; ts = &lt;span class=&quot;kw1&quot;&gt;CStr&lt;/span&gt;(i * n)&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; j = 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; k&lt;br&gt;
&#160; &#160; &#160; &#160; p = InStr(1, ts, Mid$(ns, j, 1))&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; p .GT. 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; Mid$(ts, p, 1) = &lt;span class=&quot;st0&quot;&gt;&quot; &quot;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; j&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Trim(ts) .NE. &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; i&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; i .GT. 6 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; Debug.&lt;span class=&quot;kw1&quot;&gt;Print&lt;/span&gt; n, Timer - dt&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Loop&lt;/span&gt;&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>Actually, using VBA with numbers converted to strings is pretty efficient (for VBA). The following took less than a second runtime.</p>
<p>[FORTRAN-like comparison operators]</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> euler52()<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>, k <span class="kw1">As</span> <span class="kw1">Long</span>, n <span class="kw1">As</span> <span class="kw1">Long</span>, p <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> s <span class="kw1">As</span> <span class="kw1">Double</span>, ns <span class="kw1">As</span> <span class="kw1">String</span>, ts <span class="kw1">As</span> <span class="kw1">String</span>, dt <span class="kw1">As</span> <span class="kw1">Double</span></p>
<p>&nbsp; dt = Timer<br />
&nbsp; s = Log(1# + 2# / 3#) / Log(10#)<br />
&nbsp; n = 100<br />
&nbsp; k = 3</p>
<p>&nbsp; <span class="kw1">Do</span><br />
&nbsp; &nbsp; n = n + 1<br />
&nbsp; &nbsp; <span class="kw1">If</span> Log(n) / Log(10#) <span class="kw1">Mod</span> 1# .GT. s <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; k = k + 1<br />
&nbsp; &nbsp; &nbsp; n = 10 ^ k + 1<br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; &nbsp; ns = <span class="kw1">CStr</span>(n)<br />
&nbsp; &nbsp; <span class="kw1">For</span> i = 2 <span class="kw1">To</span> 6<br />
&nbsp; &nbsp; &nbsp; ts = <span class="kw1">CStr</span>(i * n)<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">For</span> j = 1 <span class="kw1">To</span> k<br />
&nbsp; &nbsp; &nbsp; &nbsp; p = InStr(1, ts, Mid$(ns, j, 1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> p .GT. 0 <span class="kw1">Then</span> Mid$(ts, p, 1) = <span class="st0">&#8221; &#8220;</span> <span class="kw1">Else</span> <span class="kw1">Exit</span> <span class="kw1">For</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Next</span> j<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> Trim(ts) .NE. <span class="st0">&#8220;&#8221;</span> <span class="kw1">Then</span> <span class="kw1">Exit</span> <span class="kw1">For</span><br />
&nbsp; &nbsp; <span class="kw1">Next</span> i<br />
&nbsp; &nbsp; <span class="kw1">If</span> i .GT. 6 <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; Debug.<span class="kw1">Print</span> n, Timer &#8211; dt<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Exit</span> <span class="kw1">Do</span><br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; <span class="kw1">Loop</span><br />
<span class="kw1">End</span> <span class="kw1">Sub</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans Schraven</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37028</link>
		<dc:creator>Hans Schraven</dc:creator>
		<pubDate>Fri, 09 Jan 2009 14:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37028</guid>
		<description>&lt;p&gt;For the length-test suffices&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;If&lt;/span&gt; Len(i) = Len(6 * i) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>For the length-test suffices</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">If</span> Len(i) = Len(6 * i) <span class="kw1">Then</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans Schraven</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37024</link>
		<dc:creator>Hans Schraven</dc:creator>
		<pubDate>Fri, 09 Jan 2009 13:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37024</guid>
		<description>&lt;p&gt;I used this one&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; Euler52()&lt;br&gt;
&#160; T = Timer&lt;br&gt;
&#160; i = 0&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt;&lt;br&gt;
&#160; &#160; i = i + 1&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Len(i) = Len(2 * i) &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; Len(i) = Len(3 * i) &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; Len(i) = Len(4 * i) &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; Len(i) = Len(5 * i) &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; Len(i) = Len(6 * i) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; j = 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; Len(i)&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; InStr(i, Mid(i * 2, j, 1)) * InStr(i * 2, Mid(i, j, 1)) * InStr(i, Mid(i * 3, j, 1)) * InStr(i * 3, Mid(i, j, 1)) * InStr(i, Mid(i * 4, j, 1)) * InStr(i * 4, Mid(i, j, 1)) * InStr(i, Mid(i * 5, j, 1)) * InStr(i * 5, Mid(i, j, 1)) * InStr(i, Mid(i * 6, j, 1)) * InStr(i * 6, Mid(i, j, 1)) = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; j .gt. Len(i) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Loop&lt;/span&gt;&lt;br&gt;
&#160; Debug.&lt;span class=&quot;kw1&quot;&gt;Print&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;answer: &#160;&quot;&lt;/span&gt; &amp; i &amp; &lt;span class=&quot;st0&quot;&gt;&quot; &#160;time: &#160;&quot;&lt;/span&gt; &amp; 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 used this one</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> Euler52()<br />
&nbsp; T = Timer<br />
&nbsp; i = 0<br />
&nbsp; <span class="kw1">Do</span><br />
&nbsp; &nbsp; i = i + 1<br />
&nbsp; &nbsp; <span class="kw1">If</span> Len(i) = Len(2 * i) <span class="kw1">And</span> Len(i) = Len(3 * i) <span class="kw1">And</span> Len(i) = Len(4 * i) <span class="kw1">And</span> Len(i) = Len(5 * i) <span class="kw1">And</span> Len(i) = Len(6 * i) <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">For</span> j = 1 <span class="kw1">To</span> Len(i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> InStr(i, Mid(i * 2, j, 1)) * InStr(i * 2, Mid(i, j, 1)) * InStr(i, Mid(i * 3, j, 1)) * InStr(i * 3, Mid(i, j, 1)) * InStr(i, Mid(i * 4, j, 1)) * InStr(i * 4, Mid(i, j, 1)) * InStr(i, Mid(i * 5, j, 1)) * InStr(i * 5, Mid(i, j, 1)) * InStr(i, Mid(i * 6, j, 1)) * InStr(i * 6, Mid(i, j, 1)) = 0 <span class="kw1">Then</span> <span class="kw1">Exit</span> <span class="kw1">For</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Next</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> j .gt. Len(i) <span class="kw1">Then</span> <span class="kw1">Exit</span> <span class="kw1">Do</span><br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; <span class="kw1">Loop</span><br />
&nbsp; Debug.<span class="kw1">Print</span> <span class="st0">&#8220;answer: &nbsp;&#8221;</span> &amp;amp; i &amp;amp; <span class="st0">&#8221; &nbsp;time: &nbsp;&#8221;</span> &amp;amp; Timer &#8211; T<br />
<span class="kw1">End</span> <span class="kw1">Sub</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37020</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Fri, 09 Jan 2009 09:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37020</guid>
		<description>&lt;p&gt;Tushar - I used strings because when I used longs I went over the maximum size.  I could have just switched to doubles, or with a little more thought have changed my approach so I didn&#039;t get such big numbers, but comparing strings just seemed the obvious way to do it.  Also I wasn&#039;t aware that it would be much slow than comparing numbers.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Tushar &#8211; I used strings because when I used longs I went over the maximum size.  I could have just switched to doubles, or with a little more thought have changed my approach so I didn&#8217;t get such big numbers, but comparing strings just seemed the obvious way to do it.  Also I wasn&#8217;t aware that it would be much slow than comparing numbers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37018</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Fri, 09 Jan 2009 08:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37018</guid>
		<description>&lt;p&gt;Why switch to strings to carry out various comparisons?  It is probably so much faster to work with numbers.  That&#039;s what I did for this problem.  The VBA code ran in under 0.2 seconds.&lt;br&gt;
&lt;a href=&quot;http://www.tushar-mehta.com/misc_tutorials/project_euler/euler052.html&quot; rel=&quot;nofollow&quot;&gt;http://www.tushar-mehta.com/misc_tutorials/project_euler/euler052.html&lt;/a&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Why switch to strings to carry out various comparisons?  It is probably so much faster to work with numbers.  That&#8217;s what I did for this problem.  The VBA code ran in under 0.2 seconds.<br />
<a href="http://www.tushar-mehta.com/misc_tutorials/project_euler/euler052.html" rel="nofollow">http://www.tushar-mehta.com/misc_tutorials/project_euler/euler052.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37008</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Fri, 09 Jan 2009 00:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37008</guid>
		<description>&lt;p&gt;Quicker if you start at the top factor(6) and work down to 1.  Comes down to 1.1 seconds for me.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Quicker if you start at the top factor(6) and work down to 1.  Comes down to 1.1 seconds for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37007</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Fri, 09 Jan 2009 00:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37007</guid>
		<description>&lt;p&gt;I did it as a function that will check for any number of factors (but it didn&#039;t find a solution going up to 7). Rather than sorting I fed the digits into an array, then formed the array into a string and compared those.  You could probably save a millisecond or two there.&lt;/p&gt;
&lt;p&gt;1.9 seconds on my machine:&lt;/p&gt;
&lt;p&gt;Function p_52(level As Long) As Variant&lt;br&gt;
    Dim i As Long, j As Long, Same As Boolean, IntA() As Long, NumDig As Long&lt;br&gt;
    Dim Fact As Long, k As Long, l As Long, CheckDig1 As String, CheckDig2 As String&lt;br&gt;
    Dim Time As Double&lt;/p&gt;
&lt;p&gt;    Time = Timer&lt;br&gt;
    i = 100&lt;br&gt;
    On Error GoTo Err&lt;br&gt;
    Do&lt;br&gt;
        i = i + 1&lt;br&gt;
        CheckDig1 = &quot;&quot;&lt;br&gt;
        ReDim IntA(0 To 9, 1 To level)&lt;br&gt;
        NumDig = Len(Trim(i))&lt;br&gt;
        For Fact = 1 To level&lt;br&gt;
            j = i * Fact&lt;br&gt;
            If Len(Trim(j)) .GT. NumDig Then&lt;br&gt;
            i = 10 ^ NumDig&lt;br&gt;
            Exit For&lt;br&gt;
            End If&lt;br&gt;
            For k = 1 To NumDig&lt;br&gt;
                l = Mid(j, k, 1)&lt;br&gt;
                IntA(l, Fact) = IntA(l, Fact) + 1&lt;br&gt;
            Next k&lt;br&gt;
            For k = 0 To 9&lt;br&gt;
            If Fact = 1 Then&lt;br&gt;
                    CheckDig1 = CheckDig1 &amp; IntA(k, Fact)&lt;br&gt;
                Else&lt;br&gt;
                    CheckDig2 = CheckDig2 &amp; IntA(k, Fact)&lt;br&gt;
                End If&lt;br&gt;
            Next k&lt;br&gt;
            If Fact .GT. 1 Then&lt;br&gt;
                If CheckDig2 .NE. CheckDig1 Then&lt;br&gt;
                    CheckDig2 = &quot;&quot;&lt;br&gt;
                  Exit For&lt;br&gt;
                End If&lt;br&gt;
                CheckDig1 = CheckDig2&lt;br&gt;
                CheckDig2 = &quot;&quot;&lt;br&gt;
            End If&lt;br&gt;
        Next Fact&lt;br&gt;
        If Fact = level + 1 Then&lt;br&gt;
            p_52 = Array(i, Timer - Time)&lt;br&gt;
            Exit Function&lt;br&gt;
        End If&lt;br&gt;
    Loop&lt;br&gt;
Err:&lt;br&gt;
p_52 = &quot;stopped at i = &quot; &amp; i&lt;/p&gt;
&lt;p&gt;End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I did it as a function that will check for any number of factors (but it didn&#8217;t find a solution going up to 7). Rather than sorting I fed the digits into an array, then formed the array into a string and compared those.  You could probably save a millisecond or two there.</p>
<p>1.9 seconds on my machine:</p>
<p>Function p_52(level As Long) As Variant<br />
    Dim i As Long, j As Long, Same As Boolean, IntA() As Long, NumDig As Long<br />
    Dim Fact As Long, k As Long, l As Long, CheckDig1 As String, CheckDig2 As String<br />
    Dim Time As Double</p>
<p>    Time = Timer<br />
    i = 100<br />
    On Error GoTo Err<br />
    Do<br />
        i = i + 1<br />
        CheckDig1 = &#8220;&#8221;<br />
        ReDim IntA(0 To 9, 1 To level)<br />
        NumDig = Len(Trim(i))<br />
        For Fact = 1 To level<br />
            j = i * Fact<br />
            If Len(Trim(j)) .GT. NumDig Then<br />
            i = 10 ^ NumDig<br />
            Exit For<br />
            End If<br />
            For k = 1 To NumDig<br />
                l = Mid(j, k, 1)<br />
                IntA(l, Fact) = IntA(l, Fact) + 1<br />
            Next k<br />
            For k = 0 To 9<br />
            If Fact = 1 Then<br />
                    CheckDig1 = CheckDig1 &amp; IntA(k, Fact)<br />
                Else<br />
                    CheckDig2 = CheckDig2 &amp; IntA(k, Fact)<br />
                End If<br />
            Next k<br />
            If Fact .GT. 1 Then<br />
                If CheckDig2 .NE. CheckDig1 Then<br />
                    CheckDig2 = &#8220;&#8221;<br />
                  Exit For<br />
                End If<br />
                CheckDig1 = CheckDig2<br />
                CheckDig2 = &#8220;&#8221;<br />
            End If<br />
        Next Fact<br />
        If Fact = level + 1 Then<br />
            p_52 = Array(i, Timer &#8211; Time)<br />
            Exit Function<br />
        End If<br />
    Loop<br />
Err:<br />
p_52 = &#8220;stopped at i = &#8221; &amp; i</p>
<p>End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37006</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 09 Jan 2009 00:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37006</guid>
		<description>&lt;p&gt;Hi fzz -&lt;/p&gt;
&lt;p&gt;The answer makes sense...it can&#039;t be over 166666 or i*6 will roll over to more decimal places.  I&#039;ve been impressed with the Parallels emulation.  Code runs faster than my on my stock PC at work (and that&#039;s a moderately fast HP).  I named that tune in 4.96875 notes errr seconds on my Mac with Parallels and XL2002 on the PC side.  I&#039;ve just got to figure out how to cleanse my cut and pastes.&lt;/p&gt;
&lt;p&gt;The first time I wrote IsPanDigital I didn&#039;t specify the first occurrence only, so all digits got swapped out, and everything was TRUE.&lt;/p&gt;
&lt;p&gt;Live and learn...&lt;br&gt;
Thanks for your help and insights.  I know that&#039;s what Dick wanted to come from this.&lt;/p&gt;
&lt;p&gt;...mrt (that answer&#039;s out there now...interesting that Dick&#039;s challenge was answered by a number 10x higher.  Euler forgive us ;-) )&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi fzz -</p>
<p>The answer makes sense&#8230;it can&#8217;t be over 166666 or i*6 will roll over to more decimal places.  I&#8217;ve been impressed with the Parallels emulation.  Code runs faster than my on my stock PC at work (and that&#8217;s a moderately fast HP).  I named that tune in 4.96875 notes errr seconds on my Mac with Parallels and XL2002 on the PC side.  I&#8217;ve just got to figure out how to cleanse my cut and pastes.</p>
<p>The first time I wrote IsPanDigital I didn&#8217;t specify the first occurrence only, so all digits got swapped out, and everything was TRUE.</p>
<p>Live and learn&#8230;<br />
Thanks for your help and insights.  I know that&#8217;s what Dick wanted to come from this.</p>
<p>&#8230;mrt (that answer&#8217;s out there now&#8230;interesting that Dick&#8217;s challenge was answered by a number 10x higher.  Euler forgive us <img src='http://www.dailydoseofexcel.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37005</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Thu, 08 Jan 2009 23:28:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37005</guid>
		<description>&lt;p&gt;Me, I used awk. With FORTRAN-like comparison operators.&lt;/p&gt;
&lt;p&gt;BEGIN {&lt;br&gt;
  n = 101&lt;br&gt;
  s = log(1 + 2/3)/log(10)&lt;br&gt;
  while (check(n)) {&lt;br&gt;
    if (log(++n)/log(10) % 1 .GT. s) n = 10 ^ int(1 + log(n)/log(10)) + 1&lt;br&gt;
  }&lt;br&gt;
  print &quot;answer&quot;, n&lt;br&gt;
}&lt;/p&gt;
&lt;p&gt;function check(n  , i, j, k, t) { # also c as an array&lt;br&gt;
  k = length(n)&lt;br&gt;
  for (j = 1; j .LE. k; ++j) c[j] = substr(n, j, 1)&lt;br&gt;
  for (i = 2; i .LE. 6; ++i) {&lt;br&gt;
    t = i * n&lt;br&gt;
    for (j = 1; j .LE. k; ++j) sub(c[j], &quot;&quot;, t)&lt;br&gt;
    if (t != &quot;&quot;) return i&lt;br&gt;
  }&lt;br&gt;
  return 0&lt;br&gt;
}&lt;/p&gt;
&lt;p&gt;answer 142857 in 6.234 seconds&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Me, I used awk. With FORTRAN-like comparison operators.</p>
<p>BEGIN {<br />
  n = 101<br />
  s = log(1 + 2/3)/log(10)<br />
  while (check(n)) {<br />
    if (log(++n)/log(10) % 1 .GT. s) n = 10 ^ int(1 + log(n)/log(10)) + 1<br />
  }<br />
  print &#8220;answer&#8221;, n<br />
}</p>
<p>function check(n  , i, j, k, t) { # also c as an array<br />
  k = length(n)<br />
  for (j = 1; j .LE. k; ++j) c[j] = substr(n, j, 1)<br />
  for (i = 2; i .LE. 6; ++i) {<br />
    t = i * n<br />
    for (j = 1; j .LE. k; ++j) sub(c[j], &#8220;&#8221;, t)<br />
    if (t != &#8220;&#8221;) return i<br />
  }<br />
  return 0<br />
}</p>
<p>answer 142857 in 6.234 seconds</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/08/euler-problem-52/#comment-37004</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Thu, 08 Jan 2009 23:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1938#comment-37004</guid>
		<description>&lt;p&gt;Me, I used awk.&lt;/p&gt;
&lt;p&gt;BEGIN {&lt;br&gt;
  n = 101&lt;br&gt;
  s = log(1 + 2/3)/log(10)&lt;br&gt;
  while (check(n)) {&lt;br&gt;
    if (log(++n)/log(10) % 1 .GT. s) n = 10 ^ int(1 + log(n)/log(10)) + 1&lt;br&gt;
  }&lt;br&gt;
  print &quot;answer&quot;, n&lt;br&gt;
}&lt;/p&gt;
&lt;p&gt;function check(n  , i, j, k, t) { # also c as an array&lt;br&gt;
  k = length(n)&lt;br&gt;
  for (j = 1; j&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Me, I used awk.</p>
<p>BEGIN {<br />
  n = 101<br />
  s = log(1 + 2/3)/log(10)<br />
  while (check(n)) {<br />
    if (log(++n)/log(10) % 1 .GT. s) n = 10 ^ int(1 + log(n)/log(10)) + 1<br />
  }<br />
  print &#8220;answer&#8221;, n<br />
}</p>
<p>function check(n  , i, j, k, t) { # also c as an array<br />
  k = length(n)<br />
  for (j = 1; j</p>
]]></content:encoded>
	</item>
</channel>
</rss>

