benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf c96730e7-e58c-53e7-8c3e-2849de60b1b9

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import numpy as np
import itertools

def task_func(matrix):
    """
    Sorts a numeric 2D numpy array in ascending order and finds all unique combinations of two elements from the sorted array.
    
    Parameters:
    - matrix (numpy.array): A 2D numpy array of any shape (m, n), where m and n are non-negative integers.
    
    Returns:
    - tuple: A tuple containing two elements:
        1. numpy.array: A 1D array with all elements of the input array sorted in ascending order.
        2. list: A list of tuples, each containing a pair of elements from the sorted array, representing all unique combinations taken two at a time.

    Requirements:
    - numpy
    - itertools
    
    Example:
    >>> task_func(np.array([[1, 3], [2, 4]]))
    (array([1, 2, 3, 4]), [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)])
    """

instruct prompt

Sorts a numeric 2D numpy array in ascending order and finds all unique combinations of two elements from the sorted array.
The function should output with:
    tuple: A tuple containing two elements:
    1. numpy.array: A 1D array with all elements of the input array sorted in ascending order.
    2. list: A list of tuples, each containing a pair of elements from the sorted array, representing all unique combinations taken two at a time.
You should write self-contained code starting with:

Code

import numpy as np
import itertools
def task_func(matrix):

code prompt

Code

import numpy as np
import itertools
def task_func(matrix):

entry point

task_func

libs

  • numpy
  • itertools

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import