benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf a9c6866d-0c46-528c-9409-7fc759be460e

Problem

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

complete prompt

from datetime import datetime, timedelta
import pytz
import calendar


def task_func(days_in_past=7):
    """
    Get the weekday of the date 'days_in_past' days ago from today.

    This function computes the date that is 'days_in_past' number of days ago from the current
    system time's date in UTC. It then determines the weekday of this target date using calendar
    and returns its name as a string.

    Parameters:
    days_in_past (int): The number of days to go back from the current date to find the weekday.
                        Defaults to 7 (one week ago). Must be a non-negative integer.

    Returns:
    weekday (str)     : The name of the weekday (e.g., 'Monday', 'Tuesday') for the computed date.

    Raises:
    ValueError: If 'days_in_past' is negative.
    
    Requirements:
    - datetime.datetime
    - datetime.timedelta
    - pytz
    - calendar

    Example:
    >>> task_func()
    'Monday'
    >>> task_func(3)
    'Friday'
    """

instruct prompt

Get the weekday of the date 'days_in_past' days ago from today. This function computes the date that is 'days_in_past' number of days ago from the current system time's date in UTC. It then determines the weekday of this target date using calendar and returns its name as a string.
The function should raise the exception for: ValueError: If 'days_in_past' is negative.
The function should output with:
    weekday (str)     : The name of the weekday (e.g., 'Monday', 'Tuesday') for the computed date.
You should write self-contained code starting with:

Code

from datetime import datetime, timedelta
import pytz
import calendar
def task_func(days_in_past=7):

code prompt

Code

from datetime import datetime, timedelta
import pytz
import calendar
def task_func(days_in_past=7):

entry point

task_func

libs

  • pytz
  • datetime
  • calendar

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