Fighting with computers

Computers are not always friendly.

Wednesday, September 24, 2008

New VMware vmplayer installer for Linux


Since yesterday vmplayer 2.5 is out for free download. One of the tools missing in Ubuntu 8.04 was this (IMHO). Of course it was possible to install it through a more entertained process. I was surprised that VMware was not offering an easy alternative to the huge Ubuntu user base.

Today I've learnt that current version is distributed with an easy (should I say Windows-like?) installer.

  1. Download the software package with .bundle extension
  2. chmod +x VMware-Player-2.5.0-118166.i386.bundle
  3. sudo ./VMware-Player-2.5.0-118166.i386.bundle

Done!

Thanks VMware!

Monday, September 22, 2008

Reasons not to upgrade a G4 iBook

Years ago we bought one of the latest G4 iBooks as a bit later Apple started using Intel processors. The 12" laptop served us well but now battery and hard disk were dying a RAM was just 256MB. Acting against my own advice I decided to upgrade the system instead of buying a new one.

Buying RAM was not easy as mini DDR 333Mhz RAM was not popular anymore. Luckily I bought it second hand from a friend. A new battery was required to get more than one hour of autonomy again, so I bought a new battery from a Chinese source on eBay. So far so good.

I knew that replacing the hard disk would be a real PITA but I fell short. I bought a 160GB 2.5" on the local shop for less than $90. I would say that physical replacement is not something you will enjoy doing more than once in a lifetime but I got the job done with only one screw missing. I had to reopen the thing because I forgot to put back the standby magnet, it was not fun.

So once I thought everything was fine as the new hard drive was put in place, all the screws back in place and the system was making the initial chord I thought I was done. I was wrong: My Leopard disk booted but after long time fiddling with the DVD-ROM I was told a former copy of OS X was not found in my system so I could not proceed with the setup. Ok, my fault. Next I put in the Tiger install DVD, this was quick: a kernel panic complaining about PowerBook6.5 platform not being supported (Is this because this DVD was from my Intel iMac?).

Ok, do not panic: What about the original Panther DVD that came with the iBook ages ago? Well, my wife found it somewhere. We can't go wrong with this one --I thought--. After some minutes of booting noises I am greeted with the OS X setup screen and after choosing the language I can see there is no hard drive to install on: the hard disk selection area is just blank as if no hard drive were installed in the system. Ok, ... now I'm worried. Time to go online to Google for other people with similar problems. Luckily I learn that new hard drives need to be erased with the hard disk utility (included in the installer). So after erasing the disk contents I can see my new disk as a possible destination for the install. I fire the install process. This time the install works and after 2 hours or so the iBook was booting Panther again using the new hard drive.

I say to myself that now it is a good moment to upgrade to Leopard (though I'm worried because the laptop barely reaches the minimum system requirements). I reboot the system with Leopard DVD and press "C" to cause the DVD unit to boot. I can "hear" the system is booting from Leopard (it did it first time as I mentioned before) but apparently after almost one hour of different noises on the DVD-ROM unit and the rotating beach ball on a dark gray background I've got nothing. Same original DVD as before but different behavior. Who knows.

When I'm reinstalling applications I discover that I cannot install Firefox 3.0 on Panther as it requires Tiger (10.4.9). I cannot install Microsoft Office 2008 for the same reason, so I have to go back to MS Office 2004 (at least I still have the CD-ROM). And, after all I'm telling to myself: "I told you, old computers are just trouble when upgraded".

The story were not very different should I have upgraded an old PC.

Sunday, September 21, 2008

Sterling numbers of the second order


I am sure once in a while you may have faced the problem of distributing n elements into k different groups. It does not seem rocket science but, do you know in how many different ways it can be done? Of course it is not a new problem a all, and here is where the Stirling numbers (of the second kind) come in handy: they tell you the ways of dividing n elements into k groups.

For the Code Jam problem "Square Fields" large dataset the numbers may seem discouraging as the number of alternatives for 15 elements are:
S2(15,1)=1
S2(15,2)=16383
S2(15,3)=2375101
S2(15,4)=42355950
S2(15,5)=210766920
S2(15,6)=420693273
S2(15,7)=408741333
S2(15,8)=216627840
S2(15,9)=67128490
S2(15,10)=12662650
S2(15,11)=1479478
S2(15,12)=106470
S2(15,13)=4550
S2(15,14)=105

But for the small dataset combinations are just a few after all:
S2(7,1)=1
S2(7,2)=63
S2(7,3)=301
S2(7,4)=350
S2(7,5)=140
S2(7,6)=21

So brute force would have worked nicely for the small dataset case but not so for the large one.

Sunday, September 14, 2008

Feeling of frustration


I joined yesterday a CodeJam practice session. It seems Googlers were fine tuning the contest site for the onsite finals to be held soon.

Problems were (or they look) easy but a combination of stubbornness and not thinking before coding let me in an embarrassing position (the best thing I can say I was not the worst player). However I failed to see the very easy relationship on the number of black balls (odd/even) and the final output of the Old Magician problem (too late I found out that even black balls lead to a WHITE result, BLACK otherwise and UNKNOWN was just a distraction).

The square fields problem looked very much like a k-clustering problem, but here the clusters are all same size and square shape. You have to answer what is the minimum size of the squares to get a partitioning on exactly k-clusters.

I can tell you how other people solve it, but you can read this by yourself. Instead I'll tell you what won't work:

My first idea was to use java awt library and Rectangle class in particular. I started with the largest side possible for the square and then I tried to obtain the full coverage of all the points by creating new rectangles to cover the points not yet included in the covered area. Once all covered I decremented the size and repeated the process. When full coverage was impossible with a given size I output the size+1 value as the result.

This approach work for some of the examples but failed on certain cases, so it was not good.

Second idea (and attempt) was to consider obtain the Minimum Spanning Tree of the points of the problem, then I would remove the k-1 longest links so I would end up with k disconnected sets. Later I will find out what is the largest dimension on any axis of every group, that will be the answer.

Again the idea worked nicely with most of the cases but not with all (Case #5 of the small set was one of the ones that didn't work with). The problem is that in this case the first point (1) is connected to 3,4,5,7 as nodes 2 and 6 remain isolated because of my algorithm. However the solution is that node 1 is connected to node 6 and then the max square side is limited by the vertical distance between nodes 5 and 3 (it's 1000 in case you wonder).

So my second approach did not work in all the cases either. So I will be happy getting a suggestion that works.

Because I've been busy failing on the second question I haven't yet been able to attempt the third exercise (Cycles) that wants us to count the number of Hamiltonian cycles on a undirected total connected graph where some links are forbidden and where shifts of the same node sequence count as 1 case only.

I guess that the result will have to do with dividing the total permutations by the different number of combinations that can be done with the forbidden links. I'm going to have a look at it as soon as I solve the second exercise with a solution that works ok everytime.

Friday, September 12, 2008

New Arduino form factor


A couple of new versions of Arduino boards can be found on Arduino blog: the Arduino Pro and the Arduino Pro Mini (depicted here). Both work at 3.3V and I think that makes them ideal for battery-powered applications.

In my case I'm going to create a small circuit to interface the Mini to an XBee wireless module to create a smallish wireless sensor. Hopefully I'll get much longer operation times than those Rob Faludi measured with Diecimila and XBee shield.

Saturday, September 06, 2008

Klondike with a twist

Before Windows I've never played Klondike (aka Solitaire). I do not like it very much as many times I've got stuck so I do not play it very often.

This time roles have switched and I find myself writing code to play the the game: There is an ongoing TopCoder programming contest where you are asked to write the "game logic" code.

I am a poor Klondike player and it shows in my code. There are many pages out there with guidelines on how to play it well, but sometimes the rules are too high-level.

To make things worse the game is known not to be solvable in some cases.

Competition will be open till September 10th.

Monday, September 01, 2008

It was about time

I've waited till the end of my holidays to upgrade the operating system of various of my computers. I was happily running Ubuntu's Gutsy (7.10) and I'm upgrading to the new Hardy (8.04). Actually it is only one month more for the new version to be available, but this time I did not wanted to upgrade in the middle of the semester.

Contrary to other times, this time I decided to do the upgrade using the embedded upgrade feature of the system updater. My conclusion is that, as usual, it is a risky proposal: My laptop froze when updating the locales (a known bug as I found out later) but killing locale-def allowed the process to come to an end. Lately the system healed itself and everything seems to work as expected now. A minor complain is that now the system takes a few more seconds to wake up from suspend.

On one of my desktops the experience was different but not fault free: No complains or hangs on the locale but an error message about not being able to install linux-ubuntu-modules-2.6.24-19. The install process aborted at the very end. I was left without network connection. The network icon on the desktop showed a red exclamation mark. Running dhclient did not return a valid address but disabling and enabling the network again did work and connection was reestablished. Afterwards a dpkg --configure -a cured the problems and all was good again. After a reboot the system came back to life nicely.

Taking in consideration the time it would take me to restore the different configuration parameters should I have installed a fresh system the upgrade proved a good though a bit rough approach.