Skip to main content
Home/Challenges/Code Generation Master
IntermediateCode Generation~15 min

Code Generation Master

Write a single prompt that generates a working Python function, its unit tests, and a README explanation — all in one response.

Your Goal

Write a prompt that: Get a Python function + unit tests + README from one prompt

Your prompt must produce three clearly separated sections: (1) a working Python function with type hints and docstring, (2) at least three pytest unit tests covering edge cases, and (3) a short README section explaining the function's purpose, parameters, and usage example. All three must appear in a single AI response.

Your Prompt

Write your prompt below. Be specific — every word matters.

AI Response Preview
### Function
```python
import re

def validate_email(email: str) -> bool:
    """
    Validate an email address format.

    Args:
        email: The email address string to validate.

    Returns:
        True if the email format is valid, False otherwise.
    """
    pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
    return bool(re.match(pattern, email))
```

### Tests
```python
import pytest
from solution import validate_email

def test_valid_email():
    assert validate_email("user@example.com") is True

def test_missing_at_sign():
    assert validate_email("userexample.com") is False

def test_empty_string():
    assert validate_email("") is False
```

### README
**validate_email(email: str) -> bool**
Checks whether the provided string conforms to a standard email format.
- **Parameters:** `email` — the string to validate.
- **Returns:** `True` for a valid format, `False` otherwise.
- **Example:** `validate_email("alice@gera.services")` → `True`
Sample response — submit to score your own prompt
Score: 85/100

Score Breakdown

Goal Achievement90/100
Constraint Adherence100/100
Creativity75/100
Prompt Efficiency80/100

Improvements: Try using a specific persona constraint. Specify the exact rhyme scheme in your prompt.

🪙
Reward
+100 GeraCoins

Earn GeraCoins for completing this challenge. Use them for discounts across all Gera services.

Hints (3)
  • 1Use a numbered list in your prompt to enumerate each required section explicitly.
  • 2Specify the exact output format: "Output exactly three sections: ### Function, ### Tests, ### README".
  • 3Pick a simple function (e.g. "validate email address") so the AI can focus on structure, not complexity.

Top 5 for This Challenge

🥇🇮🇳 PromptKing_Dev97
🥈🇮🇹 LLM_Hunter_Marco93
🥉🇳🇬 ContextCrafter_Zara90
#4🇧🇷 AIAlchemist_Sofia86
#5🇰🇷 PromptPhD_Kim82
View Global Leaderboard →
Browse All Challenges