Rotating Pixels and Right Brained Programming

In this refreshing article, Niall Murphy provides a few anecdotes on how to apply lateral thinking to programming.

Engineers can slip into the habit of using the same algorithms to tackle whatever problems are presented to them. A bit of lateral thinking can lead to more interesting and sometimes more optimal solutions. It's not always easy to look at something in a different way, but exercising your brain in this manner can be fruitful for your project (and keep your brain young, too).

The key is solving the problem backwards.

Ask yourself, "If I had the answer, would I be able to discover the question?" Other mathematical challenges are amenable to this sort of approach. Finding the square root of a number is fiendishly complex. If you already had the answer, however, checking it by squaring it is a simple case of multiplying it by itself. So if we guess at the answer we can check it. If the guess is too large, the result of squaring it is larger than the original value. We can iteratively improve our guesses as we get the result of each trial.

It's sometimes necessary to throw away the current way of doing things in order to see that alternatives are possible.

One of the reasons I love reading Dr. Dobb's Journal is that they seem to attract authors like Niall.