benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf dd0a4aa8-71d0-593c-96cc-c66b77fdb57f

Problem

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

complete prompt

import os
import re
import shutil

# Constants
SOURCE_DIR = '/source/dir'
TARGET_DIR = '/target/dir'
FILE_PATTERN = re.compile(r'^(.*?)-\d+\.json$')

def task_func():
    """
    Move all json files in a source directory to a target directory and rename them by splitting the filename the last time "-" occurs and keeping the prefix part of the filename.
    
    Parameters:
    - None

    Returns:
    - None

    Requirements:
    - os
    - re
    - shutil

    Example:
    >>> task_func()

    """

instruct prompt

Move all json files in a source directory to a target directory and rename them by splitting the filename the last time "-" occurs and keeping the prefix part of the filename.
The function should output with:
    None
You should write self-contained code starting with:

Code

import os
import re
import shutil
# Constants
SOURCE_DIR = '/source/dir'
TARGET_DIR = '/target/dir'
FILE_PATTERN = re.compile(r'^(.*?)-\d+\.json$')
def task_func():

code prompt

Code

import os
import re
import shutil
# Constants
SOURCE_DIR = '/source/dir'
TARGET_DIR = '/target/dir'
FILE_PATTERN = re.compile(r'^(.*?)-\d+\.json$')
def task_func():

entry point

task_func

libs

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