data_source
string
prompt
list
ability
string
reward_model
dict
extra_info
dict
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a Python class named `Book` to manage book details. The class should have the following attributes:\n- `title`: ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", 1949).describe() == \\\"1984 by George Orwell, published in 1949\\\"\\n \\n assert Book(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\", 1960).describe() == \\\"To Kill ...
{ "split": "train", "index": "0", "task_id": "L0/train/0", "reference_solution": "class Book:\n def __init__(self, title, author, publication_year):\n self.title = title\n self.author = author\n self.publication_year = publication_year\n \n def describe(self):\n return f\"{s...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Movie` class in Python. The class should have the following specifications:\n\n- **Attributes:**\n - `title`...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert str(Movie(\\\"Inception\\\", 2010, \\\"Sci-Fi\\\")) == \\\"Title: Inception, Year: 2010, Genre: Sci-Fi\\\"\\n \\n assert str(Movie(\\\"The Matrix\\\", 1999, \\\"Action\\\")) == \\\"Title: The Matrix, Year: 1999, G...
{ "split": "train", "index": "1", "task_id": "L0/train/1", "reference_solution": "class Movie:\n def __init__(self, title: str, year: int, genre: str):\n self.title = title\n self.year = year\n self.genre = genre\n \n def __str__(self):\n return f\"Title: {self.title}, Year:...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Book` with the following specifications:\n\n- **Attributes:**\n - `title`: A string representing the title of the book...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"The Great Gatsby\\\", \\\"F. Scott Fitzgerald\\\", 1925, \\\"9780743273565\\\").get_book_info() == \\\"Title: The Great Gatsby, Author: F. Scott Fitzgerald, Year Published: 1925, ISBN: 9780743273565\\\"\\n \...
{ "split": "train", "index": "2", "task_id": "L0/train/2", "reference_solution": "class Book:\n def __init__(self, title, author, year_published, isbn):\n self.title = title\n self.author = author\n self.year_published = year_published\n self.isbn = isbn\n \n def get_book_in...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should support the following functionalities:\n\n- **Initialization**: ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(5, 10).area() == 50\\n \\n assert Rectangle(5, 10).perimeter() == 30\\n \\n assert Rectangle(0, 0).area() == 0\\n \\n assert Rectangle(0, 0).perimeter() == 0\\n \\n assert Rectangle(7, ...
{ "split": "train", "index": "3", "task_id": "L0/train/3", "reference_solution": "class Rectangle:\n def __init__(self, width, height):\n self.width = width\n self.height = height\n \n def area(self):\n return self.width * self.height\n \n def perimeter(self):\n return...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class in Python. The class should have the following attributes: `title`, `author`, and `publication_ye...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", 1949).get_details() == \\\"Title: 1984, Author: George Orwell, Year: 1949\\\"\\n \\n assert Book(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\", 1960).get_details() == ...
{ "split": "train", "index": "4", "task_id": "L0/train/4", "reference_solution": "class Book:\n def __init__(self, title, author, publication_year):\n self.title = title\n self.author = author\n self.publication_year = publication_year\n \n def get_details(self):\n return f\...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should support the following functionalities:\n\n- **Initialization**: ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(3, 4).area() == 12\\n \\n assert Rectangle(5, 5).perimeter() == 20\\n \\n assert str(Rectangle(2, 3)) == \\\"Rectangle(width=2, height=3)\\\"\\n \\n assert Rectangle(0, 0).area() == 0\\n \...
{ "split": "train", "index": "5", "task_id": "L0/train/5", "reference_solution": "class Rectangle:\n def __init__(self, width, height):\n self.width = width\n self.height = height\n \n def area(self):\n return self.width * self.height\n \n def perimeter(self):\n return...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Person` with the following specifications:\n\n- **Attributes:**\n - `first_name`: A string representing the first name...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Person(\\\"John\\\", \\\"Doe\\\", 25, \\\"john.doe@example.com\\\").get_full_name() == \\\"John Doe\\\"\\n \\n assert Person(\\\"Jane\\\", \\\"Smith\\\", 17, \\\"jane.smith@example.com\\\").is_adult() == False\\n ...
{ "split": "train", "index": "6", "task_id": "L0/train/6", "reference_solution": "class Person:\n def __init__(self, first_name, last_name, age, email):\n self.first_name = first_name\n self.last_name = last_name\n self.age = age\n self.email = email\n \n def get_full_name(s...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should have an initializer to set the width and height of the rectangle...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(3, 4).area() == 12\\n \\n assert Rectangle(5, 5).perimeter() == 20\\n \\n assert Rectangle(0, 0).area() == 0\\n \\n assert Rectangle(10, 2).perimeter() == 24\\n \\n assert Rectangle(7, ...
{ "split": "train", "index": "7", "task_id": "L0/train/7", "reference_solution": "class Rectangle:\n def __init__(self, width, height):\n self.width = width\n self.height = height\n \n def area(self):\n return self.width * self.height\n \n def perimeter(self):\n return...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a class `FinancialTransaction` for a financial application. This class should encapsulate the details of a finan...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert FinancialTransaction(100, '2023-10-01', 'Salary').is_debit() == False\\n \\n assert FinancialTransaction(-50, '2023-10-02', 'Groceries').is_debit() == True\\n \\n assert FinancialTransaction(0, '2023-10-03',...
{ "split": "train", "index": "8", "task_id": "L0/train/8", "reference_solution": "class FinancialTransaction:\n def __init__(self, amount, date, description):\n self.amount = amount\n self.date = date\n self.description = description\n \n def is_debit(self):\n return self.am...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Car` with the following specifications:\n- The class should have an initializer that accepts three parameters: `make`, ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert toyota_camry.make == \\\"Toyota\\\"\\n \\n assert toyota_camry.model == \\\"Camry\\\"\\n \\n assert toyota_camry.year == 2021\\n \\n assert honda_accord.make == \\\"Honda\\\"\\n \\n assert honda_...
{ "split": "train", "index": "9", "task_id": "L0/train/9", "reference_solution": "class Car:\n def __init__(self, make, model, year):\n self.make = make\n self.model = model\n self.year = year\n \n def display_info(self):\n print(f\"Make: {self.make}, Model: {self.model}, Ye...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Movie` with the following attributes and methods:\n\n- **Attributes:**\n - `title`: A string representing the title of...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Movie(\\\"Inception\\\", 2010, \\\"Sci-Fi\\\", 148, 8.8).title == \\\"Inception\\\"\\n \\n assert Movie(\\\"Inception\\\", 2010, \\\"Sci-Fi\\\", 148, 8.8).release_year == 2010\\n \\n assert Movie(\\\"Incepti...
{ "split": "train", "index": "10", "task_id": "L0/train/10", "reference_solution": "class Movie:\n def __init__(self, title, release_year, genre, duration, imdb_rating):\n self.title = title\n self.release_year = release_year\n self.genre = genre\n self.duration = duration\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class with the following requirements:\n\n- The class should have two attributes: `length` and `wi...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(4, 5).area() == 20\\n \\n assert Rectangle(4, 5).perimeter() == 18\\n \\n assert Rectangle(4, 5).isSquare() == False\\n \\n assert Rectangle(6, 6).area() == 36\\n \\n assert Rectangle(6...
{ "split": "train", "index": "11", "task_id": "L0/train/11", "reference_solution": "class Rectangle:\n def __init__(self, length, width):\n self.length = length\n self.width = width\n \n def area(self):\n return self.length * self.width\n \n def perimeter(self):\n retu...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Car` that simulates a simple car object. The class should have the following attributes and methods:\n\n- **Attributes:...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert str(Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020, 15000)) == \\\"Car(make='Toyota', model='Corolla', year=2020, mileage=15000)\\\"\\n \\n assert str(Car(\\\"Honda\\\", \\\"Civic\\\", 2018, 20000)) == \\\"Car(make='Ho...
{ "split": "train", "index": "12", "task_id": "L0/train/12", "reference_solution": "class Car:\n def __init__(self, make, model, year, mileage):\n self.make = make\n self.model = model\n self.year = year\n self.mileage = mileage\n \n def drive(self, distance):\n self....
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class in Python. The class should have the following attributes:\n- `title`: a string representing the ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert str(Book(\\\"1984\\\", \\\"George Orwell\\\", 1949)) == \\\"'1984' by George Orwell, published in 1949\\\"\\n \\n assert str(Book(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\", 1960)) == \\\"'To Kill a Mocking...
{ "split": "train", "index": "13", "task_id": "L0/train/13", "reference_solution": "class Book:\n def __init__(self, title, author, year):\n self.title = title\n self.author = author\n self.year = year\n \n def __str__(self):\n return f\"'{self.title}' by {self.author}, publ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should have the following specifications:\n\n- **Attributes:**\n - `wi...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(3, 4).area() == 12\\n \\n assert Rectangle(5, 5).perimeter() == 20\\n \\n assert Rectangle(0, 0).area() == 0\\n \\n assert Rectangle(10, 2).perimeter() == 24\\n \\n assert Rectangle(7, ...
{ "split": "train", "index": "14", "task_id": "L0/train/14", "reference_solution": "class Rectangle:\n def __init__(self, width, height):\n self.width = width\n self.height = height\n \n def area(self):\n return self.width * self.height\n \n def perimeter(self):\n retu...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a Python class named `Employee` to manage employee records. The class should have the following attributes: `emp...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Employee(123, 'John Doe', 'Finance', 50000).display_info() == None\\n \\n assert Employee(456, 'Jane Smith', 'IT', 60000).display_info() == None\\n \\n assert Employee(789, 'Alice Johnson', 'HR', 55000).disp...
{ "split": "train", "index": "15", "task_id": "L0/train/15", "reference_solution": "class Employee:\n def __init__(self, employee_id, name, department, salary):\n self.employee_id = employee_id\n self.name = name\n self.department = department\n self.salary = salary\n \n def...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with developing a function to analyze weather data for a competitive programming challenge. Given a list of dictionaries, where ea...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert filter_weather_data([{'date': '2023-01-01', 'temperature': 25, 'humidity': 80, 'wind_speed': 10}, {'date': '2023-01-02', 'temperature': 35, 'humidity': 70, 'wind_speed': 15}], lambda report: report['temperature'] > 30) ...
{ "split": "train", "index": "16", "task_id": "L0/train/16", "reference_solution": "def filter_weather_data(weather_data, condition):\n return [report for report in weather_data if condition(report)]" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a `BankAccount` class with the following specifications:\n\n- **Attributes:**\n - `owner`: A string representing the owner's name.\n ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert BankAccount(\\\"John\\\", 100.0).get_balance() == 100.0\\n \\n assert BankAccount(\\\"Alice\\\", 0.0).get_balance() == 0.0\\n \\n assert str(BankAccount(\\\"Bob\\\", 250.0)) == \\\"Account owner: Bob, Balanc...
{ "split": "train", "index": "17", "task_id": "L0/train/17", "reference_solution": "class BankAccount:\n def __init__(self, owner: str, balance: float):\n self.owner = owner\n self.balance = balance\n \n def deposit(self, amount: float) -> None:\n if amount <= 0:\n raise...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with simulating a dice roll in a game. Write a function `roll_dice` that returns a random integer between 1 and 6, inclusive, simu...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert 1 <= roll_dice() <= 6\\n \\n assert 1 <= roll_dice() <= 6\\n \\n assert 1 <= roll_dice() <= 6\\n \\n assert 1 <= roll_dice() <= 6\\n \\n assert 1 <= roll_dice() <= 6\\n \\n assert 1 <= roll...
{ "split": "train", "index": "18", "task_id": "L0/train/18", "reference_solution": "import random\n\ndef roll_dice():\n return random.randint(1, 6)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Given a list of integers, your task is to implement a function that removes all duplicate elements from the list while preserving the order of th...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert remove_duplicates([1, 2, 3, 2, 1]) == [1, 2, 3]\\n \\n assert remove_duplicates([4, 5, 6, 4, 7, 5]) == [4, 5, 6, 7]\\n \\n assert remove_duplicates([10, 10, 10, 10]) == [10]\\n \\n assert remove_duplic...
{ "split": "train", "index": "19", "task_id": "L0/train/19", "reference_solution": "def remove_duplicates(input_list):\n seen = set()\n result = []\n for num in input_list:\n if num not in seen:\n seen.add(num)\n result.append(num)\n return result" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Circle` class in Python. The class should support the following functionalities:\n\n1. **Initialization**: Th...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Circle(1).area() == math.pi\\n \\n assert Circle(0).area() == 0\\n \\n assert Circle(2.5).area() == math.pi * 2.5 ** 2\\n \\n assert Circle(1).circumference() == 2 * math.pi\\n \\n assert Circle(...
{ "split": "train", "index": "20", "task_id": "L0/train/20", "reference_solution": "import math\n\nclass Circle:\n def __init__(self, radius):\n self.radius = radius\n \n def area(self):\n return math.pi * (self.radius ** 2)\n \n def circumference(self):\n return 2 * math.pi ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to implement a function `find_max_in_list` that returns the maximum value in the list. You are not...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert find_max_in_list([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 9\\n \\n assert find_max_in_list([10, 20, 30, 40, 50]) == 50\\n \\n assert find_max_in_list([-10, -20, -30, -40, -50]) == -10\\n \\n assert find_m...
{ "split": "train", "index": "21", "task_id": "L0/train/21", "reference_solution": "def find_max_in_list(nums):\n if not nums:\n return None\n max_val = nums[0]\n for num in nums[1:]:\n if num > max_val:\n max_val = num\n return max_val" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a class `Circle` with the following specifications:\n\n- **Attributes:**\n - `radius`: A float representing the radius of the circle.\...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Circle(1).area() == math.pi\\n \\n assert Circle(0).area() == 0\\n \\n assert Circle(2).circumference() == 4 * math.pi\\n \\n assert Circle(1.5).area() == math.pi * (1.5 ** 2)\\n \\n assert Circl...
{ "split": "train", "index": "22", "task_id": "L0/train/22", "reference_solution": "import math\n\nclass Circle:\n def __init__(self, radius):\n self.radius = radius\n \n def area(self):\n return math.pi * (self.radius ** 2)\n \n def circumference(self):\n return 2 * math.pi ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a string `text` representing a sentence. Your task is to implement a function `reverse_sentence` that returns the sentence with the...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert reverse_sentence(\\\"Hello world this is a test\\\") == \\\"test a is this world Hello\\\"\\n \\n assert reverse_sentence(\\\"Python is fun\\\") == \\\"fun is Python\\\"\\n \\n assert reverse_sentence(\\\"Op...
{ "split": "train", "index": "23", "task_id": "L0/train/23", "reference_solution": "def reverse_sentence(text):\n words = text.split()\n reversed_words = words[::-1]\n return \" \".join(reversed_words)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a Python class named `Employee` to manage employee data. The class should have the following attributes and meth...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Employee(\\\"John\\\", \\\"Doe\\\", 123).get_full_name() == \\\"John Doe\\\"\\n \\n assert Employee(\\\"Jane\\\", \\\"Smith\\\", 456).get_employee_info() == \\\"Employee ID: 456, Full Name: Jane Smith\\\"\\n \\...
{ "split": "train", "index": "24", "task_id": "L0/train/24", "reference_solution": "class Employee:\n def __init__(self, first_name, last_name, employee_id):\n self.first_name = first_name\n self.last_name = last_name\n self.employee_id = employee_id\n \n def get_full_name(self):\n...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with creating a Python class named `Book` to manage book information. The class should have the following functionalities:\n- An i...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"9780451524935\\\").get_details() == \\\"Title: 1984, Author: George Orwell, ISBN: 9780451524935\\\"\\n \\n assert Book(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\...
{ "split": "train", "index": "25", "task_id": "L0/train/25", "reference_solution": "class Book:\n def __init__(self, title, author, isbn):\n self.title = title\n self.author = author\n self.isbn = isbn\n \n def get_details(self):\n return f\"Title: {self.title}, Author: {sel...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to implement a function named `remove_duplicates` that processes this list and returns a new list ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert remove_duplicates([1, 2, 3, 4, 5, 1, 2, 6, 7, 8, 3, 4]) == [1, 2, 3, 4, 5, 6, 7, 8]\\n \\n assert remove_duplicates([10, 20, 20, 10, 30]) == [10, 20, 30]\\n \\n assert remove_duplicates([1, 1, 1, 1, 1]) == [...
{ "split": "train", "index": "26", "task_id": "L0/train/26", "reference_solution": "def remove_duplicates(input_list):\n seen = set()\n unique_list = []\n for num in input_list:\n if num not in seen:\n seen.add(num)\n unique_list.append(num)\n return unique_list" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should have two attributes, `width` and `height`, and two methods: `are...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(3, 4).area() == 12\\n \\n assert Rectangle(5, 5).area() == 25\\n \\n assert Rectangle(0, 10).area() == 0\\n \\n assert Rectangle(7, 2).perimeter() == 18\\n \\n assert Rectangle(10, 10)....
{ "split": "train", "index": "27", "task_id": "L0/train/27", "reference_solution": "class Rectangle:\n def __init__(self, width, height):\n self.width = width\n self.height = height\n \n def area(self):\n return self.width * self.height\n \n def perimeter(self):\n retu...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class to manage book details and perform operations related to discounts. The class should have the fol...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"1234567890\\\", 9.99, 1949).get_summary() == \\\"Title: 1984, Author: George Orwell, Published: 1949\\\"\\n \\n assert Book(\\\"To Kill a Mockingbird\\\", \\\"Harper L...
{ "split": "train", "index": "28", "task_id": "L0/train/28", "reference_solution": "class Book:\n def __init__(self, title, author, isbn, price, publication_year):\n self.title = title\n self.author = author\n self.isbn = isbn\n self.price = price\n self.publication_year = ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers `numbers`. Your task is to determine whether there are any duplicate elements in the list. If duplicates are fou...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert has_duplicates([1, 2, 3, 4, 5, 1]) == True\\n \\n assert has_duplicates([1, 2, 3, 4, 5]) == False\\n \\n assert has_duplicates([]) == False\\n \\n assert has_duplicates([1, 1, 1, 1, 1]) == True\\n \...
{ "split": "train", "index": "29", "task_id": "L0/train/29", "reference_solution": "def has_duplicates(numbers):\n return len(numbers) != len(set(numbers))" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a string `s`. Your task is to implement a function `reverse_string(s: str) -> str` that returns the reversed version of the string ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert reverse_string(\\\"hello\\\") == \\\"olleh\\\"\\n \\n assert reverse_string(\\\"Python\\\") == \\\"nohtyP\\\"\\n \\n assert reverse_string(\\\"\\\") == \\\"\\\"\\n \\n assert reverse_string(\\\"a\\\") ...
{ "split": "train", "index": "30", "task_id": "L0/train/30", "reference_solution": "def reverse_string(s: str) -> str:\n return s[::-1]" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a recursive function named `calculate_factorial` that computes the factorial of a given non-negative integer `n`...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert calculate_factorial(0) == 1\\n \\n assert calculate_factorial(1) == 1\\n \\n assert calculate_factorial(5) == 120\\n \\n assert calculate_factorial(3) == 6\\n \\n assert calculate_factorial(10) =...
{ "split": "train", "index": "31", "task_id": "L0/train/31", "reference_solution": "def calculate_factorial(n):\n if n == 0:\n return 1\n else:\n return n * calculate_factorial(n - 1)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Book` with the following specifications:\n- The class should have an initializer that accepts three parameters: `title`...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", 1949).get_info() == \\\"Title: 1984, Author: George Orwell, Publication Year: 1949\\\"\\n \\n assert Book(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\", 1960).get_info...
{ "split": "train", "index": "32", "task_id": "L0/train/32", "reference_solution": "class Book:\n def __init__(self, title, author, publication_year):\n self.title = title\n self.author = author\n self.publication_year = publication_year\n \n def get_info(self):\n return f\"...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class to manage book information. The class should support the following functionalities:\n\n- **Constr...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"The Great Gatsby\\\", \\\"F. Scott Fitzgerald\\\", 180).summary() == \\\"Title: The Great Gatsby, Author: F. Scott Fitzgerald, Pages: 180\\\"\\n \\n assert Book(\\\"The Great Gatsby\\\", \\\"F. Scott Fitz...
{ "split": "train", "index": "33", "task_id": "L0/train/33", "reference_solution": "class Book:\n def __init__(self, title, author, pages):\n self.title = title\n self.author = author\n self.pages = pages\n \n def summary(self):\n return f\"Title: {self.title}, Author: {...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class in Python. The class should have the following specifications:\n\n- **Attributes:**\n - `title`:...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"9780451524935\\\", 1949).get_details() == \\\"Title: 1984, Author: George Orwell, ISBN: 9780451524935, Publication Year: 1949\\\"\\n \\n assert Book(\\\"To Kill a Mock...
{ "split": "train", "index": "34", "task_id": "L0/train/34", "reference_solution": "class Book:\n def __init__(self, title, author, isbn, publication_year):\n self.title = title\n self.author = author\n self.isbn = isbn\n self.publication_year = publication_year\n \n def get...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a Python class named `Car` that encapsulates the properties of a car. The class should have the following attrib...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert str(Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020)) == \\\"Toyota Corolla 2020\\\"\\n \\n assert str(Car(\\\"Honda\\\", \\\"Civic\\\", 2018)) == \\\"Honda Civic 2018\\\"\\n \\n assert str(Car(\\\"Ford\\\", \\\"M...
{ "split": "train", "index": "35", "task_id": "L0/train/35", "reference_solution": "class Car:\n def __init__(self, make, model, year):\n self.make = make\n self.model = model\n self.year = year\n \n def __str__(self):\n return f\"{self.make} {self.model} {self.year}\"" ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a dictionary `grades` where each key is a string representing a subject and each value is an integer representing the grade in that...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert calculate_average_grade({\\\"Math\\\": 85, \\\"Science\\\": 92, \\\"History\\\": 78}) == 85.0\\n \\n assert calculate_average_grade({\\\"Math\\\": 100, \\\"Science\\\": 100, \\\"History\\\": 100}) == 100.0\\n \...
{ "split": "train", "index": "36", "task_id": "L0/train/36", "reference_solution": "def calculate_average_grade(grades):\n if not grades:\n return None\n total = sum(grades.values())\n average = total / len(grades)\n return float(average)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a class `Car` with the following specifications:\n\n- **Attributes:**\n - `make`: A string representing the make of the car.\n - `mod...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020).make == \\\"Toyota\\\"\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020).model == \\\"Corolla\\\"\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020).ye...
{ "split": "train", "index": "37", "task_id": "L0/train/37", "reference_solution": "class Car:\n def __init__(self, make, model, year):\n self.make = make\n self.model = model\n self.year = year\n self.speed = 0\n \n def accelerate(self, amount):\n self.speed += amoun...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to implement a function `calculate_average(numbers)` that computes the average of the numbers in t...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert calculate_average([10, 20, 30, 40, 50]) == 30.0\\n \\n assert calculate_average([1, 2, 3, 4, 5]) == 3.0\\n \\n assert calculate_average([100, 200, 300]) == 200.0\\n \\n assert calculate_average([-10, -...
{ "split": "train", "index": "38", "task_id": "L0/train/38", "reference_solution": "def calculate_average(numbers):\n if len(numbers) == 0:\n return None\n return sum(numbers) / len(numbers)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class in Python. The class should have the following attributes: `title`, `author`, and `year`. Impleme...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", 1949).get_info() == \\\"Title: 1984, Author: George Orwell, Year: 1949\\\"\\n \\n assert Book(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\", 1960).get_info() == \\\"Ti...
{ "split": "train", "index": "39", "task_id": "L0/train/39", "reference_solution": "class Book:\n def __init__(self, title, author, year):\n self.title = title\n self.author = author\n self.year = year\n \n def get_info(self):\n return f\"Title: {self.title}, Author: {se...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a class `Circle` that models a circle with a given radius. The class should include the following methods:\n\n- `__init__(self, radius)...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Circle(1).area() == math.pi\\n \\n assert Circle(0).area() == 0\\n \\n assert Circle(2).circumference() == 4 * math.pi\\n \\n assert Circle(1.5).area() == math.pi * 2.25\\n \\n assert Circle(10)....
{ "split": "train", "index": "40", "task_id": "L0/train/40", "reference_solution": "import math\n\nclass Circle:\n def __init__(self, radius):\n self.radius = radius\n \n def area(self):\n return math.pi * self.radius ** 2\n \n def circumference(self):\n return 2 * math.pi * ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should have two attributes, `width` and `height`, which are initialized...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(3, 4).area() == 12\\n \\n assert Rectangle(3, 4).perimeter() == 14\\n \\n assert Rectangle(0, 0).area() == 0\\n \\n assert Rectangle(0, 0).perimeter() == 0\\n \\n assert Rectangle(5, 5)...
{ "split": "train", "index": "41", "task_id": "L0/train/41", "reference_solution": "class Rectangle:\n def __init__(self, width, height):\n self.width = width\n self.height = height\n \n def area(self):\n return self.width * self.height\n \n def perimeter(self):\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a Python class `Employee` to manage employee records. The class should support the following operations:\n\n1. *...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Employee(\\\"John Doe\\\", 123, \\\"HR\\\").get_employee_details() == \\\"Employee Name: John Doe, ID: 123, Department: HR\\\"\\n \\n assert Employee(\\\"Jane Smith\\\", 456, \\\"Engineering\\\").get_employee_deta...
{ "split": "train", "index": "42", "task_id": "L0/train/42", "reference_solution": "class Employee:\n def __init__(self, name, employee_id, department):\n self.name = name\n self.employee_id = employee_id\n self.department = department\n \n def update_department(self, new_departmen...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given two lists of integers. Your task is to implement a function `find_common_elements` that returns a sorted list of unique integers th...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert find_common_elements([1, 2, 3], [2, 3, 4]) == [2, 3]\\n \\n assert find_common_elements([5, 6, 7], [8, 9, 10]) == []\\n \\n assert find_common_elements([1, 1, 2, 2], [2, 2, 3, 3]) == [2]\\n \\n assert ...
{ "split": "train", "index": "43", "task_id": "L0/train/43", "reference_solution": "def find_common_elements(list1, list2):\n return sorted(set(list1) & set(list2))" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to implement a function `sort_and_filter_list(input_list)` that processes the list by first removi...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert sort_and_filter_list([-10, 5, -3, 8, 0, -1]) == [0, 5, 8]\\n \\n assert sort_and_filter_list([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\\n \\n assert sort_and_filter_list([-1, -2, -3, -4, -5]) == []\\n \\n as...
{ "split": "train", "index": "44", "task_id": "L0/train/44", "reference_solution": "def sort_and_filter_list(input_list):\n return sorted([x for x in input_list if x >= 0])" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class in Python. The class should have the following attributes:\n- `title`: A string representing the ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", 1949).get_details() == \\\"Title: 1984, Author: George Orwell, Year: 1949\\\"\\n \\n assert Book(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\", 1960).get_details() == ...
{ "split": "train", "index": "45", "task_id": "L0/train/45", "reference_solution": "class Book:\n def __init__(self, title, author, year):\n self.title = title\n self.author = author\n self.year = year\n \n def get_details(self):\n return f\"Title: {self.title}, Author: {sel...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Counter` with the following specifications:\n\n- The class should have an initializer that accepts an optional paramete...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Counter().get_count() == 0\\n \\n assert Counter(5).get_count() == 5\\n \\n assert Counter(-3).get_count() == -3\\n \\n c = Counter(); c.increment(); assert c.get_count() == 1\\n \\n c = Counter(...
{ "split": "train", "index": "46", "task_id": "L0/train/46", "reference_solution": "class Counter:\n def __init__(self, initial_count=0):\n self.count = initial_count\n \n def increment(self):\n self.count += 1\n \n def decrement(self):\n self.count -= 1\n \n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to compute the cumulative sum of the list. The cumulative sum at each position is the sum of the c...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert cumulative_sum([1, 2, 3, 4]) == [1, 3, 6, 10]\\n \\n assert cumulative_sum([0, 0, 0, 0]) == [0, 0, 0, 0]\\n \\n assert cumulative_sum([10, 20, 30]) == [10, 30, 60]\\n \\n assert cumulative_sum([-1, -2,...
{ "split": "train", "index": "47", "task_id": "L0/train/47", "reference_solution": "def cumulative_sum(nums):\n total = 0\n result = []\n for num in nums:\n total += num\n result.append(total)\n return result" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a Python class named `Employee` to manage employee data. The class should store the following attributes for eac...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Employee(\\\"John Doe\\\", 123, \\\"HR\\\", 50000).get_name() == \\\"John Doe\\\"\\n \\n assert Employee(\\\"Jane Smith\\\", 456, \\\"Engineering\\\", 75000).get_id() == 456\\n \\n assert Employee(\\\"Alice ...
{ "split": "train", "index": "48", "task_id": "L0/train/48", "reference_solution": "class Employee:\n def __init__(self, name, id, department, salary):\n self._name = name\n self._id = id\n self._department = department\n self._salary = salary\n \n def get_name(self):\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class named `Person` with the following specifications:\n- The class should have three attributes: `name`, `age`, and `email`....
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Person(\\\"Alice\\\", 25, \\\"alice@example.com\\\").get_details() == \\\"Name: Alice, Age: 25, Email: alice@example.com\\\"\\n \\n assert Person(\\\"Bob\\\", 40, \\\"bob@example.com\\\").get_details() == \\\"Name...
{ "split": "train", "index": "49", "task_id": "L0/train/49", "reference_solution": "class Person:\n def __init__(self, name, age, email):\n self.name = name\n self.age = age\n self.email = email\n \n def get_details(self):\n return f\"Name: {self.name}, Age: {self.age}, Emai...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with processing a dataset of customer reviews and their corresponding ratings. Each review is represented as a string, and each ra...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert classify_reviews([(\\\"Great product!\\\", 5)]) == [(\\\"Great product!\\\", \\\"positive\\\")]\\n \\n assert classify_reviews([(\\\"Not bad, but could be better.\\\", 3)]) == [(\\\"Not bad, but could be better.\\...
{ "split": "train", "index": "50", "task_id": "L0/train/50", "reference_solution": "def classify_reviews(reviews):\n result = []\n for review, rating in reviews:\n if rating >= 4:\n result.append((review, \"positive\"))\n elif rating <= 2:\n result.append((review, \"neg...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a dictionary and a key. Your task is to implement a function that returns the value associated with the key if it exists in the dic...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert get_value_from_dict({'a': 1, 'b': 2}, 'a', 0) == 1\\n \\n assert get_value_from_dict({'a': 1, 'b': 2}, 'c', 0) == 0\\n \\n assert get_value_from_dict({}, 'a', 'default') == 'default'\\n \\n assert get_...
{ "split": "train", "index": "51", "task_id": "L0/train/51", "reference_solution": "def get_value_from_dict(d, key, default):\n return d.get(key, default)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a function `generate_random_sentence(nouns, verbs, adjectives)` that constructs a random sentence by selecting o...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert generate_random_sentence([\\\"cat\\\"], [\\\"jumps\\\"], [\\\"happy\\\"]) == \\\"The happy cat jumps.\\\"\\n \\n assert generate_random_sentence([\\\"dog\\\"], [\\\"runs\\\"], [\\\"lazy\\\"]) == \\\"The lazy dog r...
{ "split": "train", "index": "52", "task_id": "L0/train/52", "reference_solution": "import random\n\ndef generate_random_sentence(nouns, verbs, adjectives):\n adjective = random.choice(adjectives)\n noun = random.choice(nouns)\n verb = random.choice(verbs)\n return f\"The {adjective} {noun} {verb}.\...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Car` with the following specifications:\n\n- The class should have an initializer `__init__` that takes four parameters...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020, 15000).make == \\\"Toyota\\\"\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020, 15000).model == \\\"Corolla\\\"\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla...
{ "split": "train", "index": "53", "task_id": "L0/train/53", "reference_solution": "class Car:\n def __init__(self, make, model, year, mileage):\n self.make = make\n self.model = model\n self.year = year\n self.mileage = mileage\n \n def update_mileage(self, new_mileage)...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a function `generate_fibonacci_sequence` that generates the first `n` numbers of the Fibonacci sequence. The Fib...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert generate_fibonacci_sequence(1) == [0]\\n \\n assert generate_fibonacci_sequence(2) == [0, 1]\\n \\n assert generate_fibonacci_sequence(3) == [0, 1, 1]\\n \\n assert generate_fibonacci_sequence(5) == [0...
{ "split": "train", "index": "54", "task_id": "L0/train/54", "reference_solution": "def generate_fibonacci_sequence(n):\n fib = []\n a, b = 0, 1\n for _ in range(n):\n fib.append(a)\n a, b = b, a + b\n return fib" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a temperature value and its scale. Your task is to write a function `convert_temperature` that converts the temperature from Celsiu...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert convert_temperature(0, \\\"C\\\") == 32.0\\n \\n assert convert_temperature(100, \\\"C\\\") == 212.0\\n \\n assert convert_temperature(32, \\\"F\\\") == 0.0\\n \\n assert convert_temperature(212, \\\"F...
{ "split": "train", "index": "55", "task_id": "L0/train/55", "reference_solution": "def convert_temperature(temp, scale):\n if scale == \"C\":\n return (temp * 9/5) + 32\n elif scale == \"F\":\n return (temp - 32) * 5/9\n else:\n raise ValueError(\"Scale must be 'C' or 'F'\")" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a JSON object represented as a dictionary where each key is a username and each value is a list of integers representing scores. Yo...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert merge_scores({\\\"alice\\\": [10, 20, 30], \\\"bob\\\": [5, 15, 25]}) == {\\\"alice\\\": 60, \\\"bob\\\": 45}\\n \\n assert merge_scores({\\\"charlie\\\": [10, 10, 10], \\\"dave\\\": [20, 20, 20, 20]}) == {\\\"cha...
{ "split": "train", "index": "56", "task_id": "L0/train/56", "reference_solution": "def merge_scores(data):\n result = {}\n for username, scores in data.items():\n total = sum(scores)\n result[username] = total\n return result" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class in Python. The class should support the following functionalities:\n\n1. **Initialization**: The ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"9780451524935\\\", 1949).get_details() == \\\"Title: 1984, Author: George Orwell, ISBN: 9780451524935, Publication Year: 1949\\\"\\n \\n assert Book(\\\"To Kill a Mock...
{ "split": "train", "index": "57", "task_id": "L0/train/57", "reference_solution": "class Book:\n def __init__(self, title, author, isbn, publication_year):\n self.title = title\n self.author = author\n self.isbn = isbn\n self.publication_year = publication_year\n \n def get...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class in Python. The class should encapsulate the properties of a book, including its title, author, an...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"9780451524935\\\").get_details() == \\\"Title: 1984, Author: George Orwell, ISBN: 9780451524935\\\"\\n \\n assert Book(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\...
{ "split": "train", "index": "58", "task_id": "L0/train/58", "reference_solution": "class Book:\n def __init__(self, title, author, isbn):\n self._title = title\n self._author = author\n self._isbn = isbn\n \n def get_details(self):\n return f\"Title: {self._title}, Author: ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a dictionary `data` containing the keys `'name'`, `'age'`, and `'email'`. Your task is to implement a function `generate_email` tha...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert generate_email({\\\"name\\\": \\\"Alice\\\", \\\"age\\\": 30, \\\"email\\\": \\\"alice@example.com\\\"}) == \\\"Hello Alice, you are 30 years old. Your email address is alice@example.com.\\\"\\n \\n assert generat...
{ "split": "train", "index": "59", "task_id": "L0/train/59", "reference_solution": "def generate_email(data):\n return f\"Hello {data['name']}, you are {data['age']} years old. Your email address is {data['email']}.\"" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a sequence of movement commands for a character on an infinite 2D grid. The character starts at the origin (0, 0). The commands can...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert final_position(['up', 'right', 'down', 'down', 'left']) == (0, -1)\\n \\n assert final_position(['up', 'up', 'up']) == (0, 3)\\n \\n assert final_position(['down', 'down', 'down']) == (0, -3)\\n \\n as...
{ "split": "train", "index": "60", "task_id": "L0/train/60", "reference_solution": "def final_position(commands):\n x = 0\n y = 0\n for command in commands:\n if command == 'up':\n y += 1\n elif command == 'down':\n y -= 1\n elif command == 'left':\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a dictionary `data` where each key is a string representing a category and each value is a list of integers representing values wit...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert sum_values({'fruits': [10, 20, 30], 'vegetables': [5, 15, 25]}) == 105\\n \\n assert sum_values({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]}) == 45\\n \\n assert sum_values({'single': [42]}) == 42\\n ...
{ "split": "train", "index": "61", "task_id": "L0/train/61", "reference_solution": "def sum_values(data):\n return sum(sum(lst) for lst in data.values())" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a function `generate_random_matrix` that constructs an `n x n` matrix filled with random integers within a given...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert len(generate_random_matrix(3, 1, 10)) == 3\\n \\n assert all(len(row) == 3 for row in generate_random_matrix(3, 1, 10))\\n \\n assert all(1 <= num <= 10 for row in generate_random_matrix(3, 1, 10) for num in...
{ "split": "train", "index": "62", "task_id": "L0/train/62", "reference_solution": "import random\n\ndef generate_random_matrix(n, min_val, max_val):\n return [[random.randint(min_val, max_val) for _ in range(n)] for _ in range(n)]" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a recursive function named `calculate_factorial` that computes the factorial of a given non-negative integer `n`...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert calculate_factorial(0) == 1\\n \\n assert calculate_factorial(1) == 1\\n \\n assert calculate_factorial(2) == 2\\n \\n assert calculate_factorial(3) == 6\\n \\n assert calculate_factorial(4) == 2...
{ "split": "train", "index": "63", "task_id": "L0/train/63", "reference_solution": "def calculate_factorial(n):\n if n < 0:\n raise ValueError(\"Factorial is not defined for negative numbers\")\n elif n == 0 or n == 1:\n return 1\n else:\n return n * calculate_factorial(n - 1)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Circle` class in Python. The class should have the following functionalities:\n- A constructor that initializ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Circle(0).area() == 0\\n \\n assert Circle(1).area() == math.pi\\n \\n assert Circle(2).area() == 4 * math.pi\\n \\n assert Circle(0).circumference() == 0\\n \\n assert Circle(1).circumference() ...
{ "split": "train", "index": "64", "task_id": "L0/train/64", "reference_solution": "import math\n\nclass Circle:\n def __init__(self, radius):\n self.radius = radius\n \n def area(self):\n return math.pi * self.radius ** 2\n \n def circumference(self):\n return 2 * ma...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with designing a class hierarchy for managing books and e-books in a digital library system. Implement a base class `Book` with th...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"1234567890\\\", 328, 15.99).get_price() == 15.99\\n \\n assert EBook(\\\"To Kill a Mockingbird\\\", \\\"Harper Lee\\\", \\\"0987654321\\\", 281, 9.99, 2.5).get_price()...
{ "split": "train", "index": "65", "task_id": "L0/train/65", "reference_solution": "class Book:\n def __init__(self, title, author, isbn, pages, price):\n self.title = title\n self.author = author\n self.isbn = isbn\n self.pages = pages\n self.price = price\n \n def g...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a Python class named `Car`. The class should have the following specifications:\n\n- **Constructor**: The constr...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2021).make == \\\"Toyota\\\"\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2021).model == \\\"Corolla\\\"\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2021).ye...
{ "split": "train", "index": "66", "task_id": "L0/train/66", "reference_solution": "class Car:\n def __init__(self, make, model, year):\n self.make = make\n self.model = model\n self.year = year\n \n def display_info(self):\n print(f\"Make: {self.make}, Model: {self.mode...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to write a function `optimize_function` that processes this list and returns a new list where all ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert optimize_function([1, 1, 2, 3, 3, 3, 4, 5, 5]) == [1, 2, 3, 4, 5]\\n \\n assert optimize_function([1, 2, 2, 3, 4, 4, 5, 5, 5]) == [1, 2, 3, 4, 5]\\n \\n assert optimize_function([1, 1, 1, 1, 1, 1, 1]) == [1]...
{ "split": "train", "index": "67", "task_id": "L0/train/67", "reference_solution": "def optimize_function(nums):\n if not nums:\n return []\n result = [nums[0]]\n for num in nums[1:]:\n if num != result[-1]:\n result.append(num)\n return result" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of words and an integer `n`. Your task is to implement a function `filter_long_words` that returns a new list containing onl...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert filter_long_words([\\\"apple\\\", \\\"banana\\\", \\\"cherry\\\", \\\"date\\\"], 5) == [\\\"banana\\\", \\\"cherry\\\"]\\n \\n assert filter_long_words([\\\"cat\\\", \\\"dog\\\", \\\"elephant\\\", \\\"giraffe\\\"]...
{ "split": "train", "index": "68", "task_id": "L0/train/68", "reference_solution": "def filter_long_words(words, n):\n return [word for word in words if len(word) > n]" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a Python class named `Person`. The class should have an initializer method `__init__` that accepts two parameter...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert str(Person(\\\"Alice\\\", 30)) == \\\"Name: Alice, Age: 30\\\"\\n \\n assert str(Person(\\\"Bob\\\", 25)) == \\\"Name: Bob, Age: 25\\\"\\n \\n assert str(Person(\\\"Charlie\\\", 40)) == \\\"Name: Charlie, Ag...
{ "split": "train", "index": "69", "task_id": "L0/train/69", "reference_solution": "class Person:\n def __init__(self, name, age):\n self.name = name\n self.age = age\n \n def __str__(self):\n return f\"Name: {self.name}, Age: {self.age}\"" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Car` class in Python. The class should have the following attributes and methods:\n\n- **Attributes:**\n - `...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020, \\\"Red\\\", 15000).make == \\\"Toyota\\\"\\n \\n assert Car(\\\"Honda\\\", \\\"Civic\\\", 2018, \\\"Blue\\\", 20000).model == \\\"Civic\\\"\\n \\n assert Car(\\\"F...
{ "split": "train", "index": "70", "task_id": "L0/train/70", "reference_solution": "class Car:\n def __init__(self, make, model, year, color, mileage):\n self.make = make\n self.model = model\n self.year = year\n self.color = color\n self.mileage = mileage\n \n de...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should have two instance variables, `width` and `height`, which are ini...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(3, 4).area() == 12\\n \\n assert Rectangle(5, 5).perimeter() == 20\\n \\n assert Rectangle(0, 0).area() == 0\\n \\n assert Rectangle(10, 2).perimeter() == 24\\n \\n assert Rectangle(7, ...
{ "split": "train", "index": "71", "task_id": "L0/train/71", "reference_solution": "class Rectangle:\n def __init__(self, width, height):\n self.width = width\n self.height = height\n \n def area(self):\n return self.width * self.height\n \n def perimeter(self):\n retu...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given two sets of integers, `set1` and `set2`. Your task is to implement a function `find_common_elements` that returns a new set contain...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert find_common_elements({1, 2, 3}, {2, 3, 4}) == {2, 3}\\n \\n assert find_common_elements({1, 2, 3}, {4, 5, 6}) == set()\\n \\n assert find_common_elements(set(), {1, 2, 3}) == set()\\n \\n assert find_c...
{ "split": "train", "index": "72", "task_id": "L0/train/72", "reference_solution": "def find_common_elements(set1, set2):\n return set1 & set2" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of positive integers. Your task is to implement a function that computes the cumulative product of the elements in the list....
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert cumulative_product([1, 2, 3, 4]) == [1, 2, 6, 24]\\n \\n assert cumulative_product([1, 1, 1, 1]) == [1, 1, 1, 1]\\n \\n assert cumulative_product([2, 3, 4]) == [2, 6, 24]\\n \\n assert cumulative_produ...
{ "split": "train", "index": "73", "task_id": "L0/train/73", "reference_solution": "def cumulative_product(lst):\n if not lst:\n return []\n result = []\n product = 1\n for num in lst:\n product *= num\n result.append(product)\n return result" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a function `generate_greeting` for a web application that provides personalized greetings to users based on the ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert generate_greeting(\\\"Alice\\\", \\\"morning\\\") == \\\"Good morning, Alice!\\\"\\n \\n assert generate_greeting(\\\"Bob\\\", \\\"afternoon\\\") == \\\"Good afternoon, Bob!\\\"\\n \\n assert generate_greeti...
{ "split": "train", "index": "74", "task_id": "L0/train/74", "reference_solution": "def generate_greeting(name, time_of_day):\n if time_of_day == \"morning\":\n return f\"Good morning, {name}!\"\n elif time_of_day == \"afternoon\":\n return f\"Good afternoon, {name}!\"\n elif time_of_day ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a simple calculator in Python that supports basic arithmetic operations: addition, subtraction, multiplication, ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Calculator.add(5, 3) == 8\\n \\n assert Calculator.subtract(5, 3) == 2\\n \\n assert Calculator.multiply(5, 3) == 15\\n \\n assert Calculator.divide(5, 3) == 5 / 3\\n \\n assert Calculator.add(-5...
{ "split": "train", "index": "75", "task_id": "L0/train/75", "reference_solution": "class Calculator:\n @staticmethod\n def add(a, b):\n return a + b\n \n @staticmethod\n def subtract(a, b):\n return a - b\n \n @staticmethod\n def multiply(a, b):\n return a * b\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to write a function that computes the sum of all unique integers in the list. Each integer should ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert sum_unique_numbers([1, 2, 3, 2, 4]) == 10\\n \\n assert sum_unique_numbers([10, 20, 20, 10, 30]) == 60\\n \\n assert sum_unique_numbers([5, 5, 5, 5, 5]) == 5\\n \\n assert sum_unique_numbers([]) == 0\\...
{ "split": "train", "index": "76", "task_id": "L0/train/76", "reference_solution": "def sum_unique_numbers(numbers):\n return sum(set(numbers))" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a string `text` and a dictionary `translation_dict` where each key-value pair represents a word and its translation. Your task is t...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert translate_text(\\\"hello world\\\", {\\\"hello\\\": \\\"hi\\\", \\\"world\\\": \\\"earth\\\"}) == \\\"hi earth\\\"\\n \\n assert translate_text(\\\"hello earth\\\", {\\\"hello\\\": \\\"hi\\\"}) == \\\"hi earth\\\"...
{ "split": "train", "index": "77", "task_id": "L0/train/77", "reference_solution": "def translate_text(text, translation_dict):\n words = text.split()\n translated_words = [translation_dict.get(word, word) for word in words]\n return \" \".join(translated_words)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers `nums` and an integer `target`. Your task is to determine the index of the first occurrence of `target` in `nums...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert find_first_occurrence([1, 2, 3, 4, 5], 3) == 2\\n \\n assert find_first_occurrence([10, 20, 30, 40, 50], 10) == 0\\n \\n assert find_first_occurrence([5, 5, 5, 5, 5], 5) == 0\\n \\n assert find_first_o...
{ "split": "train", "index": "78", "task_id": "L0/train/78", "reference_solution": "def find_first_occurrence(nums, target):\n for i, num in enumerate(nums):\n if num == target:\n return i\n return -1" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to write a function named `double_integers` that processes this list and returns a new list where ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert double_integers([1, 2, 3]) == [2, 4, 6]\\n \\n assert double_integers([-1, -2, -3]) == [-2, -4, -6]\\n \\n assert double_integers([0, 0, 0]) == [0, 0, 0]\\n \\n assert double_integers([10, -10, 20, -20...
{ "split": "train", "index": "79", "task_id": "L0/train/79", "reference_solution": "def double_integers(int_list):\n return [x * 2 for x in int_list]" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should have two attributes, `length` and `width`, and should provide tw...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(5, 3).area() == 15\\n \\n assert Rectangle(5, 3).perimeter() == 16\\n \\n assert Rectangle(0, 0).area() == 0\\n \\n assert Rectangle(0, 0).perimeter() == 0\\n \\n assert Rectangle(10, 2...
{ "split": "train", "index": "80", "task_id": "L0/train/80", "reference_solution": "class Rectangle:\n def __init__(self, length, width):\n self.length = length\n self.width = width\n \n def area(self):\n return self.length * self.width\n \n def perimeter(self):\n retu...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class to manage a library's inventory. The class should support the following functionalities:\n\n- Ini...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"1234567890\\\", 15.99, 10).title == \\\"1984\\\"\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"1234567890\\\", 15.99, 10).author == \\\"George Orwell\\\"...
{ "split": "train", "index": "81", "task_id": "L0/train/81", "reference_solution": "class Book:\n def __init__(self, title, author, isbn, price, quantity):\n self.title = title\n self.author = author\n self.isbn = isbn\n self.price = price\n self.quantity = quantity\n \n...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a simple stack data structure using a class in Python. Your stack should support the following operations:\n- `push(item)`: Adds an ite...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Stack().is_empty() == True\\n \\n assert Stack().peek() == None\\n \\n assert Stack().pop() == None\\n \\n s = Stack(); s.push(1); assert s.peek() == 1\\n \\n s = Stack(); s.push(1); s.push(2); a...
{ "split": "train", "index": "82", "task_id": "L0/train/82", "reference_solution": "class Stack:\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n if self.is_empty():\n return None\n return sel...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a string `s` consisting of characters '(', ')', and other non-parenthesis characters. Your task is to determine if the parentheses ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert is_balanced_parentheses(\\\"()\\\") == True\\n \\n assert is_balanced_parentheses(\\\"(())\\\") == True\\n \\n assert is_balanced_parentheses(\\\"(()())\\\") == True\\n \\n assert is_balanced_parenthes...
{ "split": "train", "index": "83", "task_id": "L0/train/83", "reference_solution": "def is_balanced_parentheses(s: str) -> bool:\n stack = []\n for char in s:\n if char == '(':\n stack.append(char)\n elif char == ')':\n if not stack:\n return False\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a string `sentence` representing a sentence where words are separated by one or more spaces. Your task is to reverse the order of t...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert reverse_words(\\\"Hello world this is a test\\\") == \\\"test a is this world Hello\\\"\\n \\n assert reverse_words(\\\" Leading and trailing spaces \\\") == \\\"spaces trailing and Leading\\\"\\n \\n a...
{ "split": "train", "index": "84", "task_id": "L0/train/84", "reference_solution": "def reverse_words(sentence):\n words = sentence.split()\n words.reverse()\n return \" \".join(words)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Book` class to manage books in a library system. The class should support the following functionalities:\n\n-...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"1234567890\\\", True).title == \\\"1984\\\"\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", \\\"1234567890\\\", True).author == \\\"George Orwell\\\"\\n \\n...
{ "split": "train", "index": "85", "task_id": "L0/train/85", "reference_solution": "class Book:\n def __init__(self, title, author, isbn, available):\n self.title = title\n self.author = author\n self.isbn = isbn\n self.available = available\n \n def check_out(self):\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a positive integer `n`. Your task is to write a Python function `calculate_sum_of_squares` that computes the sum of the squares of ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert calculate_sum_of_squares(1) == 1\\n \\n assert calculate_sum_of_squares(2) == 5\\n \\n assert calculate_sum_of_squares(3) == 14\\n \\n assert calculate_sum_of_squares(4) == 30\\n \\n assert calcu...
{ "split": "train", "index": "86", "task_id": "L0/train/86", "reference_solution": "def calculate_sum_of_squares(n):\n return sum([i**2 for i in range(1, n+1)])" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a string `s` consisting of various characters. Your task is to implement a function `remove_non_alpha` that processes this string a...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert remove_non_alpha(\\\"abc123\\\") == \\\"abc\\\"\\n \\n assert remove_non_alpha(\\\"123abc\\\") == \\\"abc\\\"\\n \\n assert remove_non_alpha(\\\"!@#$%^&*()\\\") == \\\"\\\"\\n \\n assert remove_non_alp...
{ "split": "train", "index": "87", "task_id": "L0/train/87", "reference_solution": "def remove_non_alpha(s):\n return ''.join(char for char in s if char.isalpha())" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a `Rectangle` class in Python. The class should encapsulate the properties of a rectangle and provide methods to...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Rectangle(3, 4).area() == 12\\n \\n assert Rectangle(5, 5).perimeter() == 20\\n \\n assert str(Rectangle(2, 3)) == \\\"Rectangle(width=2, height=3)\\\"\\n \\n assert Rectangle(0, 0).area() == 0\\n \...
{ "split": "train", "index": "88", "task_id": "L0/train/88", "reference_solution": "class Rectangle:\n def __init__(self, width, height):\n self.width = width\n self.height = height\n \n def area(self):\n return self.width * self.height\n \n def perimeter(self):\n retu...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given two sorted lists of integers, `list1` and `list2`. Your task is to write a function `merge_sorted_lists` that merges these two list...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert merge_sorted_lists([1, 3, 5], [2, 4, 6]) == [1, 2, 3, 4, 5, 6]\\n \\n assert merge_sorted_lists([], [1, 2, 3]) == [1, 2, 3]\\n \\n assert merge_sorted_lists([1, 2, 3], []) == [1, 2, 3]\\n \\n assert me...
{ "split": "train", "index": "89", "task_id": "L0/train/89", "reference_solution": "def merge_sorted_lists(list1, list2):\n i, j = 0, 0\n result = []\n n = len(list1)\n m = len(list2)\n \n while i < n and j < m:\n if list1[i] <= list2[j]:\n result.append(list1[i])\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a recursive function to compute the factorial of a given non-negative integer `n`. The factorial of a non-negati...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert factorial(0) == 1\\n \\n assert factorial(1) == 1\\n \\n assert factorial(2) == 2\\n \\n assert factorial(3) == 6\\n \\n assert factorial(4) == 24\\n \\n assert factorial(5) == 120\\n \\...
{ "split": "train", "index": "90", "task_id": "L0/train/90", "reference_solution": "def factorial(n):\n if n == 0:\n return 1\n else:\n return n * factorial(n - 1)" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a class `Book` with the following attributes: `title`, `author`, `year_published`, and `genre`. The class should include the following ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Book(\\\"1984\\\", \\\"George Orwell\\\", 1949, \\\"Dystopian\\\").get_book_info() == \\\"Title: 1984, Author: George Orwell, Year: 1949, Genre: Dystopian\\\"\\n \\n assert str(Book(\\\"To Kill a Mockingbird\\\", ...
{ "split": "train", "index": "91", "task_id": "L0/train/91", "reference_solution": "class Book:\n def __init__(self, title, author, year_published, genre):\n self.title = title\n self.author = author\n self.year_published = year_published\n self.genre = genre\n \n def get_bo...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Car` for a car rental company. The class should have the following attributes and methods:\n\n- **Attributes:**\n - `m...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2020, 50).rent_car(3) == 150\\n \\n assert Car(\\\"Honda\\\", \\\"Civic\\\", 2019, 45).rent_car(5) == 225\\n \\n assert Car(\\\"Ford\\\", \\\"Mustang\\\", 2021, 100).rent...
{ "split": "train", "index": "92", "task_id": "L0/train/92", "reference_solution": "class Car:\n def __init__(self, make, model, year, rental_price_per_day):\n self.make = make\n self.model = model\n self.year = year\n self.rental_price_per_day = rental_price_per_day\n \n de...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to write a function that determines the maximum and minimum values in the list without using any b...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert find_max_min([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == (9, 1)\\n \\n assert find_max_min([10, 20, 30, 40, 50]) == (50, 10)\\n \\n assert find_max_min([-10, -20, -30, -40, -50]) == (-10, -50)\\n \\n assert ...
{ "split": "train", "index": "93", "task_id": "L0/train/93", "reference_solution": "def find_max_min(numbers):\n max_value = numbers[0]\n min_value = numbers[0]\n for num in numbers[1:]:\n if num > max_value:\n max_value = num\n if num < min_value:\n min_value = num\...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a dictionary representing a list of employees where the keys are employee names and the values are their respective salaries. Your ...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert filter_employees_by_salary({'John Doe': 50000, 'Jane Smith': 60000, 'Alice Johnson': 48000, 'Bob Brown': 72000}, 50000) == {'John Doe': 50000, 'Jane Smith': 60000, 'Bob Brown': 72000}\\n \\n assert filter_employee...
{ "split": "train", "index": "94", "task_id": "L0/train/94", "reference_solution": "def filter_employees_by_salary(employees, min_salary):\n return {name: salary for name, salary in employees.items() if salary >= min_salary}" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of integers. Your task is to classify these integers into three categories: positive, negative, and zero. Implement a functi...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert classify_numbers([1, -1, 0]) == {'positive': [1], 'negative': [-1], 'zero': [0]}\\n \\n assert classify_numbers([0, 0, 0]) == {'positive': [], 'negative': [], 'zero': [0, 0, 0]}\\n \\n assert classify_number...
{ "split": "train", "index": "95", "task_id": "L0/train/95", "reference_solution": "def classify_numbers(numbers):\n result = {\n 'positive': [],\n 'negative': [],\n 'zero': []\n }\n for num in numbers:\n if num > 0:\n result['positive'].append(num)\n elif ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: Implement a Python class `Employee` with the following specifications:\n\n- The class should have an initializer that accepts an optional paramet...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Employee().get_salary() == 0\\n \\n assert Employee(50000).get_salary() == 50000\\n \\n assert Employee(100000).get_salary() == 100000\\n \\n employee = Employee(50000)\\n employee.set_salary(60000)...
{ "split": "train", "index": "96", "task_id": "L0/train/96", "reference_solution": "class Employee:\n def __init__(self, salary=0):\n self.salary = salary\n \n def get_salary(self):\n return self.salary\n \n def set_salary(self, new_salary):\n if new_salary < 0:\n ...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are tasked with implementing a class hierarchy for vehicles. Define a base class `Car` with the following specifications:\n- Constructor `__i...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert Car(\\\"Toyota\\\", \\\"Corolla\\\", 2021).get_info() == \\\"Toyota Corolla 2021\\\"\\n \\n assert ElectricCar(\\\"Tesla\\\", \\\"Model S\\\", 2020, 75).get_info() == \\\"Tesla Model S 2020, Battery Size: 75 kWh\\...
{ "split": "train", "index": "97", "task_id": "L0/train/97", "reference_solution": "class Car:\n def __init__(self, make, model, year):\n self.make = make\n self.model = model\n self.year = year\n \n def get_info(self):\n return f\"{self.make} {self.model} {self.year}\"\n\nc...
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a list of dictionaries. Your task is to write a Python function `filter_none_values` that processes this list and returns a new lis...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert filter_none_values([{'a': 1, 'b': None, 'c': 3}]) == [{'a': 1, 'c': 3}]\\n \\n assert filter_none_values([{'x': None, 'y': None}]) == [{}]\\n \\n assert filter_none_values([{'key1': 'value1', 'key2': 'value2...
{ "split": "train", "index": "98", "task_id": "L0/train/98", "reference_solution": "def filter_none_values(input_list):\n return [ {k: v for k, v in d.items() if v is not None} for d in input_list ]" }
humaneval
[ { "role": "user", "content": "You are an expert Python programmer. Write a solution to the following task and return it in a single ```python code block.\n\nTask: You are given a temperature in Fahrenheit and your task is to write a function that converts this temperature to Celsius using the formula `(Fahr...
code
{ "style": "rule", "ground_truth": "{\"functional\": \"def check(candidate):\\n \\n assert convert_to_celsius(32) == 0.0\\n \\n assert convert_to_celsius(212) == 100.0\\n \\n assert convert_to_celsius(-40) == -40.0\\n \\n assert convert_to_celsius(0) == -17.77777777777778\\n \\n assert...
{ "split": "train", "index": "99", "task_id": "L0/train/99", "reference_solution": "def convert_to_celsius(fahrenheit):\n return (fahrenheit - 32) * 5 / 9" }