Back to Blog

3 AI Models, 1 Prompt: Who Writes Better Code? (Claude Coding Challenge)

Sandy LaneSandy Lane

Video: 3 AI Models, 1 Prompt: Who Writes Better Code? (Claude Coding Challenge) by Taught by Celeste AI - AI Coding Coach

Watch full page →

3 AI Models, 1 Prompt: Who Writes Better Code? (Claude Coding Challenge)

In this coding challenge, three Claude AI models—Opus, Sonnet, and Haiku—were given the same prompt to write a Python palindrome checker. Each model produced a perfect solution that passed all 8 evaluation criteria, but their coding styles varied significantly, showcasing different approaches to clarity, documentation, and complexity analysis.

Code

def is_palindrome(s):
  """
  Check if the input string s is a palindrome.
  Ignores case, spaces, and punctuation.
  """
  import string

  # Normalize the string: lowercase, remove spaces and punctuation
  s = s.lower()
  s = ''.join(ch for ch in s if ch not in string.punctuation and ch != ' ')

  # Check palindrome by comparing string to its reverse
  return s == s[::-1]

# Example test cases
test_cases = [
  "A man, a plan, a canal: Panama",
  "No lemon, no melon",
  "Hello, World!",
  "",
  "Was it a car or a cat I saw?"
]

for text in test_cases:
  print(f"'{text}' -> {is_palindrome(text)}")

Key Points

  • All three Claude models produced fully correct palindrome checkers that handle case, spaces, and punctuation.
  • Opus’s solution is concise and straightforward, focusing on minimalism and clarity.
  • Sonnet adds formatted summaries and structured documentation to enhance readability.
  • Haiku includes verbose explanations and complexity analysis, offering deeper insight into the algorithm.
  • Despite stylistic differences, all models scored perfectly across correctness, edge cases, and code quality.