Problem solving and Python programming fun! This solution involves the conception and creation of a custom distance function, and the usage of a sliding window to find an optimal value.
I participate in a various programming competitions, however not competitively. The types of problems you encounter there are a lot of fun to try and solve, and more often than not it’s the logic and algorithm that’s hard to work out – not the implementation itself. The challenge is often in scalability: a naive, slow solution may seem trivial, but will not scale to solve the problem with large inputs.
I participate in short (1-3 hour) competitions which usually consist of 4 or 5 questions, where the first is quite easy (relatively) and it becomes much, much more difficult from there. I often end up only answering the easy question and am cheering if I manage a second one! The websites I use are CodeChef, HackerRank and HackerEarth (for SQL challenges), and I keep track of all of my attempts on GitHub.
The time zones are a challenge for me, as most of the competitions run between 1-3am in Australia, but I find it so enjoyable that I strive to participate whenever practical. I even got one of my good friends involved. He’s not a programmer, but is super smart and has a good grasp of mathematics and logic, so he enjoys it too, and I enjoy watching him slowly starting to understand some elements of programming and devising scalable solutions, even though he’s not doing the programming himself.
So where do Spills come in? Basically I want to share some of the fun problem solving moments, perhaps in the hope of helping others realise the fun in it and give it a go. A lot of the Spills I’ll make will be from questions in these programming competitions that I’ve found particularly interesting. However, I’ll also include some real-world situations which won’t be as logically challenging in most situations, but a good demonstration of how a little fun programming can be used to solve or greatly simplify real problems.
Each Spill will be a single problem. I’ll spend some time defining the problem and the expected solution. Then I usually break the problem down into something more simple to work with – an important part of problem solving. From there I’ll devise the algorithm and finally walk through its implementation in Python (to start with).
I’ve just published the first Spill on YouTube. Hopefully my video creation/editing skills and efficiency will improve over time and I can get into the habit of creating these Spills regularly. On that note I’d appreciate any feedback in how I could improve for future videos, or any comments at all for that matter :)