{"id":32,"date":"2021-04-10T22:54:02","date_gmt":"2021-04-10T22:54:02","guid":{"rendered":"https:\/\/blog.wordgeeks.net\/?p=32"},"modified":"2021-04-10T22:54:02","modified_gmt":"2021-04-10T22:54:02","slug":"gcj-2021-r1a","status":"publish","type":"post","link":"https:\/\/blog.wordgeeks.net\/?p=32","title":{"rendered":"GCJ 2021 R1A"},"content":{"rendered":"\n<p>I&#8217;ll recap my participation in Google Code Jam 2021 Round 1A here.<\/p>\n\n\n\n<p>The performance is not too impressive. If I weren&#8217;t able to fix a silly bug and submit in the last minute, I wouldn&#8217;t have advanced to the next round. At the beginning of the contest, I also wasted 20 minutes for the easiest problem.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"528\" height=\"171\" src=\"https:\/\/blog.wordgeeks.net\/wp-content\/uploads\/2021\/04\/gcj-2021-r1a-c.png\" alt=\"\" class=\"wp-image-33\" srcset=\"https:\/\/blog.wordgeeks.net\/wp-content\/uploads\/2021\/04\/gcj-2021-r1a-c.png 528w, https:\/\/blog.wordgeeks.net\/wp-content\/uploads\/2021\/04\/gcj-2021-r1a-c-300x97.png 300w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><figcaption>Submission for &#8220;Hacked Exam&#8221;<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"343\" src=\"https:\/\/blog.wordgeeks.net\/wp-content\/uploads\/2021\/04\/gcj-2021-r1a-a.png\" alt=\"\" class=\"wp-image-34\" srcset=\"https:\/\/blog.wordgeeks.net\/wp-content\/uploads\/2021\/04\/gcj-2021-r1a-a.png 473w, https:\/\/blog.wordgeeks.net\/wp-content\/uploads\/2021\/04\/gcj-2021-r1a-a-300x218.png 300w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><figcaption>Submission for &#8220;Append Sort&#8221;<\/figcaption><\/figure><\/div>\n\n\n\n<p>Things I could have done better:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Take the time to refine the idea and <strong>craft some test cases covering all conditions<\/strong>. For &#8220;Append Sort&#8221;, 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:<ul><li>If y is already longer (more digits) than x, then we do nothing.<\/li><li>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&#8217;s to y to make its length equal to x; otherwise, we append 0&#8217;s to y to make it longer than x by 1.<\/li><li>If the remaining of x is some form of &#8220;99&#8230;9&#8221; (possibly zero 9&#8217;s), we have to append 0&#8217;s to y to make it longer than x by 1.<\/li><li>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&#8217;s to y to make its length equal to x.<\/li><li>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 &#8220;1923954 1&#8221;.<\/li><\/ul><\/li><li>Prepare and refine the library for common data structures and algorithms.<ul><li>If I had an implementation of Rational beforehand, then I wouldn&#8217;t have to code one during the contest. And of course, to do &#8220;1 &#8211; p\/q&#8221;, I wouldn&#8217;t have written &#8220;Rational{q -p, p}&#8221;.<\/li><\/ul><\/li><li>VS Code is helpful, especially its debugging tool. I can add and remove breakpoints by a simple click while the program is running.<\/li><\/ul>\n\n\n\n<p>Overall, after working, I do feel more rusty. And the competition happening on a Friday evening also makes things worse. And I&#8217;m considering participating in time-constrained contests more regularly instead of relying on ad-hoc practice and CodeChef long challenges.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ll recap my participation in Google Code Jam 2021 Round 1A here. The performance is not too impressive. If I weren&#8217;t able to fix a silly bug and submit in the last minute, I wouldn&#8217;t have advanced to the next round. At the beginning of the contest, I also wasted 20 minutes for the easiest&hellip; <a class=\"more-link\" href=\"https:\/\/blog.wordgeeks.net\/?p=32\">Continue reading <span class=\"screen-reader-text\">GCJ 2021 R1A<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,2],"tags":[11,12,3],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-competitive","category-programming","tag-competitive","tag-gcj","tag-programming","entry"],"_links":{"self":[{"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=32"}],"version-history":[{"count":1,"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":35,"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions\/35"}],"wp:attachment":[{"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wordgeeks.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}