benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f33c797f-fdb9-5fe9-a882-0cbaa28e4be9

Problem

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

complete prompt

import sys
import json
from datetime import datetime

# Constants
PATH_TO_APPEND = '/path/to/whatever'
JSON_FILE = '/path/to/json_file.json'

def task_func(path_to_append=PATH_TO_APPEND, json_file=JSON_FILE):
    """
    Add a specific path to sys.path and update a JSON file with the current date and time.
    This function appends a given path to Python's sys.path and updates a JSON file with the current date and time under the key 'last_updated'.
    
    Parameters:
    - path_to_append (str): The path to append to sys.path. Default is '/path/to/whatever'.
    - json_file (str): The path to the JSON file to update. Default is '/path/to/json_file.json'. The file should exist before running the function.

    Returns:
    - json_data (dict): The updated JSON data. The dictionary will contain a 'last_updated' key with the current datetime as its value.

    Requirements:
    - sys
    - json
    - datetime.datetime

    Example:
    >>> task_func('/path/to/new_directory', '/path/to/new_json_file.json')
    {'last_updated': '2023-08-28 12:34:56'}
    """

instruct prompt

Add a specific path to sys.path and update a JSON file with the current date and time. This function appends a given path to Python's sys.path and updates a JSON file with the current date and time under the key 'last_updated'.
The function should output with:
    json_data (dict): The updated JSON data. The dictionary will contain a 'last_updated' key with the current datetime as its value.
You should write self-contained code starting with:

Code

import sys
import json
from datetime import datetime
# Constants
PATH_TO_APPEND = '/path/to/whatever'
JSON_FILE = '/path/to/json_file.json'
def task_func(path_to_append=PATH_TO_APPEND, json_file=JSON_FILE):

code prompt

Code

import sys
import json
from datetime import datetime
# Constants
PATH_TO_APPEND = '/path/to/whatever'
JSON_FILE = '/path/to/json_file.json'
def task_func(path_to_append=PATH_TO_APPEND, json_file=JSON_FILE):

entry point

task_func

libs

  • datetime
  • json
  • sys

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