Okay now I want to share my experience in joining facebook hacker cup 2011. I only managed to get to semifinal (Round 2) though. But it is a very rewarding learning experience for me.

Background

At early of this year, I saw one of my friend’s profile on facebook sharing the page to facebook hacker cup. Well seriously at that time I thought it is a security breach competition or something similar so I don’t really bother to take a look.

Few days just before the qualification round started, I took a peek at the facebook hacker cup page just for curiosity. To my surprise here, this is not a hacking (in term of security lingo) competition, but this is a programming competition. Now me myself haven’t join this kind of competition since I graduated from college. I did participate in a lot of programming contest during 2002-2005 timeframe where I went to college though. But anyway I see this as a good chance to reboot my programming skill again and decided to enter the competition. Luckily for me it wasn’t too late for me.

Reading the rules and terms of the contest, someone posted that the rules are almost a copy-paste from google code jam. Since I never joined GCJ (but I do know their presence), I googled the gcj to read their terms and yes…. it is like 90% of the rules are copy-paste from GCJ. But here I learned something new for me. All this time I misunderstood between the ACM-ICPC and GCJ, I thought they targeted the same segment. While ACM-ICPC can only be joined if you are currently enrolled in University, but GCJ is free for all. I always thought GCJ is also for University’s student only, which is why I never bother in the first place to participate in GCJ after I graduated.

Learned up to this point : GCJ is free for all

Qualification Round

On qualification round, I chose the 3rd (string manipulation) problem and after I solved it I went to hit the submit. And ow boy here is me, a windows boy… when I downloaded and opened the input file, on notepad I am surprised that the format is not….. formated. So basically I am kinda panicked a little bit and try to format it again myself. but Alas when I tried to run it I got an error, so there is a bug on my code, after tracking and solving the bug, I ran out of time (the timer is only 6 minutes). But actually later on, they lifted the timer restriction on qualification round and my solution for this 3rd problem got accepted.

At that time I thought I was already failed at 3rd problem, which leave 1st and 2nd problem. The first one is math and the second one is map traversing problem. I decided to do the math one and hoping this time I could pass the time limit. and.. Yes I passed it.

Learned up this point : Unix and Windows have different new line character set and notepad on windows couldn’t detect it and shows it as whitespace . But the program will know that it is a new line so you don’t need to reformat. Wordpad on Windows could detect this new line.

Round 1 A

Goes to Round 1A. well actually there is only 1 problem that I have a chance to solve and still I couldn’t derive a solution in time. But since there were a lot of bugs from facebook itself this round got cancelled.

instead they gave Round 1 A Reprise. Well, still it was a tough one to compete, I ended up solving nothing but learned a great experience.

Learned up to this point : Probability theory, Pascal Triangle for Combination, Rencontres Number theory.

Round 1 B

Round 1 B was held on weekday, and in Japan it’s early morning at 6 PM. I got a job, although I could just take a paid day off but I didn’t. After reading the problem after, if only I joined this round I could just might pass because one of the problem is a widely known Josephus problem.

Round 1 C

Decided to do the prime related problems and really make sure my code could pass the time limit, and luckily it did pass. The timer is 6 minutes and my code run for about 4 minutes.

And then move on to the map traversing related problem, I actually solved it but it was too late. if only I had 3  more minutes, I could get this one accepted too. After the contest over, someone posted the right input and output for the problem and I tried in on my program and it passed. So I did solve it but couldn’t solve it fast enough because some stupid bugs.

But I already got 1 problem solved so I move to the next round.

Learned up to this point : Always watch for your global and local var (this is the bug that I didn’t find fast enough), memoization (array storage) could be used for approximately the limit size of int. Dynamic programming for map traversing using recursion is easier than I thought

Round 2

A tough one for me. I couldn’t solve even 1 problem. actually only 150 people that managed to atleast solved 1 problem with 5 people solved all of them perfectly.

Considering more than 120.000 people “like” the facebook hacker cup page so let’s assume they all registered, only around 5000 people passed the qualfication round, after that only around 1600 people passed the 1st round and only 150 people passed the 2nd round.

Congratulations for the first top 25 that will compete for grandprize.

Misc

although this time I used C#, but seeing the available solution that are dominated by C++ I also learned a few things I didn’t know until now.

Learned things regardings to C++: how to use preprocessor directive like to develop custom looping function and other cool stuff (for example #if 0)

Advertisements