One Problem, Four Paradigms
Explore with me how one simple problem, taken from Advent of Code, can be solved in four different languages using four different ways of thinking.
Recently, I thought it would be a good idea to start training what I considered my worst skills, technical programming by doing competitive programming. This blog aims to log my journey through the first beginner contest.
Published on Oct 4, 2026
2,195 words • 11 min read
I have heard of this website and its contests quite long ago, but I never was very into competitive programming, or thinking that it wasn’t very useful in product-based careers such as what I was targeting. After quitting a job that frankly, was completely different from the Job Description, I was promised Business Analyst-type of consultant, but it turned out to be telemarketing which was the thing I hated to do the most.
For more details on why I quit and what lessons I learned from just three days there, you can checkout this journal entry. But in short, I learned a few lessons that, to put in perspective, probably worth my three days sitting there:
There was really no reason why I chose to do it. I just looked at the time, and the unrated Easy Daily Training contest was about to start, and thought, how bad could it be, and signed up. It was the AtCoder Daily Training, Easy on October 1st. Literally two days ever since I quit the aforementioned job. (I did it in Python, just to let you know how oblivious I was to competitive programming.)
There were only 30-ish signups, which was expected from a daily thing, let alone the easy division. I just didn’t want to head straight to the All division, just simply wanting to see what it is, since I only heard of LeetCode and the cult surrounding it.
This was a huge breath of fresh air. It felt very similar to what I felt when I discovered Advent of Code, while everyone else was grinding LeetCode. AoC was truly something special, doesn’t matter what tools you have, doesn’t matter what language you use, as long as given the input, you can find out the answer. The diversity of the puzzles is also hugely varied, numbers, operators to strings. I immediately dropped LeetCode ever since the first year of university.
I also have a repository dedicated to this event here,
where each year I would be able to do something wildly different thanks to the
nature of the event. For example, in 2023, I tried to do 25 different languages
for 25 different puzzles. In 2016 (unfinished) and a redo of 2015 (finished), I
did everything in Dyalog APL. And in the last 2 years, 2024 and 2025, I tried
to do everything in Uiua (a stack-based array language that focuses on tacit
programming), but had to get help from Python for certain puzzles, such as
scipy.optimize. You can also read up how one problem in AoC, can be solved with
OOP, Functional Programming, Procedural and Array Programming here from my writeup!
The problems are not difficult at all, fitting for the easy league:
1 1 1 3 would be possible, by
adding a 3.4 would generate ABCD.|, then for each number, generate as many - and a | afterwards.
This sounded like being worded oddly, but essentially it’s just splitting at |
and counting -s.I originally had some trouble with the 5th problem, but knowing the constraints of how can be, it’s safe to say that an exhaustive search will never work. So I started looking other ways, whether given , we can reconstruct the number.
I wrote down the sequence on a notebook to the th number, and started to notice
that they come in groups of 5s, and the only meaningful boundary is at 8. My
first intuition, given that, it means for the -th number if it didn’t end in 8,
then the -th number is always . I started prototyping a piece that generates
numbers in chunks. Which, led to the next discovery.
These numbers appear in chunks of 5. to , then to , and so on. I noticed that doing would get me the last digit. This gave way into another intuition that we could reconstruct the number directly piece by piece, rather than finding where it is like the first method I had.
Something else that I really liked about this kind of input and output that relies
solely on stdin and stdout, is that it’s very easily testable, and doable in
many types of languages. In fact, I had full intentions to go with Uiua for this
contest, but because the Uiua Language Server was having an off day, so I went with
Python (which was extremely popular in AoC, so I figured it applied here). The
flexibility of stdin and stdout allowed you to do it in whatever IDE you fancy,
instead of the weird editor LeetCode has. In fact, some may say that you can do LC
in IDEs also, but it was so odd having to parse input properly just to pass into
the function LC expected.
After the contest, I had some chats and started reading up editorials, I learned one thing that surprised me greatly, is that it seems like C++ was much more favored in this scene. I always knew C++ was something verbose as I did use a wide range of features for my C++ game, and came into a lot of best practices. But turned out, competitive programming doesn’t need those best practices. You won’t get TLEs on high copy counts rather than moves most likely, but you get TLEs on bad solutions.
The next day, I decided to go from the Easy League to the Open League, hence I signed up for the AtCoder Daily Training ALL. There are 9 problems, against 30 people who signed up. I finished 6 of the easier problems and got 1200/2550 points. Funnily, I was actually 30 minutes late to this, because I had something going on, and finished those 6 problems in 35 minutes. The others started to get too difficult for me.
I also started using C++, rather than just Python from now!
set
and std::lower_bound helped tremendously.I finished 20th out of 30 people. Bottom half, exactly where I expected I would be, since I have no experience in competitive programming, and frankly, haven’t done any programming for a few months. This feels the need to reiterate, that if I stayed in that telemarketing job, this kind of skills that I already don’t have much, will start to deteriorate and close all any doors to more senior developer positions.
Knowing that the next day would be the actual Weekly Contest, I started to look over some solutions, editorials, and even trying to upsolve a few problems in those virtual contests I had.
I did a lot of virtual contests, adhering to all the rules to see how far I can usually take before I break, and which types of problems would cause that. I learned a few small things during those 24 hours before the Weekly Contest:
clang++, and pasting in
the correct inputs.bits/stdc++.h and namespace std allows a lot to be truncated,
much faster than including one by one.Is it obvious I have been watching One Piece Live Action? Can you guess which character is my favorite?
To put it short, I was humbled.
7 problems, and I solved only 2, stuck on 3rd and 4th. With 2 submission errors, I got penalized by 10 minutes, leaving position #6500 out of 9300 participants. Again, bottom half, what I totally expected. I thought I saw what made the 3rd problem solvable, but I wasn’t able to implement it, and it didn’t seem correct according to the editorial. I actually still don’t understand the editorial for the 3rd problem. It just seemed difficult to imagine why that would be the case.
Problem 7th and 6th, I don’t even know what it was talking about, some convex points in 2D space, or finding the number of trees that satisfy a condition. I saw that the latter required the answer to modulo some constant, that’s literally a flag to tell me to not try this problem for now.
What I got annoyed at, was the 3rd and 4th.
Of course, this is only the start. I feel great being humbled. It makes you feel like you have lots to learn more.
At the last telemarketing job, I was ashamed when amongst peers. The boss said that it was because I was not good at the talk, so that’s why I was withdrawn, and also why I never felt withdrawn before in other technical activities because I was always the best. Now that I see it, I think the answer was much simpler than he and I thought. It was that, I never liked it in the first place. But this? Getting humbled by people who have been finalists at crazy competitions that write code akin to mathematicians’ notes? It feels great.
Explore with me how one simple problem, taken from Advent of Code, can be solved in four different languages using four different ways of thinking.
A simple Bloom Filter implementation in C++ to handle account registrations and logins. A project for a Data Structures and Algorithms course.