Command Palette

Search for a command to run...

Hectal
Phase 3: Prompting as Engineering
LLM Engineering · Exercise 5 of 6 PreviousNext
Intermediate

Score a prompt and gate the change

Write score(model, prompt, cases) that calls model(prompt, text) for each (text, expected) in cases and returns the number of exact matches.

Write can_ship(best, new_score) that returns True when new_score is at least best, so a change that lowers the score is blocked.

What Check tests

  1. A good prompt scores 3 of 3
  2. A chatty prompt scores 0
  3. score works with any model function and an empty case list
  4. can_ship allows equal or better scores
  5. can_ship blocks a lower score

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.