Sorting the list of palindromes
palindromes . sort ( ) NEW_LINE l , r = 0 , len ( palindromes ) - 1 NEW_LINE while l < r : NEW_LINE INDENT if palindromes [ l ] + palindromes [ r ] == N : NEW_LINE INDENT return 2 NEW_LINE DEDENT elif palindromes [ l ] + palindromes [ r ] < N : NEW_LINE INDENT l += 1 NEW_LINE DEDENT else : NEW_LINE INDENT r -= 1 NEW_LINE DEDENT DEDENT