In case you didn't know, during the last months Ibuildings has launched many challenges to PHP developers, rewarding the winners with iPads and tickets for the DPC 2010.
Unfortunately the contest is not for us, but a PHP challenge can't be refused, right?
The first challenge consisted on developing a script to calculate the shortest path through a list of towns, one of the TSP variants. Forgetting the problem complexity, that could be approached in many different ways with exact or approximate algorithms, dynamic programming, genetic algorithms, euristics, branch&bound etc., the challenge required to minimize time, memory, lines of code and complexity. You can find more details and an interesting reading on Andy Thompson blog.
The second challenge, just closed at the end of June, required to write a PHP class to cover all the tests of a PHPUnit class provided by Ibuildings, with the least number of rows (following best practices, not everything on a row). At the same time a much more interesting (to me) an unofficial challenge started on Twitter: writing the shortest solution in terms of bytes
.
Going straight to the point, skipping all the refactoring/compression stuff, these are two solutions I submitted plus one I just posted following some crazy comments to the Techportal blog post.
The "honest" one: 192 bytes
<?eval(str_replace(range(B,I),split(X,'De( $n)X;}E FX+self::FXfuncIXoperaIXH{returnHX($n)Xtion'),'class numbercruncher{E FaG+4CbG*3CcG/2*HCfG/2*9*HCgGDdH-DeH-HCdG?H*Dd(H-1):1CeG<2?H:BB;}}'));This works out of the box on any system, without using any trick or assumption, the one I spent more time on. It would work also in the case that more tests are added. It's not listed on Ibuildings post because I sent also the following one, apparently it's the shortest honest solution.
The "cheating" one: 153 bytes
<?class NumberCruncher{function __call($a,$b){$t=debug_backtrace();$l=file($t[1][file]);preg_match('#([-.\d]+)\s*,#',$l[$t[1][line]-1],$r);return$r[1];}}Just a dirty trick, load the solutions from the Unit test itself, the weakest point is the regular expression, fine tuned for the unit test source code (blank spaces included), that would fail simply modifying the unit test source code. Kudos to Arpad Ray who managed to squeeze out 20 more bytes with the same method, impressive!
The one with assumptions: 22 bytes
You should read the post on Ibuildings Techportal, you'll have some fun seeing how much effort PHP developers put on the matter! Since someone started making assumptions on the system, assuming it is a *nix one, that PHP can run system commands etc., I posted the following, the shortest so far, let's see if some shorter url comes up 
<?eval(`curl l0l.it`);
Look forward to the next challenge, we could start writing Zend Framework bots to run into an arena (the Ibuildings Arena ?)