M
Michele Dondi
No, but that doesn't mean that JAPHs and golf promote "bad" habits
(whatever the definition of "bad" might be). I have never spent too much
time on JAPHs, but have done so on perlgolf (over at perlgolf.org during
its earlier days). And, I must admit, I learnt lots of useful techniques
and discovered a lot of interesting properties of Perl's built-in vars
in the process of squeezing just one more character out of my code. As a
Indeed! Personally I'm only a mediocre golfer, but I have an IMHO
enlightening example: in a contest at terje the goal was a program
that given any input string would output the *smallest* palindrome
obtained extending that string either on the left or on the right.
(I must say that I have tried my own hand at that contest, when
closed, and taking much time: had I actually took part to it I would
have classified at 4th place IIRC. The point is, anyway, that I chose
an approach similar to that of most other ones.)
The actual winner instead had taken a completely different path, and
as a result he did win not for a hole or two, but for something like
30 or more! Basically he was |'ing the given string with a reverse()d
copy of it "shifted left or right" an increasing amount of chars until
it matched the original string.
I remember I was amazed when I saw *that* solution: the algorithm was
conceptually the most simple of all. Then he did other "awful" things
in order to squeeze the very last byte off his script, like using
symrefs (and in a possibly obscure way!) et similia. Of course one
shouldn't/wouldn't do such things in "production code", but if for any
reason he had to realize that particular task, then an excellent
technique could be the one described above.
Michele