3D Surface Area

Think in 2D. Then, proceed to 3D.

3D Surface Area

There are thousands of coding challenges available online, and your time is limited. How should you pick the right one to study? My answer is to choose the one which triggers an allergic reaction inside of you.

Today, I chose the following coding challenge.

3D Surface Area | HackerRank
Find the surface area of a 3D Toy

I succeeded in solving this question in one try. The secret that I could pull it off is that I observed the problem systematically and cautiously. At first glance, the question looked quite complex because I do not handle 3D geometry every day. So, rather than tacking the original problem head-first, I thought about an equivalent question in 2D and analyzed it as in the following picture.

I deduced the formula of 2D surface by moving my hand.

Gaining the formula for 2D, I became confident that I can handle the 3D version with this knowledge. Here is my note about the original problem.

With the insight that I got in 2D, extending it to 3D was very natural.

I could write code out of the above note. It was a good exercise.