Monday, June 6, 2022

Lessons learned from joining coding competitions - 2012 vs 2022


In 2011, I took photos in front of Google's Mountain View, California office. Wouldn't it be great to also be able to take a look inside? I wasn't able to do it then. But this thought inspired me to join Google Code Jam a year later (2012). The finals were usually held at a Google office anywhere in the world. This was a great opportunity. Add to that the bonus of winning a big cash prize, getting some swag (Google T-shirt & stickers, etc), and getting recognition for my skills. During that time, I was also trying to learn Ruby, and I thought joining a coding competition would be a great way to practice.

Fast forward to 2022, finally there is a local coding competition that I could join, i.e. StackLeague. I saw the tournament as a means to stay sharp as a developer. With the fast pace of technology evolution these days, I needed to stay on top of the latest trends to remain competitive. 

StackLeague also offered more chances of winning prizes, as there are many events and categories to join. Winners of all levels can win cash prizes, cool swag, and also gain recognition and possibly tech job opportunities. As a bonus for me, I found their ambassador program incentives a good motivation for me to keep my blog alive and updated.


How I prepared for the coding competitions - then and now

Back in 2012, I prepared for Google Code Jam (GCJ) by practicing on past coding questions which they keep in their contest archive. I also took time to learn my preferred programming language back then (Ruby). 

Now with StackLeague, I needed to boost my strategy in order to be in the same league as the younger and more keen challengers. My schedule is packed these days, so I made the most of my time on StackLeague by:

  1. Trying out the practice challenges
  2. Taking on the training courses.
  3. Setting up an efficient coding environment, including having the right tools and references (more on this later).
  4. Trying out the main challenges multiple times. As of this writing, I've taken 14 bronze challenges (12 failed, 2 passed)
  5. Focusing on small wins and alternative ways to win. I knew gaining ambassador status could also win me a cash prize, some swag, and recognition.


Lessons Learned

Here are some lessons I learned so far in joining StackLeague events.

#1 Age doesn't matter

You may think that seasoned developers have an unfair advantage over students, new developers, or career shifters. This is not necessarily the case. If the more mature (a.k.a. "older") developers are not up-to-date with the latest technologies, the newbies can take on them easily. Even as simple as not knowing about the latest features of their preferred programming language could cost them inefficiency. (For example, knowing just the JavaScript of the early 2010's, versus the new features of ES7). 

In the same way, newer developers don't have the upper hand either. Tenured professionals have encountered many algorithmic problems of various kinds, that they have the insight to identify the problem and the solution quickly.

My keyboard has a shortcut key for the calculator. 

#2 Use the right tools

The in-browser code editor has the bare essentials. But having a full-featured IDE provides flexibility in attacking the challenges. 

  • IDEs have features that help you focus on the core problem by automating repetitive tasks. Examples: Code completion, API documentation, code highlighting, shortcuts to find variable references, quick text replace, etc.
  • IDEs have more detailed logging. This is especially useful in figuring out why some unit tests failed.
  • IDEs have a debug mode to step through code and inspect how variable values change. This is very useful for challenges that involve iterations.

Google Code Jam allowed participants to use their own tools. I believe StackLeague allows it as well.

Aside from software tools, specialized hardware may also help. I do not yet have a mouse with extra buttons (though I might buy one in the future). But my keyboard does have extra shortcut keys -- e.g. to quickly bring up the calculator. I found this very handy.



#3 Learn to focus

I have three monitors for my work from home setup. People say this increases productivity. But there is also a negative effect to productivity in that you might be looking at 3 different things, thus distracting you from the main task on hand.

To counter this, while competing in an event, I have only 3 windows open -- one on each screen, and each window is maximized to full screen. 

  • Main screen: Code editor in full screen
  • Second screen: StackLeague challenge site, also in full screen.
  • Third screen: empty browser window for Googling and checking references. 
  • Notifications and instant messaging apps are turned off.
  • Having background music might help. I find it easier to concentrate when I have Lo-Fi Chill instrumental music playing in the background.

#4 Sharpen the ability to identify problems

The challenges I've encountered so far have been related to combinatorics, Number Theory, arithmetic operations, binary operations, strings, arrays, recursion, etc. Being able to identify the type of problem already wins half the battle. 

#5 Solve it with pen and paper first

I find it easier to understand a challenge by first simulating it with pen and paper. First solving the problem by hand allows me to find a pattern quickly.


In it to win it

When I joined Google Code Jam in 2012, I didn't pass the qualifying round that year. I either I ran out of time, or couldn't get the code to work for the larger data set. But I just kept practicing and I just kept joining in succeeding years (until 2014). This year as I compete in StackLeague, I will approach it with the same persistence and consistency, but with additional strategies. Join me!

Wednesday, June 1, 2022

StackLeague Challengers Find May '22 Lightning Round Nerve-Wracking

 StackLeague Lightning Series - Bronze Category - May 24, 2022

I was able to join the Bronze Lightning Round for the month of May, together with seven other challengers. It was both exciting and nerve-wracking for everyone, as we all raced to finish two Bronze-level challenges within just one hour. 

What is the StackLeague Lightning Series?

Lightning Series are a by-invitation competition open only to challengers from the same Challenger Level. Gold-level challengers are disqualified. The Bronze Category is open only to Bronze-level challengers.

Why join the Lightning Series in addition to the other challenge categories?

The Lightning Series offers yet even more opportunities to win cash prizes and swag. The top 2 winners for Bronze Category will each receive ₱ 1,200 cash prize and a StackLeague T-shirt.


Results of the Lightning Series

The entire program was streamed live on YouTube. The official timer started at 6:30PM. Challengers had to solve two Bronze-level challenges within one hour. Below is a play-by-play coverage of the competition:



  • 06:30PM - Only 6 players were on the leaderboard at first. Two other players seem to enter the challenge a little late.

                    - At first I was a little relieved that there were only 2 challenges to tackle. But upon reading both problems, my mind was panicking a little bit in trying to comprehend the problems and choose which one to solve first.

  • 06:31PM - All 8 challengers were now on the board, all at 0 points.

                     - I've decided to work on the second challenge first, which I think was related to binary arithmetic.

  • 06:34PM - Rankings still haven't moved with everyone still at zero.

                    - The clock is ticking, and I had to force myself out of my analysis paralysis. I started coding a naive solution, just to find momentum.

  • 06:38PM - Still no change in rankings. So I thought I still have a chance to get ahead of everyone if I could just solve this one problem quickly. But then a challenger finally breaks through...

  • 06:39PM - Finally Efren Mercado Jr secures the top spot with 50 points (1 out of 2 challenges solved).

  • 06:44PM - Efren finishes both challenges and gets 100 points while others were still at zero points. It's now a battle for the second place.

  • 06:48PM - My solution for problem number 2 worked with the small unit test but failed with the larger test data set. I couldn't figure out how to optimize my code. Maybe I should move on to the other problem, so that I can still beat the others for second place.

  • 06:57PM - Aloever Dulay finishes his first problem (50 pts) and takes the second place.


  • 06:58PM - Albert Francisco follows at 3rd place with 50 points as well.

                    - I tried to shift to problem #1 for a bit, but decided to go back to problem 2. At this point, I was just trying to at least not end with zero points.

  • 07:05PM - I finally get a breakthrough with Problem #2. It turns out attempting to perform bitwise operations was naive, and had I known to do a simpler boolean operation, I would have finished earlier.

  • 07:06PM - The leaderboard now has the first to fifth places filled: With Efren at 1st place (100pts); Aloever, Albert, and myself (Eliel) at 2nd, 3rd, and 4th places respectively (each with 50pts); Lorie Lie Cubid took 5th place with 13.64 points.

  • 07:08PM - Albert Francisco finishes his 2nd challenge and snatches second place from Aloever. I started to work on the next challenge that apparently had to do with calculating pairwise distance.

  • 07:14PM - Aloever increases his score to 54.55 and remains at 3rd place. No score movement for myself and the others.

  • 07:15PM - Aloever finishes his second challenge and gains 100 points, securing 3rd place.

  • 07:17PM - At this point the other challengers can actually give up, since only first and second place will get prizes. 

                    - But I pushed on, and I picked up my notebook and pen to draw and better visualize the challenge scenarios. I should've done this much earlier!

  • 07:23PM - Jigger John Mendeja finally breaks through and scores 50 points (6th place)

                    - With only 7 minutes left, I hacked on, having gained clearer perspective of the problem.

  • 07:24PM - I ran my code on both small and large data set, so that I could at least raise my score a bit more if it passed at least some of the tests if not all.

  • 07:25PM - Only 5 minutes left, and I was still trying to figure out why the sum returned by my code was off by 4 compared to the expected answers.

  • 07:26PM - I just subtracted 4 from my final answer - it worked! I finished both challenges and got 100 points at 4th place.

                    - There were no more score movements for the other challengers. Either they already gave up, or were still trying to solve the challenges.

  • 07:30PM - The timer ends with Efren at 1st place and Albert at 2nd place. As for me, at least I wasn't last, and at least my score was 100.

Recognition of the Winners of the StackLeague Bronze Lightning Series

When interviewed, second place winner Albert Francisco laughed. "Nakakatawa lang... nanginginig kamay ko hanggang ngayon." He was still trembling due to the pressure and excitement of the Lightning Round. When asked what tips he would give to fellow challengers, he said, "Mag-isip muna talaga, wag muna agad code." Albert encourages challengers to think hard about the problem before diving into the solution. The first solution you come up with might be complicated, but when you try to first clarify the logic involved, a simpler solution will come to you. "Isipin muna ang algorithm tapos saka na i-code."

Efren Mercado Jr, a little bit more composed, said that he had fun with this round. He found the questions tricky but the solutions turned out to be simple. Efren suggests starting with the easier challenge first. The way the problem is stated is sometimes complicated to distract you from the real problem. In the end, the solution will be simple if you focus on the real meaning of the problem. Efren is already a professional and is already well-versed in coding.


What's next?

The May Playoffs happened on May 28, though I wasn't able to join this time. StackLeague offers many other ways to practice and improve coding skills. So just keep practicing, keep improving, and keep your eyes on the goal -- whether that goal be winning the cash prize, finding job opportunities, or improving your skills.

Fastest Dev in the Cloud: Using JHipster and AWS for rapid application development

 Summary: How to become the fastest dev in the cloud: Use a rapid development platform. In this blog, we will use JHipster for Java. Use a c...