The Value of Coding Challenges
I recently spent some time doing coding practice with Codility, a website that sets coding challenges and a time limit and grades your solution on various factors at the end (correctness, scalability, edge case handling etc.).
Most of the challenges are able to, or meant to be done using basic techniques such as primitive array and character manipulation, which is something I generally don’t need to do when working in a language with a rich library like Java. So it was a bit of a hurdle at first.
I found that there are certain techniques and patterns that emerge. The more I attempted, the more I was able to identify problems as being a certain category and therefore had a grasp of how to find the solution. For example a lot of array-based problems could be solved in one pass by sorting/using intermediate structures.
A lot of the time I also found myself shamefully scoring 20% or so because I’d forgotten one small thing, or used an i instead of a j. It’s quite humbling to see how easy it is to make a mistake when coding without the tools I usually have at my disposal. Thankfully when I first learnt Java I used a plain text editor with simple syntax highlighting and compiled/ran directly from the command line, so it wasn’t entirely unfamiliar to me.
A benefit of performing these challenges is that I feel I’ve improved my knowledge of Big O. Most of the problem descriptions included some expected level of time and space complexity, which meant I had to factor this in when coming up with an initial design. I’m now a little more confident identifying the traits of O(N) and O(N^2) problems and the like, which is something that’s important when designing scalable systems and should actively be borne in mind during the design and implementation phases in my opinion.
Ultimately I found it to be really interesting to get a chance to solve these sorts of problems that I don’t have much call to do in my usual day-to-day (focusing on higher-level problems such as GUI or web service design), and I feel it’s helped sharpen my skills. It’s definitely something I intend to keep up from time-to-time.
To round it off I’ve linked my solution to one of the medium-level problems below, the description of which is here. Note that due to the time limit I felt sloppy commenting was permissible!
You can find the rest of my solutions, imperfections and all, on GitHub.
Thanks for reading.