I’ll recap my participation in Google Code Jam 2021 Round 1A here.
The performance is not too impressive. If I weren’t able to fix a silly bug and submit in the last minute, I wouldn’t have advanced to the next round. At the beginning of the contest, I also wasted 20 minutes for the easiest problem.


Things I could have done better:
- Take the time to refine the idea and craft some test cases covering all conditions. For “Append Sort”, the essence is simple: for two integers x and y, append digits to y to make it minimally larger than x. The logic I have is:
- If y is already longer (more digits) than x, then we do nothing.
- Starting from the most significant digit, we find the first one that x and y differ. If that digit of y is larger, we append 0’s to y to make its length equal to x; otherwise, we append 0’s to y to make it longer than x by 1.
- If the remaining of x is some form of “99…9” (possibly zero 9’s), we have to append 0’s to y to make it longer than x by 1.
- Take the least significant digit that is not 9 in x. Make the higher digits equal in y and x, make this digit in y larger than x by 1, and append 0’s to y to make its length equal to x.
- In the last step, I somehow mistakenly used the most significant digit. However, the mistake can easily be caught by a case as simple as “1923954 1”.
- Prepare and refine the library for common data structures and algorithms.
- If I had an implementation of Rational beforehand, then I wouldn’t have to code one during the contest. And of course, to do “1 – p/q”, I wouldn’t have written “Rational{q -p, p}”.
- VS Code is helpful, especially its debugging tool. I can add and remove breakpoints by a simple click while the program is running.
Overall, after working, I do feel more rusty. And the competition happening on a Friday evening also makes things worse. And I’m considering participating in time-constrained contests more regularly instead of relying on ad-hoc practice and CodeChef long challenges.