4 ms·
I've written a bit about this in context of companies which use a palindrome detector as a phone-screen question. My current implementation does normalization a
by ubernostrum 10y ago
I've written a bit about this in context of companies which use a palindrome detector as a phone-screen question. My current implementation does normalization and uses Unicode character categories to strip out characters which should be ignored, but also comes with a free half-hour lecture about why A) this is a hard problem, B) no programming language I know can easily solve it, and C) this is a bad phone-screen question and indicative of bad process at the company.
- ubernostrum 10y agoAnd I wrote this, and then decided to poke at it again, and discovered: https://pypi.python.org/pypi/regex https://pypi.python.org/pypi/regex Which implements the '\X' grapheme-matching operator, and does in fact allow Python to identify palindromes in Unicode (first normalize and strip out any categories of characters to ignore, then findall(r'\X') returns a list of graphemes in the input, which can be compared to itself in reverse to determine palindromicity).