From dfa0869042e3860227626800a55147182a2a438a Mon Sep 17 00:00:00 2001 From: spark Date: Thu, 29 Oct 2026 11:34:07 +0000 Subject: [PATCH] spark: add palindrome checker utility --- wizard-work/spark/palindrome.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 wizard-work/spark/palindrome.py diff --git a/wizard-work/spark/palindrome.py b/wizard-work/spark/palindrome.py new file mode 100644 index 0000000..750dbe9 --- /dev/null +++ b/wizard-work/spark/palindrome.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +"""Palindrome checker - returns 0 if palindrome, 1 otherwise.""" +import sys + +def is_palindrome(s: str) -> bool: + """Check if string is palindrome (ignoring case, non-alphanumeric).""" + cleaned = ''.join(c.lower() for c in s if c.isalnum()) + return cleaned == cleaned[::-1] + +if __name__ == '__main__': + if len(sys.argv) < 2: + print("Usage: python3 palindrome.py ") + sys.exit(2) + result = is_palindrome(sys.argv[1]) + print(f"{sys.argv[1]!r} is {'a palindrome' if result else 'not a palindrome'}") + sys.exit(0 if result else 1) \ No newline at end of file