En op 14 april 2002 sprak /-\ndrew:
> I think using =~ above is sound. If you think it unsound,
> please provide a counter-example word on which it fails.

En op 15 april 2002 sprak Piers Cawley:
> Is there a guarantee about what input is valid? If not
> then 'foo?' will break it.

It wasn't explicitly stated. Yet being a Unix-y challenge,
I guess it was meant to work with /usr/dict/words (which
does not contain any Perl regex meta-characters).

In tpr02 and "get even", a word was specified as [a-z].
We might assume that was the intention here too because
the winning solution, being case sensitive, does not find
palindromes such as 'Abba'.

Modifying Ton's solution with 'i' modifier:

#!/perl -p
$_ x=reverse=~/$_/xi

finds 9 palindromes in /usr/dict/words not found by the
winning solution, namely:

Ababa
Abba
Ada
Anna
Eve
Hannah
Nan
Otto
Sus

BTW, I was blown away by Ton using the 'x' modifier.
Never in my wildest dreams could I have imagined that
this modifier would have been useful in golf!

/-\ndrew

Reply via email to