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).

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.