zlacker

[return to "Pushing ChatGPT's Structured Data Support to Its Limits"]
1. ljm+JN[view] [source] 2023-12-27 19:45:39
>>goranm+(OP)
Is the first Python example correct since it strips out non-alphanumeric characters? An errant space or punctuation in one half of the string will turn a non-palindromic string into a palindromic one. Never mind the lowercasing!

    def is_palindrome(s):
      # Convert the string to lowercase and remove non-alphanumeric characters
      cleaned_string = ''.join(char.lower() for char in s if char.isalnum())

      # Compare the cleaned string with its reverse
      return cleaned_string == cleaned_string[::-1]
It's not the same as the C version which simply compares the value of two pointers at opposite offsets of the string.

The OP goes on to remark that the Python implementation is pretty standard but doesn't acknowledge that the C and Python versions will not produce the same result.

Basically... you still need to code-review GPT function output. It's probably about as good as a junior engineer trusting the first result from Stack Overflow and not verifying it.

◧◩
2. minima+bQ[view] [source] 2023-12-27 19:57:59
>>ljm+JN
I mention in a footnote that the input has no non-alphanumeric characters is an implied constraint for palindrome problems. Just doing a two-pointer approach would fail the test case of "A man, a plan, a canal, Panama!" (an extremely famous palindrome) that iteration of the ChatGPT-generated solution also gives.

Another implicit constraint now that I'm looking at it again is that the characters are uncased, so the ChatGPT-solution would fail the test case due to the capital P of Panama.

[go to top]