benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6a818fd0-edfc-5cea-80a7-f3ee9d28c555

Problem

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

complete prompt

import numpy as np
import matplotlib.pyplot as plt
from random import randint
import math

def task_func(POINTS=100):
    """
    Simulates a random walk in a two-dimensional space and draws the path using matplotlib.
    The walk is determined by randomly choosing directions at each step. The function generates
    two numpy arrays representing the x and y coordinates of each step and plots these points
    to visualize the path of the walk.

    Parameters:
        POINTS (int): The number of steps in the random walk. Default is 100.

    Returns:
        A matplotlib figure object representing the plot of the random walk.

    Requirements:
        - numpy
        - matplotlib.pyplot
        - random.randint
        - math

    Examples:
        >>> import matplotlib
        >>> fig = task_func(200)  # Displays a plot of a random walk with 200 steps
        >>> isinstance(fig, matplotlib.figure.Figure)
        True
    """

instruct prompt

Simulates a random walk in a two-dimensional space and draws the path using matplotlib. The walk is determined by randomly choosing directions at each step. The function generates two numpy arrays representing the x and y coordinates of each step and plots these points to visualize the path of the walk.
The function should output with:
    A matplotlib figure object representing the plot of the random walk.
You should write self-contained code starting with:

Code

import numpy as np
import matplotlib.pyplot as plt
from random import randint
import math
def task_func(POINTS=100):

code prompt

Code

import numpy as np
import matplotlib.pyplot as plt
from random import randint
import math
def task_func(POINTS=100):

entry point

task_func

libs

  • math
  • numpy
  • matplotlib
  • random

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