benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7d20c7f2-1986-547d-83de-7212c5729d87

Problem

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

complete prompt

import os
import hashlib
import json
from pathlib import Path

def task_func(directory: str) -> str:
    """
    Create SHA256 hashes for all files in the specified directory, including files in subdirectories, 
    and save these hashes in a JSON file named 'hashes.json' in the given directory.

    Parameters:
    - directory (str): The path to the directory containing files to be hashed.
    
    Returns:
    str: The absolute path of the JSON file ('hashes.json') containing the hashes.
    
    Requirements:
    - os
    - hashlib
    - json
    - pathlib.Path

    Example:
    >>> json_file = task_func("/path/to/directory")
    >>> print(f"Hashes saved at: {json_file}")
    """

instruct prompt

Create SHA256 hashes for all files in the specified directory, including files in subdirectories, and save these hashes in a JSON file named 'hashes.json' in the given directory.
The function should output with:
    str: The absolute path of the JSON file ('hashes.json') containing the hashes.
You should write self-contained code starting with:

Code

import os
import hashlib
import json
from pathlib import Path
def task_func(directory: str) -> str:

code prompt

Code

import os
import hashlib
import json
from pathlib import Path
def task_func(directory: str) -> str:

entry point

task_func

libs

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