<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	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>KeyZero Conversation</title>
	<atom:link href="http://keyzero.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://keyzero.wordpress.com</link>
	<description>Comments on Computing</description>
	<lastBuildDate>Sun, 29 Jan 2012 02:07:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='keyzero.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>KeyZero Conversation</title>
		<link>http://keyzero.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://keyzero.wordpress.com/osd.xml" title="KeyZero Conversation" />
	<atom:link rel='hub' href='http://keyzero.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Project Euler Problem #65</title>
		<link>http://keyzero.wordpress.com/2012/01/29/project-euler-problem-65/</link>
		<comments>http://keyzero.wordpress.com/2012/01/29/project-euler-problem-65/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 02:00:52 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Project Euler Solutions 061-070]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ProjectEuler]]></category>

		<guid isPermaLink="false">https://keyzero.wordpress.com/?p=637</guid>
		<description><![CDATA[Read the details of the problem here Summary Find the sum of digits in the numerator of the 100th convergent of the continued fraction for e. Solution This question immediately reminded me of Problem #57 which ended up being quite a simple solution though it sounded involved initially. I took a look at that, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=637&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://http://projecteuler.net/problem=65" target="_blank">Read the details of the problem here</a></p>
<p><strong>Summary</strong></p>
<p>Find the sum of digits in the numerator of the 100<sup>th</sup> convergent of the continued fraction for <i>e</i>.</p>
<p><strong>Solution</strong></p>
<p>This question immediately reminded me of <a href="http://keyzero.wordpress.com/2010/05/21/project-euler-problem-57/" target="_blank">Problem #57</a> which ended up being quite a simple solution though it sounded involved initially. I took a look at that, and adopted a similar approach to this one.</p>
<p>The trick with this problem was to spot the pattern as to how the numerator changed down the sequence. As it turned out, the values of the denominator are superflous to this and can just be ignored for this purpose.</p>
<p>Taking the first ten terms as given (with a zeroth term for completeness) given this is how it works:</p>
<p>
<table border="1" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<th valign="top" width="100">Term</td>
<th valign="top" width="100">Numerator</td>
<th valign="top" width="100">Multiplier</td>
<th valign="top" width="200">Formula</td>
</tr>
<tr>
<td valign="top" width="100">0</td>
<td valign="top" width="100">1</td>
<td valign="top" width="100">&nbsp;</td>
<td valign="top" width="200">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="100">1</td>
<td valign="top" width="100">2</td>
<td valign="top" width="100">2</td>
<td valign="top" width="200">2 * num<sub>0</sub></td>
</tr>
<tr>
<td valign="top" width="100">2</td>
<td valign="top" width="100">3</td>
<td valign="top" width="100">1</td>
<td valign="top" width="200">1 * num<sub>1</sub> + num<sub>0</sub></td>
</tr>
<tr>
<td valign="top" width="100">3</td>
<td valign="top" width="100">8</td>
<td valign="top" width="100">2</td>
<td valign="top" width="200">2 * num<sub>2</sub> + num<sub>1</sub></td>
</tr>
<tr>
<td valign="top" width="100">4</td>
<td valign="top" width="100">11</td>
<td valign="top" width="100">1</td>
<td valign="top" width="200">1 * num<sub>3</sub> + num<sub>2</sub></td>
</tr>
<tr>
<td valign="top" width="100">5</td>
<td valign="top" width="100">19</td>
<td valign="top" width="100">1</td>
<td valign="top" width="200">1 * num<sub>4</sub> + num<sub>3</sub></td>
</tr>
<tr>
<td valign="top" width="100">6</td>
<td valign="top" width="100">87</td>
<td valign="top" width="100">4</td>
<td valign="top" width="200">4 * num<sub>5</sub> + num<sub>4</sub></td>
</tr>
<tr>
<td valign="top" width="100">7</td>
<td valign="top" width="100">106</td>
<td valign="top" width="100">1</td>
<td valign="top" width="200">1 * num<sub>6</sub> + num<sub>5</sub></td>
</tr>
<tr>
<td valign="top" width="100">8</td>
<td valign="top" width="100">193</td>
<td valign="top" width="100">1</td>
<td valign="top" width="200">1 * num<sub>7</sub> + num<sub>6</sub></td>
</tr>
<tr>
<td valign="top" width="100">9</td>
<td valign="top" width="100">1264</td>
<td valign="top" width="100">6</td>
<td valign="top" width="200">6 * num<sub>8</sub> + num<sub>7</sub></td>
</tr>
<tr>
<td valign="top" width="100">10</td>
<td valign="top" width="100">1457</td>
<td valign="top" width="100">1</td>
<td valign="top" width="200">1 * num<sub>9</sub> + num<sub>8</sub></td>
</tr>
</tbody>
</table>
<p>So this can be summarised as:</p>
<p>num<sub>n</sub> = mul<sub>n</sub> * num<sub>n-1</sub> + num<sub>n-2</sub></p>
<p>Where <i>n</i> is the term being calculated and mul<sub>n</sub> is the n<sup>th</sup> element of the continued fraction.&#160; This is simply <i>n</i> / 3 * 2 when <i>n</i> mod 3 == 0, and 1 otherwise.</p>
<p>Given that the multipliers work in triplets, this can be used to advantage and reduce the number of calculations required. I created a function that given the n-1 and n-2 numerators, and a term number could calculate the next three numerators in the sequence. It meant that I didn&#8217;t have to do any modulus calculations as long as I kept the boundary aligned correctly i.e. only call it for terms, 2, 5, 8, etc. which were the start of the triplets.</p>
<p>Starting at term 2, I then called this recursively until it was being asked to calculate the 101<sup>st</sup> term.  At this point the 100<sup>th</sup> term would be the n-1 numerator value and could be returned.
<p><pre class="brush: groovy; wrap-lines: false;">
def f(p1, p2, tc) {
  if (tc == 101) return p1
  def m = p1 + p2
  def n = ((tc + 1).intdiv(3) * 2) * m + p1
  f(n + m, n, tc + 3)
}

def answer =
    (f(2G, 1G, 2).toString() as List)*.toInteger().sum()
</pre></p>
<p>This runs in around 115 ms, with sum of the digits taking about 10 ms. A port of this code to Java runs in around 1.3 ms in total.</p>
<p><strong>Conclusion</strong></p>
<p>Groovy was a nice language to do this in. Not having to mess about with BigInteger objects explicitly is always a boon in the Java world. Performance was quite disappointing though &#8211; given that f() is only ever called with BigInteger arguments the compiler should be able to work out exactly what types the variables are and the generated bytecode should be pretty similar to that which javac outputs&#8230;but it’s not. In this case Groovy is nearly two orders of magnitude slower and I really don’t see a good reason for it at this stage in the language maturity.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/637/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/637/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/637/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/637/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/637/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/637/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/637/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/637/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/637/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/637/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/637/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/637/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/637/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/637/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=637&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2012/01/29/project-euler-problem-65/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler Problem #243</title>
		<link>http://keyzero.wordpress.com/2012/01/21/project-euler-problem-243/</link>
		<comments>http://keyzero.wordpress.com/2012/01/21/project-euler-problem-243/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 15:57:31 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Project Euler Solutions 241-250]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">https://keyzero.wordpress.com/?p=631</guid>
		<description><![CDATA[Read the details of the problem here Summary Find the smallest denominator d, having a resilience R(d) &#60; 15499 ⁄ 94744 Solution Due to real-life intrusion I haven’t been doing much Project Euler for the last few months but a conversation with a colleague at work the other day brought the subject up and I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=631&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://projecteuler.net/index.php?section=problems&amp;id=243" target="_blank">Read the details of the problem here</a></p>
<p><strong>Summary</strong></p>
<p>Find the smallest denominator <i>d</i>, having a resilience <i>R</i>(<i>d</i>) &lt; 15499 ⁄ 94744</p>
<p><strong>Solution</strong></p>
<p>Due to real-life intrusion I haven’t been doing much Project Euler for the last few months but a conversation with a colleague at work the other day brought the subject up and I thought I’d revisit the site.</p>
<p>They&#8217;ve changed their format quite a lot now and though it’s still fundamentally the same, the concept of “badges” has been introduced &#8211; “awards” above and beyond just the old numbers of puzzles solved (which is now more granular). I&#8217;m a sucker for things like that and one of them &#8211; “<a href="http://projecteuler.net/award=16" target="_blank">Trinary Triumph</a>” &#8211; just needed one more question to complete so it was, as the saying goes, like a red rag to a bull!</p>
<p>The problem was actually worded quite straightforwardly, and a little thought showed that this was very similar to <a href="http://keyzero.wordpress.com/2010/05/21/project-euler-problem-69/" target="_blank">Problem #69</a> and <a href="http://keyzero.wordpress.com/2010/05/05/project-euler-problem-70/" target="_blank">Problem #70</a>. The numerator in the resilience function is going to be the count of terms that are relatively prime to the denominator i.e. Euler&#8217;s Totient (φ) function. The solution to <a href="http://keyzero.wordpress.com/2010/05/21/project-euler-problem-69/" target="_blank">Problem #69</a> was found by maximising n/φ(n) whereas, in this problem we&#8217;re looking to minimize φ(d)/(d-1) &#8211; so it&#8217;s essentially the same thing.  The answer is likely to be found by looking for a number consisting of the product of many small prime factors perhaps with some multiplier (also a product of small primes) i.e. some of those factors may be of a higher power.</p>
<p><a href="http://keyzero.wordpress.com/2010/06/05/project-euler-problem-108/" target="_blank">Problem #108</a> and <a href="http://keyzero.wordpress.com/2010/06/12/project-euler-problem-110/" target="_blank">Problem #110</a> also tackled the domain of products of powers of primes and the solution to the latter seemed a good place to start as the one to the former ended up as being a bit of a lucky hack. As per that solution, taking the approach of assuming that the answer was to be found somewhere at n * product(prime factors) and driving off that meant that factorisation of large numbers wasn&rsquo;t needed so Groovy would remain a viable language to do this in.</p>
<p>Again, when doing these problems with Groovy, it&rsquo;s best to try to work out the potential scope ahead of runtime as it doesn&rsquo;t perform that well at number crunching.</p>
<p>What I did need to how to calculate the totient value for numbers with large numbers of factors &#8211; I&rsquo;d kind of worked it out from a bit of guess work for two factors when doing <a href="http://keyzero.wordpress.com/2010/05/05/project-euler-problem-70/" target="_blank">Problem #70</a> but this wouldn&rsquo;t work for this.  Luckily <a href="http://en.wikipedia.org/wiki/Euler's_totient_function" target="_blank">Wikipedia came to the rescue</a> giving the formula quite succinctly as:</p>
<p>φ(n) = n(1-1/p<sub>1</sub>)(1-1/p<sub>2</sub>)&#8230;(1-1/p<sub>r</sub>).</p>
<p>Using this I found that the product of a prime sequence 2..23 gave a totient above what was being sought, whilst 2..29 was a potential solution itself.  The answer probably fell somewhere between these two and this therefore formed the search space.</p>
<p>I then just reused the helper function I&rsquo;d used in <a href="http://keyzero.wordpress.com/2010/06/12/project-euler-problem-110/" target="_blank">Problem #110</a> with a bit of an educated guess as to what the maximum power might be. If the multipler was 2<sup>5</sup> i.e. 32, this would exceed the solution of the longer prime sequence &#8211; so a maximum power of 4 seemed reasonable to use. I also seeded the generator function with the assumption that all of the primes between 2..23 were going to be factors &#8211; this seemed a reasonable assumption given what I knew of the totient function characteristics.</p>
<p><pre class="brush: groovy; wrap-lines: false;">
def gen_powers(range, maxlen, yield) {
  gen_powers(range, maxlen, [], yield)
}

def gen_powers(range, maxlen, pows, yield) {
  if (pows.size() == maxlen)
    yield(pows)
  else if (pows.size() == 0)
    range.each { gen_powers(range, maxlen, [it], yield) }
  else
    range.findAll { it &gt;= pows[0] }
         .each { gen_powers(range, maxlen, [it]+pows, yield) }
}

def ( answer, TARGET, POWER_RANGE ) = [ Long.MAX_VALUE, 15499/94744, (0..4) ]
def primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ]

gen_powers(POWER_RANGE, primes.size(), [1] * primes.size()- 1) { powers -&gt;
  def (d, factors) = [ 1G, [] ]
  powers.eachWithIndex { v, i -&gt;
    d *= primes[i] ** v
    if (v &gt; 0) factors &lt;&lt; primes[i]
  }
  if ((d &gt; 1) &amp;&amp;
      (answer &gt; d) &amp;&amp;
      (((int)(factors.inject(d) { p, v -&gt; p * (1 - 1/v) })) / (d-1) &lt; TARGET)) {
    answer = d
  }
}
</pre></p>
<p>Despite the heavy use of the slow Groovy listops (and a bit of hacky code) this runs in around 940 ms.</p>
<p>Next will be <a href="http://projecteuler.net/problem=65" target="_blank">Problem #65</a>, a question on continued fractions, that will give me my “<a href="http://projecteuler.net/award=3" target="_blank">As Easy As Pi</a>” award!</p>
<p><strong>Conclusion</strong></p>
<p>With the upfront analysis on the problem and the re-use of the power generator, Groovy made it easy to put together a terse solution that ran in a reasonable time. When doing the calculation of the value of the denominator I did find myself missing Python&#8217;s <a href="http://docs.python.org/library/functions.html#map" target="_blank">map()</a> capability to process <strong>two</strong> lists against a closure and return a result. Sounds like the sort of thing that should be in there, maybe it&rsquo;s buried in the Groovy docs somewhere&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/631/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/631/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/631/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/631/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/631/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/631/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/631/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/631/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/631/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/631/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/631/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/631/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/631/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/631/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=631&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2012/01/21/project-euler-problem-243/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
		<item>
		<title>A 360&#176; View of 3D</title>
		<link>http://keyzero.wordpress.com/2011/09/21/a-360-view-of-3d/</link>
		<comments>http://keyzero.wordpress.com/2011/09/21/a-360-view-of-3d/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 00:38:11 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Chit-Chat]]></category>

		<guid isPermaLink="false">https://keyzero.wordpress.com/2011/09/21/a-360-view-of-3d/</guid>
		<description><![CDATA[The time has come at last to splash out on one of the new fangled plasma or LED TV sets. However, my ancient 28&#34; Panasonic QuintrixF box with the excellent Tau flat-screen, having done 10 years of faithful service (albeit with a couple of repairs during that time), has started to show tell-tale signs of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=624&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The time has come at last to splash out on one of the new fangled plasma or LED TV sets.</p>
<p>However, my ancient 28&quot; Panasonic QuintrixF box with the excellent Tau flat-screen, having done 10 years of faithful service (albeit with a couple of repairs during that time), has started to show tell-tale signs of impending failure &#8211; the Dolby Surround circuitry lost the centre channel a year ago and the picture does an occasional wobble at the top.</p>
<p>I would get it repaired but I&#8217;ve a feeling that finding parts might be problematic now and, besides, there are some excellent new TVs on the market (or so I&#8217;m told) that should do the job AND they&#8217;re 3D capable too.</p>
<p>I&#8217;ve put off buying a new TV over the last few years, even when true 1080p HD came out as the picture quality on these sets, even with all their HD-ness, just wasn&#8217;t up to the QuintrixF Tau screen. When it came to watching standard definition (SD) video on them, they couldn&#8217;t hold a candle to my Panasonic CRT TV.</p>
<p>But it&#8217;s time to look around.&#160; I&#8217;m a bit of sceptic when it comes to the marketing-hype of consumer electronics and like to see the products in real-life use.</p>
<p>The up-market screens from pretty much all the major manufacturers are very capable now, though I&#8217;d argue that their HD picture quality is no better to my current TV, and are much improved in up-scaling SD signals so as to avoid that apparently blurry image especially prevalent on low-bitrate channels.</p>
<p>Buying such an up-market screen generally means getting a 3D-capable set as the manufacturers pair their best panels with the best electronics.&#160; I imagine that this seriously over-weights the statistics of people &quot;buying into&quot; 3D technology over the last year so. </p>
<p>With this in mind, I&#8217;ve spent the last few months pestering friends and relatives who did take the plunge last Christmas and bought a 3D capable set back then.&#160; So now, having now watched quite a bit of 3D footage, courtesy of their hospitality, I&#8217;ve made some observations of the medium.</p>
<p>Apart from the technical issues, such as faded colours, image cross-talk, the physical restrictions of passive 3D glasses and the costs of active 3D glasses that people often talk about, there are four perceptual problems of 3D that I&#8217;ve noticed.&#160; This is just my opinion, but it&#8217;s my blog, so here they are:</p>
<p><strong>Lack of Near-Field Parallax     <br /></strong>I&#8217;m not sure if this is what it is really called but it seems quite descriptive of the effect.&#160; When an object is in the foreground and is apparently close to the viewer, if that viewer moves their head they’d expect the object to move in relation to the background, revealing new areas and obscuring others.&#160; Obviously as the picture is actually flat and only presents a static 3D view this doesn&#8217;t happen and spoils the immersive experience.</p>
<p>This isn&#8217;t such a problem with more distant objects as a viewer expects much less <a href="http://en.wikipedia.org/wiki/Parallax" target="_blank">parallax</a> to occur between such an object and the background.&#160; The best way around this seems to sit still and watch TV as if you&#8217;re in the cinema &#8211; maybe some people do this but, personally, I don&#8217;t.</p>
<p><strong>Assuming an Infinite Depth of Field     <br /></strong>In standard 2D content the director typically denotes the main subject of the scene by focusing on them with a shallow depth of field. The background appears deliberately out of focus but that OK as it&#8217;s pretty much how our eyes work.</p>
<p>In 3D content there seems to be a preference to demonstrate its 3D nature by having an infinite depth of field with everything in focus, even when a &quot;special&quot; 3D effect is used, as is the wont in the traditional realm of 3D horror films.&#160; This practice makes the next two effects seem worse than they might otherwise be.</p>
<p><strong>Billboarding     <br /></strong>I don&#8217;t believe that this is a correct term but it&#8217;s quite descriptive of the apparent effect.&#160; In short, current 3D technologies don&#8217;t seem to capable of providing a completely smooth depth transition between objects in a scene.&#160; I don&#8217;t know if this is a feature of the cameras or the TVs.</p>
<p>This shortcoming leads to &quot;billboarding&quot; &#8211; in that it appears that a 2D picture of a 3D scene has been pasted onto a billboard which is then set at a distance into the scene. This technique used in video game development to reduce the computational complexity in rendering.</p>
<p>The scene is seen to be composed of a set of these &quot;planes&quot; rather than being smoothly graduated.&#160; In worst cases, this effect is even seen on single objects. For example, on one demo the viewer was taken across the <a href="http://en.wikipedia.org/wiki/Ponte_Sant'Angelo" target="_blank">Pont Sant&#8217;Angelo</a> in Rome (which I recommend visiting sometime) and there were close ups on the <a href="http://en.wikipedia.org/wiki/Ponte_Sant'Angelo#List_of_angels" target="_blank">17C angelic statues</a>.</p>
<p>Unfortunately, although the picture was excellent, the statues appeared dislocated. Where a hand was pointing “out” of the screen it was disjointed from the forearm, which was on another &quot;plane&quot;, and this extended to the shoulder, wings, etc. It was as if it was a <a href="http://www.youtube.com/watch?v=-CVdllN67OQ" target="_blank">Channel 4 ident</a> with pieces of stone suspended on invisible wires and visible as a solid body only when viewed from a specific angle.</p>
<p><strong>Focal Distance Adjustment     <br /></strong>This seems to sort of related to the &quot;Infinite Depth of Field&quot; issue I&#8217;ve mentioned above.&#160; In order to &quot;believe&quot; a 3D scene, it seems that my eyes have to be fooled into assuming that the objects are a certain distance away.&#160; When the scene shifts whereby the &quot;focus&quot; is now apparently at a different distance but remains in focus without my eyes having to re-adjust, it seems wrong. At best this just destroys the illusion of 3D until I &quot;lock in&quot; again but, at worst, it makes me feel a little seasick!</p>
<p>So what do I believe this means for 3D TV?</p>
<p>The technology will continue to improve so the technical concerns will probably be consigned to history within the next few generations of the systems themselves.</p>
<p>The limitations of physical equipment will be solved as, I imagine, should the &quot;billboarding&quot; effect described above &#8211; unless this is actually some form of physiological limitation of human cognitive processing.</p>
<p>The issue with lack of near field parallax will probably drive the adoption of VERY large 60”+ screens that can be placed farther away from the viewer so that the problem is just less pronounced.&#160; Unless the TV can generate a private 3D image for each viewer and use some form of individual eye tracking I don’t see how else this might be tackled.</p>
<p>The other issues are really a matter of direction style.&#160; The modern way of shooting 2D TV seems to to use close in cameras with rapidly changing viewpoints in order to engage the viewer and make them feel like they’re actually part of the action.&#160; What works well for 2D simply doesn’t work for 3D.&#160; The rapidly changing perspective just leads to disorientation and destroys the immersive 3D experience.</p>
<p>I believe that, for 3D, viewers need to be treated more like a theatre audience as passive onlookers onto a scene.&#160; Viewpoints need to be established and held in order for the audience to “lock in” to the scene’s perspective.&#160; This means that the 2D version of a film won’t just be a single-eye image of a 3D film but, for a large part, a differently shot piece of work.&#160; Obviously this will push up production costs.&#160; I don’t like to think that we’ll be seeing 2D movies going the same way as black and white movies and only being shot as art nouveau retro pieces.</p>
<p>In short, 3D holds a lot of promise, especially in the gaming market where the scene is being generated on the fly, but for general viewing I’m really not convinced that there’s a great need at the moment (sport may be an exception though) until the content production industry works out how to handle the artistic differences between 2D and 3D in order to get the most from both mediums.&#160; There is some fantastic 3D content out there but not enough to warrant buying a 3D set specifically to see it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/624/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=624&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2011/09/21/a-360-view-of-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
		<item>
		<title>1. IDEA, 2. Kotlin, 3. Profit.</title>
		<link>http://keyzero.wordpress.com/2011/07/29/1-idea-2-kotlin-3-profit/</link>
		<comments>http://keyzero.wordpress.com/2011/07/29/1-idea-2-kotlin-3-profit/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 07:57:33 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Chit-Chat]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[ceylon]]></category>
		<category><![CDATA[closure]]></category>
		<category><![CDATA[commerce]]></category>
		<category><![CDATA[high-order functions]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[jee]]></category>
		<category><![CDATA[jetbrains]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[kotlin]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[profit]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://keyzero.wordpress.com/?p=608</guid>
		<description><![CDATA[I was interested to see that JetBrains, creators of the splendid IntelliJ IDEA IDE amongst other things, are working on their own &#8220;better-Java-than-Java&#8221; language, Kotlin. Ostensibly this is to resolve some of the &#8220;issues&#8221; that the Java language has, whilst being simpler than the currently strongest competitor, Scala.  Kotlin is going to be supported as a first-class [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=608&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was interested to see that <a href="http://www.jetbrains.com/">JetBrains</a>, creators of the splendid <a href="http://www.jetbrains.com/idea/">IntelliJ IDEA IDE</a> amongst other things, are working on their own &#8220;better-Java-than-Java&#8221; language, <a href="http://confluence.jetbrains.net/display/Kotlin/Welcome">Kotlin</a>.</p>
<p>Ostensibly this is to resolve some of the &#8220;issues&#8221; that the Java language has, whilst being simpler than the currently strongest competitor, <a href="http://www.scala-lang.org/">Scala</a>.  Kotlin is going to be supported as a first-class citizen in the IDEA IDE from around the end of 2011.</p>
<p>There&#8217;s a lot of talk on various fora about the need (or lack of) for introducing a new language when others like Scala, Groovy and Clojure are becoming more established.  This is similar to the fuss back in April 2011 when Gavin King &#8220;<a href="http://www.infoq.com/presentations/ceylon">leaked</a>&#8221; the news that Red Hat were working on their &#8220;<a href="http://en.wikipedia.org/wiki/Ceylon_Project">Ceylon</a>&#8221; JVM-hosted language.  The public launch of Ceylon is likely to be in the same sort of timescale.</p>
<p>Most of the chatter seems to be about the benefits around the features of the languages, semantic overhead of learning, efficiency of execution, dilution of Java skillsets, etc.  All are interesting and sound discussions.</p>
<p>What I&#8217;m not seeing is anyone saying about the pure commercial value of a company such as JetBrains or RedHat launching their languages focusing on their their own ecosystems.  I don&#8217;t believe these guys aren&#8217;t doing it for the love of the Java community. They&#8217;re doing it for cold, hard cash&#8230; any why not?</p>
<p>It&#8217;s interesting that JetBrains are saying that Kotlin is intended for &#8220;industrial use&#8221;.  By this I&#8217;m expecting the real value-add features (which must be compelling) to be supported in their paid-for &#8220;Ultimate&#8221; edition of IDEA rather than the free &#8221;Community&#8221; version and they&#8217;re targeting the &#8220;enterprise&#8221; market.</p>
<p>They would need to convince &#8220;corporate&#8221; development managers of the benefits of the Kotlin, disabuse them of the risks of selecting a single vendor language  and get it embedded into their companies order to monetise the investment in developing it.</p>
<p>That&#8217;s not to say they&#8217;re wrong to try - look at how successful VB6 was and that&#8217;s a single company language supported by a strong IDE!</p>
<p>They&#8217;ll have to be quick though.</p>
<p>Java 7 has just been <a href="http://www.infoq.com/news/2011/07/javase7-ga">released</a> and Java 8 is due in late 2012.  Whilst J7 addresses quite a few &#8220;niggles&#8221; with Java (including reducing some noise around <a href="http://en.wikipedia.org/wiki/Generics_in_Java">Generics</a> and the equivalent of <a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a>&#8216;s &#8220;<a href="http://en.wikibooks.org/wiki/C_Sharp_Programming/Keywords/using">using</a>&#8221; statement)  and add some good features into the JVM it&#8217;s not the complete &#8220;Project Coin&#8221; package.</p>
<p>The &#8220;big thing&#8221; being sold in all these new languages are Lambdas/Closures which won&#8217;t come until J8.  (You can see the split of features <a href="http://blogs.oracle.com/henrik/entry/java_roadmap_from_javaone_2010">here</a>.) This means that they&#8217;ll have 12 months to get some traction before the &#8220;official&#8221; Java language supports this.</p>
<p>Personally, I don&#8217;t believe that having closures in an OO imperative language is that important.  Useful, of course, but not the end of world if they&#8217;re lacking.  There didn&#8217;t seem to be much demand for them in Java before <a href="http://rubyonrails.org/">Ruby on Rails</a> became popular in 2006 and there was an outbreak of scripting-envy across the Java community.</p>
<p>Of course, with the JVM bytecode instruction <a href="http://jcp.org/en/jsr/detail?id=292">InvokeDynamic</a> being added in Java 7 it means that dynamic language such as <a href="http://www.jruby.org/">JRuby</a> should become much more performant so, if you really want closures on the JVM why not just use that?</p>
<p>I think it&#8217;s disappointing that the official Java/JVM ecosystem has been on a bit of a hiatus for the last 5 years (Java 6 was released in 2006) but it&#8217;s kind of understandable given the situation with Sun and Oracle.  It&#8217;s also disappointing that Coin was split across two releases as this will delay adoption too and, in the Java world, allow third-parties to fill the perceived gap with semi-official solutions in the interim.</p>
<p>It will be interesting to see how this all plays out.  I do hope it doesn&#8217;t distract JetBrain or RedHat/JBoss from continuting to provide world-class platform support for the official Java stack on their products.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/608/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/608/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/608/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/608/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/608/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/608/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/608/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/608/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/608/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/608/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/608/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/608/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/608/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/608/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=608&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2011/07/29/1-idea-2-kotlin-3-profit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler Problem #86</title>
		<link>http://keyzero.wordpress.com/2011/05/24/project-euler-problem-86/</link>
		<comments>http://keyzero.wordpress.com/2011/05/24/project-euler-problem-86/#comments</comments>
		<pubDate>Tue, 24 May 2011 22:55:55 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Project Euler Solutions 081-090]]></category>

		<guid isPermaLink="false">https://keyzero.wordpress.com/2011/05/24/project-euler-problem-86/</guid>
		<description><![CDATA[Read the details of the problem here Summary Exploring the shortest path from one corner of a cuboid to another. Solution It’s been a while since I’ve posted a Project Euler solution and the ones I have posted have been catch-ups. The other day I saw a specific search on this site for a solution [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=584&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://projecteuler.net/index.php?section=problems&amp;id=86" target="_blank">Read the details of the problem here</a></p>
<p><strong>Summary</strong></p>
<p>Exploring the shortest path from one corner of a cuboid to another.</p>
<p><strong>Solution</strong></p>
<p>It’s been a while since I’ve posted a Project Euler solution and the ones I have posted have been catch-ups. The other day I saw a specific search on this site for a solution to Problem 86 which I hadn’t yet completed so I thought I’d give it a go&#8230;</p>
<p>On first reading this seemed a little unclear but it comes apart quite easily with a little prodding and poking. Taking the example that Euler gives and flattening it makes it apparent what’s going on. The shortest path (SF) is the hypotenuse of a Pythagorean triangle with sides of { 6, 8 (3+5), 10 }.</p>
<p><a href="http://keyzero.files.wordpress.com/2011/05/pe0086_1.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:5px;" title="pe0086_1" border="0" alt="pe0086_1" src="http://keyzero.files.wordpress.com/2011/05/pe0086_1_thumb.jpg?w=237&#038;h=181" width="237" height="181" /></a></p>
<p>The diagram below shows the case of an M x M x M cuboid to demonstrate the three variants of the shortest path in a very obvious manner.</p>
<p><a href="http://keyzero.files.wordpress.com/2011/05/pe0086_2.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:5px;" title="pe0086_2" border="0" alt="pe0086_2" src="http://keyzero.files.wordpress.com/2011/05/pe0086_2_thumb.jpg?w=244&#038;h=205" width="244" height="205" /></a></p>
<p>So it’s just a case of checking for Pythagorean triangles with an adjacent side of length M, and up to 2M for the opposite side. Note that, due to this abstraction from the actual cuboid, it’s not necessary to deal with the other two sides individually &#8211; the opposite side length is taken as the total of the depth and height of the cuboid. Once a suitable triangle is found the number of solutions for it, taking into account the ways in which the opposite side length may be composed for any given potential cuboids, are added onto the running total.</p>
<p>
<pre class="brush: groovy; wrap-lines: false;">
def ( answer, solutions ) = [ 1, 0 ]

while (true) {
  for (i in 2..(2 * answer)) {
    def hyp = Math.sqrt(answer * answer + i * i)
    if (hyp == Math.floor(hyp)) {
      solutions += (i ? answer + 1) ?
          (answer + answer + 2 - i).intdiv(2) : i.intdiv(2)
    }
  }
  if (solutions &gt; 1e6) break
  answer++
}
</pre>
</p>
<p>The solution is quite succinct and, even though it’s simply a brute force algorithm, runs in around 1.31 seconds &#8211; so well within the 15 second target. Smarter algorithms might include changing this one to a bisection search of across the solution space, or maybe pre-generating Pythagorean triangles and driving directly off of those.</p>
<p><strong>Conclusion</strong></p>
<p>Groovy was perfectly fast enough for solving this problem, both in terms of coding and runtime. From a performance perspective it’s advisable to use the Math.floor() function rather than a straight cast to (int) and calling intdiv() is also a must compared to a straight division.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/584/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/584/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/584/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=584&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2011/05/24/project-euler-problem-86/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>

		<media:content url="http://keyzero.files.wordpress.com/2011/05/pe0086_1_thumb.jpg" medium="image">
			<media:title type="html">pe0086_1</media:title>
		</media:content>

		<media:content url="http://keyzero.files.wordpress.com/2011/05/pe0086_2_thumb.jpg" medium="image">
			<media:title type="html">pe0086_2</media:title>
		</media:content>
	</item>
		<item>
		<title>The Tau of Pi</title>
		<link>http://keyzero.wordpress.com/2011/04/14/the-tau-of-pi/</link>
		<comments>http://keyzero.wordpress.com/2011/04/14/the-tau-of-pi/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 23:20:34 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Chit-Chat]]></category>
		<category><![CDATA[tau pi manifesto mathematics equation circle formula radius circumference diameter constant geometry]]></category>

		<guid isPermaLink="false">https://keyzero.wordpress.com/2011/04/14/the-tau-of-pi/</guid>
		<description><![CDATA[I came across this interesting article – The Tau Manifesto. It&#8217;s proposed that the stalwart constant of geometry &#8211; Pi (π) &#8211; be replaced by a new, more natural constant &#8211; Tau (τ) &#8211; which is simply Circumference/Radius and is so equivalent to 2π. They make quite a convincing argument as to why this should [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=576&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I came across this interesting article – <a href="http://tauday.com/" target="_blank">The Tau Manifesto</a>.</p>
<p>It&rsquo;s proposed that the stalwart constant of geometry &#8211; Pi (π) &#8211; be replaced by a new, more natural constant &#8211; Tau (τ) &#8211; which is simply Circumference/Radius and is so equivalent to 2π.  They make quite a convincing argument as to why this should be the case.</p>
<p>Those multiples of 2&pi; in equations always made me twitchy&#8230; and now I realise why!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/576/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=576&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2011/04/14/the-tau-of-pi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
		<item>
		<title>Blackberry shows off the Playbook tablet</title>
		<link>http://keyzero.wordpress.com/2011/03/03/blackberry-shows-off-the-playbook-tablet/</link>
		<comments>http://keyzero.wordpress.com/2011/03/03/blackberry-shows-off-the-playbook-tablet/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 00:25:29 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://keyzero.wordpress.com/?p=572</guid>
		<description><![CDATA[Always makes me chuckle when some marketing guy talks, in early 2011, about how their software fully supports HTML5 when that set of APIs aren’t even due to meet a Candidate Recommendation stage until 2012 (some 4 YEARS late) and have a target of 2014 for completion. The Last Call for comments isn’t until May [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=572&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Always makes me chuckle when some marketing guy talks, in early 2011, about how their software fully supports <a href="http://en.wikipedia.org/wiki/HTML5">HTML5 </a>when that set of APIs aren’t even due to meet a Candidate Recommendation stage until 2012 (some 4 <strong>YEARS</strong> late) and have a target of 2014 for completion.  The Last Call for comments isn’t until May 2012 so it really seems like a very <del>foolish</del> brave statement to make.</p>
<p><a href="http://www.bbc.co.uk/news/technology-12476859">http://www.bbc.co.uk/news/technology-12476859</a></p>
<p>At some point I&#8217;ll take a look to see exactly what subset of HTML5 APIs they’re currently supporting and at what specification snapshot level.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/572/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=572&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2011/03/03/blackberry-shows-off-the-playbook-tablet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
		<item>
		<title>Amazon Kindle Color</title>
		<link>http://keyzero.wordpress.com/2011/01/18/amazon-kindle-color/</link>
		<comments>http://keyzero.wordpress.com/2011/01/18/amazon-kindle-color/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 00:43:12 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://keyzero.wordpress.com/?p=565</guid>
		<description><![CDATA[Any rumors that Amazon are going to be launching an Amazon Kindle Color based on Qualcomm Mirasol display technology at around the same time as the Apple iPad2 release are completely unfounded. Pity. I&#8217;d want one.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=565&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Any rumors that Amazon are going to be launching an <a href="http://www.pcworld.com/article/192154/color_and_video_for_amazons_kindle_ebook_reader.html">Amazon Kindle Color</a> based on <a href="http://www.qualcomm.com/products_services/consumer_electronics/displays/mirasol/index.html">Qualcomm Mirasol</a> display technology at around the same time as the <a href="http://www.techradar.com/news/computing/apple/ipad-2-rumours-what-you-need-to-know-900232">Apple iPad2</a> release are completely unfounded.</p>
<p>Pity. I&#8217;d want one.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/565/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=565&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2011/01/18/amazon-kindle-color/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
		<item>
		<title>IE9 previewed on BBC.co.uk</title>
		<link>http://keyzero.wordpress.com/2010/09/15/ie9-previewed-on-bbc-co-uk/</link>
		<comments>http://keyzero.wordpress.com/2010/09/15/ie9-previewed-on-bbc-co-uk/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 18:19:31 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Chit-Chat]]></category>

		<guid isPermaLink="false">https://keyzero.wordpress.com/2010/09/15/ie9-previewed-on-bbc-co-uk/</guid>
		<description><![CDATA[Great. Now Internet Explorer can consume 100% of my PC&#8217;s resources. Like it doesn&#8217;t do that already&#8230;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=561&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Great. Now Internet Explorer can <a href="http://www.bbc.co.uk/news/technology-11315819" target="_blank">consume 100% of my PC&#8217;s resources</a>. Like it doesn&rsquo;t do that already&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/561/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=561&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2010/09/15/ie9-previewed-on-bbc-co-uk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler Problem #92</title>
		<link>http://keyzero.wordpress.com/2010/09/11/project-euler-problem-92/</link>
		<comments>http://keyzero.wordpress.com/2010/09/11/project-euler-problem-92/#comments</comments>
		<pubDate>Sat, 11 Sep 2010 18:27:54 +0000</pubDate>
		<dc:creator>keyzero</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Project Euler Solutions 091-100]]></category>

		<guid isPermaLink="false">https://keyzero.wordpress.com/2010/09/11/project-euler-problem-92/</guid>
		<description><![CDATA[Read the details of the problem here Summary Investigating a square digits number chain with a surprising property. Solution Simple and straight-forward non-mathematical problem to solve. I coded up the following program &#8211; note that after one pass the value of the sum of the squares will reduce to 7&#215;92 (or 567) at most so [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=555&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://projecteuler.net/index.php?section=problems&amp;id=92" target="_blank">Read the details of the problem here</a></p>
<p><strong>Summary</strong></p>
<p>Investigating a square digits number chain with a surprising property.</p>
<p><strong>Solution</strong></p>
<p>Simple and straight-forward non-mathematical problem to solve. I coded up the following program &#8211; note that after one pass the value of the sum of the squares will reduce to 7&#215;9<sup>2</sup> (or 567) at most so the cache is relatively small for the entire range of numbers.</p>
<p><pre class="brush: groovy; wrap-lines: false;">
def LIMIT = 10000000
def CACHE_SIZE = 9 * 9 * 7
def sumsOfSquares = new int[CACHE_SIZE+1]

Arrays.fill(sumsOfSquares,0)
sumsOfSquares[1] = 1
sumsOfSquares[89] = 89

def answer = 0

for (i in 2..LIMIT) {

  def sum = i

  while ((sum != 1) &amp;&amp; (sum != 89)) {
    def n = sum
    sum = 0

    for (c in n.toString()) {
      def v = c.toInteger()
      sum += v * v
    }

    if (sumsOfSquares[sum] != 0) sum = sumsOfSquares[sum]
  }
  if (i &lt;= CACHE_SIZE) sumsOfSquares[i] = sum
  if (sum == 89) answer++
}
</pre></p>
<p>This ran in 36.14 seconds so it was well outside my 15 second target. I did some tweaks to the code converting it into to a recursive function and trying some extra cache lookups at the beginning of the calculation but only managed to reduce the runtime down to 31.81 seconds. (Using Groovy listops rather than the explicit loops for calculating the sum pushes the time out to over 2 minutes.) Although a straight Java conversion would probably run in a second or two I felt that some improvement could be made to the algorithm as the curent solution didn&rsquo;t really use much of one to speak of.</p>
<p>The obvious observation is that the sum of squares function is being performed many times for numbers that are fundamentally the same as the sum will be the same for all permutations of a given set of digits i.e. the number 3241218, is the same as 2314821 or 1122348. A quick experiment revealed that there are only 11,440 such unique permutations &#8211; that would reduce the number of times the expensive summing operation had to be called by a factor of around 870.</p>
<p>In order to maintain the count it would be necessary to know many times a given set of digits can occur in the full 10<sup>7</sup> range. This is simply the factorial of the total number of elements divided by the product of the factorials of the counts of the unique elements.</p>
<p>As there were only a total of 7 digits I could have just coded nested loops to construct the numbers but I already had a generator for such a purpose built as part of the solution to <a href="http://keyzero.wordpress.com/2010/06/12/project-euler-problem-110/" target="_blank">Problem #110</a>. This generates the digits in descending order and is general purpose but would do the job easily though, as it uses Groovy listops, isn&rsquo;t the fastest means.</p>
<p>So it was just a case of pre-populating the cache, generating the unique digit sequences, calculating the initial sum of squares, pulling the terminal result from the cache and, for those that resulted in 89 getting the multiples of that to add to the total.</p>
<p><pre class="brush: groovy; wrap-lines: false;">
def sumOfSquares(n) {
  def sum = 0
  for (c in n.toString()) {
    def v = c.toInteger()
    sum += v * v
  }
  return sum
}

def permutations(n) {
  def factorials = [ 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 ]                     
  def s = 1
  for (i in n) {
    s *= factorials[i]
  }
  return factorials[7].intdiv(s)
}

def gen_digits(range, maxlen, yield) {
  gen_digits(range, maxlen, [], yield)
}

def gen_digits(range, maxlen, digits, yield) {
  if (digits.size() == maxlen)
    yield(digits)
  else if (digits.size() == 0)
    range.each { gen_digits(range, maxlen, [it], yield) }
  else
    range.findAll { it &gt;= digits[0] }
         .each { gen_digits(range, maxlen, [it]+digits, yield) }
}

def MAX = 9 * 9 * 7
def sumsOfSquares = new int[MAX+1]

Arrays.fill(sumsOfSquares,0)
sumsOfSquares[1] = 1
sumsOfSquares[89] = 89

for (i in 2..MAX) {
  def sum = i
  while ((sum != 1) &amp;&amp; (sum != 89)) {
    sum = sumOfSquares(sum)
    if (sumsOfSquares[sum] != 0) sum = sumsOfSquares[sum]
  }
  sumsOfSquares[i] = sum
}

def answer = 0

gen_digits((0..9), 7) { digits -&gt;
  def sum = sumsOfSquares[sumOfSquares(digits.join().toInteger())]
  if (sum == 89) {
    def nn = new int[10]
    digits.each { nn[it]++ }
    answer += permutations(nn)
  }
}
</pre></p>
<p>It&#8217;s all a little too verbose for my liking but does run in 0.57 seconds so nicely succeeds in the objective. Expanding out the listops to explicit loops in the gen_digits() generator method reduces the runtime to 0.36 seconds &#8211; a substantial saving of 37% but at the expense of a few more lines of code.</p>
<p><strong>Conclusion</strong></p>
<p>Groovy general &ldquo;slowness&rdquo; meant that some &ldquo;cleverness&rdquo; was required to get this to execute in a reasonable amount of time. If I&#8217;d been using C++ or native Java for this I would have just stuck with the simple initial approach.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keyzero.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keyzero.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/keyzero.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/keyzero.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/keyzero.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/keyzero.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/keyzero.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/keyzero.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/keyzero.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/keyzero.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/keyzero.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/keyzero.wordpress.com/555/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/keyzero.wordpress.com/555/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/keyzero.wordpress.com/555/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keyzero.wordpress.com&amp;blog=8719922&amp;post=555&amp;subd=keyzero&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keyzero.wordpress.com/2010/09/11/project-euler-problem-92/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3386ec19565e435c6392f9c2bc4c78a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keyzero</media:title>
		</media:content>
	</item>
	</channel>
</rss>
