File size: 2,656 Bytes
e6389a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
How to Write the Ideal Question Prompt for Code Evaluation
==========================================================

The Code Evaluator API uses a rigorous static analysis engine to grade code. It maps the student's code logic and control flow strictly against the constraints you provide in the `<QUESTION_OBJECTIVE>`. 

Because the engine acts as an "Automated Code Auditor", the ideal question prompt should be highly structured and leave no room for ambiguity.

To get the most precise and accurate grading, ensure your prompt includes the following 4 pillars:

1. Clear Functional Goal
------------------------
Clearly state what the algorithm must accomplish. The engine checks this to map the control flow and state changes against the requirements.
Example: "Write a function that calculates the nth Fibonacci number."

2. Precise Input/Output Mapping
-------------------------------
Provide the exact data types and formats you expect to go in and come out.
Example: "Input: A single non-negative integer `n`. Output: A single integer representing the Fibonacci value. If the input is not an integer, return `null`."

3. Explicit Constraints & Complexity Limits
-------------------------------------------
The evaluator has a specific pillar for "Algorithmic Complexity" where it docks points for inefficiency. If you have strict performance requirements, you MUST state them in the prompt.
Example: "Time Complexity must be O(n). Space Complexity must be O(1) (do not use arrays to store previous values)."

4. Required Edge Cases (Boundary Conditions)
--------------------------------------------
The engine is specifically instructed to mentally stress-test the code against edge cases (e.g., null inputs, empty collections, negative integers, overflow). Listing these explicitly in the objective ensures the LLM grades the student on whether they handled them.
Example: "The code must safely handle `n = 0`, `n = 1`, and extremely large numbers without causing a stack overflow."


==========================================================
Template Example for API 'question_objective' Parameter:
==========================================================

Problem: Implement a function `find_max_profit(prices)` that calculates the maximum profit possible from a single buy and sell of a stock.
Input: An array of integers `prices` representing the stock price on a given day.
Output: An integer representing the maximum profit. Return 0 if no profit is possible.
Constraints: Time complexity must be O(N). Space complexity O(1).
Edge Cases to Check: Empty array, array with only 1 price, continuously decreasing prices (should return 0).