benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 067aa8c6-b8a9-5259-ad0f-d8c8a4412a09

Problem

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

complete prompt

from random import choice
import pytz
from dateutil.parser import parse

# Constants
TIMEZONES = ['America/New_York', 'Europe/London', 'Asia/Shanghai', 'Asia/Tokyo', 'Australia/Sydney']


def task_func(date_str, from_tz):
    """
    Converts a datetime string from a given timezone to a datetime string in a randomly chosen timezone.

    Parameters:
    - date_str (str): The datetime string in "yyyy-mm-dd hh:mm:ss" format.
    - from_tz (str): The timezone of the given datetime string.

    Returns:
    - tuple: A tuple containing the converted datetime string and the randomly chosen timezone.
    
    Requirements:
    - pytz
    - dateutil.parser
    - random

    Example:
    >>> date_str, from_tz = '2023-06-15 12:00:00', 'UTC'
    >>> converted_date, to_tz = task_func(date_str, from_tz)
    >>> to_tz in TIMEZONES
    True
    """

instruct prompt

Converts a datetime string from a given timezone to a datetime string in a randomly chosen timezone.
The function should output with:
    tuple: A tuple containing the converted datetime string and the randomly chosen timezone.
You should write self-contained code starting with:

Code

from random import choice
import pytz
from dateutil.parser import parse
# Constants
TIMEZONES = ['America/New_York', 'Europe/London', 'Asia/Shanghai', 'Asia/Tokyo', 'Australia/Sydney']
def task_func(date_str, from_tz):

code prompt

Code

from random import choice
import pytz
from dateutil.parser import parse
# Constants
TIMEZONES = ['America/New_York', 'Europe/London', 'Asia/Shanghai', 'Asia/Tokyo', 'Australia/Sydney']
def task_func(date_str, from_tz):

entry point

task_func

libs

  • pytz
  • dateutil
  • random

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