benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf edab8ce3-eed6-5e73-9e1a-776835ff2a20

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(dimension, seed=42):
    """
    Create a 2D numeric array (matrix) of a given dimension with random integers between 1 and 100, 
    and a flat list of all elements in the matrix.

    Parameters:
    - dimension (int): The dimension of the square matrix to be created. It must be a positive integer.

    Returns:
    tuple: A tuple containing:
        - A 2D numpy array of the given dimension with random integers between 1 and 100.
        - A flat list of all elements in the matrix.

    Requirements:
    - numpy
    - itertools

    Example:
    >>> matrix, flat_list = task_func(3)
    >>> print(matrix)
    [[52 93 15]
     [72 61 21]
     [83 87 75]]
    >>> print(flat_list)
    [52, 93, 15, 72, 61, 21, 83, 87, 75]
    """

instruct prompt

Create a 2D numeric array (matrix) of a given dimension with random integers between 1 and 100, and a flat list of all elements in the matrix.
The function should output with:
    tuple: A tuple containing:
    A 2D numpy array of the given dimension with random integers between 1 and 100.
    A flat list of all elements in the matrix.
You should write self-contained code starting with:

Code

import numpy as np
import itertools
def task_func(dimension, seed=42):

code prompt

Code

import numpy as np
import itertools
def task_func(dimension, seed=42):

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