<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: $7.11</title>
	<atom:link href="http://programmingpraxis.com/2009/11/27/7-11/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/11/27/7-11/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Mon, 28 May 2012 03:30:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Elvis Montero</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-1320</link>
		<dc:creator><![CDATA[Elvis Montero]]></dc:creator>
		<pubDate>Sat, 12 Jun 2010 21:47:47 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-1320</guid>
		<description><![CDATA[&lt;a href=&quot;http://elvismontero.com/progpraxis/SevenEleven.html&quot; rel=&quot;nofollow&quot;&gt;Here&#039;s my solution.&lt;/a&gt; My Java code resembles some of the Python code posted by other commentators.]]></description>
		<content:encoded><![CDATA[<p><a href="http://elvismontero.com/progpraxis/SevenEleven.html" rel="nofollow">Here&#8217;s my solution.</a> My Java code resembles some of the Python code posted by other commentators.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: $7.11 in four prices and the Decimal &#171; Wrong Side of Memphis</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-947</link>
		<dc:creator><![CDATA[$7.11 in four prices and the Decimal &#171; Wrong Side of Memphis]]></dc:creator>
		<pubDate>Fri, 22 Jan 2010 16:21:54 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-947</guid>
		<description><![CDATA[[...] 2009 de khelben    There&#8217;s an fun and not very difficult programming exercise, presented on Programming Praxis . The problem is easy to [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 2009 de khelben    There&#8217;s an fun and not very difficult programming exercise, presented on Programming Praxis . The problem is easy to [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Haug</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-868</link>
		<dc:creator><![CDATA[Scott Haug]]></dc:creator>
		<pubDate>Sun, 03 Jan 2010 03:59:11 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-868</guid>
		<description><![CDATA[Late to the game on this one, but I&#039;m using this site to get some practice writing clojure. Here&#039;s my submission:

[sourcecode lang=&quot;css&quot;]
(use &#039;[clojure.contrib.combinatorics :only (combinations)])
(filter
  #(and (= (apply + %) 711)
        (= (apply * %) 711000000))
  (combinations
    (filter #(zero? (mod 711000000 (int %)))
            (range 1 712))
    4))
[/sourcecode]

Not the fastest by any means, but it gets the job done in about 1.4 secs on my laptop.]]></description>
		<content:encoded><![CDATA[<p>Late to the game on this one, but I&#8217;m using this site to get some practice writing clojure. Here&#8217;s my submission:</p>
<pre class="brush: css;">
(use '[clojure.contrib.combinatorics :only (combinations)])
(filter
  #(and (= (apply + %) 711)
        (= (apply * %) 711000000))
  (combinations
    (filter #(zero? (mod 711000000 (int %)))
            (range 1 712))
    4))
</pre>
<p>Not the fastest by any means, but it gets the job done in about 1.4 secs on my laptop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Schoch</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-811</link>
		<dc:creator><![CDATA[Dan Schoch]]></dc:creator>
		<pubDate>Fri, 04 Dec 2009 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-811</guid>
		<description><![CDATA[/* FWIW -- Here&#039;s my Oracle PL/SQL solution */
declare
    done                boolean         := false ;
    item4               pls_integer ;
begin
    for item1 in 1..711
    loop
        for item2 in item1..(711-item1)
        loop
            for item3 in item2..(711-item1-item2)
            loop
                item4 := 711-(item1+item2+item3) ;
                if item1*item2*item3*item4 = 711000000 then
                    dbms_output.put_line(&#039;Item 1 = $&#039;&#124;&#124;to_char(item1/100,&#039;fm999.00&#039;)) ;
                    dbms_output.put_line(&#039;Item 2 = $&#039;&#124;&#124;to_char(item2/100,&#039;fm999.00&#039;)) ;
                    dbms_output.put_line(&#039;Item 3 = $&#039;&#124;&#124;to_char(item3/100,&#039;fm999.00&#039;)) ;
                    dbms_output.put_line(&#039;Item 4 = $&#039;&#124;&#124;to_char(item4/100,&#039;fm999.00&#039;)) ;
                    done := true ;
                end if ;
                exit when done ;
            end loop ;
            exit when done ;
        end loop ;
        exit when done ;
    end loop ;
end ;
/]]></description>
		<content:encoded><![CDATA[<p>/* FWIW &#8212; Here&#8217;s my Oracle PL/SQL solution */<br />
declare<br />
    done                boolean         := false ;<br />
    item4               pls_integer ;<br />
begin<br />
    for item1 in 1..711<br />
    loop<br />
        for item2 in item1..(711-item1)<br />
        loop<br />
            for item3 in item2..(711-item1-item2)<br />
            loop<br />
                item4 := 711-(item1+item2+item3) ;<br />
                if item1*item2*item3*item4 = 711000000 then<br />
                    dbms_output.put_line(&#8216;Item 1 = $&#8217;||to_char(item1/100,&#8217;fm999.00&#8242;)) ;<br />
                    dbms_output.put_line(&#8216;Item 2 = $&#8217;||to_char(item2/100,&#8217;fm999.00&#8242;)) ;<br />
                    dbms_output.put_line(&#8216;Item 3 = $&#8217;||to_char(item3/100,&#8217;fm999.00&#8242;)) ;<br />
                    dbms_output.put_line(&#8216;Item 4 = $&#8217;||to_char(item4/100,&#8217;fm999.00&#8242;)) ;<br />
                    done := true ;<br />
                end if ;<br />
                exit when done ;<br />
            end loop ;<br />
            exit when done ;<br />
        end loop ;<br />
        exit when done ;<br />
    end loop ;<br />
end ;<br />
/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PHW</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-802</link>
		<dc:creator><![CDATA[PHW]]></dc:creator>
		<pubDate>Tue, 01 Dec 2009 22:20:49 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-802</guid>
		<description><![CDATA[Rejigged my earlier solution to take advantage of the idea that all 4 costs must be a factor of the overall product. Also (hopefully) I pretty-printed the code this time. The code now completes in less than a second.


#!/usr/bin/perl
&lt;strong&gt;use&lt;/strong&gt; strict;

&lt;strong&gt;my&lt;/strong&gt; $PRODUCT = 711000000;

&lt;strong&gt;for&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt;&lt;strong&gt;my&lt;/strong&gt; $a=708; $a&gt;=1 ; $a-= 1&lt;strong&gt;)&lt;/strong&gt; &lt;strong&gt;{&lt;/strong&gt;
  &lt;strong&gt;if&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt;$PRODUCT % $a&lt;strong&gt;)&lt;/strong&gt; !=0 &lt;strong&gt;)&lt;/strong&gt; &lt;strong&gt;{&lt;/strong&gt;&lt;strong&gt;next&lt;/strong&gt;;&lt;strong&gt;}&lt;/strong&gt;
  &lt;strong&gt;for&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt;&lt;strong&gt;my&lt;/strong&gt; $b=&lt;strong&gt;(&lt;/strong&gt;709-$a&lt;strong&gt;)&lt;/strong&gt;; $b &gt;=$a ; $b-=1&lt;strong&gt;)&lt;/strong&gt; &lt;strong&gt;{&lt;/strong&gt;
    &lt;strong&gt;if&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt;$PRODUCT % $b&lt;strong&gt;)&lt;/strong&gt; !=0 &lt;strong&gt;)&lt;/strong&gt; &lt;strong&gt;{&lt;/strong&gt;&lt;strong&gt;next&lt;/strong&gt;;&lt;strong&gt;}&lt;/strong&gt;
    &lt;strong&gt;for&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt;&lt;strong&gt;my&lt;/strong&gt; $c=&lt;strong&gt;(&lt;/strong&gt;710-$a-$b&lt;strong&gt;)&lt;/strong&gt;; $c&gt;=$b; $c-=1&lt;strong&gt;)&lt;/strong&gt; &lt;strong&gt;{&lt;/strong&gt;
      &lt;strong&gt;if&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt;$PRODUCT % $c&lt;strong&gt;)&lt;/strong&gt; !=0 &lt;strong&gt;)&lt;/strong&gt; &lt;strong&gt;{&lt;/strong&gt;&lt;strong&gt;next&lt;/strong&gt;;&lt;strong&gt;}&lt;/strong&gt;
      &lt;strong&gt;my&lt;/strong&gt; $d = 711 - $a - $b - $c;
      &lt;strong&gt;if&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt;$d&gt;$c&lt;strong&gt;)&lt;/strong&gt; &lt;strong&gt;{&lt;/strong&gt;
        &lt;strong&gt;my&lt;/strong&gt; $prd = $a*$b*$c*$d;
        &lt;strong&gt;if&lt;/strong&gt; &lt;strong&gt;(&lt;/strong&gt;$prd==$PRODUCT&lt;strong&gt;)&lt;/strong&gt; &lt;strong&gt;{&lt;/strong&gt;
          &lt;strong&gt;printf&lt;/strong&gt; &quot;%3.2f %3.2f %3.2f %3.2f\n&quot;,$a/100,$b/100,$c/100,$d/100;
        &lt;strong&gt;}&lt;/strong&gt;
      &lt;strong&gt;}&lt;/strong&gt;
    &lt;strong&gt;}&lt;/strong&gt;
  &lt;strong&gt;}&lt;/strong&gt;
&lt;strong&gt;}&lt;/strong&gt;]]></description>
		<content:encoded><![CDATA[<p>Rejigged my earlier solution to take advantage of the idea that all 4 costs must be a factor of the overall product. Also (hopefully) I pretty-printed the code this time. The code now completes in less than a second.</p>
<p>#!/usr/bin/perl<br />
<strong>use</strong> strict;</p>
<p><strong>my</strong> $PRODUCT = 711000000;</p>
<p><strong>for</strong> <strong>(</strong><strong>my</strong> $a=708; $a&gt;=1 ; $a-= 1<strong>)</strong> <strong>{</strong><br />
  <strong>if</strong> <strong>(</strong> <strong>(</strong>$PRODUCT % $a<strong>)</strong> !=0 <strong>)</strong> <strong>{</strong><strong>next</strong>;<strong>}</strong><br />
  <strong>for</strong> <strong>(</strong><strong>my</strong> $b=<strong>(</strong>709-$a<strong>)</strong>; $b &gt;=$a ; $b-=1<strong>)</strong> <strong>{</strong><br />
    <strong>if</strong> <strong>(</strong> <strong>(</strong>$PRODUCT % $b<strong>)</strong> !=0 <strong>)</strong> <strong>{</strong><strong>next</strong>;<strong>}</strong><br />
    <strong>for</strong> <strong>(</strong><strong>my</strong> $c=<strong>(</strong>710-$a-$b<strong>)</strong>; $c&gt;=$b; $c-=1<strong>)</strong> <strong>{</strong><br />
      <strong>if</strong> <strong>(</strong> <strong>(</strong>$PRODUCT % $c<strong>)</strong> !=0 <strong>)</strong> <strong>{</strong><strong>next</strong>;<strong>}</strong><br />
      <strong>my</strong> $d = 711 &#8211; $a &#8211; $b &#8211; $c;<br />
      <strong>if</strong> <strong>(</strong>$d&gt;$c<strong>)</strong> <strong>{</strong><br />
        <strong>my</strong> $prd = $a*$b*$c*$d;<br />
        <strong>if</strong> <strong>(</strong>$prd==$PRODUCT<strong>)</strong> <strong>{</strong><br />
          <strong>printf</strong> &quot;%3.2f %3.2f %3.2f %3.2f\n&quot;,$a/100,$b/100,$c/100,$d/100;<br />
        <strong>}</strong><br />
      <strong>}</strong><br />
    <strong>}</strong><br />
  <strong>}</strong><br />
<strong>}</strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kernelbob</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-799</link>
		<dc:creator><![CDATA[kernelbob]]></dc:creator>
		<pubDate>Mon, 30 Nov 2009 01:32:31 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-799</guid>
		<description><![CDATA[Oh.  You dropped the requirement that c &lt;= d.  I had missed that.

Thanks for a fun problem.]]></description>
		<content:encoded><![CDATA[<p>Oh.  You dropped the requirement that c &lt;= d.  I had missed that.</p>
<p>Thanks for a fun problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: programmingpraxis</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-798</link>
		<dc:creator><![CDATA[programmingpraxis]]></dc:creator>
		<pubDate>Mon, 30 Nov 2009 00:31:53 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-798</guid>
		<description><![CDATA[The product 7.11 &#215; 10&lt;sup&gt;8&lt;/sup&gt; factors as 2&lt;sup&gt;6&lt;/sup&gt; &#215; 3&lt;sup&gt;2&lt;/sup&gt; &#215; 5&lt;sup&gt;6&lt;/sup&gt; &#215; 79.  The 79 factor has to be there someplace, and &lt;em&gt;d&lt;/em&gt; is as good a place as any.  And by the way, the multiplier can&#039;t be 7, because there is no 7 in the factorization, can&#039;t be 9, because 9 &#215; 79 = 711 leaving no room for the other factors, and you&#039;ve already demonstrated that it can&#039;t be 1 or 2.]]></description>
		<content:encoded><![CDATA[<p>The product 7.11 &times; 10<sup>8</sup> factors as 2<sup>6</sup> &times; 3<sup>2</sup> &times; 5<sup>6</sup> &times; 79.  The 79 factor has to be there someplace, and <em>d</em> is as good a place as any.  And by the way, the multiplier can&#8217;t be 7, because there is no 7 in the factorization, can&#8217;t be 9, because 9 &times; 79 = 711 leaving no room for the other factors, and you&#8217;ve already demonstrated that it can&#8217;t be 1 or 2.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kernelbob</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-797</link>
		<dc:creator><![CDATA[kernelbob]]></dc:creator>
		<pubDate>Sun, 29 Nov 2009 22:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-797</guid>
		<description><![CDATA[677040, correct.  I transcribed the number wrong.

It&#039;s not clear to me that d has to be a multiple of 79.  Can you explain your reasoning?  It seems to me that it could be any of the 62 factors, though it&#039;s at least the fourth root of 711000000 (i.e., greater than 163).]]></description>
		<content:encoded><![CDATA[<p>677040, correct.  I transcribed the number wrong.</p>
<p>It&#8217;s not clear to me that d has to be a multiple of 79.  Can you explain your reasoning?  It seems to me that it could be any of the 62 factors, though it&#8217;s at least the fourth root of 711000000 (i.e., greater than 163).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: programmingpraxis</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-795</link>
		<dc:creator><![CDATA[programmingpraxis]]></dc:creator>
		<pubDate>Sun, 29 Nov 2009 19:28:30 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-795</guid>
		<description><![CDATA[I get 677,040, which is close to your calculation.  See &lt;a href=&quot;http://programmingpraxis.codepad.org/tvysKxmF&quot; rel=&quot;nofollow&quot;&gt;http://programmingpraxis.codepad.org/tvysKxmF&lt;/a&gt;.

Since the prime factors of 711 are 3, 3, and 79, you could do even better by having &lt;em&gt;d&lt;/em&gt; iterate through 1&#215;79, 2&#215;79, ... 9&#215;79.  See &lt;a href=&quot;http://programmingpraxis.codepad.org/B0W4qEU0&quot; rel=&quot;nofollow&quot;&gt;http://programmingpraxis.codepad.org/B0W4qEU0&lt;/a&gt;.  That reduces the size of the cross-product to 374,976.]]></description>
		<content:encoded><![CDATA[<p>I get 677,040, which is close to your calculation.  See <a href="http://programmingpraxis.codepad.org/tvysKxmF" rel="nofollow">http://programmingpraxis.codepad.org/tvysKxmF</a>.</p>
<p>Since the prime factors of 711 are 3, 3, and 79, you could do even better by having <em>d</em> iterate through 1&times;79, 2&times;79, &#8230; 9&times;79.  See <a href="http://programmingpraxis.codepad.org/B0W4qEU0" rel="nofollow">http://programmingpraxis.codepad.org/B0W4qEU0</a>.  That reduces the size of the cross-product to 374,976.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kbob</title>
		<link>http://programmingpraxis.com/2009/11/27/7-11/#comment-794</link>
		<dc:creator><![CDATA[kbob]]></dc:creator>
		<pubDate>Sun, 29 Nov 2009 15:42:40 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1725#comment-794</guid>
		<description><![CDATA[Indentation weirded out, sorry.  I guess Wordpress assumes tab stops every four columns.  I assumed eight.]]></description>
		<content:encoded><![CDATA[<p>Indentation weirded out, sorry.  I guess WordPress assumes tab stops every four columns.  I assumed eight.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

