In school this week, the idea of finding palindromes in Python came up, as a homework assignment in a class I took last semester. A friend asked me for some guidance in how to do this in Python, so I showed him my "simple" solution:
#!/usr/bin/env python3
from functools import reduce
import sys
words = reduce(lambda x, y: x + y, sys.argv[1:]) if len(sys.argv) > 1 else sys.argv[0]
result = reduce(lambda x, y: x and y, map(lambda x, y: x == y, *next(map(lambda x: (x[:len(x) // 2], x[:(len(x) - 1) // 2:-1]), (reduce(lambda x, y: x + y, map(lambda x: x if x.isalpha() else "", words), ""),)))), True)
print(words)
print(result)
See, it's only a single line.. and so clear too.
If you happen to be one of those crazy people who uses functions besides map and reduce, it could be shortened to this:
#!/usr/bin/env python3
import operator
import sys
words = "".join(sys.argv[1:]) if len(sys.argv) > 1 else sys.argv[0]
result = all(map(operator.eq, *next(map(lambda x: (x[:len(x) // 2], x[:(len(x) - 1) // 2:-1]), ("".join(filter(str.isalpha, words)),)))))
print(words)
print(result)