Search code examples
code-golfrosetta-stonepalindrome

Palindrome Golf


The goal: Any language. The smallest function which will return whether a string is a palindrome. Here is mine in Python:

R=lambda s:all(a==b for a,b in zip(s,reversed(s)))

50 characters.

The accepted answer will be the current smallest one - this will change as smaller ones are found. Please specify the language your code is in.


Solution

  • 7 characters in J: Not sure if this is the best way, I'm somewhat new to J :)

    p=:-:|.
    

    explanation: |. reverses the input. -: compares. the operands are implicit.

    p 'radar'
    1
    
    p 'moose'
    0