<?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 54</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 18:06:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37666</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Sun, 01 Feb 2009 22:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37666</guid>
		<description>&lt;p&gt;Hans.. LOL. When finetuning code I just loop it 1000 times so I can get a reliable timing. Why do you think x goes from 0 to 999? It&#039;s because timer can&#039;t handle anything faster than 1/64th of a second. Try my code for x= 0 to 0. Even on PIII it&#039;ll take &lt; 0.0625 (4/64)secs.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hans.. LOL. When finetuning code I just loop it 1000 times so I can get a reliable timing. Why do you think x goes from 0 to 999? It&#8217;s because timer can&#8217;t handle anything faster than 1/64th of a second. Try my code for x= 0 to 0. Even on PIII it&#8217;ll take &lt; 0.0625 (4/64)secs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans Schraven</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37652</link>
		<dc:creator>Hans Schraven</dc:creator>
		<pubDate>Sun, 01 Feb 2009 17:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37652</guid>
		<description>&lt;p&gt;KeepITkool: I have to disappoint you. Your code gives the wrong answer and is, tested on the same system as my code, 10 to 15 times slower (22 seconds) than mine (1,4 seconds).&lt;br&gt;
Besides I wouldn&#039;t rely on your arithmetic &#039;1000×1000x2=&gt; 87secs&#039;, because it only runs 1000 times; that&#039;s all. I&#039;d say: let the timer do the counting.&lt;br&gt;
So there is still a long way to go compressing the code (220 lines compared to 40) and speeding up the code (from 22 seconds to 1,4)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>KeepITkool: I have to disappoint you. Your code gives the wrong answer and is, tested on the same system as my code, 10 to 15 times slower (22 seconds) than mine (1,4 seconds).<br />
Besides I wouldn&#8217;t rely on your arithmetic &#8217;1000×1000&#215;2=&gt; 87secs&#8217;, because it only runs 1000 times; that&#8217;s all. I&#8217;d say: let the timer do the counting.<br />
So there is still a long way to go compressing the code (220 lines compared to 40) and speeding up the code (from 22 seconds to 1,4)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37629</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Sat, 31 Jan 2009 21:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37629</guid>
		<description>&lt;p&gt;Be sure to dim T as single!.. Your Proc as is: 0,09375secs.  ReadOnce then run 1000×1000x2=&gt; 87secs.&lt;br&gt;
I&#039;ve got my code down to 1.08secs. So you&#039;ve still a factor 80 to go :-)&lt;br&gt;
IIf and Choose are compact but (very) slow... Plus all the string stuff (Join/Split/Replace) requires time.&lt;br&gt;
With strings I really noticed a change when I bought my PC 2 years ago. DuoCore 2.6GHz 2GB DDR2@400Mhz)&lt;/p&gt;
&lt;p&gt;My next step is evaluate hands during games of Hold&#039;m... mucho more complex.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Be sure to dim T as single!.. Your Proc as is: 0,09375secs.  ReadOnce then run 1000×1000&#215;2=&gt; 87secs.<br />
I&#8217;ve got my code down to 1.08secs. So you&#8217;ve still a factor 80 to go <img src='http://www.dailydoseofexcel.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <br />
IIf and Choose are compact but (very) slow&#8230; Plus all the string stuff (Join/Split/Replace) requires time.<br />
With strings I really noticed a change when I bought my PC 2 years ago. DuoCore 2.6GHz 2GB DDR2@400Mhz)</p>
<p>My next step is evaluate hands during games of Hold&#8217;m&#8230; mucho more complex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans Schraven</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37623</link>
		<dc:creator>Hans Schraven</dc:creator>
		<pubDate>Sat, 31 Jan 2009 14:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37623</guid>
		<description>&lt;p&gt;KeepITcool&lt;/p&gt;
&lt;p&gt;You must be kidding. The responses I get vary between 1,39 and 2,4 seconds. Your computer must be to cool, because these values were obtained on a Pentium II, 350Mhz system.&lt;br&gt;
I made some improvements (see below)&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; euler54()&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; t &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;, j &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, jj &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, c0 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, c5 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, c2 &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; t = Timer&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Open&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;E:OFpoker.txt&quot;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Input&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; #1&lt;br&gt;
&#160; &#160; c0 = &lt;span class=&quot;kw1&quot;&gt;Input&lt;/span&gt;(LOF(1), #1)&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Close&lt;/span&gt; #1&lt;br&gt;
&#160; sb = Split(&lt;span class=&quot;st0&quot;&gt;&quot;T&#124;J&#124;Q&#124;K&#124;A&#124;10&#124;11&#124;12&#124;13&#124;14&quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&quot;&#124;&quot;&lt;/span&gt;)&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; j = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 4&lt;br&gt;
&#160; &#160; c0 = Replace(c0, sb(j), sb(j + 5))&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; sb = Filter(Split(c0, vbCr &amp; Chr(10)), &lt;span class=&quot;st0&quot;&gt;&quot; &quot;&lt;/span&gt;)&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; j = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(sb)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; sp(15) &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160; first hand matrix&lt;br&gt;
&lt;/span&gt; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; sr(15) &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160; second hand matrix&lt;br&gt;
&lt;/span&gt;&lt;br&gt;
&#160; &#160; st = Split(sb(j))&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; jj = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 4 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160; &#160; &#160; sort and count per cardvalue&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160;sp(15) = IIf(jj = 0, Right(st(jj), 1), IIf(sp(15) = Right(st(jj), 1), sp(15), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;))&lt;br&gt;
&#160; &#160; &#160; &#160; x = Val(st(jj))&lt;br&gt;
&#160; &#160; &#160; &#160; sp(x) = (sp(x)  100 + 1) * (100 + x) + Choose(sp(x)  100 + 1, 0, 0, 100, 0, 300)&lt;br&gt;
&#160; &#160; &#160; &#160; sr(15) = IIf(jj = 0, Right(st(jj + 5), 1), IIf(sr(15) = Right(st(jj + 5), 1), sr(15), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;))&lt;br&gt;
&#160; &#160; &#160; &#160; n = Val(st(jj + 5))&lt;br&gt;
&#160; &#160; &#160; &#160; sr(n) = (sr(n)  100 + 1) * (100 + n) + Choose(sr(n)  100 + 1, 0, 0, 100, 0, 300)&lt;br&gt;
&#160; &#160; &#160; &#160; st(jj) = 0&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; jj = 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 2 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160;scoring first and second hand&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160;c2 = WorksheetFunction.Max(Choose(jj, sp, sr))&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Select&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; Len(Format(Val(Join(Choose(jj, sp, sr), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;))))&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 6&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; c2  100 = 4 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = 700 + (c2 &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 100)&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 9&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; c2  100 = 2 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = 300 + (c2 &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 100)&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 15&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; InStr(Trim(Left(Join(Choose(jj, sp, sr)), Len(Join(Choose(jj, sp, sr))) - 1)), &lt;span class=&quot;st0&quot;&gt;&quot; &#160;&quot;&lt;/span&gt;) = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = 500 + (c2 &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 100)&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Select&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Choose(jj, sp(15), sr(15)) .ISNOT. &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = 600 + (c2 &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 100) + IIf(st(jj)  100 = 5, 300 + IIf(Choose(jj, sp(14), sr(14)) = &lt;span class=&quot;st0&quot;&gt;&quot;114&quot;&lt;/span&gt;, 100, 0), 0) &lt;span class=&quot;co1&quot;&gt;&#039; flush, straight flush and royal flush&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; st(jj) = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = c2 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160;high card, 1 pair, three of a kind and flush&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;While&lt;/span&gt; st(1) = st(2) &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; Replace(Join(sp, &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;), st(1), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;) .ISNOT. &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt; &#160; &#160; &#160; &#160; &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039; &#160; &#160; &#160;solve ties&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160;st(1) = &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(Split(RTrim(Replace(Join(sp), st(1), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;))))&lt;br&gt;
&#160; &#160; &#160; &#160; st(2) = &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(Split(RTrim(Replace(Join(sr), st(2), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;))))&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Loop&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Val(st(1)) .GT. Val(st(2)) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; c5 = c5 + 1&lt;br&gt;
&#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Next&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>KeepITcool</p>
<p>You must be kidding. The responses I get vary between 1,39 and 2,4 seconds. Your computer must be to cool, because these values were obtained on a Pentium II, 350Mhz system.<br />
I made some improvements (see below)</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> euler54()<br />
&nbsp; <span class="kw1">Dim</span> t <span class="kw1">As</span> <span class="kw1">Long</span>, n <span class="kw1">As</span> <span class="kw1">Long</span>, j <span class="kw1">As</span> <span class="kw1">Long</span>, jj <span class="kw1">As</span> <span class="kw1">Long</span>, c0 <span class="kw1">As</span> <span class="kw1">String</span>, c5 <span class="kw1">As</span> <span class="kw1">Long</span>, c2 <span class="kw1">As</span> <span class="kw1">Long</span></p>
<p>&nbsp; t = Timer<br />
&nbsp; <span class="kw1">Open</span> <span class="st0">&#8220;E:OFpoker.txt&#8221;</span> <span class="kw1">For</span> <span class="kw1">Input</span> <span class="kw1">As</span> #1<br />
&nbsp; &nbsp; c0 = <span class="kw1">Input</span>(LOF(1), #1)<br />
&nbsp; <span class="kw1">Close</span> #1<br />
&nbsp; sb = Split(<span class="st0">&#8220;T|J|Q|K|A|10|11|12|13|14&#8243;</span>, <span class="st0">&#8220;|&#8221;</span>)<br />
&nbsp; <span class="kw1">For</span> j = 0 <span class="kw1">To</span> 4<br />
&nbsp; &nbsp; c0 = Replace(c0, sb(j), sb(j + 5))<br />
&nbsp; <span class="kw1">Next</span><br />
&nbsp; sb = Filter(Split(c0, vbCr &amp;amp; Chr(10)), <span class="st0">&#8221; &#8220;</span>)</p>
<p>&nbsp; <span class="kw1">For</span> j = 0 <span class="kw1">To</span> <span class="kw1">UBound</span>(sb)<br />
&nbsp; &nbsp; <span class="kw1">ReDim</span> sp(15) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp; first hand matrix<br />
</span> &nbsp; &nbsp;<span class="kw1">ReDim</span> sr(15) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp; second hand matrix<br />
</span><br />
&nbsp; &nbsp; st = Split(sb(j))<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">For</span> jj = 0 <span class="kw1">To</span> 4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp; &nbsp; &nbsp; sort and count per cardvalue<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp;sp(15) = IIf(jj = 0, Right(st(jj), 1), IIf(sp(15) = Right(st(jj), 1), sp(15), <span class="st0">&#8220;&#8221;</span>))<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = Val(st(jj))<br />
&nbsp; &nbsp; &nbsp; &nbsp; sp(x) = (sp(x)  100 + 1) * (100 + x) + Choose(sp(x)  100 + 1, 0, 0, 100, 0, 300)<br />
&nbsp; &nbsp; &nbsp; &nbsp; sr(15) = IIf(jj = 0, Right(st(jj + 5), 1), IIf(sr(15) = Right(st(jj + 5), 1), sr(15), <span class="st0">&#8220;&#8221;</span>))<br />
&nbsp; &nbsp; &nbsp; &nbsp; n = Val(st(jj + 5))<br />
&nbsp; &nbsp; &nbsp; &nbsp; sr(n) = (sr(n)  100 + 1) * (100 + n) + Choose(sr(n)  100 + 1, 0, 0, 100, 0, 300)<br />
&nbsp; &nbsp; &nbsp; &nbsp; st(jj) = 0<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Next</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span class="kw1">For</span> jj = 1 <span class="kw1">To</span> 2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp;scoring first and second hand<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp;c2 = WorksheetFunction.Max(Choose(jj, sp, sr))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Select</span> <span class="kw1">Case</span> Len(Format(Val(Join(Choose(jj, sp, sr), <span class="st0">&#8220;&#8221;</span>))))<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 6<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> c2  100 = 4 <span class="kw1">Then</span> st(jj) = 700 + (c2 <span class="kw1">Mod</span> 100)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 9<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> c2  100 = 2 <span class="kw1">Then</span> st(jj) = 300 + (c2 <span class="kw1">Mod</span> 100)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 15<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> InStr(Trim(Left(Join(Choose(jj, sp, sr)), Len(Join(Choose(jj, sp, sr))) &#8211; 1)), <span class="st0">&#8221; &nbsp;&#8221;</span>) = 0 <span class="kw1">Then</span> st(jj) = 500 + (c2 <span class="kw1">Mod</span> 100)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">Select</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> Choose(jj, sp(15), sr(15)) .ISNOT. <span class="st0">&#8220;&#8221;</span> <span class="kw1">Then</span> st(jj) = 600 + (c2 <span class="kw1">Mod</span> 100) + IIf(st(jj)  100 = 5, 300 + IIf(Choose(jj, sp(14), sr(14)) = <span class="st0">&#8220;114&#8243;</span>, 100, 0), 0) <span class="co1">&#8216; flush, straight flush and royal flush<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> st(jj) = 0 <span class="kw1">Then</span> st(jj) = c2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp;high card, 1 pair, three of a kind and flush<br />
</span> &nbsp; &nbsp; &nbsp;<span class="kw1">Next</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Do</span> <span class="kw1">While</span> st(1) = st(2) <span class="kw1">And</span> Replace(Join(sp, <span class="st0">&#8220;&#8221;</span>), st(1), <span class="st0">&#8220;&#8221;</span>) .ISNOT. <span class="st0">&#8220;&#8221;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">&#8216; &nbsp; &nbsp; &nbsp;solve ties<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp;st(1) = <span class="kw1">UBound</span>(Split(RTrim(Replace(Join(sp), st(1), <span class="st0">&#8220;&#8221;</span>))))<br />
&nbsp; &nbsp; &nbsp; &nbsp; st(2) = <span class="kw1">UBound</span>(Split(RTrim(Replace(Join(sr), st(2), <span class="st0">&#8220;&#8221;</span>))))<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Loop</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> Val(st(1)) .GT. Val(st(2)) <span class="kw1">Then</span> c5 = c5 + 1<br />
&nbsp; &nbsp;<span class="kw1">Next</span><br />
<span class="kw1">End</span> <span class="kw1">Sub</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37619</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Sat, 31 Jan 2009 05:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37619</guid>
		<description>&lt;p&gt;Hans, I grant you it&#039;s compact, but too slow for my liking. My goal was speed: 1000 loops in 1,5 secs (yours takes 1,5 minutes)&lt;br&gt;
P.S. I&#039;ve modified my code to solve &quot;ties&quot;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hans, I grant you it&#8217;s compact, but too slow for my liking. My goal was speed: 1000 loops in 1,5 secs (yours takes 1,5 minutes)<br />
P.S. I&#8217;ve modified my code to solve &#8220;ties&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans Schraven</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37612</link>
		<dc:creator>Hans Schraven</dc:creator>
		<pubDate>Fri, 30 Jan 2009 15:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37612</guid>
		<description>&lt;p&gt;Maybe some compacter code will do as well (at least it generates the correct answer).&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; euler54()&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; x &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;, jj &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, c5 &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;Open&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;E:OFpoker.txt&quot;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Input&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; #1&lt;br&gt;
&#160; sb = Filter(Split(Replace(Replace(Replace(Replace(Replace(&lt;span class=&quot;kw1&quot;&gt;Input&lt;/span&gt;(LOF(1), #1), &lt;span class=&quot;st0&quot;&gt;&quot;T&quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&quot;10&quot;&lt;/span&gt;), &lt;span class=&quot;st0&quot;&gt;&quot;J&quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&quot;11&quot;&lt;/span&gt;), &lt;span class=&quot;st0&quot;&gt;&quot;Q&quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&quot;12&quot;&lt;/span&gt;), &lt;span class=&quot;st0&quot;&gt;&quot;K&quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&quot;13&quot;&lt;/span&gt;), &lt;span class=&quot;st0&quot;&gt;&quot;A&quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&quot;14&quot;&lt;/span&gt;), vbCr &amp; Chr(10)), &lt;span class=&quot;st0&quot;&gt;&quot; &quot;&lt;/span&gt;)&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Close&lt;/span&gt; #1&lt;br&gt;
&#160; &#160;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; j = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(sb)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; sp(15) &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160; first hand matrix&lt;br&gt;
&lt;/span&gt; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; sr(15) &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160; second hand matrix&lt;br&gt;
&lt;/span&gt;&lt;br&gt;
&#160; &#160; st = Split(sb(j))&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; jj = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 4 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039; &#160; &#160; &#160; sort and count per cardvalue&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;sp(15) = IIf(jj = 0, Right(st(jj), 1), IIf(sp(15) = Right(st(jj), 1), sp(15), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;)) &#160;&lt;span class=&quot;co1&quot;&gt;&#039; &#160;same kind&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;x = Val(st(jj))&lt;br&gt;
&#160; &#160; &#160; sp(x) = (sp(x)  100 + 1) * (100 + x) + Choose(sp(x)  100 + 1, 0, 0, 100, 0, 300) &#160; &lt;span class=&quot;co1&quot;&gt;&#039; first hand sort and count&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;sr(15) = IIf(jj = 0, Right(st(jj + 5), 1), IIf(sr(15) = Right(st(jj + 5), 1), sr(15), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;))&lt;br&gt;
&#160; &#160; &#160; n = Val(st(jj + 5))&lt;br&gt;
&#160; &#160; &#160; sr(n) = (sr(n)  100 + 1) * (100 + n) + Choose(sr(n)  100 + 1, 0, 0, 100, 0, 300) &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160;second hand sort and count&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;st(jj) = 0&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; jj = 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 2 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160;scoring first and second hand&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;c2 = WorksheetFunction.Max(Choose(jj, sp, sr))&lt;br&gt;
&#160; &#160; &#160; c3 = Format(Val(Join(Choose(jj, sp, sr), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;)))&lt;br&gt;
&#160; &#160; &#160; c4 = Len(c3)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; InStr(Trim(Left(Join(Choose(jj, sp, sr)), Len(Join(Choose(jj, sp, sr))) - 1)), &lt;span class=&quot;st0&quot;&gt;&quot; &#160;&quot;&lt;/span&gt;) = 0 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; c4 = 15 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = 500 + (c2 &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 100) &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039; &#160; &#160; straight (5 consecutive)&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; c2  100 = 2 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; c4 = 9 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = 300 + (c2 &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 100) &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160; &#160; &#160; 2 pairs&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; c2  100 = 4 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; c4 = 6 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = 700 + (c2 &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 100) &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160; &#160; &#160; full house&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Choose(jj, sp(15), sr(15)) ISNOT. &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = 600 + (c2 &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; 100) + IIf(st(jj)  100 = 5, 300, 0) + IIf(InStr(c3, &lt;span class=&quot;st0&quot;&gt;&quot;110111112113114&quot;&lt;/span&gt;) GT. 0, 100, 0) &#160;&lt;span class=&quot;co1&quot;&gt;&#039; flush, straight flush and royal flush&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; st(jj) = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; st(jj) = c2 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160;high card, 1 pair, three of a kind and flush&lt;br&gt;
&lt;/span&gt; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;While&lt;/span&gt; st(1) = st(2) &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; Replace(Join(sp, &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;), st(1), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;) ISNOT. &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt; &#160;&lt;span class=&quot;co1&quot;&gt;&#039; &#160; &#160; &#160;solve ties&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;st(1) = &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(Split(RTrim(Replace(Join(sp), st(1), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;))))&lt;br&gt;
&#160; &#160; &#160; st(2) = &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(Split(RTrim(Replace(Join(sr), st(2), &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;))))&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Loop&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Val(st(1)) GT. Val(st(2)) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; c5 = c5 + 1&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&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>Maybe some compacter code will do as well (at least it generates the correct answer).</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> euler54()<br />
&nbsp; <span class="kw1">Dim</span> x <span class="kw1">As</span> <span class="kw1">Long</span>, j <span class="kw1">As</span> <span class="kw1">Long</span>, jj <span class="kw1">As</span> <span class="kw1">Long</span>, c5 <span class="kw1">As</span> <span class="kw1">Long</span></p>
<p>&nbsp; <span class="kw1">Open</span> <span class="st0">&#8220;E:OFpoker.txt&#8221;</span> <span class="kw1">For</span> <span class="kw1">Input</span> <span class="kw1">As</span> #1<br />
&nbsp; sb = Filter(Split(Replace(Replace(Replace(Replace(Replace(<span class="kw1">Input</span>(LOF(1), #1), <span class="st0">&#8220;T&#8221;</span>, <span class="st0">&#8220;10&#8243;</span>), <span class="st0">&#8220;J&#8221;</span>, <span class="st0">&#8220;11&#8243;</span>), <span class="st0">&#8220;Q&#8221;</span>, <span class="st0">&#8220;12&#8243;</span>), <span class="st0">&#8220;K&#8221;</span>, <span class="st0">&#8220;13&#8243;</span>), <span class="st0">&#8220;A&#8221;</span>, <span class="st0">&#8220;14&#8243;</span>), vbCr &amp;amp; Chr(10)), <span class="st0">&#8221; &#8220;</span>)<br />
&nbsp; <span class="kw1">Close</span> #1<br />
&nbsp; &nbsp;<br />
&nbsp; <span class="kw1">For</span> j = 0 <span class="kw1">To</span> <span class="kw1">UBound</span>(sb)<br />
&nbsp; &nbsp; <span class="kw1">ReDim</span> sp(15) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp; first hand matrix<br />
</span> &nbsp; &nbsp;<span class="kw1">ReDim</span> sr(15) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp; second hand matrix<br />
</span><br />
&nbsp; &nbsp; st = Split(sb(j))<br />
&nbsp; &nbsp; <span class="kw1">For</span> jj = 0 <span class="kw1">To</span> 4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">&#8216; &nbsp; &nbsp; &nbsp; sort and count per cardvalue<br />
</span> &nbsp; &nbsp; &nbsp;sp(15) = IIf(jj = 0, Right(st(jj), 1), IIf(sp(15) = Right(st(jj), 1), sp(15), <span class="st0">&#8220;&#8221;</span>)) &nbsp;<span class="co1">&#8216; &nbsp;same kind<br />
</span> &nbsp; &nbsp; &nbsp;x = Val(st(jj))<br />
&nbsp; &nbsp; &nbsp; sp(x) = (sp(x)  100 + 1) * (100 + x) + Choose(sp(x)  100 + 1, 0, 0, 100, 0, 300) &nbsp; <span class="co1">&#8216; first hand sort and count<br />
</span> &nbsp; &nbsp; &nbsp;sr(15) = IIf(jj = 0, Right(st(jj + 5), 1), IIf(sr(15) = Right(st(jj + 5), 1), sr(15), <span class="st0">&#8220;&#8221;</span>))<br />
&nbsp; &nbsp; &nbsp; n = Val(st(jj + 5))<br />
&nbsp; &nbsp; &nbsp; sr(n) = (sr(n)  100 + 1) * (100 + n) + Choose(sr(n)  100 + 1, 0, 0, 100, 0, 300) &nbsp; <span class="co1">&#8216; &nbsp;second hand sort and count<br />
</span> &nbsp; &nbsp; &nbsp;st(jj) = 0<br />
&nbsp; &nbsp; <span class="kw1">Next</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">For</span> jj = 1 <span class="kw1">To</span> 2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp;scoring first and second hand<br />
</span> &nbsp; &nbsp; &nbsp;c2 = WorksheetFunction.Max(Choose(jj, sp, sr))<br />
&nbsp; &nbsp; &nbsp; c3 = Format(Val(Join(Choose(jj, sp, sr), <span class="st0">&#8220;&#8221;</span>)))<br />
&nbsp; &nbsp; &nbsp; c4 = Len(c3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> InStr(Trim(Left(Join(Choose(jj, sp, sr)), Len(Join(Choose(jj, sp, sr))) &#8211; 1)), <span class="st0">&#8221; &nbsp;&#8221;</span>) = 0 <span class="kw1">And</span> c4 = 15 <span class="kw1">Then</span> st(jj) = 500 + (c2 <span class="kw1">Mod</span> 100) &nbsp; &nbsp;<span class="co1">&#8216; &nbsp; &nbsp; straight (5 consecutive)<br />
</span> &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> c2  100 = 2 <span class="kw1">And</span> c4 = 9 <span class="kw1">Then</span> st(jj) = 300 + (c2 <span class="kw1">Mod</span> 100) &nbsp; <span class="co1">&#8216; &nbsp; &nbsp; &nbsp; 2 pairs<br />
</span> &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> c2  100 = 4 <span class="kw1">And</span> c4 = 6 <span class="kw1">Then</span> st(jj) = 700 + (c2 <span class="kw1">Mod</span> 100) &nbsp; &nbsp; <span class="co1">&#8216; &nbsp; &nbsp; &nbsp; full house<br />
</span> &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> Choose(jj, sp(15), sr(15)) ISNOT. <span class="st0">&#8220;&#8221;</span> <span class="kw1">Then</span> st(jj) = 600 + (c2 <span class="kw1">Mod</span> 100) + IIf(st(jj)  100 = 5, 300, 0) + IIf(InStr(c3, <span class="st0">&#8220;110111112113114&#8243;</span>) GT. 0, 100, 0) &nbsp;<span class="co1">&#8216; flush, straight flush and royal flush<br />
</span> &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> st(jj) = 0 <span class="kw1">Then</span> st(jj) = c2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp;high card, 1 pair, three of a kind and flush<br />
</span> &nbsp; &nbsp;<span class="kw1">Next</span><br />
&nbsp; &nbsp; <span class="kw1">Do</span> <span class="kw1">While</span> st(1) = st(2) <span class="kw1">And</span> Replace(Join(sp, <span class="st0">&#8220;&#8221;</span>), st(1), <span class="st0">&#8220;&#8221;</span>) ISNOT. <span class="st0">&#8220;&#8221;</span> &nbsp;<span class="co1">&#8216; &nbsp; &nbsp; &nbsp;solve ties<br />
</span> &nbsp; &nbsp; &nbsp;st(1) = <span class="kw1">UBound</span>(Split(RTrim(Replace(Join(sp), st(1), <span class="st0">&#8220;&#8221;</span>))))<br />
&nbsp; &nbsp; &nbsp; st(2) = <span class="kw1">UBound</span>(Split(RTrim(Replace(Join(sr), st(2), <span class="st0">&#8220;&#8221;</span>))))<br />
&nbsp; &nbsp; <span class="kw1">Loop</span><br />
&nbsp; &nbsp; <span class="kw1">If</span> Val(st(1)) GT. Val(st(2)) <span class="kw1">Then</span> c5 = c5 + 1<br />
&nbsp; <span class="kw1">Next</span><br />
<span class="kw1">End</span> <span class="kw1">Sub</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37600</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Fri, 30 Jan 2009 04:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37600</guid>
		<description>&lt;p&gt;removed type declaration chars and hex codes.cleaned up code.inserted GT&#039;s LT&#039;s and NOTEQUAL&lt;br&gt;
pressed [submit] and hope for the best.&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;Option&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Explicit&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; kSF &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 80000 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;StraightFlush&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; k4K &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 70000 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;FourKind&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; kFH &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 60000 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;FullHouse&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; kFL &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 50000 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;Flush&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; kST &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 40000 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;Straight&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; k3K &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 30000 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;ThreeKind&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; k2P &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 20000 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;TwoPair&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; k2K &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 10000 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;OnePair&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; k1K &#160;&lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 0&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; HFF &#160; &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 255 &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039;0000 0000 1111 1111: 255&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; HFF00 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt; = 65280 &#160; &lt;span class=&quot;co1&quot;&gt;&#039;1111 1111 0000 0000: 65535-255=65280&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; SUITS &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt; = &lt;span class=&quot;st0&quot;&gt;&quot;CDHS&quot;&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; RANKS &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt; = &lt;span class=&quot;st0&quot;&gt;&quot;23456789TJQKA&quot;&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;co1&quot;&gt;&#039;Reference nneded for Microsoft Scripting Runtime&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; mNums &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; Dictionary&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; mProd &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; Dictionary&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; euler54_kic()&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; list &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; cube(999, 1, 4) &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; rslt(1) &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, wins &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; h &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;, c &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; t &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Single&lt;/span&gt;, x &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;br&gt;
&#160; t = Timer&lt;br&gt;
&#160; &lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;Prepare Cache&lt;br&gt;
&lt;/span&gt; &#160;PrepScores&lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;Read Id&#039;s (separate cells)&lt;br&gt;
&lt;/span&gt; &#160;list = [p54!cardsIDS]&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;Convert id&#039;s to numbers&lt;br&gt;
&lt;/span&gt; &#160;&lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; h = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(cube, 1)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(cube, 2)&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; c = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 4&lt;br&gt;
&#160; &#160; &#160; &#160; cube(h, p, c) = mNums(list(h + 1, p * 5 + c + 1))&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; p&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; h&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;Score numbers (1000 loops for effective timing)&lt;br&gt;
&lt;/span&gt; &#160;&lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; x = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 999&lt;br&gt;
&#160; &#160; wins = 0&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; h = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(cube, 1)&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; p = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;UBound&lt;/span&gt;(cube, 2)&lt;br&gt;
&#160; &#160; &#160; &#160; ScoreNums rslt(p), cube(h, p, 0), cube(h, p, 1), cube(h, p, 2), cube(h, p, 3), cube(h, p, 4)&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; p&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; rslt(0) GT rslt(1) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; wins = wins + 1&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; h&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; x&lt;br&gt;
&#160; t = Timer - t&lt;br&gt;
&#160; Debug.&lt;span class=&quot;kw1&quot;&gt;Print&lt;/span&gt; wins, t, &lt;span class=&quot;st0&quot;&gt;&quot;Euler54&quot;&lt;/span&gt;&lt;br&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;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; ScoreNums(rslt &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, n0 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, n1 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, n2 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, n3 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, n4 &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; 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;co1&quot;&gt;&#039;Product of numbers (use LoByte=Prime)&lt;br&gt;
&lt;/span&gt; &#160;p = (n0 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; HFF) * (n1 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; HFF) * (n2 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; HFF) * (n3 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; HFF) * (n4 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; HFF)&lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;Find in dictionary&lt;br&gt;
&lt;/span&gt; &#160;rslt = mProd(p)&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; rslt LT 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039;Flush?&lt;br&gt;
&lt;/span&gt; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; n0 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; n1 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; n2 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; n3 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; n4 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; HFF00 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039;Yes! MixUps become Flushes and Straights become StraightFlushes&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; -rslt LT kST &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; rslt = kFL - rslt &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt; rslt = kSF - kST - rslt&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039;No. Highcard is all&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;rslt = -rslt&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;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&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;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; PrepScores()&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; i1 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, i2 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, i3 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, i4 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, i5 &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;Long&lt;/span&gt;, r &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;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; bits &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, prod &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, rslt &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; rank(0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12) &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; sums(1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 4) &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; high(1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 4) &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; kick(1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 4) &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; prim &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; dBits &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; Dictionary&lt;br&gt;
&#160; &lt;br&gt;
&#160; &lt;br&gt;
&#160; prim = Array(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41)&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Set&lt;/span&gt; mNums = &lt;span class=&quot;kw1&quot;&gt;New&lt;/span&gt; Dictionary&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; s = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 3&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; r = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &#160; &#160; mNums.add Mid$(RANKS, r + 1, 1) &amp; Mid$(SUITS, s + 1, 1), (2 ^ s) * 256 + prim(r)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;All single suit combinations&lt;br&gt;
&lt;/span&gt; &#160;&lt;span class=&quot;kw1&quot;&gt;Set&lt;/span&gt; dBits = &lt;span class=&quot;kw1&quot;&gt;New&lt;/span&gt; Dictionary&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i1 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i2 = i1 + 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i3 = i2 + 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i4 = i3 + 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i5 = i4 + 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &#160; bits = 2 ^ i1 + 2 ^ i2 + 2 ^ i3 + 2 ^ i4 + 2 ^ i5&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Select&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; bits&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 4111: rslt = kST + 300 &#160; &#160;&lt;span class=&quot;co1&quot;&gt;&#039;Wheel&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 31: rslt = kST + 400&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 62: rslt = kST + 500&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 124: rslt = kST + 600&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 248: rslt = kST + 700&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 496: rslt = kST + 800&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 992: rslt = kST + 900&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 1984: rslt = kST + 1000&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 3968: rslt = kST + 1100&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; 7936: rslt = kST + 1200&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;: rslt = k1K + HighKick(i1, i2, i3, i4, i5)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Select&lt;/span&gt;&lt;br&gt;
&#160; &#160; dBits.add bits, rslt&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;br&gt;
&lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;All other hands&lt;br&gt;
&lt;/span&gt; &#160;&lt;span class=&quot;kw1&quot;&gt;Set&lt;/span&gt; mProd = &lt;span class=&quot;kw1&quot;&gt;New&lt;/span&gt; Dictionary&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i1 = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i2 = i1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i3 = i2 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i4 = i3 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i5 = i4 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &#160; &lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; i5 NOTEQUAL i1 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; bits = 2 ^ i1 + 2 ^ i2 + 2 ^ i3 + 2 ^ i4 + 2 ^ i5&lt;br&gt;
&#160; &#160; &#160; prod = prim(i1) * prim(i2) * prim(i3) * prim(i4) * prim(i5)&lt;br&gt;
&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; dBits.Exists(bits) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; &#160; &#160; &#160; mProd.add prod, -dBits(bits)&lt;br&gt;
&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039;How many of each rank&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Erase&lt;/span&gt; rank, sums, high, kick&lt;br&gt;
&#160; &#160; &#160; &#160; rank(i1) = rank(i1) + 1&lt;br&gt;
&#160; &#160; &#160; &#160; rank(i2) = rank(i2) + 1&lt;br&gt;
&#160; &#160; &#160; &#160; rank(i3) = rank(i3) + 1&lt;br&gt;
&#160; &#160; &#160; &#160; rank(i4) = rank(i4) + 1&lt;br&gt;
&#160; &#160; &#160; &#160; rank(i5) = rank(i5) + 1&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; r = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 12&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039;Nifty calculating!&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; rank(r) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; sums(rank(r)) = sums(rank(r)) + 1&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; kick(rank(r)) = high(rank(r))&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; high(rank(r)) = r&lt;br&gt;
&#160; &#160; &#160; &#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; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Select&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;True&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; sums(4) = 1 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; sums(1) = 1: rslt = k4K + high(4) * 100 + high(1)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; sums(3) = 1 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; sums(2) = 1: rslt = kFH + high(3) * 100 + high(2)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; sums(3) = 1 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; sums(1) = 2: rslt = k3K + high(3) * 100 + high(1)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; sums(2) = 2 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; sums(1) = 1: rslt = k2P + high(2) * 100 + kick(2)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Case&lt;/span&gt; sums(2) = 1 &lt;span class=&quot;kw1&quot;&gt;And&lt;/span&gt; sums(1) = 3: rslt = k2K + high(2) * 100 + high(1)&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Select&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&#160; &#160; &#160; &#160; mProd.add prod, rslt&lt;br&gt;
&lt;br&gt;
&#160; &#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; &#160; &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;
&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;br&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;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt; HighKick(&lt;span class=&quot;kw1&quot;&gt;ParamArray&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;&lt;br&gt;
&#160; &lt;span class=&quot;co1&quot;&gt;&#039;Finds high card and kicker&lt;br&gt;
&lt;/span&gt; &#160;&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; h &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;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; n = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; 4&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; i(n) GT h &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; &lt;br&gt;
&#160; &#160; &#160; k = h&lt;br&gt;
&#160; &#160; &#160; h = i(n)&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;Next&lt;/span&gt;&lt;br&gt;
&#160; HighKick = h * 100 + k&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>removed type declaration chars and hex codes.cleaned up code.inserted GT&#8217;s LT&#8217;s and NOTEQUAL<br />
pressed [submit] and hope for the best.</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Option</span> <span class="kw1">Explicit</span></p>
<p><span class="kw1">Const</span> kSF &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 80000 &nbsp; &nbsp;<span class="co1">&#8216;StraightFlush<br />
</span><span class="kw1">Const</span> k4K &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 70000 &nbsp; &nbsp;<span class="co1">&#8216;FourKind<br />
</span><span class="kw1">Const</span> kFH &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 60000 &nbsp; &nbsp;<span class="co1">&#8216;FullHouse<br />
</span><span class="kw1">Const</span> kFL &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 50000 &nbsp; &nbsp;<span class="co1">&#8216;Flush<br />
</span><span class="kw1">Const</span> kST &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 40000 &nbsp; &nbsp;<span class="co1">&#8216;Straight<br />
</span><span class="kw1">Const</span> k3K &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 30000 &nbsp; &nbsp;<span class="co1">&#8216;ThreeKind<br />
</span><span class="kw1">Const</span> k2P &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 20000 &nbsp; &nbsp;<span class="co1">&#8216;TwoPair<br />
</span><span class="kw1">Const</span> k2K &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 10000 &nbsp; &nbsp;<span class="co1">&#8216;OnePair<br />
</span><span class="kw1">Const</span> k1K &nbsp;<span class="kw1">As</span> <span class="kw1">Long</span> = 0</p>
<p><span class="kw1">Const</span> HFF &nbsp; <span class="kw1">As</span> <span class="kw1">Long</span> = 255 &nbsp; &nbsp; <span class="co1">&#8217;0000 0000 1111 1111: 255<br />
</span><span class="kw1">Const</span> HFF00 <span class="kw1">As</span> <span class="kw1">Long</span> = 65280 &nbsp; <span class="co1">&#8217;1111 1111 0000 0000: 65535-255=65280<br />
</span><span class="kw1">Const</span> SUITS <span class="kw1">As</span> <span class="kw1">String</span> = <span class="st0">&#8220;CDHS&#8221;</span><br />
<span class="kw1">Const</span> RANKS <span class="kw1">As</span> <span class="kw1">String</span> = <span class="st0">&#8220;23456789TJQKA&#8221;</span></p>
<p><span class="co1">&#8216;Reference nneded for Microsoft Scripting Runtime<br />
</span><span class="kw1">Dim</span> mNums <span class="kw1">As</span> Dictionary<br />
<span class="kw1">Dim</span> mProd <span class="kw1">As</span> Dictionary</p>
<p>
<span class="kw1">Sub</span> euler54_kic()<br />
&nbsp; <span class="kw1">Dim</span> list <span class="kw1">As</span> <span class="kw1">Variant</span><br />
&nbsp; <span class="kw1">Dim</span> cube(999, 1, 4) <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> rslt(1) <span class="kw1">As</span> <span class="kw1">Long</span>, wins <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> h <span class="kw1">As</span> <span class="kw1">Long</span>, p <span class="kw1">As</span> <span class="kw1">Long</span>, c <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> t <span class="kw1">As</span> <span class="kw1">Single</span>, x <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <br />
&nbsp; t = Timer<br />
&nbsp; <br />
&nbsp; <span class="co1">&#8216;Prepare Cache<br />
</span> &nbsp;PrepScores<br />
&nbsp; <span class="co1">&#8216;Read Id&#8217;s (separate cells)<br />
</span> &nbsp;list = [p54!cardsIDS]</p>
<p>&nbsp; <span class="co1">&#8216;Convert id&#8217;s to numbers<br />
</span> &nbsp;<span class="kw1">For</span> h = 0 <span class="kw1">To</span> <span class="kw1">UBound</span>(cube, 1)<br />
&nbsp; &nbsp; <span class="kw1">For</span> p = 0 <span class="kw1">To</span> <span class="kw1">UBound</span>(cube, 2)<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">For</span> c = 0 <span class="kw1">To</span> 4<br />
&nbsp; &nbsp; &nbsp; &nbsp; cube(h, p, c) = mNums(list(h + 1, p * 5 + c + 1))<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Next</span><br />
&nbsp; &nbsp; <span class="kw1">Next</span> p<br />
&nbsp; <span class="kw1">Next</span> h</p>
<p>&nbsp; <span class="co1">&#8216;Score numbers (1000 loops for effective timing)<br />
</span> &nbsp;<span class="kw1">For</span> x = 0 <span class="kw1">To</span> 999<br />
&nbsp; &nbsp; wins = 0<br />
&nbsp; &nbsp; <span class="kw1">For</span> h = 0 <span class="kw1">To</span> <span class="kw1">UBound</span>(cube, 1)<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">For</span> p = 0 <span class="kw1">To</span> <span class="kw1">UBound</span>(cube, 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; ScoreNums rslt(p), cube(h, p, 0), cube(h, p, 1), cube(h, p, 2), cube(h, p, 3), cube(h, p, 4)<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Next</span> p<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> rslt(0) GT rslt(1) <span class="kw1">Then</span> wins = wins + 1<br />
&nbsp; &nbsp; <span class="kw1">Next</span> h<br />
&nbsp; <span class="kw1">Next</span> x<br />
&nbsp; t = Timer &#8211; t<br />
&nbsp; Debug.<span class="kw1">Print</span> wins, t, <span class="st0">&#8220;Euler54&#8243;</span></p>
<p><span class="kw1">End</span> <span class="kw1">Sub</span><br />
<span class="kw1">Sub</span> ScoreNums(rslt <span class="kw1">As</span> <span class="kw1">Long</span>, n0 <span class="kw1">As</span> <span class="kw1">Long</span>, n1 <span class="kw1">As</span> <span class="kw1">Long</span>, n2 <span class="kw1">As</span> <span class="kw1">Long</span>, n3 <span class="kw1">As</span> <span class="kw1">Long</span>, n4 <span class="kw1">As</span> <span class="kw1">Long</span>)<br />
&nbsp; <span class="kw1">Dim</span> p <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="co1">&#8216;Product of numbers (use LoByte=Prime)<br />
</span> &nbsp;p = (n0 <span class="kw1">And</span> HFF) * (n1 <span class="kw1">And</span> HFF) * (n2 <span class="kw1">And</span> HFF) * (n3 <span class="kw1">And</span> HFF) * (n4 <span class="kw1">And</span> HFF)<br />
&nbsp; <span class="co1">&#8216;Find in dictionary<br />
</span> &nbsp;rslt = mProd(p)<br />
&nbsp; <span class="kw1">If</span> rslt LT 0 <span class="kw1">Then</span><br />
&nbsp; &nbsp; <span class="co1">&#8216;Flush?<br />
</span> &nbsp; &nbsp;<span class="kw1">If</span> n0 <span class="kw1">And</span> n1 <span class="kw1">And</span> n2 <span class="kw1">And</span> n3 <span class="kw1">And</span> n4 <span class="kw1">And</span> HFF00 <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; <span class="co1">&#8216;Yes! MixUps become Flushes and Straights become StraightFlushes<br />
</span> &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> -rslt LT kST <span class="kw1">Then</span> rslt = kFL &#8211; rslt <span class="kw1">Else</span> rslt = kSF &#8211; kST &#8211; rslt<br />
&nbsp; &nbsp; <span class="kw1">Else</span><br />
&nbsp; &nbsp; &nbsp; <span class="co1">&#8216;No. Highcard is all<br />
</span> &nbsp; &nbsp; &nbsp;rslt = -rslt<br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
<span class="kw1">End</span> <span class="kw1">Sub</span></p>
<p>
<span class="kw1">Sub</span> PrepScores()<br />
&nbsp; <span class="kw1">Dim</span> i1 <span class="kw1">As</span> <span class="kw1">Long</span>, i2 <span class="kw1">As</span> <span class="kw1">Long</span>, i3 <span class="kw1">As</span> <span class="kw1">Long</span>, i4 <span class="kw1">As</span> <span class="kw1">Long</span>, i5 <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">Long</span>, r <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <br />
&nbsp; <span class="kw1">Dim</span> bits <span class="kw1">As</span> <span class="kw1">Long</span>, prod <span class="kw1">As</span> <span class="kw1">Long</span>, rslt <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> rank(0 <span class="kw1">To</span> 12) <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> sums(1 <span class="kw1">To</span> 4) <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> high(1 <span class="kw1">To</span> 4) <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> kick(1 <span class="kw1">To</span> 4) <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="kw1">Dim</span> prim <span class="kw1">As</span> <span class="kw1">Variant</span><br />
&nbsp; <span class="kw1">Dim</span> dBits <span class="kw1">As</span> Dictionary<br />
&nbsp; <br />
&nbsp; <br />
&nbsp; prim = Array(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41)</p>
<p>&nbsp; <span class="kw1">Set</span> mNums = <span class="kw1">New</span> Dictionary<br />
&nbsp; <span class="kw1">For</span> s = 0 <span class="kw1">To</span> 3<br />
&nbsp; &nbsp; <span class="kw1">For</span> r = 0 <span class="kw1">To</span> 12<br />
&nbsp; &nbsp; &nbsp; mNums.add Mid$(RANKS, r + 1, 1) &amp;amp; Mid$(SUITS, s + 1, 1), (2 ^ s) * 256 + prim(r)<br />
&nbsp; &nbsp; <span class="kw1">Next</span><br />
&nbsp; <span class="kw1">Next</span></p>
<p>&nbsp; <span class="co1">&#8216;All single suit combinations<br />
</span> &nbsp;<span class="kw1">Set</span> dBits = <span class="kw1">New</span> Dictionary<br />
&nbsp; <span class="kw1">For</span> i1 = 0 <span class="kw1">To</span> 12<br />
&nbsp; <span class="kw1">For</span> i2 = i1 + 1 <span class="kw1">To</span> 12<br />
&nbsp; <span class="kw1">For</span> i3 = i2 + 1 <span class="kw1">To</span> 12<br />
&nbsp; <span class="kw1">For</span> i4 = i3 + 1 <span class="kw1">To</span> 12<br />
&nbsp; <span class="kw1">For</span> i5 = i4 + 1 <span class="kw1">To</span> 12<br />
&nbsp; &nbsp; bits = 2 ^ i1 + 2 ^ i2 + 2 ^ i3 + 2 ^ i4 + 2 ^ i5<br />
&nbsp; &nbsp; <span class="kw1">Select</span> <span class="kw1">Case</span> bits<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 4111: rslt = kST + 300 &nbsp; &nbsp;<span class="co1">&#8216;Wheel<br />
</span> &nbsp; &nbsp; &nbsp;<span class="kw1">Case</span> 31: rslt = kST + 400<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 62: rslt = kST + 500<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 124: rslt = kST + 600<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 248: rslt = kST + 700<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 496: rslt = kST + 800<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 992: rslt = kST + 900<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 1984: rslt = kST + 1000<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 3968: rslt = kST + 1100<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> 7936: rslt = kST + 1200<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> <span class="kw1">Else</span>: rslt = k1K + HighKick(i1, i2, i3, i4, i5)<br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">Select</span><br />
&nbsp; &nbsp; dBits.add bits, rslt<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></p>
<p>&nbsp; <span class="co1">&#8216;All other hands<br />
</span> &nbsp;<span class="kw1">Set</span> mProd = <span class="kw1">New</span> Dictionary<br />
&nbsp; <span class="kw1">For</span> i1 = 0 <span class="kw1">To</span> 12<br />
&nbsp; <span class="kw1">For</span> i2 = i1 <span class="kw1">To</span> 12<br />
&nbsp; <span class="kw1">For</span> i3 = i2 <span class="kw1">To</span> 12<br />
&nbsp; <span class="kw1">For</span> i4 = i3 <span class="kw1">To</span> 12<br />
&nbsp; <span class="kw1">For</span> i5 = i4 <span class="kw1">To</span> 12<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">If</span> i5 NOTEQUAL i1 <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; bits = 2 ^ i1 + 2 ^ i2 + 2 ^ i3 + 2 ^ i4 + 2 ^ i5<br />
&nbsp; &nbsp; &nbsp; prod = prim(i1) * prim(i2) * prim(i3) * prim(i4) * prim(i5)</p>
<p>&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> dBits.Exists(bits) <span class="kw1">Then</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; mProd.add prod, -dBits(bits)</p>
<p>&nbsp; &nbsp; &nbsp; <span class="kw1">Else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216;How many of each rank<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Erase</span> rank, sums, high, kick<br />
&nbsp; &nbsp; &nbsp; &nbsp; rank(i1) = rank(i1) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; rank(i2) = rank(i2) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; rank(i3) = rank(i3) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; rank(i4) = rank(i4) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; rank(i5) = rank(i5) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">For</span> r = 0 <span class="kw1">To</span> 12<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216;Nifty calculating!<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> rank(r) <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sums(rank(r)) = sums(rank(r)) + 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kick(rank(r)) = high(rank(r))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; high(rank(r)) = r<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Next</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Select</span> <span class="kw1">Case</span> <span class="kw1">True</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> sums(4) = 1 <span class="kw1">And</span> sums(1) = 1: rslt = k4K + high(4) * 100 + high(1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> sums(3) = 1 <span class="kw1">And</span> sums(2) = 1: rslt = kFH + high(3) * 100 + high(2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> sums(3) = 1 <span class="kw1">And</span> sums(1) = 2: rslt = k3K + high(3) * 100 + high(1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> sums(2) = 2 <span class="kw1">And</span> sums(1) = 1: rslt = k2P + high(2) * 100 + kick(2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Case</span> sums(2) = 1 <span class="kw1">And</span> sums(1) = 3: rslt = k2K + high(2) * 100 + high(1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">Select</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; mProd.add prod, rslt</p>
<p>&nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span></p>
<p>&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></p>
<p><span class="kw1">End</span> <span class="kw1">Sub</span></p>
<p><span class="kw1">Function</span> HighKick(<span class="kw1">ParamArray</span> i()) <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; <span class="co1">&#8216;Finds high card and kicker<br />
</span> &nbsp;<span class="kw1">Dim</span> h <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><br />
&nbsp; <span class="kw1">For</span> n = 0 <span class="kw1">To</span> 4<br />
&nbsp; &nbsp; <span class="kw1">If</span> i(n) GT h <span class="kw1">Then</span> <br />
&nbsp; &nbsp; &nbsp; k = h<br />
&nbsp; &nbsp; &nbsp; h = i(n)<br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; <span class="kw1">Next</span><br />
&nbsp; HighKick = h * 100 + k<br />
<span class="kw1">End</span> <span class="kw1">Function</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37596</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Fri, 30 Jan 2009 01:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37596</guid>
		<description>&lt;p&gt;Code to complex and Me too lazy for rewrite and ten trial posts. Whay can&#039;t I post some PRE formatted code?&lt;br&gt;
Just for the sake of some fancy highlighting. If interested drop me mail. keepITcool AT chello DOT nl&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Code to complex and Me too lazy for rewrite and ten trial posts. Whay can&#8217;t I post some PRE formatted code?<br />
Just for the sake of some fancy highlighting. If interested drop me mail. keepITcool AT chello DOT nl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37595</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Thu, 29 Jan 2009 23:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37595</guid>
		<description>&lt;p&gt;kIc - looks like the the HTML bug has bitten you.  If you have a paired set of angle brackets in your text- left angle followed by right angle, no matter how separated, the software parses that as an HTML tag, and doesn&#039;t display it.&lt;/p&gt;
&lt;p&gt;We&#039;ve gotten used to such workarounds as LT or LTE or GT or GTE and some others to convey the thought.&lt;/p&gt;
&lt;p&gt;I&#039;ve never used a dictionary, VB-wise at least ;-), and want to see how that goes.&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>kIc &#8211; looks like the the HTML bug has bitten you.  If you have a paired set of angle brackets in your text- left angle followed by right angle, no matter how separated, the software parses that as an HTML tag, and doesn&#8217;t display it.</p>
<p>We&#8217;ve gotten used to such workarounds as LT or LTE or GT or GTE and some others to convey the thought.</p>
<p>I&#8217;ve never used a dictionary, VB-wise at least <img src='http://www.dailydoseofexcel.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> , and want to see how that goes.</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/24/euler-problem-54/#comment-37594</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Thu, 29 Jan 2009 21:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1953#comment-37594</guid>
		<description>&lt;p&gt;Convert ID&#039;s (AS QH etc) to (long) integers.&lt;br&gt;
The LoByte contains a prime from 2 to 41 to represent the rank.&lt;br&gt;
The HiByte (of Loword) is a mask for the suit of the card.&lt;br&gt;
The HiWord can be used for a mask of the rank, but I found it confusing.&lt;br&gt;
xxxAKQJT98765432 xxxxDHSDxxPPPPPP = long(4bytes)&lt;/p&gt;
&lt;p&gt;First prep a dictionary for all 6175 possible products 4888 Combinations (score&gt;0) and 1287 Uniques (score aRes(1) Then win = win + 1&lt;br&gt;
    Next h&lt;br&gt;
  Next x&lt;br&gt;
  t = Timer - t&lt;br&gt;
  Debug.Print win, t, &quot;&lt;Num&quot;&lt;/p&gt;
&lt;p&gt;End Sub&lt;br&gt;
Sub ScoreNums(res&amp;, n0&amp;, n1&amp;, n2&amp;, n3&amp;, n4&amp;)&lt;br&gt;
  Dim p&amp;&lt;br&gt;
  p = (n0 And Not &amp;HFF00) * (n1 And Not &amp;HFF00) * (n2 And Not &amp;HFF00) * (n3 And Not &amp;HFF00) * (n4 And Not &amp;HFF00)&lt;br&gt;
  res = dProd(p)&lt;br&gt;
  If res &lt; 0 Then&lt;br&gt;
    If n0 And n1 And n2 And n3 And n4 And &amp;HF00 Then&lt;br&gt;
      If -res  h Then&lt;br&gt;
      k = h&lt;br&gt;
      h = i(n)&lt;br&gt;
    End If&lt;br&gt;
  Next&lt;br&gt;
  HighKick = h * 100 + k&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Convert ID&#8217;s (AS QH etc) to (long) integers.<br />
The LoByte contains a prime from 2 to 41 to represent the rank.<br />
The HiByte (of Loword) is a mask for the suit of the card.<br />
The HiWord can be used for a mask of the rank, but I found it confusing.<br />
xxxAKQJT98765432 xxxxDHSDxxPPPPPP = long(4bytes)</p>
<p>First prep a dictionary for all 6175 possible products 4888 Combinations (score&gt;0) and 1287 Uniques (score aRes(1) Then win = win + 1<br />
    Next h<br />
  Next x<br />
  t = Timer &#8211; t<br />
  Debug.Print win, t, &#8220;&lt;Num&#8221;</p>
<p>End Sub<br />
Sub ScoreNums(res&amp;, n0&amp;, n1&amp;, n2&amp;, n3&amp;, n4&amp;)<br />
  Dim p&amp;<br />
  p = (n0 And Not &amp;HFF00) * (n1 And Not &amp;HFF00) * (n2 And Not &amp;HFF00) * (n3 And Not &amp;HFF00) * (n4 And Not &amp;HFF00)<br />
  res = dProd(p)<br />
  If res &lt; 0 Then<br />
    If n0 And n1 And n2 And n3 And n4 And &amp;HF00 Then<br />
      If -res  h Then<br />
      k = h<br />
      h = i(n)<br />
    End If<br />
  Next<br />
  HighKick = h * 100 + k<br />
End Function</p>
]]></content:encoded>
	</item>
</channel>
</rss>

