The “Eureka!” of Coding

When the Ancient Greek scholar, Archimedes, once stepped into his bath, he was amazed to see the level of the water rise.

It’s a phenomenon that we don’t even notice today, but back then it was a revelation. Archimedes realised that the displacement of water was equal to the volume of his submerged body.

Legend has it that upon discovering the water displacement, Archimedes jumped out of the bath and cried, “Eureka!”.

“Eureka!” can be roughly translated as “I found it!”. Archimedes had found the solution to something which had troubled him for a while.

Arguably, this could be one of the first, and most notable, examples of an Aha! moment.

I still remember clearly my first two Aha! moments regarding coding, algorithms and problem solving.

They were both related to being able to solve a problem on my own, without any external help. No google searches, no video explanations, nothing.

Just me and myself:

  • thinking about the problem
  • writing down one or two examples
  • understanding how the answer is deducted and why it works that way
  • laying down on paper the steps that are needed to solve the problem
  • coding up the solution
  • fixing the compile / syntax errors
  • running the code with the input example
  • Seeing that it gives a wrong answer
  • Using print statements to debug
  • Fixing the error
  • Trying on different inputs and seeing that it works
  • Submitting to the online judge and getting accepted

The first time I had an Aha! moment was when I was able to solve a simple problem on my own.

The second time is when I solved my first hard problem on my own (yes, it was a Dynamic Programming one).

This involved a few more steps like generating large input tests to make sure my program was fast enough and works well on big inputs.

Why is this important you might ask?

When you know that you can solve problems without any help, you KNOW that during a Coding Interview you will be able to solve anything they throw at you.

They might give you a problem with a twist. If you only know the classical problem by heart, you might not be able to solve it.

Or they might just surprise you with a problem you’ve never heard before.

Those Aha! moments give you the confidence you need to pass those Coding Interviews with flying colors.