Generate a JSON object suitable for automating the programming task…
- User
Assistant: User: Generate a JSON object suitable for automating the programming task testing platform, strictly in the following format:
{ "Title": "Task Name", "Task Description": "Description of the task.", "Function Signature": "def function_name(parameters) -> return_type:", "Solve": "Python code for the solution", "Input": "Description of the input parameters.", "Output": "Description of the expected output.", "Examples": [ { "input": "Example input here", "output": "Expected output here" }, { "input": "Another example input here", "output": "Another expected output here" } ] } Ensure that the JSON follows this exact structure and does not include any additional text or variations. The task should be complex and unique, avoiding direct copying from common platforms like LeetCode or similar sources.
Assistant:
- Assistant
{ "Title": "Matrix Spiral Traversal", "Task Description": "Write a function that takes a 2D matrix and returns a list containing the elements of the matrix in spiral order, starting from the top-left corner.", "Function Signature": "def spiral_order(matrix: List[List[int]]) -> List[int]:", "Solve": "def spiral_order(matrix: List[List[int]]) -> List[int]:\n if not matrix or not matrix[0]:\n return []\n result = []\n top, bottom, left, right = 0, len(matrix), 0, len(matrix[0])\n while top < bottom and left < right:\n for i in range(left, right):\n result.append(matrix[top][i])\n top += 1\n for i in range(top, bottom):\n result.append(matrix[i][right - 1])\n right -= 1\n if not (top < bottom and left < right):\n break\n for i in range(right - 1, left - 1, -1):\n result.append(matrix[bottom - 1][i])\n bottom -= 1\n for i in range(bottom - 1, top - 1, -1):\n result.append(matrix[i][left])\n left += 1\n return result", "Input": "A two-dimensional list of integers representing the matrix, where the outer list is the rows and the inner lists are the columns.", "Output": "A list of integers representing the elements of the matrix in spiral order.", "Examples": [ { "input": "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]", "output": "[1, 2, 3, 6, 9, 8, 7, 4, 5]" }, { "input": "[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]", "output": "[1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7]" } ] }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.