<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-9193160645817040317</atom:id><lastBuildDate>Wed, 17 Dec 2025 08:36:59 +0000</lastBuildDate><category>Solution</category><category>Java</category><category>Puzzle</category><category>Puzzles</category><category>Programming</category><category>Operator</category><category>Tresure Hunt</category><category>Arithmetic</category><category>Optimization</category><category>Updates</category><category>Floating Point Arithmetic</category><category>Inheritance</category><category>Loop</category><category>Operators</category><category>Recursion</category><category>SoftReference</category><category>String</category><category>Swap</category><category>Vacation</category><category>Autoboxing</category><category>Birthday</category><category>Code Complete</category><category>Code challenge</category><category>Comeback</category><category>Double</category><category>Future</category><category>Garbage Collector</category><category>Generics</category><category>List</category><category>Multithreading</category><category>News</category><category>Overloading</category><category>Points</category><category>Polymorphism</category><category>Primitive Type</category><category>Quiz4j</category><category>Set</category><category>Substraction</category><category>Swapping</category><category>Wrapper Class</category><title>Twisters - The New Age Java Quiz</title><description>Java Coding with a difference!</description><link>http://java-twisters.blogspot.com/</link><managingEditor>noreply@blogger.com (Saifuddin Merchant)</managingEditor><generator>Blogger</generator><openSearch:totalResults>138</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-8380430188281429278</guid><pubDate>Tue, 06 Dec 2011 18:47:00 +0000</pubDate><atom:updated>2011-12-07T00:53:59.613+05:30</atom:updated><title>Javachats - My Personal Blog</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Its been over a year since I wrote a blog post. I ran out of puzzles - after all how many quirks could a single language have ;)!&lt;br /&gt;
&lt;br /&gt;
I started writing out a bit again - this time its a more personal blog. More about stuff I do, things day in and day out and the occasional general post. Of course since I work in and around Java most if it would be about Java!&lt;br /&gt;
&lt;br /&gt;
Hoping to see some old friends again @ my new blog - &lt;a href=&quot;http://javachats.blogspot.com/&quot;&gt;http://javachats.blogspot.com/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Signing off - Sam!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://java-twisters.blogspot.com/2011/12/javachats-my-personal-blog.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-7547401508302099074</guid><pubDate>Mon, 02 Aug 2010 14:19:00 +0000</pubDate><atom:updated>2010-08-08T13:35:44.578+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Future</category><category domain="http://www.blogger.com/atom/ns#">Multithreading</category><title>Puzzle 64 - The Future is Secure</title><description>Java 1.5 adds a lot when it comes to threading. However thread programing is always a little tricky and Threading casually can lead to problems - &lt;b&gt;With Great Power Come Great Responsibility&lt;/b&gt;. There is a Major bug (and a minor performance bug). Can you spot them both? &lt;br /&gt;
&lt;br /&gt;
&lt;div id=&#39;iframeDivc7931e4e-76d7-4c93-ac42-3eca64289255&#39; style=&#39;display:none;margin:0px;&#39;&gt;&lt;iframe id=&#39;iframec7931e4e-76d7-4c93-ac42-3eca64289255&#39; src=&#39;http://www.blogtrog.com/code.aspx?id=c7931e4e-76d7-4c93-ac42-3eca64289255&#39; style=&#39;width: 500px; height: 500px; border: 1px solid #e0e0e0;margin:0px;&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&#39;noIframeDivc7931e4e-76d7-4c93-ac42-3eca64289255&#39; style=&#39;display:block;margin:0px;&#39;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; com.test;

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.Random;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.concurrent.Callable;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.concurrent.ExecutionException;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.concurrent.Executor;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.concurrent.Future;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.concurrent.FutureTask;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.concurrent.ScheduledThreadPoolExecutor;

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; MyObject {
    
        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Executor ex &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ScheduledThreadPoolExecutor(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
        
        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; main(String[] args) &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; InterruptedException, ExecutionException {
            
            Tracker t &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Tracker();
            Future&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Tracker&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; f[] &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Future[&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;];
            
            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;;i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;;i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;){
                &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;The code in MyFutureTask.call() would be executed sometime in the future&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
                f[i] &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; FutureTask&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Tracker&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; MyFutureTask(t));
                ex.execute((Runnable) f[i]);
            }
            
            &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;Wait for all the future task to complete!&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;;i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;;i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;){
                f[i].get();
            }
            
            &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;Print out the number of future task that we have completed&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
            System.out.println(t.getValue());    &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;This prints the number of task executed - 1000&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
        }
}

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; MyFutureTask &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;implements&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Callable&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Tracker&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;{

    Tracker myTracker;
    MyFutureTask(Tracker t)
    {
        myTracker &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; t;
    }
    
    @Override
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;synchronized&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Tracker call() &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Exception {
        
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;Some complex business logic inserted at this point&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; rand &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Random().nextInt(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
        Thread.sleep(rand);
    
        myTracker.increment();
        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; myTracker;
    }
}

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Tracker{
    Integer value &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;;
    
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; increment()
    {
        value&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;;
    }
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; getValue(){
        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; value;
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&#39;javascript&#39; src=&#39;http://www.blogtrog.com/scripts/bt_code.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;&lt;script language=&#39;javascript&#39; type=&#39;text/javascript&#39;&gt;bt_code_init(&#39;c7931e4e-76d7-4c93-ac42-3eca64289255&#39;);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2010/08/puzzle-63-future-is-secure.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-6302700114903348011</guid><pubDate>Wed, 28 Jul 2010 05:30:00 +0000</pubDate><atom:updated>2010-07-28T11:00:17.840+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Autoboxing</category><title>Puzzle 63 - Out of the Box</title><description>Java 1.5 introduced Autoboxing and since then a lot of code has been indiscriminately been using Autoboxing. I&#39;ve picked up a simple case this time around (in fact its based on Joshua Bloch&#39;s - Effective Java). We&#39;ll look at a more real world problem next week.&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&#39;iframeDivf8d3006b-0245-454d-ab87-2ad9a03e58ac&#39; style=&#39;display:none;margin:0px;&#39;&gt;&lt;iframe id=&#39;iframef8d3006b-0245-454d-ab87-2ad9a03e58ac&#39; 

src=&#39;http://www.blogtrog.com/code.aspx?id=f8d3006b-0245-454d-ab87-2ad9a03e58ac&#39; style=&#39;width: 500px; height: 300px; border: 1px solid #e0e0e0;margin:0px;&#39; 

frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&#39;noIframeDivf8d3006b-0245-454d-ab87-2ad9a03e58ac&#39; style=&#39;display:block;margin:0px;&#39;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; com.test;

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.Comparator;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt; Order {

    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; main(String[] args) {
        Comparator&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span 

style=&quot;color: #000000;&quot;&gt; naturalOrder &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: 

#0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Comparator&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(){
            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt; compare(Integer first, Integer second)
            {
                &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; first &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span 

style=&quot;color: #000000;&quot;&gt; second &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;-&lt;/span&gt;&lt;span 

style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; :(first &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; second 

&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
            }
        };
        
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;This one is obviously broken - outputs 1 instead of 0 - Why?&lt;/span&gt;&lt;span 

style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
        System.out.println(naturalOrder.compare(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Integer(&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Integer(&lt;/span&gt;&lt;span 

style=&quot;color: #000000;&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)));
        
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;This one works but is still broken - outputs 0 as expected! - Why is this 

broken?&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
        System.out.println(naturalOrder.compare(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;));
    }
}
&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&#39;javascript&#39; src=&#39;http://www.blogtrog.com/scripts/bt_code.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;&lt;script language=&#39;javascript&#39; 

type=&#39;text/javascript&#39;&gt;bt_code_init(&#39;f8d3006b-0245-454d-ab87-2ad9a03e58ac&#39;);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2010/07/puzzle-63-out-of-box.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-2475758509249432014</guid><pubDate>Sun, 18 Jul 2010 06:24:00 +0000</pubDate><atom:updated>2010-07-18T11:54:43.563+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Generics</category><title>Puzzle 62 - WARNING - Is this the End?</title><description>The world is about to end, but maybe, just maybe there is some Hope. So it give it a spin and try it. After all the fate of Earth rests in your hands!&lt;br /&gt;
(The code is well commented, I think you&#39;ll find everything you need out there.)&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&#39;iframeDiv562bc2e5-0a53-44d9-80a8-710e405d7ecf&#39; style=&#39;display:none;margin:0px;&#39;&gt;&lt;iframe id=&#39;iframe562bc2e5-0a53-44d9-80a8-710e405d7ecf&#39; src=&#39;http://www.blogtrog.com/code.aspx?id=562bc2e5-0a53-44d9-80a8-710e405d7ecf&#39; style=&#39;width: 500px; height: 600px; border: 1px solid #e0e0e0;margin:0px;&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&#39;noIframeDiv562bc2e5-0a53-44d9-80a8-710e405d7ecf&#39; style=&#39;display:block;margin:0px;&#39;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; com.test;

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.ArrayList;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.List;

&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;This class had been set to trigger on December 21, 2012.
 *Due to a programming this class will trigger off in the next 15 mins 
 *of you reading it. 
 *Yes its a know issue and we&#39;ve sorry about it, but right now there are other major
 *issues to solve and this can wait for later!
 *&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; DoomsDayEarth 
{
    &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;No point in returning anything once the world has been destroyed!&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; destroyWorld(List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;EvilObject&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; evilObjects)
    {
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;You do get a chance to save the world. Try it!&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
        Hope.save(evilObjects);
        
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;This code destroys the world and prints world destroyed.
         *Prevent that from happening and if possible get it to print world saved
         * &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(Destroy d : evilObjects)
        {
            d.destroy();
        }
    }
    
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; main(String[] args) {
        List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;EvilObject&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; evil &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;EvilObject&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;();
        evil.add(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; EvilObject());
        DoomsDayEarth.destroyWorld(evil);
    }
}

&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;This is the only class that you can modify. Whatever happens there is always Hope!&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Hope
{
    &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;Write some code here that will save the world. Remember you just have 15 mins
     *to save the world, before main starts up, so be quick.
     *&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; save(List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;EvilObject&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; evilObjects)
    {
    }
}

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;interface&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Destroy{
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; destroy();
}

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; EvilObject &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;implements&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Destroy
{
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; destroy()
    {
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;This method has the power to destroy the world!
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;To prevent any possible misuse, the code has been censored
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;and is not published on twisters!&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;        System.out.println(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;The world is destroyed!&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
    }
}

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; GoodObject &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;implements&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Destroy
{
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; destroy()
    {
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;This method does nothing. Its sole purpose is to replicate the EvilObject
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;without doing any evil!!&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;        System.out.println(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;The world is saved!&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&#39;javascript&#39; src=&#39;http://www.blogtrog.com/scripts/bt_code.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;&lt;script language=&#39;javascript&#39; type=&#39;text/javascript&#39;&gt;bt_code_init(&#39;562bc2e5-0a53-44d9-80a8-710e405d7ecf&#39;);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2010/07/puzzle-62-warning-is-this-end.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>10</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-1663568362487403013</guid><pubDate>Sun, 11 Jul 2010 17:26:00 +0000</pubDate><atom:updated>2010-07-12T10:09:53.857+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">List</category><category domain="http://www.blogger.com/atom/ns#">Optimization</category><category domain="http://www.blogger.com/atom/ns#">Set</category><title>Puzzle 61 - Set for Optimization?</title><description>I&#39;m back with an optimization question. Lately I&#39;ve been dealing with some huge volume of data and I&#39;ve realized how performance can start to be a serious problem as the data increases. Here is a small illustration with relatively less data (50,000 values). Hopefully the question should be self explanatory from the code. &lt;br /&gt;
&lt;br /&gt;
&lt;div id=&#39;iframeDiv26a04a05-3511-4087-ab4b-624ba95a0241&#39; style=&#39;display:none;margin:0px;&#39;&gt;&lt;iframe id=&#39;iframe26a04a05-3511-4087-ab4b-624ba95a0241&#39; src=&#39;http://www.blogtrog.com/code.aspx?id=26a04a05-3511-4087-ab4b-624ba95a0241&#39; style=&#39;width: 500px; height: 600px; border: 1px solid #e0e0e0;margin:0px;&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&#39;noIframeDiv26a04a05-3511-4087-ab4b-624ba95a0241&#39; style=&#39;display:block;margin:0px;&#39;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; com.test;

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.List;
&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; java.util.ArrayList;

&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; MyCollection{

    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; populateList(List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; l, &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; multiple){
        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;; i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;50000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;; i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;){
            Long value &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Long.valueOf(i&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;multiple);
            l.add(value);
        }
    }
    
    &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; main(String[] args) {
        List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; listOf2 &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;();
        populateList(listOf2, &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
        
        List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; listOf3 &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;();
        populateList(listOf3, &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
        
        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; startTimestamp, endTimestamp; 
        List&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; commonA &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;, commonB &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;, commonC &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;;
        
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;First Attempt - Runs in  60 seconds&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;        startTimestamp &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; System.currentTimeMillis();
        commonA &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(listOf2);
        commonA.retainAll(listOf3);
        endTimestamp &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; System.currentTimeMillis();
        System.out.println(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Execution Time : &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (endTimestamp&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;startTimestamp)&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
        
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;Second Attempt - Runs in 73 seconds - 
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;There are fewer elements in commonB shouldn&#39;t this run faster?&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;        startTimestamp &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; System.currentTimeMillis();
        commonB &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Long&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(listOf3);
        commonB.retainAll(listOf2);
        endTimestamp &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; System.currentTimeMillis();
        System.out.println(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Execution Time : &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (endTimestamp&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;startTimestamp)&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
        
        System.out.println(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Are Equal : &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (commonA.equals(commonB)));
        
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;Third Attempt - Runs in 2 seconds&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;        startTimestamp &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; System.currentTimeMillis();
        &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt; This part has been intentionally left blank.
         * That is because I need to have a question for the puzzle,
         * and I felt like leaving out the Third part would be the right 
         * thing do to.
         * I&#39;ve done most of the hard work so this should be easy to fill. 
         * Yes this must run 10 times faster than the solution I have provided
         * and should be done just as many lines (3 to 5 lines of code should be fine!).
         * Well I never said anything about life being fair, did I?
         * &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;
        
        endTimestamp &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; System.currentTimeMillis();
        System.out.println(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Execution Time : &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (endTimestamp&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;startTimestamp)&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;);
        
        System.out.println(&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Are Equal : &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (commonA.equals(commonC)));
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&#39;javascript&#39; src=&#39;http://www.blogtrog.com/scripts/bt_code.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;&lt;script language=&#39;javascript&#39; type=&#39;text/javascript&#39;&gt;bt_code_init(&#39;26a04a05-3511-4087-ab4b-624ba95a0241&#39;);&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
Just keep in mind that both the &quot;Are Equal&quot; print statements print true and that you don&#39;t use the reference commonA or commonB when writing the code for the third part. You are free to make any other changes (in the place where the comments are there).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Update &lt;/b&gt;- The commonA, commonB were incorrectly pointing to the objects listOf2/listof3. That has been corrected to create new Objects -- it now reads commonA = new ArrayList&lt;long&gt;(listOf2); instead of commonA = listOf2;.&lt;br /&gt;
Thanks to Colin Hebert for pointing it out.</description><link>http://java-twisters.blogspot.com/2010/07/puzzle-61-set-for-optimization.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>17</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-3952991188493805634</guid><pubDate>Sun, 11 Jul 2010 06:12:00 +0000</pubDate><atom:updated>2010-07-11T11:42:01.482+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">SoftReference</category><title>Puzzle 60 (Go Soft) - Solution</title><description>Last week we looked at soft-reference and the answer that naturally comes is what the Java Doc has to say about soft references &quot;As long as the referent of a soft reference is strongly reachable, that is, is actually in use, the soft reference will not be cleared&quot;.&lt;br /&gt;
Looking at the &lt;a href=&quot;http://twisters.quiz4j.com/2010/07/go-soft.html&quot;&gt;code&lt;/a&gt; - we have strongly reachable reference to the MemoryIntensiveObject(), &lt;i&gt;&lt;b&gt;O&lt;/b&gt;&lt;/i&gt; and one would expect the soft reference to exists. However as Jeremy Manson points out &lt;a href=&quot;http://jeremymanson.blogspot.com/2010/02/garbage-collection-softreferences.html&quot;&gt;in his blog&lt;/a&gt;, this might not necessarily be the case.&lt;br /&gt;
&lt;br /&gt;
As mentioned before this question was based on the Jeremy Manson blog post.</description><link>http://java-twisters.blogspot.com/2010/07/puzzle-60-go-soft-solution.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-7430565155484472916</guid><pubDate>Mon, 05 Jul 2010 06:18:00 +0000</pubDate><atom:updated>2010-07-05T11:48:35.618+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Garbage Collector</category><category domain="http://www.blogger.com/atom/ns#">SoftReference</category><title>Go Soft?</title><description>An interesting post that I read sometime ago rakes up this discussion. I&#39;ll add the reference to the original post next week.&lt;br /&gt;
&lt;br /&gt;
To give a bit of background we first see what a &lt;a href=&quot;http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ref/SoftReference.html&quot;&gt;SoftReference &lt;/a&gt;object is. SoftReference is an object which is cleared at the discretion of the garbage collector in response to memory demand. Soft references are most often used to implement memory-sensitive caches. An object that is reachable (only) from a SoftReference is eligible for Garbage collection. The java doc is pretty clear - I &lt;a href=&quot;http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ref/SoftReference.html&quot;&gt;recommend reading it&lt;/a&gt;!&lt;br /&gt;
&lt;br /&gt;
The problem is the pretty little three line code below,&lt;br /&gt;
&lt;div id=&#39;iframeDive54da917-8369-4470-bafb-1da495680d64&#39; style=&#39;display:none;margin:0px;&#39;&gt;&lt;iframe id=&#39;iframee54da917-8369-4470-bafb-1da495680d64&#39; 

src=&#39;http://www.blogtrog.com/code.aspx?id=e54da917-8369-4470-bafb-1da495680d64&#39; style=&#39;width: 500px; height: 200px; border: 1px solid #e0e0e0;margin:0px;&#39; 

frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&#39;noIframeDive54da917-8369-4470-bafb-1da495680d64&#39; style=&#39;display:block;margin:0px;&#39;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style=&quot;color: #000000;&quot;&gt;Object someMethod() 
{
  Object o &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt; MemoryIntensiveObject();
  SoftReference&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;MemoryIntensiveObject&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ref &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: 

#0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; SoftReference&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: 

#000000;&quot;&gt;MemoryIntensiveObject&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(o);
  &lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;Assume garbage collector at this point and needed to free up memory.&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ref.get(); 
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&#39;javascript&#39; src=&#39;http://www.blogtrog.com/scripts/bt_code.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;&lt;script language=&#39;javascript&#39; 
type=&#39;text/javascript&#39;&gt;bt_code_init(&#39;e54da917-8369-4470-bafb-1da495680d64&#39;);&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
Is the soft reference bound to return the object that was originally pointed by o ?</description><link>http://java-twisters.blogspot.com/2010/07/go-soft.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-2704507531576215829</guid><pubDate>Mon, 28 Jun 2010 18:29:00 +0000</pubDate><atom:updated>2010-06-29T00:00:26.448+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Birthday</category><category domain="http://www.blogger.com/atom/ns#">Comeback</category><title>More puzzles coming this way.</title><description>Its been over 6 months since I have posted here - mostly cause I ran out of stuff to post!! Well time to announce a come back. That&#39;s right folks next week (Sunday) onwards we&#39;ll start of with some POJP - thats Plain Old Java Puzzles!! &lt;br /&gt;
&lt;br /&gt;
If anyone is wondering why today, do have a look at this one for a clue -- &lt;a href=&quot;http://twisters.quiz4j.com/2009/06/puzzle-37-fun-with-strings-birthday.html&quot;&gt;http://twisters.quiz4j.com/2009/06/puzzle-37-fun-with-strings-birthday.html&lt;/a&gt;</description><link>http://java-twisters.blogspot.com/2010/06/more-puzzles-coming-this-way.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-4303244948050720233</guid><pubDate>Sun, 13 Dec 2009 10:24:00 +0000</pubDate><atom:updated>2009-12-13T16:06:47.333+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Puzzle</category><title>Java Puzzler - on Code-o-matic</title><description>I don&#39;t have a puzzle of my own today - I&#39;ve covered up most things I know &amp;amp; I really don&#39;t want to end up repeating myself! So for now I am going to point you to a puzzle I had come across some time ago - &lt;a href=&quot;http://code-o-matic.blogspot.com/2009/02/crazy-java-puzzler.html&quot;&gt;http://code-o-matic.blogspot.com/2009/02/crazy-java-puzzler.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I really don&#39;t know the answer to this puzzle - but then again I&#39;ve never been good with Generics  or hardcore Java - you folks might know an answer. Give it a shot - and do let us know too if you got an answer!</description><link>http://java-twisters.blogspot.com/2009/12/java-puzzler-on-code-o-matic.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-9187059996972351965</guid><pubDate>Sun, 22 Nov 2009 13:22:00 +0000</pubDate><atom:updated>2009-11-22T18:57:24.416+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><title>Puzzle 59 – Comparing the Java way.</title><description>&lt;span style=&quot;font-family:arial;&quot;&gt;A really cool part of the collection framework is the &lt;span style=&quot;font-style: italic;&quot;&gt;Collections.sort()&lt;/span&gt; function. The function sorts out a collection based on the natural ordering of elements. Of course – for you own data types you need to define what the ‘natural’ ordering is. Doing that is really simple though – just implement the &lt;span style=&quot;font-style: italic;&quot;&gt;compareTo()&lt;/span&gt; method of the &lt;span style=&quot;font-style: italic;&quot;&gt;Comparable&lt;/span&gt; interface and we are ready to go.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;That brings me to today’s questions. The code below for the Points class implements the &lt;span style=&quot;font-style: italic;&quot;&gt;compareTo()&lt;/span&gt; method. Now my manager kept insisting that there is something not right about it – but the code looks alright to me.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;What do you folks think – are there any problems with the code below?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDiva025b376-566a-46c8-9ac8-cc0af8714f1d&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframea025b376-566a-46c8-9ac8-cc0af8714f1d&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=a025b376-566a-46c8-9ac8-cc0af8714f1d&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiva025b376-566a-46c8-9ac8-cc0af8714f1d&quot; style=&quot;margin: 0px; display: block; font-family: arial;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; com.twister;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; java.util.ArrayList;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; java.util.Collections;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Points &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;implements&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Comparable&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Points&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; xCoordinate;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;&lt;br /&gt;* 1. Returns 0 if both points have same xCoordinate (say 3 &amp;amp; 3) - returns 3-3=0&lt;br /&gt;* 2. Returns +ve if first point is on the&lt;br /&gt;* right hand side of the second point (say 5, -3) - returns 5 - (-3) = 8&lt;br /&gt;* 3. Returns -ve if first point is on the&lt;br /&gt;* left hand side of the second point (say -5, 3) - returns (-5) - (3) = -8&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; compareTo(Points p) {&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; xCoordinate &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; p.xCoordinate;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] args) {&lt;br /&gt;   ArrayList&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Points&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; arrPoints &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Points&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;();&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; Add lots of points to the array list &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;br /&gt;   Collections.sort(arrPoints);&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;Print the sorted collection &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;a025b376-566a-46c8-9ac8-cc0af8714f1d&#39;);&lt;/script&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Got a view? Leave one &lt;a href=&quot;http://twisters.quiz4j.com/2009/11/puzzle-59-comparing-java-way.html&quot;&gt;here.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;obj=new Object;obj.clockfile=&quot;9001e-red.swf&quot;;obj.TimeZone=&quot;GMT0530&quot;;obj.width=288;obj.height=18;obj.Target=&quot;2009,11,29,12,00,0&quot;;obj.Title=&quot;Time%20Remaining&quot;;obj.Message=&quot;Solution Posted&quot;;obj.wmode=&quot;transparent&quot;;showClock(obj);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/11/puzzle-59-comparing-java-way.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-4145372125861988675</guid><pubDate>Wed, 18 Nov 2009 05:23:00 +0000</pubDate><atom:updated>2009-11-18T12:33:56.716+05:30</atom:updated><title>So where is the puzzle this week?</title><description>&lt;span style=&quot;font-family:arial;&quot;&gt;I have been a irregular with puzzles on Twister for some time now – for one I have covered most of the puzzles that could be covered in the twister format and secondly I been working on &lt;/span&gt;&lt;a href=&quot;http://www.quiz4j.com/&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Quiz4j &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;– adding puzzles and quizzes to it.&lt;br /&gt;&lt;br /&gt;When I started &lt;/span&gt;&lt;a href=&quot;http://www.quiz4j.com/&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Quiz4j &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;my vision was to create site that would cater to Java Programming Puzzles and Quizzes. I found programming puzzles a really good way to learn and keep in touch with some challenging programming. The more I got interested the more stuff I found around – and I released that there were loads of good programming quizzes and puzzle resources out there – and really having one more site which did the same thing was not going to help much!&lt;br /&gt;Considering that there is a limitation to what one person could do – my plan is to gradually evolve Quiz4J into a community of people like us who enjoy programming puzzles. It’s not going to be something that happens overnight but something that I look forward to happening in the next 3-4 months. You’ll see some quick updates in the next few weeks on Quiz4J – getting rid of some stuff and addition of a lot more.&lt;br /&gt;&lt;br /&gt;So what about twisters? Are we not going to have any more of these puzzles? Yes – sure I am going to continue posting puzzles on Twisters. I planning to cut a few overheads – score cards, answer post are few of the things you would see going off. The comment system would be used more as a discussion tool than just posting answers. Puzzles might get a bit more difficult – and you might see me pointing a to existing discussion that writing my own puzzles.&lt;br /&gt;&lt;br /&gt;Well so what do you folks think? I really really interested in hearing from you!!!&lt;/span&gt;</description><link>http://java-twisters.blogspot.com/2009/11/so-where-is-puzzle-this-week.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-2411208208088920487</guid><pubDate>Sun, 15 Nov 2009 18:31:00 +0000</pubDate><atom:updated>2009-11-16T00:03:28.925+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Solution</category><title>Puzzle 58 – Solution</title><description>&lt;span style=&quot;font-family: arial;&quot;&gt;There are a couple of solutions possible for this puzzle – I’ll leave figuring out how these solutions work to you!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;The first one,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDivc29ed70f-0c63-4595-8c40-532db712afc5&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframec29ed70f-0c63-4595-8c40-532db712afc5&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=c29ed70f-0c63-4595-8c40-532db712afc5&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivc29ed70f-0c63-4595-8c40-532db712afc5&quot; style=&quot;margin: 0px; display: block; font-family: arial;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; com.twister;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; java.util.ArrayList;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; java.util.List;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Gener {&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; read(List&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;?&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; x){}&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] args) {&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Gener().read(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Float&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;());&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;c29ed70f-0c63-4595-8c40-532db712afc5&#39;);&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;and the second,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDiv065f8932-4f12-4aad-9be7-b4f6828954ad&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframe065f8932-4f12-4aad-9be7-b4f6828954ad&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=065f8932-4f12-4aad-9be7-b4f6828954ad&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv065f8932-4f12-4aad-9be7-b4f6828954ad&quot; style=&quot;margin: 0px; display: block; font-family: arial;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; com.twister;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; java.util.ArrayList;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; java.util.List;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Gener {&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; read(List&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; x){}&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] args) {&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Gener().read(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Float&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;());&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;065f8932-4f12-4aad-9be7-b4f6828954ad&#39;);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/11/puzzle-58-solution.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-5966041438789537386</guid><pubDate>Sun, 08 Nov 2009 09:40:00 +0000</pubDate><atom:updated>2009-11-08T15:13:51.321+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Puzzle</category><title>Puzzle 58 – Simple Upgrade.</title><description>&lt;span style=&quot;font-family: arial;&quot;&gt;Language – Java | Type – Concept | Last date 15-Nov-2009 12:00 p.m. IST | Points 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;Here is the puzzle straight and simple. A piece of code was written which had a read() method with the signature below. Thing change and instead of using integers – it was now required to use Floats instead of Integers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;To cut a long story short what is the minimum change considering additions/deletions (each char added or deleted count as 1) to get the code below to compile. (I think it can be done in less than 10 characters)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDivfebffd90-244c-4ccb-855a-fafa24ae9f7c&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframefebffd90-244c-4ccb-855a-fafa24ae9f7c&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=febffd90-244c-4ccb-855a-fafa24ae9f7c&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivfebffd90-244c-4ccb-855a-fafa24ae9f7c&quot; style=&quot;margin: 0px; display: block; font-family: arial;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; com.twister;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; java.util.ArrayList;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; java.util.List;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Gener {&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; read(List&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Integer&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; x){}&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] args) {&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; Gener().read(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; ArrayList&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Float&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;());&lt;br /&gt;  }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;febffd90-244c-4ccb-855a-fafa24ae9f7c&#39;);&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;Got an answer? Leave one &lt;/span&gt;&lt;a style=&quot;font-family: arial;&quot; href=&quot;http://twisters.quiz4j.com/2009/11/puzzle-58-simple-upgrade.html&quot;&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;obj=new Object;obj.clockfile=&quot;9001e-red.swf&quot;;obj.TimeZone=&quot;GMT0530&quot;;obj.width=288;obj.height=18;obj.Target=&quot;2009,11,15,12,00,0&quot;;obj.Title=&quot;Time%20Remaining&quot;;obj.Message=&quot;Solution Posted&quot;;obj.wmode=&quot;transparent&quot;;showClock(obj);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/11/puzzle-58-simple-upgrade.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-553949805252458908</guid><pubDate>Sun, 08 Nov 2009 08:17:00 +0000</pubDate><atom:updated>2009-11-08T13:49:34.908+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Solution</category><title>Puzzle 57 – Solution</title><description>Here is the first solution that works for last weeks puzzle,&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDiva3df5ea7-45b4-433d-98b1-c782a13acb9d&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframea3df5ea7-45b4-433d-98b1-c782a13acb9d&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=a3df5ea7-45b4-433d-98b1-c782a13acb9d&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiva3df5ea7-45b4-433d-98b1-c782a13acb9d&quot; style=&quot;margin: 0px; display: block;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; X{&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] a){&lt;br /&gt;       System.out.print(a[&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;]);&lt;br /&gt;   } &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Run the program as given below&lt;br /&gt;java X &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Hello World&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;a3df5ea7-45b4-433d-98b1-c782a13acb9d&#39;);&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;The second one – (the one that I had in mind) is&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDivdc410f8f-dff8-4f54-a12e-412d4c611e35&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframedc410f8f-dff8-4f54-a12e-412d4c611e35&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=dc410f8f-dff8-4f54-a12e-412d4c611e35&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivdc410f8f-dff8-4f54-a12e-412d4c611e35&quot; style=&quot;margin: 0px; display: block;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; X {&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; {&lt;br /&gt;       System.out.print(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Hello World&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;       System.exit(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;   }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;dc410f8f-dff8-4f54-a12e-412d4c611e35&#39;);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/11/puzzle-57-solution.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-2642829474619684550</guid><pubDate>Sun, 01 Nov 2009 08:44:00 +0000</pubDate><atom:updated>2009-11-01T14:27:19.166+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Puzzle</category><title>Puzzle 57 – Hello World - Again</title><description>&lt;span style=&quot;font-family:arial;&quot;&gt;Language – Java | Type – Concept | Last date 8-Nov-2009 12:00 p.m. IST | Points 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;It&#39;s been two weeks since I wrote a puzzle out here – so I end up typing the simplest program I could think of in Java.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDiv8a6c5425-95a6-4f5c-b2b7-c9017b8bdedb&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframe8a6c5425-95a6-4f5c-b2b7-c9017b8bdedb&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=8a6c5425-95a6-4f5c-b2b7-c9017b8bdedb&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv8a6c5425-95a6-4f5c-b2b7-c9017b8bdedb&quot; style=&quot;margin: 0px; display: block; font-family: arial;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; X{&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] a){&lt;br /&gt;    System.out.print(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Hello World&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;8a6c5425-95a6-4f5c-b2b7-c9017b8bdedb&#39;);&lt;/script&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;That&#39;s the smallest program that I could in java that prints hello world (72 characters excluding all the white spaces). Hope you folks noticed the clever use of variable names and print instead of println.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Well here is the really simple challenge. Write some code that does exactly what the above code does – just use less number of characters. Remember the code has got to compile cleanly and run cleanly and produce the same output as the snippet above. Easy!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Looking for more Java Puzzles? Check out &lt;/span&gt;&lt;a style=&quot;font-family: arial;&quot; href=&quot;http://www.quiz4j.com/contest.do&quot;&gt;these sites.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Got an answer? Leave one &lt;a href=&quot;http://twisters.quiz4j.com/2009/11/puzzle-57-hello-world-again.html&quot;&gt;here.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;obj=new Object;obj.clockfile=&quot;9001e-red.swf&quot;;obj.TimeZone=&quot;GMT0530&quot;;obj.width=288;obj.height=18;obj.Target=&quot;2009,11,08,12,00,0&quot;;obj.Title=&quot;Time%20Remaining&quot;;obj.Message=&quot;Solution Posted&quot;;obj.wmode=&quot;transparent&quot;;showClock(obj);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/11/puzzle-57-hello-world-again.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-793761196471768078</guid><pubDate>Sun, 25 Oct 2009 13:15:00 +0000</pubDate><atom:updated>2009-10-25T19:44:42.926+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Quiz4j</category><category domain="http://www.blogger.com/atom/ns#">Updates</category><title>Puzzles, Puzzles and more Puzzles.</title><description>The past couple of months I have been pretty much fascinated with programming puzzles. I have been on a lookout for really good puzzle sites - and participating in competitions whenever I get the chance.&lt;br /&gt;&lt;br /&gt;It all started a couple of months back when I first heard of Google Code Jam. The idea really fascinated me and since then I been solving lots of puzzles around the net (with some attempts to write my own).  Currently you find me on &lt;a href=&quot;http://azspcs.net/&quot;&gt;Al Zimmermann&#39;s Programming Contests&lt;/a&gt; playing around with the darts.&lt;br /&gt;&lt;br /&gt;I have also been busy compiling of all puzzle/programming sites on the web - you can have a look at it here - &lt;a href=&quot;http://www.quiz4j.com/contest.do&quot;&gt;http://www.quiz4j.com/contest.do&lt;/a&gt;. I am still working on the page and it might be a couple of weeks before my list is finally complete (if ever) - but it’s pretty huge already. Do have &lt;a href=&quot;http://www.quiz4j.com/contest.do&quot;&gt;a look&lt;/a&gt; - I&#39;m sure you will find something you like. If like what you see please share the link around!!!&lt;br /&gt;&lt;br /&gt;There are no puzzles this week on twister - I&#39;ll be back with the regular java questions (and maybe a couple of tricky ones!!!) from next week.</description><link>http://java-twisters.blogspot.com/2009/10/puzzles-puzzles-and-more-puzzles.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-3001498017596417979</guid><pubDate>Sun, 18 Oct 2009 11:36:00 +0000</pubDate><atom:updated>2009-10-18T17:12:15.100+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Code challenge</category><category domain="http://www.blogger.com/atom/ns#">Puzzle</category><title>Puzzle 56 – Cube Traversal</title><description>&lt;span style=&quot;font-family: arial;&quot;&gt;Language – Java | Type – Concept | Last date 25-Oct-2009 12:00 p.m. IST | Points 5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;We been dealing with Java concepts lately and its time to give concepts a break and get to some real world puzzles. Here is a small programming puzzle to get things started. Do let me know what you think of this question so I could think about adding more questions like these.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;label style=&quot;font-family: arial;&quot; class=&quot;widget_code&quot;&gt;Cube Puzzle&lt;br /&gt;&lt;/label&gt;&lt;pre style=&quot;font-family: arial;&quot;&gt;&lt;code&gt;&lt;!-- scarky widget http://scarky.com/ --&gt;&lt;br /&gt;&lt;iframe style=&quot;border: 0px none ; overflow: hidden;&quot; src=&quot;http://scarky.com/widget/getiframe/P3DD3F27/width=500&amp;amp;height=370&quot; frameborder=&quot;0&quot; height=&quot;370&quot; width=&quot;500&quot;&gt;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;br&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;&lt;/iframe&gt;&lt;br /&gt;&lt;!-- end scarky widget --&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;Submitting java code on scarky has few rules that need to be followed.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;1. You can just have one class and it must be named Main. It should not be inside any package.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;2. You need to read all input before you can start writing any output. (Use System.out.print() &amp;amp; System.out.println() for output)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;3. For the exact format of input and output refer to the example test case.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;You can find a standard template to read the input data &lt;/span&gt;&lt;a style=&quot;font-family: arial;&quot; href=&quot;http://www.blogtrog.com/code.aspx?id=0ede09b4-6d3a-4da6-a2c2-3104e6abcce4&quot;&gt;here&lt;/a&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;Your solution would be evaluated automatically by scarky.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;In case of any issues you could reach me at &lt;/span&gt;&lt;a style=&quot;font-family: arial;&quot; href=&quot;mailto:admin@quiz4j.com&quot;&gt;admin@quiz4j.com&lt;/a&gt;</description><link>http://java-twisters.blogspot.com/2009/10/puzzle-56-cube-traversal.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-4574236842557032986</guid><pubDate>Sun, 18 Oct 2009 10:02:00 +0000</pubDate><atom:updated>2009-10-18T15:34:05.549+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Solution</category><title>Puzzle 55 – Solution</title><description>The solution to last time puzzle was to use an instance initializer. An instance initalizer is a piece of code similar to a static block that gets called whenever an instance is created (the compiler inlines this code at the beginning of each constructor).&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDivefd33f48-bccd-4732-bc48-1f80dd653eed&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframeefd33f48-bccd-4732-bc48-1f80dd653eed&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=efd33f48-bccd-4732-bc48-1f80dd653eed&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivefd33f48-bccd-4732-bc48-1f80dd653eed&quot; style=&quot;margin: 0px; display: block;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; com.twisters;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; NoConstructor {&lt;br /&gt;  &lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; isConstructor &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;No changes permitted to this line&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;    {isConstructor &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;;}&lt;br /&gt;&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; No Code may be added or changed in main&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] args) {&lt;br /&gt;       NoConstructor noConstructor &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; NoConstructor();&lt;br /&gt;       System.out.println(noConstructor.isConstructor);    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;Prints true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;efd33f48-bccd-4732-bc48-1f80dd653eed&#39;);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/10/puzzle-55-solution.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-7767494692075307353</guid><pubDate>Mon, 12 Oct 2009 18:12:00 +0000</pubDate><atom:updated>2009-10-12T23:56:02.127+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Puzzle</category><title>Puzzle 55 – The No constructor dilemma.</title><description>&lt;span style=&quot;font-family: arial;&quot;&gt;Language – Java | Type – Concept | Last date 18-Oct-2009 12:00 p.m. IST | Points 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;This week’s puzzle is pretty simple and the question self explanatory (I hope).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDiv5b82330e-aae6-4017-916d-242bc6315b9a&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframe5b82330e-aae6-4017-916d-242bc6315b9a&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=5b82330e-aae6-4017-916d-242bc6315b9a&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv5b82330e-aae6-4017-916d-242bc6315b9a&quot; style=&quot;margin: 0px; display: block; font-family: arial;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; com.twisters;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; NoConstructor {&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; isConstructor &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;No changes permitted to this line&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt; No Code may be added or changed in main&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] args) {&lt;br /&gt;   NoConstructor noConstructor &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; NoConstructor();&lt;br /&gt;   System.out.println(noConstructor.isConstructor);    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;Prints true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;    }&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;5b82330e-aae6-4017-916d-242bc6315b9a&#39;);&lt;/script&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;The NoConstructor class must not have any explicit constructor (that is - don’t use the word NoConstructor any more times in your solution). That&#39;s all - everything else about the puzzle should be self explanatory from the comments!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;Got an answer? Leave one &lt;/span&gt;&lt;a style=&quot;font-family: arial;&quot; href=&quot;http://twisters.quiz4j.com/2009/10/puzzle-55-no-constructor-dilemma.html&quot;&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;obj=new Object;obj.clockfile=&quot;9001e-red.swf&quot;;obj.TimeZone=&quot;GMT0530&quot;;obj.width=288;obj.height=18;obj.Target=&quot;2009,10,18,12,00,0&quot;;obj.Title=&quot;Time%20Remaining&quot;;obj.Message=&quot;Solution Posted&quot;;obj.wmode=&quot;transparent&quot;;showClock(obj);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/10/puzzle-55-no-constructor-dilemma.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-1446940244998289008</guid><pubDate>Mon, 12 Oct 2009 17:31:00 +0000</pubDate><atom:updated>2009-10-12T23:53:51.458+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Solution</category><title>Puzzle 54 – Solution</title><description>&lt;span style=&quot;font-family: arial;&quot;&gt;The principle that I wanted to bring out in this puzzle was that we can break out of any labeled block by using a break statement.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDivdc1e6262-c626-45ca-a585-55d8555fc4e6&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframedc1e6262-c626-45ca-a585-55d8555fc4e6&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=dc1e6262-c626-45ca-a585-55d8555fc4e6&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDivdc1e6262-c626-45ca-a585-55d8555fc4e6&quot; style=&quot;margin: 0px; display: block; font-family: arial;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; com.twister;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; NoIf {&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] args) {&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;){}&lt;br /&gt;    System.out.println(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Print This&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;    noPrint:{&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;){&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;break&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; noPrint;}&lt;br /&gt;        System.out.println(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Print This - Not!&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;            }&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;){}&lt;br /&gt;    System.out.println(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Print This&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;dc1e6262-c626-45ca-a585-55d8555fc4e6&#39;);&lt;/script&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;The other popular solution was to wrap the code in a try-catch-finally block. As the catch block will not execute without any exception – the second print statement is skipped.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;My favorite solution for this puzzle is the one by vector9x,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;System.out.println(&quot;Print This - Not!&quot;.substring(0,10));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;Scores to be updated next week!!&lt;/span&gt;</description><link>http://java-twisters.blogspot.com/2009/10/puzzle-54-solution.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-3169249753013875378</guid><pubDate>Sun, 04 Oct 2009 12:56:00 +0000</pubDate><atom:updated>2009-10-04T18:31:17.566+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Puzzle</category><title>Puzzle 54 – No More If’s</title><description>&lt;span style=&quot;font-family:arial;&quot;&gt;Language – Java | Type – Concept | Last date 11-Oct-2009 12:00 p.m. IST | Points 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Today’s unearthly puzzle finds its roots in code written by a Jalvanian master. The question in today’s puzzle should be self explanatory.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;iframeDiv05fc4050-b8bc-42ce-8601-2b35046f6a74&quot; style=&quot;margin: 0px; display: none;&quot;&gt;&lt;iframe id=&quot;iframe05fc4050-b8bc-42ce-8601-2b35046f6a74&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=05fc4050-b8bc-42ce-8601-2b35046f6a74&quot; style=&quot;border: 1px solid rgb(224, 224, 224); margin: 0px; width: 500px; height: 200px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv05fc4050-b8bc-42ce-8601-2b35046f6a74&quot; style=&quot;margin: 0px; display: block; font-family: arial;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; com.twister;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; NoIf {&lt;br /&gt;&lt;br /&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt; main(String[] args) {&lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;){}&lt;br /&gt;     System.out.println(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Print This&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;){}&lt;br /&gt;     System.out.println(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Print This - Not!&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;){}&lt;br /&gt;     System.out.println(&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;Print This&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;05fc4050-b8bc-42ce-8601-2b35046f6a74&#39;);&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;It’s kind of pretty obvious what needs to be done – the code says it all.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;You must of course follow the Three Jalvanian Laws.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;1. You may only add but not delete nor comment out any of the code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;2. A real Jalvanian would never use an &lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:arial;&quot; &gt;else&lt;/span&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; so neither must you.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;3. You may not use any more boolean variables (there are three in the code – which must remain unaltered) or conditions that evaluate to a boolean value. (So no true==false – since false is a boolean value etc).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;That’s all folks!!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Got an answer? Do leave it &lt;a href=&quot;http://twisters.quiz4j.com/2009/10/puzzle-54-no-more-ifs.html&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;obj=new Object;obj.clockfile=&quot;9001e-red.swf&quot;;obj.TimeZone=&quot;GMT0530&quot;;obj.width=288;obj.height=18;obj.Target=&quot;2009,10,11,12,00,0&quot;;obj.Title=&quot;Time%20Remaining&quot;;obj.Message=&quot;Solution Posted&quot;;obj.wmode=&quot;transparent&quot;;showClock(obj);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/10/puzzle-54-no-more-ifs.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>10</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-7735630605077337774</guid><pubDate>Sun, 27 Sep 2009 08:07:00 +0000</pubDate><atom:updated>2009-09-27T13:38:35.820+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Updates</category><category domain="http://www.blogger.com/atom/ns#">Vacation</category><title>Out on Vacation!</title><description>&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;I am on a vacation this week – so no new puzzle this week.&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;br /&gt;However for those looking for a Java puzzle to think over this post should be interesting - &lt;a href=&quot;http://www.javaspecialists.eu/archive/Issue173.html&quot;&gt;http://www.javaspecialists.eu/archive/Issue173.html&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://java-twisters.blogspot.com/2009/09/out-on-vacation.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-6733718786834375644</guid><pubDate>Sun, 27 Sep 2009 08:03:00 +0000</pubDate><atom:updated>2009-09-27T13:40:06.995+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Solution</category><title>Puzzle 53 – Solution</title><description>&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;The problem that occurred was that even though the Constants class was recompiled the MyData class still continues to retain the old value of the constant Author. This happens because &lt;b&gt;&lt;i&gt;static final fields&lt;/i&gt;&lt;/b&gt; are in-lined into the code.&lt;br /&gt;&lt;br /&gt;As c0dep0et points out in his comment,&lt;br /&gt;&quot;From JLS:&lt;br /&gt;Simple names that refer to final variables whose initializers are constant expressions qualify to be compile-time constants.&quot;&lt;br /&gt;&lt;br /&gt;One way to resolve this problem would be to make sure that all files depended on the Constants file are recompiled when the Constants file is recompiled. (Alternately not declaring the field as final would work!).&lt;br /&gt;&lt;br /&gt;Modern IDE are more intelligent and usually recompile depended class when a final static field is changed in a class!&lt;/span&gt;</description><link>http://java-twisters.blogspot.com/2009/09/puzzle-53-solution.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-7767926718004860232</guid><pubDate>Sun, 20 Sep 2009 11:44:00 +0000</pubDate><atom:updated>2009-09-20T17:22:58.055+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Updates</category><title>Twister updates.</title><description>&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;There have been a few suggestions and questions that have been asked and since a lot of new folks have joined Twisters its time for a few updates.&lt;br /&gt;&lt;br /&gt;1. @Anonymous – Appreciate your comment on &#39;code not showing up right in feed readers.&#39; I think I have got that fixed and things should look right from now on (at least that’s what I hope)!&lt;br /&gt;&lt;br /&gt;2. @tonthatduy – There is a score sheet that I update after every puzzle (it&#39;s the last link in the Top Score widget).&lt;br /&gt;If your solution is deemed right – you get points for that puzzle.&lt;br /&gt;If your solution is wrong – well it should be marked up as a 0 (or sometime when I am just feeling lazy – I just leave it blank!)&lt;br /&gt;&lt;br /&gt;To answer your question in particular, your solution for puzzle 51 was not quite right. It broke one of the rules – &quot;no deletes, no moving about the code, &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;no commenting out …&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&quot; Putting two slashes // ended up commenting out some of the code!&lt;br /&gt;&lt;br /&gt;3. I have made a small change to the way the sharing icons works (if you have not noticed they are the cute icons that you can see at the bottom of each post). Clicking on the link would no longer bookmark/submit the individual post but rather submits the Twisters site. Considering that a post on usually Twisters expire in a week – sharing an individual post does not make much sense.&lt;br /&gt;&lt;br /&gt;4. For those who like solving puzzles there is &lt;/span&gt;&lt;a href=&quot;http://www.treasurehunt.quiz4j.com/&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;JFactor - Java Treasure Hunt&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; that I had designed a few moths ago, that you could try out. Hope you find the Treasure Hunt fun and challenging!!&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;Finally&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;, I would like to thank all you folks for your support and encouragement in keeping Twisters going!!!&lt;/span&gt;</description><link>http://java-twisters.blogspot.com/2009/09/twister-updates.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9193160645817040317.post-5018079246494177271</guid><pubDate>Sun, 20 Sep 2009 10:18:00 +0000</pubDate><atom:updated>2009-09-20T16:03:55.136+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Puzzle</category><title>Puzzle 53 – Statically Speaking.</title><description>&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;Language – Java | Type – Concept | Last date 27-Sep-2009 12:00 p.m. IST | Points 3&lt;br /&gt;&lt;br /&gt;This puzzle is interesting because it&#39;s based on a real life incident that happened with a colleague of mine. To give you a gist of what happened, here is the code (well this isn&#39;t the real code – just the important part)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div id=&quot;iframeDiv4d16dcdd-1a47-49c3-9f8e-856f333ebea3&quot; style=&quot;display:none;margin:0px;&quot;&gt;&lt;iframe id=&quot;iframe4d16dcdd-1a47-49c3-9f8e-856f333ebea3&quot; src=&quot;http://www.blogtrog.com/code.aspx?id=4d16dcdd-1a47-49c3-9f8e-856f333ebea3&quot; style=&quot;width: 500px; height: 200px; border: 1px solid #e0e0e0;margin:0px;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;div id=&quot;noIframeDiv4d16dcdd-1a47-49c3-9f8e-856f333ebea3&quot; style=&quot;display:block;margin:0px;&quot;&gt;&lt;pre&gt;&lt;div&gt;&lt;!--  Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/  --&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;package&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; com.twister;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; MyData{&lt;br /&gt;String author &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; com.twister.Constants.AUTHOR;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;lot of other stuff comes here…    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; main(String[] args) {&lt;br /&gt;  MyData mydata &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; MyData();&lt;br /&gt;  System.out.println(mydata.author);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;package&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; com.twister;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; Constants{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#0000FF;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;final&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; String AUTHOR &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;SAM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;Me of course&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;script language=&quot;javascript&quot; src=&quot;http://www.blogtrog.com/scripts/bt_code.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;bt_code_init(&#39;4d16dcdd-1a47-49c3-9f8e-856f333ebea3&#39;);&lt;/script&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:arial;&quot;&gt;&lt;br /&gt;Here is what happened. This was some code that I had written – see my name in the Constants file. Well my colleague picked up my code and just modified the String &lt;b&gt;Author&lt;/b&gt; to his, recompiled the Constants file and went on to show a demo to the manager. Ops something went wrong here, which got him into a lot of trouble. Can you figure out what went wrong? (Assume he codes using Notepad). What are the possible solutions to this problem?&lt;br /&gt;&lt;br /&gt;Got an answer? Do leave &lt;a href=&quot;http://twisters.quiz4j.com/2009/09/puzzle-53-statically-speaking.html&quot;&gt;it here.&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;obj=new Object;obj.clockfile=&quot;9001e-red.swf&quot;;obj.TimeZone=&quot;GMT0530&quot;;obj.width=288;obj.height=18;obj.Target=&quot;2009,9,27,12,00,0&quot;;obj.Title=&quot;Time%20Remaining&quot;;obj.Message=&quot;Solution Posted&quot;;obj.wmode=&quot;transparent&quot;;showClock(obj);&lt;/script&gt;</description><link>http://java-twisters.blogspot.com/2009/09/puzzle-53-statically-speaking.html</link><author>noreply@blogger.com (Saifuddin Merchant)</author><thr:total>4</thr:total></item></channel></rss>