In Google Code Jam 2009, Round 1B, there is a problem called Decision Tree that lent itself to rather creative solutions.
Post your shortest solution; I’ll update the Accepted Answer to the current shortest entry on a semi-frequent basis, assuming you didn’t just create a new language just to solve this problem. 😛
Current rankings:
- 107 Perl
- 121 PostScript (binary)
- 132 Ruby
- 154 Arc
- 160 PostScript (ASCII85)
- 170 PostScript
- 192 Python
- 196 JavaScript
- 199 Common Lisp
- 212 LilyPond
- 273 Scheme
- 280 R
- 281 sed w/ bc
- 312 Haskell
- 314 PHP
- 339 m4 w/ bc
- 346 C
- 381 Fortran
- 462 Java
- 718 OCaml
- 759 F#
- 1554 sed
- C++ not qualified for now
Perl in 107 characters
Newlines for legibility; none of them is necessary or counted in.
It uses features found only in the latest versions of Perl, so run with
perl -M5.010or later.I used to be a Perl noob too, so this works almost the same as the ruby one. Original version 126 chars, optimizations by peutri.
Backlinks:
Word Aligned – Power Programming