Generate a unique JSON object suitable for automating the programming…
- User
Assistant: User: Generate a unique 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 must have function signature from 'Function Signature'.", "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: 1.The JSON follows this exact structure and does not include any additional text or variations. 2.The task should be complex and unique, avoiding direct copying from common platforms like LeetCode or similar sources. 3.The solution must not use any imports in the code (i.e., no import statements). 4.The solution must contain only one function. 5.This is being generated for automated task testing, so structure the problem accordingly.
Assistant:
- Assistant
{ "Title": "Matrix Diagonal Difference", "Task Description": "Calculate the absolute difference between the sums of the matrix's two diagonals.", "Function Signature": "def diagonal_difference(matrix: list[list[int]]) -> int:", "Solve": "def diagonal_difference(matrix: list[list[int]]) -> int:\n n = len(matrix)\n primary_diagonal_sum = 0\n secondary_diagonal_sum = 0\n for i in range(n):\n primary_diagonal_sum += matrix[i][i]\n secondary_diagonal_sum += matrix[i][n - 1 - i]\n return abs(primary_diagonal_sum - secondary_diagonal_sum)", "Input": "A square matrix (list of lists) where each list represents a row of the matrix. The matrix is guaranteed to have an equal number of rows and columns with integer elements.", "Output": "An integer representing the absolute difference between the sums of the primary and secondary diagonals.", "Examples": [ { "input": "3x3 matrix: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]", "output": "0" }, { "input": "2x2 matrix: [[3, 1], [2, 4]]", "output": "4" } ] }