|
Well, I must add that the practice of solving comp pro problems is quite worthwhile for me (without the competition part). I'm always humbled when I try to solve something, need 50-100 lines of code, and then there's a solution that really gets what the inputs/outputs/intermediate data structures are and it turns out to be just 10 lines of code (written during live competition, I'm amazed by the truly simple thinking of these authors). The best problems that demonstrate that are most often just algorithms with arrays (no specific algorithm, only required knowledge is working with arrays). True display of thinking things through before coding. I guess example that come to mind (a mindblowingly simple algorith, try to find it yourself):
https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_v... It gives me similar feeling (but less pronounced) to looking at tinycc, or looking at some tree enumeration algorithm in TAOCP, or the modification of it done by Knuth to support enumerating arithmetic expressions without redundant parentheses (also just an array algorithm, figure out how to modify an array that represents existing expression into an array that represents next expression, literally just a bunch of loops). I had to handle time series data at work. There already exists 1000s of lines of code that deal with time series, sorted timestamp arrays, {up,down}sampling, timezone handling etc. All of that can be replaced by a simple 5 line function that works faster (supports tz, sampling, appends etc.). Only possible to write if you really focus on the problem you're solving and realize that the sub-problem you envisioned (the "efficient" time series data structure) does not really help you. |