4 ms·
Competitive programming develops these skills quite well. Reaching high performance means knowing the solution before coding it up. Witnessing high level comp
by cleancoder0 5y ago
Competitive programming develops these skills quite well.
Reaching high performance means knowing the solution before coding it up.
Witnessing high level competitive programmers scribble stuff on paper for 5-10 minutes, and then just a pure stream of thought into a 100 line C++ program that was compiled once, run through examples, submitted and accepted, is out of this world.
Another example is when solution is unclear (mostly for number theoretic stuff that needs to be efficient), scribble on paper, code up pattern generating code, generate patterns, look at them, stop, scribble on paper, code the O(1) solution, submitted and accepted (an easy example is to efficiently calculate the sum of first N Fibonacci numbers).
- ChrisMarshallNY 5y agoAnd that's why I'm not a competitive programmer. I'm not competitive, anyway. It's really a life choice, and a moral stance. Also, that's not how my brain works. I'm not really interested in proving myself to anyone, or beating anyone else. I just enjoy writing good stuff that people use.
- cleancoder0 5y agoWell, 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_vote_algorithm 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.