Posted by: felipe | July 17, 2008

Code Jam in JavaScript

Today was the qualification round of Google Code Jam 2008. This year Google remodelled the contest format, moving from the traditional competition arenas where you code using some of the pre-specified languages (usually C++/Java/Python/VB) directly into a window and the code is compiled and run server-side, to a more open format where you just download an input file and submit the output of your program. I liked this change very much, because it brings two good advantages for the competitors: first, you can use the editors, environment and programming tools that you’re most comfortable with; second, you can use any programming language that you want (as long as its freely available). This is definitely cool because if, for example, some complex math problem appears, one could even open some free math environment like Sage or Scilab to solve some integrals or matrix equations.

In the past I’ve participated of such contests coding in C/C++ and I was warming up for this year’s edition in C++ and maybe Perl if some tricky parsing gets needed, but then I decided to try something a bit different this time and check how nice it would be to participate in the contest using JavaScript. Turns out it was totally cool!

Before the contest started, I coded a little JS arena to make it quicker to work with my code, without the need of saving and reloading files all the time. It also supports working with the input/output in a way which is generally expected by such competitions: by reading one line at a time, getting the values as strings or numbers, and printing to the output one line at a time, generally one line for each test case. It is similar to Jesse Ruderman’s JS Env, albeit much simpler, but with the added twist of accessing an input. Another available feature is actually running two different source codes as input altogether, useful if you want to code some helper functions but don’t want them to keep visually distracting you (The helper functions are kept in a hidden textarea that you can toggle).

JS Arena

JS Arena

Having the opportunity to work in the contest using a language full of features like arrays with built-in sorts, RegExp, lambda functions, OOP, Hashmaps/Dictionaries/however-you-call-it makes a lot of difference when you are running against the time to solve an algorithm problem. And it was also very nice (and geek) to use Firefox as my development environment for the contest, as it’s already the case for many people doing webdesign entirely using FF and its great extensions. The qualification round has ended, now let’s see how far I can go with JavaScript in the next rounds!

As this arena is not only useful for this contest, but also if you want to do some quick JavaScript coding/parsing, I’ve put it online (JS Arena). It comes loaded with the code and input from one of the problems of the qualification round (which was about search engines), but you can just erase the pre-loaded text and type your code. The whole CSS and scripts are contained in a single .htm file because it was easier to submit to the contest, and it makes it easier too if you want to grab the file for offline usage.



  1. Yeah, the contest was pretty cool, and building up your own arena makes things really interesting! Actually, you BUILT your own “comfortable environment”. HAhaa, very nice and creative! =D

  2. […] – bookmarked by 3 members originally found by nahlaalzareen on 2008-10-10 Code Jam in JavaScript – bookmarked by 3 members […]

  3. Hi! A very nice coding arena indeed! Do you have
    all tasks from qualification round in 2008? I you
    do can you upload them somewhere or simply e-mail me. Thanks in advance!

  4. That’s really great! I was planning to do JavaScript in Code Jam this year (Code Jam 2011) and I thought no one else was even thinking about it. How far did you get in the competition? Are you going to Code Jam again this year?

  5. Visit – javascript online editor for google code jam. It’s using web workers, so you can utilize you cpu power in more convenient way. Useful in code jam tasks with large input…


%d bloggers like this: