Library › Coding AI › Job seekers

Finish a practice take-home function without breaking the rules

Practice: Setting limits and rules. About 5 minutes.

About this exercise

Finish the practice take-home function so it returns the IDs of orders placed at or after cutoff_hour. Keep the name and arguments exactly as given, and don't add any imports (the grader blocks them), so read the hour straight from the placed_at string. Return the IDs sorted from lowest to highest, and an empty list (not None) when orders is empty. No prints. One code block with only the function, at most 8 lines, then under 25 words outside the code.

Common mistakes when you ask AI for this

  • Not mentioning the import ban. The AI imports datetime, which this grader blocks. Try: Add: "No imports; read the hour from the string."
  • Not giving the edge rules. The AI uses > instead of >=, or returns the list unsorted. Try: Add: "At or after the hour, sorted lowest to highest."
  • Forgetting empty input. The AI returns None or prints the result for empty input. Try: Add: "Return [] for an empty list, no prints."
  • Getting a menu of options. The AI likes to offer two or three versions of the function, so you're left to pick and test them yourself. Try: Add: "Give one function only, in one code block, no alternatives."
  • Getting a tutorial. By default the AI explains every part of the code at length, which you then have to scroll past. Try: Add: "After the code, one line under 12 words. Nothing else."

What a strong prompt includes

  • Keeps the signature
  • Bans imports
  • Sets the edge rules
  • Handles empty input
  • Caps the code length

Practice this now ↑

Related exercises