benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1bb16403-fe69-5b12-a5d6-5d656377c0f9

Problem

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

complete prompt

import os
import re
import hashlib

def task_func(path, delimiter):
    """
    Splits a file path by a specified delimiter, retaining the delimiter in the output, and computes the hash of each component if it is a file.
    
    Parameters:
    path (str): The file path to split.
    delimiter (str): The delimiter to use for splitting the path.

    Returns:
    list[tuple]: A list of tuples, where each tuple contains a path component and its hash (if it's a file).
                 If the component is not a file, its hash will be None.

    Requirements:
    - os
    - re
    - hashlib

    Example:
    >>> task_func("Docs/src/file.txt", "/")
    [('Docs', None), ('/', None), ('src', None), ('/', None), ('file.txt', 'hash_value')]
    """

instruct prompt

Splits a file path by a specified delimiter, retaining the delimiter in the output, and computes the hash of each component if it is a file.
The function should output with:
    list[tuple]: A list of tuples, where each tuple contains a path component and its hash (if it's a file).
    If the component is not a file, its hash will be None.
You should write self-contained code starting with:

Code

import os
import re
import hashlib
def task_func(path, delimiter):

code prompt

Code

import os
import re
import hashlib
def task_func(path, delimiter):

entry point

task_func

libs

  • hashlib
  • 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