The Uber Drivers app occasionally formats numeric values such as driver-facing trip references in a way that benefits from a nearby palindromic value. Given a positive integer as a decimal string, return the closest different positive-or-zero palindrome.
If two palindromes are equally close, return the smaller one.
Implement closest_palindrome(n), where n is a decimal string with no leading zeros unless n is "0". Return a decimal string representing the palindrome p that minimizes abs(int(n) - int(p)), subject to p != n.
The result may be "0". You may use integer arithmetic within the stated constraints.
def closest_palindrome(n):