Write a program to test if a string is palindromic, with the added condition that the program be palindromic itself.
|
Ruby
Prints 1 if the input is a palindrome, 0 if it isn't. Input without linebreak. Doesn't use any comments, instead it uses 2 tricks:
Obvious solution using comments (prints true/false):
|
||||
Perl
no comment tricks, just cleverly abusing the substitution operator (hey, perl variables start with a $ too, so what?) |
|||
|
|
|
Python without comment
I'm surprised that no one found that trick yet, it should work in most languages! |
|||
|
|
|
Python
|
|||
|
|
Golfscript
|
||||
|
|
PHP
Uses some odd tricks to avoid the
This is a working one that uses PHP's |
||||
|
|
C
Running example:
|
|||
|
|
PHP
Facts:
The reason why it will not be possible to implement palindromic palindrome checker in PHP it's because PHP variables are named starting with a |
||||
|
|
CoffeeScriptI actually struggled with the reverse spellings of 'split', 'reverse' and 'join' :\
|
|||
|
|
Groovy
|
|||
|
|
JavaScriptalert('That is'+((X=prompt()).split('').reverse().join('')==X?'':"n't")+' a palindrome.'))'.emordnilap a '+)"t'n":''?X==)''(nioj.)(esrever.)''(tilps.))(tpmorp=X((+'si tahT'(trela
The in the middle is the null character. |
|||
|
|