The past few weeks I have been solving problems on the online competitive coding judge Kattis. Kattis is a site where you can create an account and solve problems for points. You submit your code to Kattis, then Kattis compiles/runs it to check it against hidden test cases.
The problems vary in difficulty from trivial to very hard. I have done mostly hard ones so far, though that is not effective for gaining points. I tend to get stuck on the hard problems, and then I can’t let the problem go until I have solved it. Sometimes it takes me a few days before finally finding a solution to a hard problem. During this time it is tempting to constantly think about the problem even when I’m not actively working on it. This process often makes me feeling stupid and frustrated, though the feeling of relief when I finally solve a difficult problem is incredible and addictive.
I am not really interested in the competitive part of competitive programming. I mostly think it is fun to solve new and interesting problems. Fundamentally, I think that problem solving is what makes programming fun. By solving these problems I might also become better at solving other problems that arise in my normal programming work.
An example of a problem that I was stuck on for a long time is Around the Track, in which you have to find the shortest looping path between two polygons.
To aid in debugging my solution, I made a program that renders an image for the computed shortest path. Below is one such image (the red path is the shortest path, the inside of the blue area is the outer polygon, and the outside of the green area is the inner polygon).