Tuesday, 30 April 2013

The Bulb Puzzle


There are 100 light bulbs lined up in a row in a long room. Each bulb has its own switch and is currently switched off. The room has an entry door and an exit door. There are 100 people lined up outside the entry door. Each bulb is numbered consecutively from 1 to 100. So is each person. Person No. 1 enters the room, switches on every bulb, and exits. Person No. 2 enters and flips the switch on every second bulb (turning off bulbs 2, 4, 6, …). Person No. 3 enters and flips the switch on every third bulb (changing the state on bulbs 3, 6, 9, …). This continues until all 100 people have passed through the room.

What is the final state of bulb No. 64? And how many of the light bulbs are illuminated after the 100th person has passed through the room?

SystemC Hierarchy Scanner

During integration of a systemC virtual platform often it is desirable to traverse deep down the hierarchy  of systemC and find out type of each systemC components. More over we can also get the hande of exact types by trying out dynamic cast operation on to it. Presenting a sample class to show case the concept of hierarchy scanning. This can be further utilized to build complex utilities. For example using this I was able to build a text based systemC pin connector.


A generic logger class


Sharing the design of a generic logger class in C++ that can be instantiated by any class that need logging facility. IT supports various features like different verbosity level, dynamic configuration of logging and C++ style streaming operator control.