Task: check whether a string reads the same forwards and backwards, ignoring case and spaces.
Solution: keep letters and digits, lower-case them and compare with the reversed copy.
Example in Python:
def is_palindrome(s):
cleaned = "".join(ch.lower() for ch in s if ch.isalnum())
return cleaned == cleaned[::-1]
Kommentit