Haiku Beat Opus?! Claude AI Coding Challenge EP03
Video: Haiku Beat Opus?! Claude AI Coding Challenge EP03 by Taught by Celeste AI - AI Coding Coach
Watch full page →Haiku Beat Opus?! Claude AI Coding Challenge EP03
In this episode of the LLM Coding Challenge, three Claude models—Opus, Sonnet, and Haiku—compete to generate ASCII-art pyramids with cycling symbols using a single-shot prompt. The challenge evaluates their code on eight criteria, including output correctness, Pythonic style, documentation, and code structure, revealing Haiku as the top performer with a perfect score.
Code
def ascii_pyramid(height, symbols):
"""
Generate an ASCII pyramid of given height using cycling symbols.
Args:
height (int): Number of pyramid levels.
symbols (str): String of symbols to cycle through.
Returns:
str: Multi-line string representing the pyramid.
"""
lines = []
for i in range(1, height + 1):
# Select symbols cycling through the provided string
line_symbols = ''.join(symbols[(j % len(symbols))] for j in range(i))
# Center the line to form a pyramid shape
lines.append(line_symbols.center(height))
return '\n'.join(lines)
if __name__ == "__main__":
pyramid = ascii_pyramid(5, "*-+")
print(pyramid)
Key Points
- The pyramid is built line by line, cycling through a string of symbols for each level.
- Using Python's
.center()method simplifies spacing and alignment of pyramid lines. - Including a clear docstring and a main guard improves code readability and usability.
- Generating output as a single string allows easy printing or further processing.
- Comparing AI-generated code highlights different approaches to the same problem and best practices.