benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 93ba9d2e-d06b-52d0-a837-da721f8f27de

Problem

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

complete prompt

import json
import random
from datetime import datetime, timedelta


# Constants
USERS = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve']

def task_func(file_path, num_entries, seed=None):
    """
    Create a JSON file on a specific file path with random user activity data.
    The number of entries in the JSON file is determined by num_entries. The written JSON file contains a list of dictionaries, with each dictionary representing a log entry with the following keys: 'user', 'action', and 'timestamp'.

    Parameters:
    file_path (str): The file path where the JSON file should be created.
    num_entries (int): The number of entries of random data to generate.
    seed (int, optional): The seed for random data generation. Default is None.

    Returns:
    str: The file path of the generated JSON file.

    Requirements:
    - os
    - json
    - random
    - datetime

    Example:
    >>> task_func('/tmp/log.json', 100)
    '/tmp/log.json'
    """

instruct prompt

Create a JSON file on a specific file path with random user activity data. The number of entries in the JSON file is determined by num_entries. The written JSON file contains a list of dictionaries, with each dictionary representing a log entry with the following keys: 'user', 'action', and 'timestamp'.
The function should output with:
    str: The file path of the generated JSON file.
You should write self-contained code starting with:

Code

import json
import random
from datetime import datetime, timedelta
# Constants
USERS = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve']
def task_func(file_path, num_entries, seed=None):

code prompt

Code

import json
import random
from datetime import datetime, timedelta
# Constants
USERS = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve']
def task_func(file_path, num_entries, seed=None):

entry point

task_func

libs

  • datetime
  • random
  • 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