benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf add9f4ce-bb25-5c49-bced-1751111269b7

Problem

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

complete prompt

import urllib.request
import os
import re

# Constants
TARGET_FILE = 'downloaded_file.txt'
SEARCH_PATTERN = r'\bERROR\b'

def task_func(url):
    """
    Download a text file from the specified url and search for occurrences of the word "ERROR."

    Parameters:
    - url (str): The url of the text file to be downloaded.

    Returns:
    - occurrences (int): The number of occurrences of the word 'ERROR'.

    Requirements:
    - urllib
    - os
    - re

    Example:
    >>> task_func('http://example.com/log.txt')
    5 # Assuming there are 5 occurrences of 'ERROR' in the file
    """

instruct prompt

Download a text file from the specified url and search for occurrences of the word "ERROR."
The function should output with:
    occurrences (int): The number of occurrences of the word 'ERROR'.
You should write self-contained code starting with:

Code

import urllib.request
import os
import re
# Constants
TARGET_FILE = 'downloaded_file.txt'
SEARCH_PATTERN = r'\bERROR\b'
def task_func(url):

code prompt

Code

import urllib.request
import os
import re
# Constants
TARGET_FILE = 'downloaded_file.txt'
SEARCH_PATTERN = r'\bERROR\b'
def task_func(url):

entry point

task_func

libs

  • urllib
  • re
  • os

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