Fantastic IDEA!

I have been using editors in one form or another for about 23 years. And now I am using IntelliJ IDEA. Man, is it impressive or is it impressive. As Photoshop is to doing graphics, IntelliJ IDEA is to cutting Java code.

The most impressive thing is the overall usability. It has been designed and built with the developer in mind. Attention to detail is unreal. It is feature rich, but not bloated. I reckon that one could run an entire course on usability using this product as the case study.

As Alex Moffat comments about the product

I would imagine that IntelliJ is written using IntelliJ, and I think this must account for some of its success. Whatever is an annoyance to IntelliJ's users will be an annoyance to its developers first, whatever makes developing the product hard or slow will make using the product hard or slow, and conversely whatever makes development easier and faster will make use easier and faster. If you can arrange it so that your software developers are also your first software users it can certainly help your product.

The keyboard customisation is fantastic. You can assign a keystroke to almost any action. The best bit is being able to assign keystrokes to a particular Ant task. So with one keystroke you can build your classes and deploy to the web container. What I thought was really useful is the way you assign an Ant task to a hotkey. Simply right click the Ant task and select the assign short key button, and Bob's your uncle.

The refactoring, which I have only started to use, is impressive.

Paste in a snippet of code that refers to an package/class that you don't have an import statement for yet, and it will prompt you to add the import statement and then do it.

Favourite features? The tight integration of Ant. The built in change control which tracks any changes you have made. The diff facility reminds me of the Apple Developer Tools difference utility. The ability to run on Win and Mac. The way it highlights variables that have been declared but not used. The ability to close all edit windows except for the one that you are currently working in.

A concept also implemented in Eclipse is the vertical bar (next to the scroll bar) that is a visual representation of the total file size. Any errors or warnings are highlighted on it showing the relative position of the error or warning in the file.

Cruft Happens

Heh, heh. A pretty good chuckle on the “pleasures” of installing an operating system at How to install Windows XP in 5 hours or less [dive into mark]

A Verity Stobb article on Cruft in Dr Dobbs Journal, is similar in spirit. Rather than detailing the installation steps, she talks about the steps a computer goes through to require a reinstall.

One interesting allusion she makes is that cruft applies to all operating systems. I must say, for all the operating systems I have worked with ranging from DOS, VM, OS/VS, MVS, OS/2, all incantantations of Win, Linux and most recently Mac OS X, cruft happens. And it eventually requires a reinstall.

However, thinking further, it could be argued that cruft is not a state of the computer, but rather those who use it. I must admit, that my clothes drawers are not neatly laid out and that there is clutter around the house. I wonder if there is a correlation between those who are fastidious by nature and the cruftidity index of there computers?

Knight’s Lives

An interesting problem sent by a colleague.

King Arthur wishes to marry off his daughter to one of the knights of his land. Being mathematical of mind she set a problem for the knights...

"I invite all the Knights of the land
Place the seats in a circle numbering them from one
Lets the knights choose their seat
Say to the first "You live"
To the second "Off with your head"
To the third "You live"
To the forth "Off with your head"
And so on until one knight remains
This will be the knight I marry"

Which seat would you choose if you were a knight wishing to marry the princess?

I couldn't visualise the answer. So I tried mapping out the solution manually and after a couple of goes knocked up a Perl script to print out the sequences.

#!/usr/bin/perl
use strict;

my ($rounds) = $ARGV[0] || 17;

foreach my $size (1..$rounds)
{
   my @list = (1..$size);
   my $knights = $#list+1;
   my $finis = 0;
   my $i = 0;

   while (!$finis)
   {
      push @list, $list[$i] if ($i+1) % 2 != 0;
      $i++;
      $finis = 1 if $#list+1 == $i;
   }
   print "For $knights knights, choose position " . $list[$#list] . "n";
}

The position for each group of knights up to group size 35 follows:

For 1 knights, choose position 1
For 2 knights, choose position 1
For 3 knights, choose position 3
For 4 knights, choose position 1
For 5 knights, choose position 3
For 6 knights, choose position 5
For 7 knights, choose position 7
For 8 knights, choose position 1
For 9 knights, choose position 3
For 10 knights, choose position 5
For 11 knights, choose position 7
For 12 knights, choose position 9
For 13 knights, choose position 11
For 14 knights, choose position 13
For 15 knights, choose position 15
For 16 knights, choose position 1
For 17 knights, choose position 3
For 18 knights, choose position 5
For 19 knights, choose position 7
For 20 knights, choose position 9
For 21 knights, choose position 11
For 22 knights, choose position 13
For 23 knights, choose position 15
For 24 knights, choose position 17
For 25 knights, choose position 19
For 26 knights, choose position 21
For 27 knights, choose position 23
For 28 knights, choose position 25
For 29 knights, choose position 27
For 30 knights, choose position 29
For 31 knights, choose position 31
For 32 knights, choose position 1
For 33 knights, choose position 3
For 34 knights, choose position 5
For 35 knights, choose position 7

From this output I deduced the following:

given a number n (the number of knights sitting around the table), find the largest number m less than n that is a power of 2. Then find the n-m+1th odd number and that is the position you should be sitting in.

So for 21 knights, the largest power of 2 less than 21 is 16. 21-16+1 = 6. The 6th odd number is 11 (1, 3, 5, 7, 9, 11). So if there are 21 knights choose position 11.