Yet another webapp that is going to change the way we do …

Let us say we have this problem at hand:

There are seven stacks of 100 coins each. Each coin weighs exactly 10g. But we think in one of the stacks the coins (all 100 of them) weigh 11g each. We have here a very accurate and expensive electronic balance. How will you find the stack of abnormal coins?

Let us see how the three different generations of software engineers will solve this.

c/c++ Engineer:
Look at 7 stacks as 7 bits. Let us say, if the bit is 1 then it has 11g coins else it is 10g coins. So we simply need a weight to turn the respective bit to 1 if the stack it represents has 11g coins.

You pick 20, 21,22,…,26 coins respectively from each stack, weigh them once. A moment’s reflection will convince you this works not just for one abnormal stack but any number of them. All this with just 1 weighing.

Agile Java Engineer:
Let us separate the interface from the implementation. Let us also recognize that we only need to solve today’s problem of one coin stack being abnormal and not tomorrow’s problem of any number of stacks being abnormal.

The simple implementation we will provide will pick 1,2,…,7 coins respectively from each stack and weigh them once. If a stack has 11g coins, then you can find it easily from the weight difference. One weighing will still do.
Say, tomorrow the product manager changes the requirements to find more than one stack? We simply provide a new implementation for the interface. Codes using the same interface need not change one bit.

Webapp Ninja:
I will have this scale hosted as a web service with REST API. It will take one coin at a time and will return the weight. You implement the client code to pass coins from stacks 1 through 7 to find the abnormal stack.

This works not just for one stack but for any number of stacks. Yes it takes 7 weighing, but we are in the age of utility computing. Computing cycles and bandwidth are cheap.

Why bother with complex algorithm when resources are in abundance? Besides, what will those two guys do when there are not 100 coins per stack?

Oh, we will provide our own browser based client as well, complete with Fail Whale page and ShareThis buttons.
Actually, we were coding while you were talking and lready have this up and running at (or weighify). This is a ridiculously easy tool to weigh coins.

We will price this using Freemium model,

Free: 1000 coins per month
Pro: 10,000 coins per month
Unlimited: Unlimited coins per month
Now go away, I am busy designing the pricing page.

No wait, we are building a platform. We are only beginning to scratch the surface.

Note1: Yes, I understand it is not possible to pass a coin through an API or enter it in a website. But let us not let that interfere with the story.
Note2: At least the webapp Ninja is thinking about monetization.
Note3: Surprised by this post? I have software in my upbringing, having written c/c++/java code for embedded real-time systems and as senior software manager I led a team that developed CDMA Radio Basestations.

(Photo courtesy of Flickr user Rodrigo Amorim )