GolfScript, 107 91 / 155 bytes
.4:ab-1:ba=;1 %ba%{...fi@@= c43.=;)('"([{ }])"'~?~'"([{ }])"')(;=.34c =@@if...}%ab% 1;=ab:1-ba:4. Newlines are artistic. fi, c43 and c are noops, but the entire code is executed.
At the cost of 64 bytes, this can be improved upon:
0!*1{!}\;:);0:f;0:i;-1:ab;9:ba; ...=;1%ab%{....i@f@@fi@@=@.=@\) +""'"([{}])"'~+?+~'"([{}])"'""+ (\@=.@=@@if@@f@i....}%ba%1;=... ;ab:9;ba:1-;i:0;f:0;(:;\{!}1*!0 As before, the entire code is executed. The difference is that every single byte affects the output.
Tests and examples
$ base64 > palindrome.gs -d <<< LjQ6YWItMTpiYT07MSViYSV7Li4uZmlAQD1jNDMuPTspKCciKFt7fV0pIid+P34nIihbe31dKSInKSg7PS4zNGM9QEBpZi4uLn0lYWIlMTs9YWI6MS1iYTo0Lg== $ wc -c palindrome.gs 91 palindrome.gs $ rev palindrome.gs | tr '([{}])' ')]}{[(' | diff - palindrome.gs $ echo -n 'r(a[c{"e"}c]a)r' | golfscript palindrome.gs -3-1-1 $ echo -n 'totallynotapalindrome' | golfscript palindrome.gs -4-1-1 $ $ base64 > palindrome.gs -d <<< MCEqMXshfVw7Oik7MDpmOzA6aTstMTphYjs5OmJhOy4uLj07MSVhYiV7Li4uLmlAZkBAZmlAQD1ALj1AXCkrIiInIihbe31dKSInfis/K34nIihbe31dKSInIiIrKFxAPS5APUBAaWZAQGZAaS4uLi59JWJhJTE7PS4uLjthYjo5O2JhOjEtO2k6MDtmOjA7KDo7XHshfTEqITA= $ wc -c palindrome.gs 155 palindrome.gs $ rev palindrome.gs | tr '([{}])' ')]}{[(' | diff - palindrome.gs $ echo -n 'r(a[c{"e"}c]a)r' | golfscript palindrome.gs 010 $ echo -n 'totallynotapalindrome' | golfscript palindrome.gs -100 $ for i in {1..154}; do head -c $i pal.gs > tmp.gs; tail -c +$[i+2] pal.gs >> tmp.gs > [ "$(echo -n 'r(a[c{"e"}c]a)r' | golfscript tmp.gs 2> /dev/null)" = "010" ] && echo $i > done; rm tmp.gs 1 for i in {1..154}; do head -c $i pal.gs > tmp.gs; tail -c +$[i+2] pal.gs >> tmp.gs > [ "$(echo -n '42' | golfscript tmp.gs 2> /dev/null)" = "-100" ] && echo $i > done | grep '^1$'; rm tmp.gs How it works
. # Duplicate the input string. 4:ab-1:ba # Save 4 in “ab” and -1 in “ba”. =; # Compare 4 to -1 and discard the result. 1% # Save every element from the input string in a new string. ab% # Reverse the input string. { # For each character in the input string: ... # Duplicate the character thrice. fi # Variable “fi” is undefined; this does nothing. @@= # Verify that the character is equal to itself; push 1. c43 # Variable “c43” is undefined; this does nothing. .=; # Verify that 1 is equal to itself and discard the result. )( # Increment and decrement the character. '"([{}])"'~ # Push that string and evaluate it. Result: '([{}])' ? # Retrieve the character's position in '([{}])'. -1 means not present. ~ # Negate the position.. Examples: -1 -> 0 0 -> -1 2 -> -3 '"([{}])"') # Push that string and pop its last element. Result: '"([{}])' 34 (; # Increment 34 (the ASCII code of a double quote) and discard. = # Retrieve the corresponding character. .34 # Duplicate the character and push 34. c # Variable “c” is undefined; this does nothing. = # If the character is a double quote, the index was -1. @@if # In that case, replace the double quote with the original character. ... # Duplicate the new character thrice. }% # ab% # Save every fourth element in a new string. This discards dummy values. 1; # Push 1 and discard. = # Push 1 if the modified string matches the original one and 0 otherwise. ab:1- # Save 4 in “1” and subtract. ba:4. # Save -1 in “4” and duplicate. 0!* # Pop and push the input string. 1{!}\;:); # Make “)” an alias for “!”. 0:f;0:i; # Variables. -1:ab;9:ba; # Moar variables. ...=; # Duplicate the input string. 1%ab% # Reverse the copy. { # For each character in the input string: .... # Duplicate the character four times. i@ # Push 0 and rotate a string copy on top of it. f@@fi@@ # Push 0 and rotate 0 on top of it. =@ # Push 1 and rotate a string copy on top of it. .=@ # Push 1 and rotate 1 on top of it. \)+ # Negate a 1 and add. Result: 1 "" # Push that string. '"([{}])"' # Push that string. ~+ # Evaluate the second string and concatenate. Result: '([{}])' ? # Retrieve the characters position in '([{}])'. -1 means not present. +~ # Add 1 to the position and negate. Examples: -1 -> -1 0 -> -2 1 -> -3 '"([{}])"' # Push that string. "" # Push that string. + # Concatenate. Result: '"([{}])"' (\ # Unshift the first double quote and swap it with the rest of the string. @=. # Retrieve the corresponding character and duplicate it. @= # If the character is a double quote, the index was -1. @@if # In that case, replace the double quote with the original character. @@ # Rotate the modified character to the bottom. f@i.... # Push dummy values. }% # ba% # Save every ninth element in a new string to discard the dummy values. 1; # Push 1 and discard. = # Push 1 if the modified string matches the original one and 0 otherwise. ...; # Duplicate thrice and discard the last copy. ab:9;ba:1-; # Variables. i:0;f:0; # Moar variables. (:;\ # Negate, override “;” and swap. {!}1*!0 # Negate twice and push 0.