Never odd or even

PHP, 55 52 bytes


takes input from STDIN; run with -R.


  • 10 for palindrome and same parity
  • 11 for palindrome and different parity
  • 0 for non-palindrome and same parity
  • 1 for non-palindrome and different parity


  • strlen($n)/2 == log($n,10)/2 == log($n,100)
  • if palindrome, compare middle digit $n[1*log($n,100)]
  • if not, first digit $n[0*log($n,100)]
  • ... to whole number (<- lowest bit <- last digit)

Jelly, 16 14 bytes


Try it online!

Outputs two lines:

  • 1 for palindrome, 0 for not
  • 0 for tricky #2, 1 for not


DµŒḂṄHC×LĊị+ḢḂ    Main link. Argument: n (number)
D                 Get the digits of n
 µ                Start a new monadic chain
  ŒḂ              Check if the digit array is a palindrome (1 if yes, 0 if no)
    Ṅ             Print the result with a newline
     H            Halve (0.5 if palindrome, 0 if not)
      C           Subtract from 1 (0.5 if palindrome, 1 if not)
       ×          Multiply by...
        L         ...length of array (length/2 if palindrome, length if not)
         Ċ        Round up
          ị       Take item at that index from the digits
           +      Add...
            Ḣ     ...first item of digits
             Ḃ    Result modulo 2

05AB1E, 15, 14 13 bytes (Thanks to Riley and carusocomputing)


Try online

Returns with brackets if it is a palindrome

Returns with 0 if the parity is different, 1 if it is the same

Ð Add input, such that I have enough input to work with

R Reverse the last element of the stack

Q Look if it is the same (takes the two top elements and performs ==)

i If statement, so only goes through when it is a palindrome

2 Push the number 2

ä Split the input in 2 equal slices

¨ Push the first element of the split (1264621 results in 1264)

} End if

È Check if last element is even

¹ Push the first input again

R Reverse that input

È Check if it is even now

Q Check if those even results are the same and implicitly print