<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Project Euler 39</title>
	<link>http://www.thattommyhall.com/2008/04/12/project-euler-39/</link>
	<description>A Random Walk Through Idea Space</description>
	<pubDate>Tue, 06 Jan 2009 23:31:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: tom</title>
		<link>http://www.thattommyhall.com/2008/04/12/project-euler-39/#comment-706</link>
		<author>tom</author>
		<pubDate>Mon, 14 Apr 2008 13:32:21 +0000</pubDate>
		<guid>http://www.thattommyhall.com/2008/04/12/project-euler-39/#comment-706</guid>
		<description>http://paste.bradleygill.com/index.php?paste_id=238</description>
		<content:encoded><![CDATA[<p><a href="http://paste.bradleygill.com/index.php?paste_id=238" rel="nofollow">http://paste.bradleygill.com/index.php?paste_id=238</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ejs</title>
		<link>http://www.thattommyhall.com/2008/04/12/project-euler-39/#comment-704</link>
		<author>ejs</author>
		<pubDate>Mon, 14 Apr 2008 11:18:11 +0000</pubDate>
		<guid>http://www.thattommyhall.com/2008/04/12/project-euler-39/#comment-704</guid>
		<description>While I don't have the code I used I remember solving it far faster using brute force. After 10 min playing this is what I think I had (hoping the indentation works):

import math
from eulerhelpers import timed

@timed
def solve39(cap=1000):
    result = [0] * (cap+1)
    for b in xrange(1, cap/2):
        for c in xrange(1, min(b, cap/2-b)+1):
            a = math.sqrt(b**2 + c**2)
            if a+b+c &#62; cap:
                break
            if not a%1:
                result[int(a)+b+c] += 1
        if not b%(cap/20):
            print b,
            yield
    print max((i, e) for e, i in enumerate(result))

On my computer, without psyco, it completes in just over 0.1 seconds or about 7 times longer than your more mathematical code. I stopped there thinking it was enough.</description>
		<content:encoded><![CDATA[<p>While I don&#8217;t have the code I used I remember solving it far faster using brute force. After 10 min playing this is what I think I had (hoping the indentation works):</p>
<p>import math<br />
from eulerhelpers import timed</p>
<p>@timed<br />
def solve39(cap=1000):<br />
    result = [0] * (cap+1)<br />
    for b in xrange(1, cap/2):<br />
        for c in xrange(1, min(b, cap/2-b)+1):<br />
            a = math.sqrt(b**2 + c**2)<br />
            if a+b+c &gt; cap:<br />
                break<br />
            if not a%1:<br />
                result[int(a)+b+c] += 1<br />
        if not b%(cap/20):<br />
            print b,<br />
            yield<br />
    print max((i, e) for e, i in enumerate(result))</p>
<p>On my computer, without psyco, it completes in just over 0.1 seconds or about 7 times longer than your more mathematical code. I stopped there thinking it was enough.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
