Saturday, February 12, 2011

Tricky question using Python defaultdict

I got a very interesting question which puzzled me, though I solved it in ten minutes. Its a nice challenge, try to answer the question before you look for the answer. Use python interpreter to try it out.

Collections module in python has a defaultdict(default_factory) which will take in a default value and return it if we try to access the key which is not there. In the case of normal dictionary, we will get a key error.

>> d = dict()
>>d['rr']
KeyError: 1

>> from collections import defaultdict
>> dd= defaultdict(int)
>>dd['rr']
0

But now if you try to access this, we get
>>dd['rr']['tt']
TypeError: 'int' object is unsubscriptable

Now, here is the question. How will you make it work? Also you need to access arbitrary number of dictionary of dictionaries (for example >>dd['rr']['tt']['t'] =1), write a function to make this possible.

Friday, January 7, 2011

Top Business Models that rocked 2010.

Even if an organization has a great product/service offering, I think it is very important that they have a very good business model in place to complement it. A successful business model not only gives an organization a sustainable competitive advantage that will set it apart from others but I think it is also often the difference between surviving and not. I came across these great slides that pretty much portray the big hitters of 2010 and I recommend looking at it. Awesome!
View more presentations from Board of Innovation (BOI).

Wednesday, January 5, 2011

Windows on Mac OS

There is always a bit of confusion about the right way to use Windows from a Mac OS, bootcamp or VMware. One nice thing about using Boot-camp and Parallels/VMware fusion together is having only one installation of Windows. Then when you are on Mac OS, if you need to run Windows for a typical office type application, you can just launch Windows via Parallels/VMware fusion(your bootcamp installation).

This way not only allows one installation of Windows but also only one Windows to update and keep current.

Also if you install your bootcamp Windows installation using a NTFS partition, you can run WinClone from the Mac side to backup your Windows installation. WinClone works great.