benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf c83916a4-2567-558a-973e-7a399c47f570

Problem

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

complete prompt

import re
import json
import requests

def task_func(data_url: str) -> list:
    """
    Fetch data from a specific URL and extract all names from the JSON-formatted data that are not enclosed by square brackets.
    No specific status code should be raised.
    
    Note:
    - The function uses regular expressions to search for names in the fetched data. Names that are inside square
    brackets are ignored.
    - The function will return "Invalid url input" if any exception is raised during the request.

    Parameters:
    - data_url (str): The URL from which to fetch data.

    Returns:
    - list[str]: A list of extracted names.

    Requirements:
    - re
    - json
    - requests

    Example:
    >>> import json
    >>> from unittest.mock import MagicMock
    >>> from io import BytesIO
    >>> mock_response = MagicMock()
    >>> mock_response.json.return_value = {"names": ["John", "[Adam]", "Eve"]}
    >>> requests.get = MagicMock(return_value=mock_response)
    >>> task_func("https://api.example.com/other_data")
    ['John', 'Eve']
    """

instruct prompt

Fetch data from a specific URL and extract all names from the JSON-formatted data that are not enclosed by square brackets. No specific status code should be raised.
Note that: The function uses regular expressions to search for names in the fetched data. Names that are inside square brackets are ignored. The function will return "Invalid url input" if any exception is raised during the request.
The function should output with:
    list[str]: A list of extracted names.
You should write self-contained code starting with:

Code

import re
import json
import requests
def task_func(data_url: str) -> list:

code prompt

Code

import re
import json
import requests
def task_func(data_url: str) -> list:

entry point

task_func

libs

  • re
  • requests
  • json

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