version
stringclasses
1 value
style
stringclasses
2 values
subset
stringclasses
12 values
question_id
stringlengths
9
23
question
stringlengths
27
8.13k
solution
stringlengths
99
5.97k
test
stringlengths
105
4.45k
test_info
listlengths
0
13
gpt_pass_sequence
listlengths
1
10
gpt_pass_trial_num
int64
1
10
gpt_difficulty
stringclasses
3 values
gpt_pass_percentage
float64
0.1
1
trials
dict
chosen_trial
stringclasses
10 values
metadata
dict
benchmark_similarity
float64
0.16
0.93
benchmark_instruction
stringclasses
1 value
benchmark_task_id
stringclasses
1 value
filter_reason
stringclasses
1 value
base_id
stringlengths
7
21
variant
stringclasses
2 values
top_function_names
listlengths
2
13
n_top_functions
int64
2
13
helper_call_edges
listlengths
1
16
n_helper_call_edges
int64
1
16
harness_functions
listlengths
0
3
structural_wrapper
bool
1 class
class_names
listlengths
0
5
has_class
bool
2 classes
test_kind
stringclasses
1 value
test_has_solution_import
bool
2 classes
third_party_imports
listlengths
0
5
stdlib_only
bool
2 classes
question_norm_sha1
stringlengths
40
40
solution_ast_sha1
stringlengths
40
40
v1.0
instruct
Filter
Filter_49493_I
Can you help me create a simple Python program that calculates the area of a circle when the radius is given by the user? I want to make sure it also handles incorrect inputs, like if someone enters a negative number or a string.
import math def calculate_circle_area(radius): """ Calculates the area of a circle given the radius. Parameters: radius (float): The radius of the circle. Returns: float: The area of the circle, or None if the input is invalid. """ if not isinstance(radius, (int, float)) or ra...
from solution import calculate_circle_area, get_circle_area_from_user_input def test_calculate_circle_area(): assert calculate_circle_area(3) == math.pi * 9 assert calculate_circle_area(0) == 0 assert calculate_circle_area(4.5) == math.pi * 4.5 * 4.5 assert calculate_circle_area(-1) == None assert ...
[ { "docstring": "Calculates the area of a circle given the radius.\n\nParameters:\nradius (float): The radius of the circle.\n\nReturns:\nfloat: The area of the circle, or None if the input is invalid.", "function_declaration": "def calculate_circle_area(radius):", "function_name": "calculate_circle_area...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_circle_area(radius):\n \"\"\"\n Calculates the area of a circle given its radius.\n \n Parameters:\n radius (float): The radius of the circle. Must ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049493", "row_id": 49493, "seed_ids": "['Qwen2.5-72B-Instruct_103497']" }
0.499195
Filter_49493
I
[ "calculate_circle_area", "get_circle_area_from_user_input" ]
2
[ [ "get_circle_area_from_user_input", "calculate_circle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3fe4f424cb65ca42fca45844ed08a8c610b23a97
b9ca88c276c5c8f527ee5aac931ff26b316ac147
v1.0
instruct
Filter
Filter_49524_I
Write a Python program to solve a Sudoku puzzle. The program should take a 9x9 grid partially filled with numbers from 1 to 9 as input and return the solved grid. The program should also handle cases where the puzzle has no solution or multiple solutions. For puzzles with multiple solutions, the program should return o...
from typing import List, Union def is_valid(board: List[List[int]], row: int, col: int, num: int) -> bool: # Check if the number is present in the row for x in range(9): if board[row][x] == num: return False # Check if the number is present in the column for x in range(9): ...
from solution import solve_sudoku def test_solve_sudoku_easy(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, 0...
[ { "docstring": null, "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": null, "function_declaration": "def solve_sudoku_util(board):", "function_name": "solve_sudoku_util", "para...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, row, col, num):\n for i in range(9):\n if board[row][i] == num or board[i][col] == num:\n return False\n start_row, start_col = 3 * (row // 3), 3 * ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049524", "row_id": 49524, "seed_ids": "['Qwen2.5-72B-Instruct_103540']" }
0.49473
Filter_49524
I
[ "is_valid", "solve_sudoku_util", "solve_sudoku" ]
3
[ [ "solve_sudoku", "solve_sudoku_util" ], [ "solve_sudoku_util", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7f6d9fa590e964955d53eb988ad35267960c120d
e74e23983c05b943908a8e6d321a950d3bad47d6
v1.0
instruct
Filter
Filter_49530_I
Write a Python script that finds the 10001st prime number. The script should be efficient and optimized for finding large prime numbers. Make sure to include comments in your code to explain the logic and any algorithms used.
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import is_prime, find_10001st_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(97) == True assert is_prime(1) == False assert is_prime(0) == F...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find the 10001st prime number using an efficient approach.", "function_declaration": "def find_10001st_prime():", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(number):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if number <= 1:\n return False\n if number == 2:\n return True\n if number % 2 == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049530", "row_id": 49530, "seed_ids": "['Qwen2.5-72B-Instruct_103549']" }
0.543401
Filter_49530
I
[ "is_prime", "find_10001st_prime" ]
2
[ [ "find_10001st_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bfb881884df3aae8b2bb344d08d2adce2bc11e2f
de07d0497ef1e67dd269af6caaa9d00c91592c29
v1.0
instruct
Filter
Filter_49537_I
Write a program that calculates the sum of all the prime numbers between 1 and 100. The program should also print out each prime number it finds. Use Python for this task.
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import is_prime, sum_of_primes def test_is_prime(): # Test known prime numbers assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(7) == True # Test known non-prime numbers assert is_prime(1) == False assert is_prime(4) == Fals...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculate the sum of all prime numbers between 1 and 100 and return the sum.", "function_declaration": "def sum_of_pr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(number):\n \"\"\"\n Returns True if the number is prime, otherwise False.\n \"\"\"\n if number <= 1:\n return False\n for i in range(2, int(number**0.5) + 1)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049537", "row_id": 49537, "seed_ids": "['Qwen2.5-72B-Instruct_103564']" }
0.60242
Filter_49537
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d31d0cd1c34a0bbea5078f9ed33e70d3e8f2a13a
09ee45636066cf3de07cda01bad3308cfe77fff1
v1.0
instruct
Filter
Filter_49622_I
Write a Python function that generates a random integer between 1 and 100, and then checks if the number is a prime number. If the number is prime, the function should return "The number X is prime." where X is the generated number. If the number is not prime, the function should return "The number X is not prime." whe...
import random def is_prime(n): """ This function checks if a number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: re...
import pytest from solution import is_prime, generate_and_check_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(17) == True assert is_prime(97) == True as...
[ { "docstring": "This function checks if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a random integer between 1 and 100 and checks if it is a prime number.\nReturns a statement wh...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef is_prime(n):\n \"\"\"\n Helper function to determine if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049622", "row_id": 49622, "seed_ids": "['Qwen2.5-72B-Instruct_103694']" }
0.738312
Filter_49622
I
[ "is_prime", "generate_and_check_prime" ]
2
[ [ "generate_and_check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
576b47f28fd6aaa80fd13d43d718f4fe8397d458
4163cde897f262883056fa3a828064878a413cd4
v1.0
instruct
Filter
Filter_49630_I
Create a Python program that reads a CSV file containing a list of names and email addresses, and sends a personalized greeting email to each person using SMTP. The CSV file has two columns: 'Name' and 'Email'. The program should connect to an SMTP server to send the emails. Assume the SMTP server details (host, port, ...
import csv import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart def send_emails(csv_file_path, smtp_details): """ Sends personalized greeting emails to each person listed in the CSV file. :param csv_file_path: str - Path to the CSV file containing names and em...
from solution import send_emails, send_email import pytest # Test the email sending function with a mocked SMTP server def test_send_email(monkeypatch): smtp_details = { 'host': 'smtp.example.com', 'port': 587, 'login': 'user@example.com', 'password': 'password' } class Moc...
[ { "docstring": "Sends personalized greeting emails to each person listed in the CSV file.\n\n:param csv_file_path: str - Path to the CSV file containing names and email addresses\n:param smtp_details: dict - Dictionary containing SMTP server details", "function_declaration": "def send_emails(csv_file_path, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport smtplib\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\n\ndef send_email(smtp_host, smtp_port, smtp_login, smtp_password, csv_file):\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049630", "row_id": 49630, "seed_ids": "['Qwen2.5-72B-Instruct_103704']" }
0.617367
Filter_49630
I
[ "send_emails", "send_email" ]
2
[ [ "send_emails", "send_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8075af3ecf5046b87b34d1713006af5fb2dd7882
58c2c13e0536ed8248d44afdc9151a69d147eb6a
v1.0
instruct
Filter
Filter_49633_I
Can you help me write a Python script that takes an image as input and converts it to grayscale? I want to use this script to process a batch of images in a folder.
from PIL import Image import os def convert_to_grayscale(image_path, save_path): """ Convert an image to grayscale and save it. Parameters: image_path (str): Path to the input image. save_path (str): Path where the grayscale image will be saved. """ # Open an image file with Image....
from solution import convert_to_grayscale, process_batch_images import os from PIL import Image import tempfile def test_convert_to_grayscale(): with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as temp_input: img = Image.new('RGB', (10, 10), color = 'red') img.save(temp_input.name) ...
[ { "docstring": "Convert an image to grayscale and save it.\n\nParameters:\nimage_path (str): Path to the input image.\nsave_path (str): Path where the grayscale image will be saved.", "function_declaration": "def convert_to_grayscale(image_path, save_path):", "function_name": "convert_to_grayscale", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from PIL import Image\nimport os\n\ndef convert_to_grayscale(image_path):\n \"\"\"\n Converts an image to grayscale and saves it.\n \"\"\"\n img = Image.open(image_path).convert('L...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049633", "row_id": 49633, "seed_ids": "['Qwen2.5-72B-Instruct_103708']" }
0.635176
Filter_49633
I
[ "convert_to_grayscale", "process_batch_images" ]
2
[ [ "process_batch_images", "convert_to_grayscale" ] ]
1
[]
false
[]
false
pytest
true
[ "PIL" ]
false
de82f849977d4029a0a7e82eaf4bfb1aa852ea5b
cf549ae16f1eb4d0e5ed9388acc38325f7253530
v1.0
instruct
Filter
Filter_49670_I
Given a variable \( n \) representing a positive integer, write a Python program to compute the factorial of \( n \) using both a loop and recursion. Compare the results from both methods to ensure they are the same, and handle any potential errors such as incorrect input types or negative numbers. Provide the output i...
def factorial_loop(n): """ Compute the factorial of n using a loop. """ if not isinstance(n, int) or n < 0: raise ValueError("Input must be a non-negative integer") result = 1 for i in range(1, n + 1): result *= i return result def factorial_recursive(n): """ Compute...
from solution import factorial_loop, factorial_recursive, compare_factorial_methods def test_factorial_loop(): assert factorial_loop(0) == 1 assert factorial_loop(1) == 1 assert factorial_loop(5) == 120 def test_factorial_recursive(): assert factorial_recursive(0) == 1 assert factorial_recursive(1...
[ { "docstring": "Compute the factorial of n using a loop.", "function_declaration": "def factorial_loop(n):", "function_name": "factorial_loop", "parameter_list": "(n)" }, { "docstring": "Compute the factorial of n using recursion.", "function_declaration": "def factorial_recursive(n):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorial_loop(n):\n \"\"\"\n Returns the factorial of n using a loop.\n \"\"\"\n if not isinstance(n, int) or n < 0:\n raise ValueError(\"Input must be a non-negative i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049670", "row_id": 49670, "seed_ids": "['Qwen2.5-72B-Instruct_103786']" }
0.652033
Filter_49670
I
[ "factorial_loop", "factorial_recursive", "compare_factorial_methods" ]
3
[ [ "compare_factorial_methods", "factorial_loop" ], [ "compare_factorial_methods", "factorial_recursive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
12ea31af924ab31f24e0e72730c5d7cd7e6ef647
9dbb4861e42dbfcd528a2972f82b5331677e7c62
v1.0
instruct
Filter
Filter_49703_I
Write a Python program that takes an input string from the user and checks if the string is a palindrome. A palindrome is a word, phrase, number, or other sequences of characters which reads the same backward as forward, such as madam or racecar. If the input string is a palindrome, the program should print "The string...
import re def is_palindrome(s): """ Checks if the given string is a palindrome, considering only alphanumeric characters and ignoring cases. """ # Remove all non-alphanumeric characters and convert the string to lower case clean_s = re.sub(r'[^a-zA-Z0-9]', '', s).lower() # Check if the cleaned ...
from solution import is_palindrome, check_palindrome def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("A man, a plan, a canal, Panama") == True assert is_palindrome("No 'x' in Nixon") ...
[ { "docstring": "Checks if the given string is a palindrome, considering only alphanumeric characters and ignoring cases.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Prints whether the given string is a palind...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_palindrome(s):\n \"\"\"\n Checks if the given string is a palindrome, considering only alphanumeric characters and ignoring cases.\n \"\"\"\n # Remove all non-a...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00049703", "row_id": 49703, "seed_ids": "['Qwen2.5-72B-Instruct_103852']" }
0.791882
Filter_49703
I
[ "is_palindrome", "check_palindrome" ]
2
[ [ "check_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b93f1d413b8dc597db0be559a220a8b1bf73a6f
8102a5c9d4457e274d6dd0eb8081f2b2bac1ed21
v1.0
instruct
Filter
Filter_49706_I
How can I calculate the average color of an image using Python? I'm working on a project where I need to process a series of images and determine their predominant color. Could you provide a Python script that calculates the average color of an image and outputs it in RGB format? Additionally, it would be great if the ...
from PIL import Image import numpy as np import matplotlib.pyplot as plt def average_color(image_path): """ Calculate the average color of an image. Parameters: - image_path (str): Path to the image file. Returns: - tuple: A tuple representing the average color in RGB format. """ ...
from PIL import Image import numpy as np from solution import average_color, display_image_with_avg_color import os def test_average_color_simple_image(): # Create a simple red image for testing red_image_path = "test_red.png" image = Image.new('RGB', (10, 10), (255, 0, 0)) image.save(red_image_path) ...
[ { "docstring": "Calculate the average color of an image.\n\nParameters:\n- image_path (str): Path to the image file.\n\nReturns:\n- tuple: A tuple representing the average color in RGB format.", "function_declaration": "def average_color(image_path):", "function_name": "average_color", "parameter_li...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from PIL import Image\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef calculate_average_color(image_path):\n \"\"\"\n Calculates the average color of the image in image_path....
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049706", "row_id": 49706, "seed_ids": "['Qwen2.5-72B-Instruct_103859']" }
0.500626
Filter_49706
I
[ "average_color", "display_image_with_avg_color" ]
2
[ [ "display_image_with_avg_color", "average_color" ] ]
1
[]
false
[]
false
pytest
true
[ "PIL", "matplotlib", "numpy" ]
false
0cb0831b028167b5148fd3951a229580ac63e747
810592068ddee7a72c4843568ab8f6ce1edb91fa
v1.0
instruct
Filter
Filter_49721_I
How can I use Python to create a script that checks if a website is up and running? I want it to notify me if the website is down.
import requests def is_website_up(url): """ Checks if the website is up and running. Args: url (str): The URL of the website to check. Returns: bool: True if the website is up, False otherwise. """ try: response = requests.get(url) if response.status_code == 20...
from solution import is_website_up, notify_if_down import requests from unittest.mock import patch def test_is_website_up_success(): with patch('requests.get') as mock_get: mock_get.return_value.status_code = 200 assert is_website_up("http://example.com") == True def test_is_website_up_failure(): ...
[ { "docstring": "Checks if the website is up and running.\n\nArgs:\nurl (str): The URL of the website to check.\n\nReturns:\nbool: True if the website is up, False otherwise.", "function_declaration": "def is_website_up(url):", "function_name": "is_website_up", "parameter_list": "(url)" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\n\ndef check_website_status(url):\n \"\"\"\n Checks if a website is up and running.\n\n Args:\n url (str): The URL of the website to check.\n\n Returns:\n boo...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049721", "row_id": 49721, "seed_ids": "['Qwen2.5-72B-Instruct_103882']" }
0.55553
Filter_49721
I
[ "is_website_up", "notify_if_down" ]
2
[ [ "notify_if_down", "is_website_up" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
6552a1812d39ff2872c893ec2b39d74ada13ccbc
69f7a63a8af1f71e64200500c71acafc5277e933
v1.0
instruct
Filter
Filter_49754_I
Write a Python script that reads a CSV file containing a list of users and their email addresses, and sends each user an email with a personalized greeting. The CSV file has two columns: `Name` and `Email`. The email should have a subject line of "Welcome to Our Community!" and the body should start with "Dear [Name], ...
import csv import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart # SMTP server details SMTP_SERVER = 'smtp.example.com' SMTP_PORT = 587 SENDER_EMAIL = 'sender@example.com' SENDER_PASSWORD = 'password' def send_email(recipient_name, recipient_email): try: subjec...
import pytest import smtplib from unittest.mock import patch, MagicMock from solution import send_email, read_csv_and_send_emails def test_send_email(): with patch('smtplib.SMTP') as mock_smtp: instance = mock_smtp.return_value instance.sendmail.return_value = {} send_email("John Doe", "jo...
[ { "docstring": null, "function_declaration": "def send_email(recipient_name, recipient_email):", "function_name": "send_email", "parameter_list": "(recipient_name, recipient_email)" }, { "docstring": null, "function_declaration": "def read_csv_and_send_emails(csv_filename):", "functi...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport smtplib\nfrom email.message import EmailMessage\n\nSMTP_SERVER = 'smtp.example.com'\nSMTP_PORT = 587\nEMAIL_ADDRESS = 'your_email@example.com'\nEMAIL_PASSWORD = 'your_passwo...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049754", "row_id": 49754, "seed_ids": "['Qwen2.5-72B-Instruct_103928']" }
0.562731
Filter_49754
I
[ "send_email", "read_csv_and_send_emails" ]
2
[ [ "read_csv_and_send_emails", "send_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c326d9a759074ff604ae6490b4a980b642a84ed5
67dcac832cfb4874a9792f1417ed3f8887ba6cca
v1.0
instruct
Filter
Filter_49761_I
How can I create a Python function that checks if a specific year is a leap year, and how can I use this function to filter a list of years to return only the leap years?
def is_leap_year(year): """ Returns True if the given year is a leap year, False otherwise. """ if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): return True else: return False def filter_leap_years(years): """ Filters and returns the list of leap years from the g...
from solution import is_leap_year, filter_leap_years def test_is_leap_year(): assert is_leap_year(2000) == True assert is_leap_year(1900) == False assert is_leap_year(2004) == True assert is_leap_year(2001) == False def test_filter_leap_years(): assert filter_leap_years([1999, 2000, 2001, 2004, 19...
[ { "docstring": "Returns True if the given year is a leap year, False otherwise.", "function_declaration": "def is_leap_year(year):", "function_name": "is_leap_year", "parameter_list": "(year)" }, { "docstring": "Filters and returns the list of leap years from the given list of years.", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_leap_year(year):\n \"\"\"\n Returns True if the given year is a leap year, False otherwise.\n \"\"\"\n if year % 4 == 0:\n if year % 100 == 0:\n if year % ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049761", "row_id": 49761, "seed_ids": "['Qwen2.5-72B-Instruct_103939']" }
0.620628
Filter_49761
I
[ "is_leap_year", "filter_leap_years" ]
2
[ [ "filter_leap_years", "is_leap_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dfcff298cb67fb936cb0e7fabe2dafd5877775f4
67a3e70562b4c691eee6ef85076e7579d586e6d0
v1.0
instruct
Filter
Filter_49796_I
Create a Python function named `huffman_encoding` that takes a string and returns the Huffman encoded output as a dictionary, mapping each character in the input string to its corresponding Huffman code (a binary string).
import heapq from collections import defaultdict, Counter class Node: def __init__(self, char, freq): self.char = char self.freq = freq self.left = None self.right = None # Defining comparators less_than and equals def __lt__(self, other): return self.freq < oth...
from solution import huffman_encoding def test_huffman_encoding_basic(): string = "abcdefg" result = huffman_encoding(string) assert len(result) == 7 def test_huffman_encoding_simple_abc(): string = "abc" result = huffman_encoding(string) assert len(result) == 3 def test_huffman_encoding_...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom collections import defaultdict, Counter\n\nclass Node:\n def __init__(self, char, freq):\n self.char = char\n self.freq = freq\n self.left = None\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049796", "row_id": 49796, "seed_ids": "['Qwen2.5-72B-Instruct_104004']" }
0.562173
Filter_49796
I
[ "build_huffman_tree", "build_codes", "huffman_encoding" ]
3
[ [ "huffman_encoding", "build_codes" ], [ "huffman_encoding", "build_huffman_tree" ] ]
2
[]
false
[ "Node" ]
true
pytest
true
[]
true
97c222ce01bda26d193f2f539e0eef8e7bc0db3a
91611c668bc0e8a49b565ba6594d362fbcf3f600
v1.0
instruct
Filter
Filter_49810_I
Create a Python program that reads a CSV file and plots a line graph using matplotlib. The CSV file has two columns: 'Year' and 'Sales'. The program should also include a function to calculate the moving average of the 'Sales' over a specified window size and plot this moving average on the same graph.
import pandas as pd import matplotlib.pyplot as plt def read_csv(file_path): """ Reads a CSV file and returns a DataFrame. Parameters: file_path (str): Path to the CSV file. Returns: pd.DataFrame: DataFrame containing the CSV data. """ return pd.read_csv(file_path) def plot_s...
import pandas as pd from solution import read_csv, plot_sales, moving_average, plot_moving_average def test_read_csv(): data = """Year,Sales 2000,100 2001,150 2002,200 """ with open('test.csv', 'w') as file: file.write(data) df = read_csv('test.csv') assert not df.empty ...
[ { "docstring": "Reads a CSV file and returns a DataFrame.\n\nParameters:\nfile_path (str): Path to the CSV file.\n\nReturns:\npd.DataFrame: DataFrame containing the CSV data.", "function_declaration": "def read_csv(file_path):", "function_name": "read_csv", "parameter_list": "(file_path)" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport matplotlib.pyplot as plt\n\ndef read_csv(file_path):\n \"\"\"\n Reads a CSV file located at file_path and returns a DataFrame.\n The CSV file is expected t...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049810", "row_id": 49810, "seed_ids": "['Qwen2.5-72B-Instruct_104021']" }
0.628577
Filter_49810
I
[ "read_csv", "plot_sales", "moving_average", "plot_moving_average" ]
4
[ [ "plot_moving_average", "moving_average" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "pandas" ]
false
5e71fb1b1185949e9a30e4d37f431d55df546f7b
19beae68e2dae238c6b811e9e0853cf76077a01c
v1.0
instruct
Filter
Filter_49847_I
Can you provide a step-by-step guide on how to create a simple chatbot using Python and Flask?
from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/chatbot', methods=['POST']) def chatbot(): user_message = request.json.get('message') if not user_message: return jsonify({"reply": "I didn't get that. Can you please repeat?"}), 400 reply = get_reply(user_message) r...
import pytest from flask import Flask, json from solution import app, get_reply def test_get_reply(): assert get_reply("hello") == "Hi there! How can I help you today?" assert get_reply("I need help") == "Sure, I'm here to help! What do you need assistance with?" assert get_reply("random text") == "I'm not...
[ { "docstring": null, "function_declaration": "def chatbot():", "function_name": "chatbot", "parameter_list": "()" }, { "docstring": "Generates a reply based on the user's message.", "function_declaration": "def get_reply(user_message):", "function_name": "get_reply", "parameter_l...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, jsonify\n\napp = Flask(__name__)\n\n@app.route('/chatbot', methods=['POST'])\ndef chatbot():\n user_message = request.json.get('message')\n if not user_...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00049847", "row_id": 49847, "seed_ids": "['Qwen2.5-72B-Instruct_104078']" }
0.395718
Filter_49847
I
[ "chatbot", "get_reply" ]
2
[ [ "chatbot", "get_reply" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
f9d040d90f1517d71affd4290dd7a5cb62db5c7a
1ec60b0c36c5ba87cda46c9c209cf4cf4c8d585f
v1.0
instruct
Filter
Filter_49851_I
Is there a way to create a Python function that takes a list of positive integers and returns the largest integer that is a prime number? If there are no prime numbers in the list, the function should return `None`. How can this be done?
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def largest_p...
from solution import is_prime, largest_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(25) == False def test_largest_prime_with_...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the largest prime number in the list of positive integers.\nIf there are no prime numbers, returns No...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049851", "row_id": 49851, "seed_ids": "['Qwen2.5-72B-Instruct_104083']" }
0.737058
Filter_49851
I
[ "is_prime", "largest_prime" ]
2
[ [ "largest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13e2f27f39d8519714edf3f633e7dceaea3a5eaa
d0ba4fbd6de21794286c4af03a73ec1910db125a
v1.0
instruct
Filter
Filter_49883_I
Can you assist me with a basic Python script that can automate the process of sending emails? I need to send multiple emails with personalized content to a list of recipients. What libraries should I use, and how can I structure the script?
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText def send_email(subject, body, to_email, from_email, smtp_server, smtp_port, username, password): """ Sends an email with the specified subject and body to the specified recipient. Args: - subject: Subjec...
import pytest from unittest.mock import patch # Assume the script file name is solution.py from solution import send_email, send_bulk_emails @patch('solution.smtplib.SMTP') def test_send_email_success(mock_smtp): mock_smtp.return_value = mock_smtp mock_smtp.sendmail.return_value = {} try: sen...
[ { "docstring": "Sends an email with the specified subject and body to the specified recipient.\n\nArgs:\n- subject: Subject of the email.\n- body: Body of the email.\n- to_email: Recipient's email address.\n- from_email: Sender's email address.\n- smtp_server: SMTP server address.\n- smtp_port: SMTP server port...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import smtplib\nfrom email.mime.multipart import MIMEMultipart\nfrom email.mime.text import MIMEText\n\ndef send_email(subject, body, to_email, from_email, smtp_server, smtp_port, username, pa...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00049883", "row_id": 49883, "seed_ids": "['Qwen2.5-72B-Instruct_104127']" }
0.579521
Filter_49883
I
[ "send_email", "send_bulk_emails" ]
2
[ [ "send_bulk_emails", "send_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
21ba5af6d2ca6702b900183b6803420c72411d8c
784aca2912cb4d840c39eeb87001ff24a93f95d9
v1.0
instruct
Filter
Filter_49919_I
How can I automate the process of adding a watermark to multiple images using Python?
from PIL import Image, ImageDraw, ImageFont def add_watermark(input_image_path, output_image_path, watermark_text, position): """ Adds a watermark to an image and saves the result. :param input_image_path: Path to the input image file :param output_image_path: Path to save the output image file ...
import os from solution import add_watermark, process_images def test_add_watermark(): input_image_path = "test_image.jpg" output_image_path = "test_image_watermarked.jpg" watermark_text = "Sample Watermark" position = (10, 10) # Create a sample image for testing sample_image = Image.new("RGB"...
[ { "docstring": "Adds a watermark to an image and saves the result.\n\n:param input_image_path: Path to the input image file\n:param output_image_path: Path to save the output image file\n:param watermark_text: Text of the watermark\n:param position: Tuple (x, y) positioning the watermark on the image", "fun...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from PIL import Image, ImageDraw, ImageFont\nimport os\n\ndef add_watermark(input_folder, output_folder, watermark_text, font_path, font_size=30, position=(0, 0), color=(255, 255, 255)):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049919", "row_id": 49919, "seed_ids": "['Qwen2.5-72B-Instruct_104187']" }
0.40656
Filter_49919
I
[ "add_watermark", "process_images" ]
2
[ [ "process_images", "add_watermark" ] ]
1
[]
false
[]
false
pytest
true
[ "PIL" ]
false
8146b6e3cb3c045501803b0b726ac733840632ad
e4245bfa412b7f866921e8d933f79904ce4a65aa
v1.0
instruct
Filter
Filter_49957_I
Create a Python script to convert a list of temperatures from Celsius to Fahrenheit, and also include a function to convert from Fahrenheit to Celsius. The script should allow for converting a list of temperatures in either direction based on user input.
def celsius_to_fahrenheit(celsius_temps): """ Converts a list of temperatures from Celsius to Fahrenheit. :param celsius_temps: List of temperatures in Celsius :return: List of temperatures in Fahrenheit """ return [(temp * 9/5) + 32 for temp in celsius_temps] def fahrenheit_to_celsius(fah...
from solution import celsius_to_fahrenheit, fahrenheit_to_celsius, convert_temperatures def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit([0, 100, -40]) == [32, 212, -40] assert celsius_to_fahrenheit([30, -10, 15]) == [86, 14, 59] def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsius...
[ { "docstring": "Converts a list of temperatures from Celsius to Fahrenheit.\n\n:param celsius_temps: List of temperatures in Celsius\n:return: List of temperatures in Fahrenheit", "function_declaration": "def celsius_to_fahrenheit(celsius_temps):", "function_name": "celsius_to_fahrenheit", "paramete...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius_list):\n \"\"\"\n Convert a list of temperatures from Celsius to Fahrenheit.\n \n :param celsius_list: List of temperatures in Celsius\n :retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049957", "row_id": 49957, "seed_ids": "['Qwen2.5-72B-Instruct_104245']" }
0.482597
Filter_49957
I
[ "celsius_to_fahrenheit", "fahrenheit_to_celsius", "convert_temperatures" ]
3
[ [ "convert_temperatures", "celsius_to_fahrenheit" ], [ "convert_temperatures", "fahrenheit_to_celsius" ] ]
2
[]
false
[]
false
pytest
true
[]
true
96323e8425a2a9f2032e078ef99a9eaa8351826c
36b28e634f304b7991f7ff43e2336e7e27745671
v1.0
instruct
Filter
Filter_49958_I
Write a Python function that calculates the total Hamming distance between all pairs of integers in a given list. The Hamming distance between two integers is the number of positions at which the corresponding bits are different. For example, the Hamming distance between 4 (binary 100) and 14 (binary 1110) is 2, as the...
def hamming_distance(x, y): """ Calculate the Hamming distance between two integers x and y. """ return bin(x ^ y).count('1') def total_hamming_distance(nums): """ Calculate the total Hamming distance between all pairs of integers in a given list. """ n = len(nums) total_distance = ...
from solution import hamming_distance, total_hamming_distance def test_hamming_distance(): assert hamming_distance(4, 14) == 2 assert hamming_distance(1, 4) == 2 assert hamming_distance(0, 0) == 0 assert hamming_distance(255, 0) == 8 def test_total_hamming_distance(): assert total_hamming_distance...
[ { "docstring": "Calculate the Hamming distance between two integers x and y.", "function_declaration": "def hamming_distance(x, y):", "function_name": "hamming_distance", "parameter_list": "(x, y)" }, { "docstring": "Calculate the total Hamming distance between all pairs of integers in a giv...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def total_hamming_distance(nums):\n \"\"\"\n Calculate the total Hamming distance between all pairs of integers in the list.\n \n Args:\n nums : List[int] : List of integers\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049958", "row_id": 49958, "seed_ids": "['Qwen2.5-72B-Instruct_104248']" }
0.8551
Filter_49958
I
[ "hamming_distance", "total_hamming_distance" ]
2
[ [ "total_hamming_distance", "hamming_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d6a6f1c77eca735f01b871e63effff8132f151ff
1aba2d1d58c5776439f7136ab940657f1bb4e9f0
v1.0
instruct
Filter
Filter_49975_I
How can I create a Python script to periodically check if a website is up and log the status?
import requests import time import logging # Configure logging logging.basicConfig(filename='website_status.log', level=logging.INFO, format='%(asctime)s %(message)s') def check_website_status(url): """ Checks if a website is up by sending a GET request. """ try: response = requests.get(url) ...
import requests from unittest.mock import patch from solution import check_website_status def test_website_up(): with patch('requests.get') as mock_get: mock_get.return_value.status_code = 200 assert check_website_status('https://example.com') == True def test_website_down(): with patch('reque...
[ { "docstring": "Checks if a website is up by sending a GET request.", "function_declaration": "def check_website_status(url):", "function_name": "check_website_status", "parameter_list": "(url)" }, { "docstring": "Periodically checks if a website is up and logs the status.\n:param url: URL o...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nimport time\nimport logging\n\ndef check_website_status(url):\n \"\"\"\n Sends a GET request to the specified URL and returns True if the status code is 200.\n \"\"\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00049975", "row_id": 49975, "seed_ids": "['Qwen2.5-72B-Instruct_104277']" }
0.601885
Filter_49975
I
[ "check_website_status", "monitor_website" ]
2
[ [ "monitor_website", "check_website_status" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
219dd0f0ae06c340adcefa79e91bf0972b1b1680
14997d1e84aacc3d0dce29807d68d025135527f2
v1.0
instruct
Filter
Filter_49990_I
Can you create a simple Python script to monitor a website for changes and send an email notification when a change is detected? It should check the website every hour.
import requests import time import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from hashlib import md5 def send_email_notification(subject, body, to_email, from_email, smtp_server, smtp_port, smtp_user, smtp_password): msg = MIMEMultipart() msg['From'] = from_ema...
import pytest from requests.models import Response from solution import get_website_content, send_email_notification def test_get_website_content(monkeypatch): class MockResponse: def raise_for_status(self): pass @property def text(self): return "mock content" d...
[ { "docstring": null, "function_declaration": "def send_email_notification(subject, body, to_email, from_email, smtp_server, smtp_port, smtp_user, smtp_password):", "function_name": "send_email_notification", "parameter_list": "(subject, body, to_email, from_email, smtp_server, smtp_port, smtp_user, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\nimport requests\nimport time\nimport smtplib\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\n\ndef get_website_content(url):\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00049990", "row_id": 49990, "seed_ids": "['Qwen2.5-72B-Instruct_104308']" }
0.401649
Filter_49990
I
[ "send_email_notification", "get_website_content", "monitor_website" ]
3
[ [ "monitor_website", "get_website_content" ], [ "monitor_website", "send_email_notification" ] ]
2
[]
false
[]
false
pytest
true
[ "requests" ]
false
6627f0e2116a1ef4ddb8f8250c53861ae4a991f8
b77d69ba087319ed3e07bd054795ca4be77bca42
v1.0
instruct
Filter
Filter_50000_I
Can you write a Python script that takes a list of numbers as input and prints each number along with its square? The script should also include a function to validate if the input is a list of numbers and handle invalid inputs gracefully.
def is_list_of_numbers(input_list): """ Validates if the input is a list of numbers. Args: input_list: The input to be validated Returns: bool: True if input_list is a list of numbers, False otherwise. """ if not isinstance(input_list, list): return False return all...
from solution import is_list_of_numbers, print_numbers_and_squares def test_is_list_of_numbers_valid_case(): assert is_list_of_numbers([1, 2, 3, 4.5]) == True def test_is_list_of_numbers_invalid_case(): assert is_list_of_numbers("12345") == False assert is_list_of_numbers([1, 2, "3", 4]) == False def tes...
[ { "docstring": "Validates if the input is a list of numbers.\n\nArgs:\ninput_list: The input to be validated\n\nReturns:\nbool: True if input_list is a list of numbers, False otherwise.", "function_declaration": "def is_list_of_numbers(input_list):", "function_name": "is_list_of_numbers", "parameter...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def validate_input(input_list):\n \"\"\"\n Validates whether the input is a list of numbers.\n \n Args:\n input_list (list): The input list to validate.\n \n Returns:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050000", "row_id": 50000, "seed_ids": "['Qwen2.5-72B-Instruct_104326']" }
0.670741
Filter_50000
I
[ "is_list_of_numbers", "print_numbers_and_squares" ]
2
[ [ "print_numbers_and_squares", "is_list_of_numbers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
798da89944e15d55a5a901fc23d67684d5547419
d0e4414093c1f65e55e9235a4db3f157f34d61c5
v1.0
instruct
Filter
Filter_50011_I
Create a Python script that can generate a random quote from a predefined list of quotes. The script should also have the functionality to add new quotes to the list and save them to a file so that they persist between runs. The script should be able to load the quotes from the file when it starts. The file should be i...
import random import os QUOTE_FILE = 'quotes.txt' def load_quotes(file_path=QUOTE_FILE): """ Load quotes from a file. """ if not os.path.isfile(file_path): return [] with open(file_path, 'r') as file: quotes = [line.strip() for line in file.readlines()] return quotes def save...
import os import pytest from solution import load_quotes, save_quotes, get_random_quote, add_quote, QUOTE_FILE @pytest.fixture def setup_quotes_file(): """ Fixture to setup and cleanup a test quotes file. """ test_quotes = ["The best way to predict the future is to invent it.", "Life...
[ { "docstring": "Load quotes from a file.", "function_declaration": "def load_quotes(file_path=QUOTE_FILE):", "function_name": "load_quotes", "parameter_list": "(file_path=QUOTE_FILE)" }, { "docstring": "Save quotes to a file.", "function_declaration": "def save_quotes(quotes, file_path=Q...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport os\n\nQUOTE_FILE = 'quotes.txt'\n\nclass QuoteManager:\n def __init__(self):\n self.quotes = []\n self.load_quotes()\n\n def load_quotes(self):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050011", "row_id": 50011, "seed_ids": "['Qwen2.5-72B-Instruct_104338']" }
0.534152
Filter_50011
I
[ "load_quotes", "save_quotes", "get_random_quote", "add_quote" ]
4
[ [ "add_quote", "save_quotes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8bcb5a8832ad8eb4338da62df42cbbf9fd5fd936
c4560531190f051d677ab4ef1d64763c7fee55fa
v1.0
instruct
Filter
Filter_50022_I
Create a Python function to compute the mean of a list of numbers. Then, write a separate function that uses the first function to find the mean of two different lists of numbers and returns the list with the higher mean. Ensure your code is well-commented to explain each step.
def mean(numbers): """ Returns the mean of a list of numbers. :param numbers: list of numerical values :return: mean (average) of the numbers """ if not numbers: return 0 return sum(numbers) / len(numbers) def higher_mean_list(list1, list2): """ Returns the list that ha...
from solution import mean, higher_mean_list def test_mean(): assert mean([1, 2, 3, 4, 5]) == 3 assert mean([10, 20, 30, 40, 50]) == 30 assert mean([-1, -2, -3, -4, -5]) == -3 assert mean([1, -1, 1, -1]) == 0 assert mean([]) == 0 def test_higher_mean_list(): assert higher_mean_list([1, 2, 3], [...
[ { "docstring": "Returns the mean of a list of numbers.\n\n:param numbers: list of numerical values\n:return: mean (average) of the numbers", "function_declaration": "def mean(numbers):", "function_name": "mean", "parameter_list": "(numbers)" }, { "docstring": "Returns the list that has the h...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compute_mean(numbers):\n \"\"\"\n Computes the mean (average) of a list of numbers.\n \n Parameters:\n numbers (list): A list of numbers (int or float)\n \n Returns:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050022", "row_id": 50022, "seed_ids": "['Qwen2.5-72B-Instruct_104352']" }
0.675989
Filter_50022
I
[ "mean", "higher_mean_list" ]
2
[ [ "higher_mean_list", "mean" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d76a073a73a86c556dc8a3b805994dad4c9b157b
2db708117f7546f03701ec9dae588b0c7b1a82fd
v1.0
instruct
Filter
Filter_50029_I
You have a list of names and emails that you need to send a personalized email to. However, you also need to ensure that the emails are sent in a specific order based on the recipients' last names. How would you go about sorting the list and sending the emails in Python?
def get_last_name(name): """ Helper function to extract the last name from a full name. """ return name.split()[-1] def sort_recipients_by_last_name(recipients): """ Sorts a list of recipients by their last names in ascending order. Each recipient is represented by a dictionary with 'name' ...
from solution import sort_recipients_by_last_name, send_email, send_emails def test_get_last_name(): assert get_last_name("John Doe") == "Doe" assert get_last_name("Jane Smith") == "Smith" assert get_last_name("Alice Johnson") == "Johnson" def test_sort_recipients_by_last_name(): recipients = [ ...
[ { "docstring": "Helper function to extract the last name from a full name.", "function_declaration": "def get_last_name(name):", "function_name": "get_last_name", "parameter_list": "(name)" }, { "docstring": "Sorts a list of recipients by their last names in ascending order.\nEach recipient ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_recipients(recipients):\n \"\"\"\n Sort a list of recipients by their last names.\n\n Args:\n recipients (list of tuple): A list of tuples where each tuple contains\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050029", "row_id": 50029, "seed_ids": "['Qwen2.5-72B-Instruct_104364']" }
0.488962
Filter_50029
I
[ "get_last_name", "sort_recipients_by_last_name", "send_email", "send_emails" ]
4
[ [ "send_emails", "send_email" ], [ "send_emails", "sort_recipients_by_last_name" ], [ "sort_recipients_by_last_name", "get_last_name" ] ]
3
[]
false
[]
false
pytest
true
[]
true
d09cd4095bb96c07ffc57abe9b7e2e8cadbed21c
6b285628c315e95c024137cf8df28e9619487f08
v1.0
instruct
Filter
Filter_50055_I
How can I design a Python script to monitor the performance of a specific stock and alert me when certain conditions are met, such as a price drop or increase?
import requests def get_stock_price(stock_symbol): """ Fetch the current price of the stock using an API. """ # Note: This is a placeholder URL; you will need to replace it with a real-world API URL. api_url = f"https://financialmodelingprep.com/api/v3/quote/{stock_symbol}?apikey=your_api_key" ...
from solution import get_stock_price, check_stock_alerts class MockResponse: @staticmethod def json(): return [{'price': 120.0}] def mock_get_stock_price(stock_symbol): return MockResponse().json()[0]['price'] def test_get_stock_price(monkeypatch): def mock_requests_get(url): return M...
[ { "docstring": "Fetch the current price of the stock using an API.", "function_declaration": "def get_stock_price(stock_symbol):", "function_name": "get_stock_price", "parameter_list": "(stock_symbol)" }, { "docstring": "Check stock price and return alerts based on given conditions.\n\nParam...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nimport smtplib\nfrom email.mime.text import MIMEText\n\ndef get_stock_price(symbol):\n \"\"\"\n Fetch the current stock price for the provided symbol from a financial AP...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050055", "row_id": 50055, "seed_ids": "['Qwen2.5-72B-Instruct_104406']" }
0.471296
Filter_50055
I
[ "get_stock_price", "check_stock_alerts" ]
2
[ [ "check_stock_alerts", "get_stock_price" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
80e84de771a505ece3a802bbea815942ac3f56e0
284bbefcdcce2d67321cc221d9001531df425e1e
v1.0
instruct
Filter
Filter_50085_I
Can you help me with a Python script to convert CSV files to JSON format? I have several CSV files, and I want to convert each one of them to a corresponding JSON file.
import csv import json import os def csv_to_json(csv_file_path, json_file_path): """ Converts a CSV file to a JSON file. :param csv_file_path: Path to the input CSV file :param json_file_path: Path to the output JSON file """ data = [] with open(csv_file_path, mode='r', encoding='...
import os import json import csv from solution import csv_to_json, convert_all_csv_to_json def test_csv_to_json(): csv_data = [ {"Name": "John", "Age": "30", "City": "New York"}, {"Name": "Anna", "Age": "22", "City": "London"}, {"Name": "Mike", "Age": "32", "City": "San Francisco"} ] ...
[ { "docstring": "Converts a CSV file to a JSON file.\n\n:param csv_file_path: Path to the input CSV file\n:param json_file_path: Path to the output JSON file", "function_declaration": "def csv_to_json(csv_file_path, json_file_path):", "function_name": "csv_to_json", "parameter_list": "(csv_file_path,...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport json\nimport os\n\ndef csv_to_json(csv_file_path, json_file_path):\n \"\"\"\n Converts a CSV file to a JSON file.\n \n Parameters:\n csv_file_path (str): The ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050085", "row_id": 50085, "seed_ids": "['Qwen2.5-72B-Instruct_104462']" }
0.732092
Filter_50085
I
[ "csv_to_json", "convert_all_csv_to_json" ]
2
[ [ "convert_all_csv_to_json", "csv_to_json" ] ]
1
[]
false
[]
false
pytest
true
[]
true
29ca4db1836e4d4b9e4d07ecb8f61788183104db
399eed0de54500909a497bbb4a5f148cb3717dbf
v1.0
instruct
Filter
Filter_50086_I
Write a Python program to convert Celsius to Fahrenheit and vice versa. The program should prompt the user to select the conversion type (Celsius to Fahrenheit or Fahrenheit to Celsius) and then input the temperature. It should then display the converted temperature.
def celsius_to_fahrenheit(celsius): """ Convert Celsius to Fahrenheit. """ return (celsius * 9/5) + 32 def fahrenheit_to_celsius(fahrenheit): """ Convert Fahrenheit to Celsius. """ return (fahrenheit - 32) * 5/9 def convert_temperature(conversion_type, temperature): """ Convert...
from solution import celsius_to_fahrenheit, fahrenheit_to_celsius, convert_temperature def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsiu...
[ { "docstring": "Convert Celsius to Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Convert Fahrenheit to Celsius.", "function_declaration": "def fahrenheit_to_celsius(f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Convert Celsius to Fahrenheit.\n \"\"\"\n return (celsius * 9/5) + 32\n\ndef fahrenheit_to_celsius(fahrenheit):\n \"\"\"\n Conv...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050086", "row_id": 50086, "seed_ids": "['Qwen2.5-72B-Instruct_104463']" }
0.444024
Filter_50086
I
[ "celsius_to_fahrenheit", "fahrenheit_to_celsius", "convert_temperature" ]
3
[ [ "convert_temperature", "celsius_to_fahrenheit" ], [ "convert_temperature", "fahrenheit_to_celsius" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b468b166d86ded8a648682e2149003d293082e3f
5056191c8f2a9f8aa9255fd450e7232215b9429d
v1.0
instruct
Filter
Filter_50090_I
Can you write a Python script that takes a number as an input and checks if it is a prime number? If the number is prime, the script should print "The number is prime." If the number is not prime, it should print "The number is not prime." The script should be efficient and handle edge cases, such as when the input is ...
def is_prime(n): """ Returns True if the number is prime, else False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i...
from solution import is_prime, check_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(17) == True assert is_prime(19) == True assert is_prime(20) == False ...
[ { "docstring": "Returns True if the number is prime, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Checks if a given number n is prime and prints a corresponding message.", "function_declaration": "def ch...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if the number is prime, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050090", "row_id": 50090, "seed_ids": "['Qwen2.5-72B-Instruct_104468']" }
0.768125
Filter_50090
I
[ "is_prime", "check_prime" ]
2
[ [ "check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8f88d776f42feeea7807a673e64128b199530c5e
6d338d8d5ccdf168189a4c69d554446ce48ea47b
v1.0
instruct
Filter
Filter_50094_I
How can I create a Python function to generate a list of all prime numbers between 1 and a given number `n`? I want to use this function to help with some cryptography tasks where prime numbers are often needed.
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True ...
from solution import generate_primes, is_prime def test_is_prime(): assert is_prime(1) == False assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(15) == False def test_generate_primes_below_10(): assert generate_pr...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a list of all prime numbers between 1 and the given number n.\n\nParameters:\nn (int): The up...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_primes(n):\n \"\"\"\n Generates a list of all prime numbers between 1 and n (inclusive).\n\n :param n: The upper limit of the range to generate prime numbers.\n :retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050094", "row_id": 50094, "seed_ids": "['Qwen2.5-72B-Instruct_104476']" }
0.629471
Filter_50094
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0bea0cf1dd329c507617a1ecf84a4ae74444b0eb
bbcd11a90b0de4ef0cc40d78ec2177117471e8d1
v1.0
instruct
Filter
Filter_50136_I
How can I automate the process of sending emails in Python, especially if I need to send personalized emails to a large list of recipients?
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import pandas as pd def send_email(smtp_server, port, sender_email, sender_password, recipient_email, subject, body): """ Sends an email using SMTP. :param smtp_server: SMTP server address :param port: P...
import pytest from unittest.mock import patch, MagicMock from solution import send_email, send_bulk_emails def test_send_email(): with patch('smtplib.SMTP') as mock_smtp: mock_server = MagicMock() mock_smtp.return_value = mock_server send_email('smtp.example.com', 587, 'sender@example.com'...
[ { "docstring": "Sends an email using SMTP.\n\n:param smtp_server: SMTP server address\n:param port: Port number for the SMTP server\n:param sender_email: Sender's email address\n:param sender_password: Sender's email password\n:param recipient_email: Recipient's email address\n:param subject: Subject of the ema...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import smtplib\nfrom email.mime.multipart import MIMEMultipart\nfrom email.mime.text import MIMEText\nimport csv\n\ndef send_personalized_emails(smtp_server, port, login, password, subject, bo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050136", "row_id": 50136, "seed_ids": "['Qwen2.5-72B-Instruct_104544']" }
0.581963
Filter_50136
I
[ "send_email", "send_bulk_emails" ]
2
[ [ "send_bulk_emails", "send_email" ] ]
1
[]
false
[]
false
pytest
true
[ "pandas" ]
false
855b187ddba59d34da8cce298fb0580b64ad941a
83b2f3060e44aaf1e560160dfb4c01808a512f0e
v1.0
instruct
Filter
Filter_50139_I
How can I implement a chatbot using Python and Flask that can answer simple math questions? I'm looking for a basic framework to get started.
from flask import Flask, request, jsonify import re app = Flask(__name__) def parse_math_question(question): """ Parses a simple math question and returns the result. For simplicity, it will support only addition, subtraction, multiplication, and division of two numbers. """ question = questio...
import pytest from solution import parse_math_question def test_addition(): assert parse_math_question("What is 3 plus 4?") == 7 def test_subtraction(): assert parse_math_question("What is 10 minus 6?") == 4 def test_multiplication(): assert parse_math_question("What is 7 times 5?") == 35 def test_divis...
[ { "docstring": "Parses a simple math question and returns the result.\nFor simplicity, it will support only addition, subtraction,\nmultiplication, and division of two numbers.", "function_declaration": "def parse_math_question(question):", "function_name": "parse_math_question", "parameter_list": "...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, jsonify\nimport re\n\napp = Flask(__name__)\n\ndef evaluate_expression(expression):\n \"\"\"\n Evaluates a simple mathematical expression.\n Supports...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050139", "row_id": 50139, "seed_ids": "['Qwen2.5-72B-Instruct_104550']" }
0.340177
Filter_50139
I
[ "parse_math_question", "chat" ]
2
[ [ "chat", "parse_math_question" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
a126ecf0656f7942e51505779252872d2db61043
4d43018a9d7fc7a9bff75b4d024bcf03cbc73633
v1.0
instruct
Filter
Filter_50150_I
You are tasked with creating a Python function that takes a list of integers as input and returns a new list containing only the prime numbers found in the input list. Additionally, the function should also sort the resulting list of prime numbers in ascending order. If the input list does not contain any prime numbers...
def is_prime(n): """ Check if a given number n is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def primes_in_list(num...
from solution import primes_in_list def test_primes_in_list_with_primes(): assert primes_in_list([11, 3, 5, 7, 2]) == [2, 3, 5, 7, 11] def test_primes_in_list_with_mixed_numbers(): assert primes_in_list([10, 15, 3, 4, 5]) == [3, 5] def test_primes_in_list_with_no_primes(): assert primes_in_list([10, 15, ...
[ { "docstring": "Check if a given number n is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, returns a new sorted list containing only the prime numbers.", "function_declaration": "de...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050150", "row_id": 50150, "seed_ids": "['Qwen2.5-72B-Instruct_104564']" }
0.613579
Filter_50150
I
[ "is_prime", "primes_in_list" ]
2
[ [ "primes_in_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3ed92816c026b4fa5467c7c4d1240adccb0046c9
0a0e1e064fcf9491d5c619228390e9173bf0516c
v1.0
instruct
Filter
Filter_50172_I
Create a Python script that reads a CSV file containing a single column of email addresses and checks if each email is valid. A valid email should have a proper format and exist in a real domain (you can use a list of common domain names for this check, for example: ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.co...
import csv import re COMMON_DOMAINS = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com'] def is_valid_email(email): """ Check if the given email is valid. A valid email should have a proper format and exist in a common domain. """ email_regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2...
import pytest from solution import is_valid_email, process_emails def test_is_valid_email(): assert is_valid_email('test@gmail.com') == True assert is_valid_email('test@yahoo.com') == True assert is_valid_email('test@hotmail.com') == True assert is_valid_email('test@outlook.com') == True assert is_...
[ { "docstring": "Check if the given email is valid.\nA valid email should have a proper format and exist in a common domain.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Reads emails from 'input_csv',...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport re\n\ndef read_emails_from_csv(file_path):\n \"\"\"\n Reads email addresses from a CSV file.\n\n Parameters:\n - file_path (str): Path to the CSV file.\n\n Re...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050172", "row_id": 50172, "seed_ids": "['Qwen2.5-72B-Instruct_104597']" }
0.593042
Filter_50172
I
[ "is_valid_email", "process_emails" ]
2
[ [ "process_emails", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f2efddc27aef34ac90a4435d5644dfdc06ffcfd0
04beb160171bb664dbb27a7413d0943538852e54
v1.0
instruct
Filter
Filter_50190_I
Create a Python function that calculates the sum of the squares of the first `n` even natural numbers. Additionally, ensure that the function validates the input to check if it is a positive integer. If the input is not a positive integer, the function should raise a `ValueError`. Include a brief docstring that describ...
def sum_of_squares_of_first_n_even(n): """ Calculates the sum of the squares of the first n even natural numbers. Parameters: n (int): The number of first even natural numbers to consider. Returns: int: The sum of squares of the first n even natural numbers. Raises: ValueE...
import pytest from solution import sum_of_squares_of_first_n_even, check_solution_with_first_5 def test_sum_of_squares_valid_input(): assert sum_of_squares_of_first_n_even(1) == 4 assert sum_of_squares_of_first_n_even(2) == 20 assert sum_of_squares_of_first_n_even(3) == 56 assert sum_of_squares_of_firs...
[ { "docstring": "Calculates the sum of the squares of the first n even natural numbers.\n\nParameters:\nn (int): The number of first even natural numbers to consider.\n\nReturns:\nint: The sum of squares of the first n even natural numbers.\n\nRaises:\nValueError: If n is not a positive integer.", "function_...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_squares_of_even_numbers(n):\n \"\"\"\n Calculates the sum of the squares of the first `n` even natural numbers.\n \n Parameters:\n n (int): The number of even natural...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050190", "row_id": 50190, "seed_ids": "['Qwen2.5-72B-Instruct_104630']" }
0.817544
Filter_50190
I
[ "sum_of_squares_of_first_n_even", "check_solution_with_first_5" ]
2
[ [ "check_solution_with_first_5", "sum_of_squares_of_first_n_even" ] ]
1
[]
false
[]
false
pytest
true
[]
true
74b867333555944773a2e72e5ac6dc2a3a320f50
06016398b877767b624f63589209e5d5ca2c5649
v1.0
instruct
Filter
Filter_50194_I
Can you help me understand how to use the function `map()` in Python for applying a function to each item in an iterable? I'm also curious to see how it can be used in a practical scenario, like transforming a list of temperatures from Celsius to Fahrenheit.
def celsius_to_fahrenheit(celsius): """ Converts Celsius to Fahrenheit. """ return (celsius * 9/5) + 32 def convert_temperatures(celsius_list): """ Converts a list of temperatures from Celsius to Fahrenheit using map(). """ return list(map(celsius_to_fahrenheit, celsius_list))
from solution import celsius_to_fahrenheit, convert_temperatures def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 assert celsius_to_fahrenheit(30) == 86 assert celsius_to_fahrenheit(37) == 98.6 ...
[ { "docstring": "Converts Celsius to Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Converts a list of temperatures from Celsius to Fahrenheit using map().", "function_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts Celsius to Fahrenheit.\n \"\"\"\n return (celsius * 9/5) + 32\n\ndef convert_temperature_list(temps):\n \"\"\"\n Conve...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050194", "row_id": 50194, "seed_ids": "['Qwen2.5-72B-Instruct_104636']" }
0.393758
Filter_50194
I
[ "celsius_to_fahrenheit", "convert_temperatures" ]
2
[ [ "convert_temperatures", "celsius_to_fahrenheit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9e0677808bc90fd40a01c19410f0e03f53ac2155
85ec5164e1e75009cb201d446f51ed1b143757c4
v1.0
instruct
Filter
Filter_50206_I
Write a Python function that generates a list of prime numbers up to a given limit and then filters this list to return only the numbers that contain the digit 5. Use a generator for prime number generation to efficiently handle large limits.
import itertools def is_prime(n): """ Checks if a number is a prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i...
from solution import primes_with_digit_5 def test_primes_with_digit_5_small_limit(): assert primes_with_digit_5(10) == [5] def test_primes_with_digit_5_medium_limit(): assert primes_with_digit_5(50) == [5] def test_primes_with_digit_5_large_limit(): result = primes_with_digit_5(100) assert 5 in resul...
[ { "docstring": "Checks if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates prime numbers up to a given limit.", "function_declaration": "def prime_generator(limit):", "function_name": ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef is_prime(n):\n \"\"\"\n Checks if a number is a prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 o...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050206", "row_id": 50206, "seed_ids": "['Qwen2.5-72B-Instruct_104654']" }
0.575233
Filter_50206
I
[ "is_prime", "prime_generator", "primes_with_digit_5" ]
3
[ [ "prime_generator", "is_prime" ], [ "primes_with_digit_5", "prime_generator" ] ]
2
[]
false
[]
false
pytest
true
[]
true
93fbc7ccf18187adb79e1f5f710438717ba67340
a17aaa7337cfada6dfe032a8ca42598bd148804a
v1.0
instruct
Filter
Filter_50209_I
Create a simple Python program that generates random math problems for kids. The program should include addition, subtraction, and multiplication problems with numbers between 1 and 10. The program should generate 10 problems and display them to the user. After the user answers, the program should tell the user if the ...
import random def generate_math_problem(): """ Generates a random math problem involving addition, subtraction, or multiplication with numbers between 1 and 10 and returns the problem and the correct answer. """ operators = ['+', '-', '*'] num1 = random.randint(1, 10) num2 = random.randint(...
from solution import generate_math_problem, generate_problems def test_generate_math_problem(): problem, answer = generate_math_problem() parts = problem.split() num1, operator, num2 = int(parts[0]), parts[1], int(parts[2]) if operator == '+': assert answer == num1 + num2 elif operator == '...
[ { "docstring": "Generates a random math problem involving addition, subtraction, or multiplication\nwith numbers between 1 and 10 and returns the problem and the correct answer.", "function_declaration": "def generate_math_problem():", "function_name": "generate_math_problem", "parameter_list": "()"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_problem():\n operations = ['+', '-', '*']\n num1 = random.randint(1, 10)\n num2 = random.randint(1, 10)\n operation = random.choice(operations)\n p...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050209", "row_id": 50209, "seed_ids": "['Qwen2.5-72B-Instruct_104659']" }
0.515248
Filter_50209
I
[ "generate_math_problem", "generate_problems", "main" ]
3
[ [ "generate_problems", "generate_math_problem" ] ]
1
[]
false
[]
false
pytest
true
[]
true
59409587d4e5340cce5b08357f1b5bafb71a97ed
36addce5be3e5a8b0bb8555fe2b6429f9f5e8700
v1.0
instruct
Filter
Filter_50218_I
Design a Python program that reads in a text file containing words and their frequencies, and then outputs the top 10 most frequent words along with their frequencies. The text file is formatted with one word per line followed by a space and then its frequency (e.g., "apple 15"). The program should handle cases where w...
def read_word_frequencies(file_path): """ Reads a text file and returns a list of (word, frequency) tuples. :param file_path: The path to the input text file. :return: A list of (word, frequency) tuples. """ word_freq = [] with open(file_path, 'r') as file: for line in file: ...
import pytest from solution import read_word_frequencies, get_top_10_frequent_words, get_top_10_words_from_file def test_read_word_frequencies(tmp_path): file_content = "apple 15\nbanana 10\ncherry 20\n" file_path = tmp_path / "testfile.txt" file_path.write_text(file_content) expected_output = [("...
[ { "docstring": "Reads a text file and returns a list of (word, frequency) tuples.\n\n:param file_path: The path to the input text file.\n:return: A list of (word, frequency) tuples.", "function_declaration": "def read_word_frequencies(file_path):", "function_name": "read_word_frequencies", "paramete...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def read_word_frequencies(file_path):\n \"\"\"\n Reads a text file and returns a list of (word, frequency) tuples.\n \n :param file_path: The path to the input text file.\n :ret...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050218", "row_id": 50218, "seed_ids": "['Qwen2.5-72B-Instruct_104672']" }
0.754967
Filter_50218
I
[ "read_word_frequencies", "get_top_10_frequent_words", "get_top_10_words_from_file" ]
3
[ [ "get_top_10_words_from_file", "get_top_10_frequent_words" ], [ "get_top_10_words_from_file", "read_word_frequencies" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1857dc4342ca031343f518acd983b0a827cd3a44
facffc873eff5c7e042221437f3aea4b95ffc07c
v1.0
instruct
Filter
Filter_50233_I
Create a Python function that simulates the rolling of a fair six-sided die. The function should return the result of the roll. Additionally, implement a second function that simulates rolling this die multiple times and returns a list of the outcomes. Use the `random` module for generating random numbers. Ensure you s...
import random def roll_die(): """ Simulates the rolling of a fair six-sided die and returns the result. """ return random.randint(1, 6) def roll_die_multiple_times(n, seed_value=0): """ Simulates rolling a fair six-sided die multiple times. Parameters: n (int): Number of times to roll...
import random from solution import roll_die, roll_die_multiple_times def test_roll_die_range(): outcomes = set(roll_die() for _ in range(100)) for i in range(1, 7): assert i in outcomes def test_roll_die_multiple_times_length(): outcomes = roll_die_multiple_times(10, seed_value=42) assert len(...
[ { "docstring": "Simulates the rolling of a fair six-sided die and returns the result.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Simulates rolling a fair six-sided die multiple times.\n\nParameters:\nn (int): Number of ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_die():\n \"\"\"\n Simulates the rolling of a fair six-sided die.\n Returns:\n An integer between 1 and 6, inclusive.\n \"\"\"\n return random.ra...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050233", "row_id": 50233, "seed_ids": "['Qwen2.5-72B-Instruct_104699']" }
0.621454
Filter_50233
I
[ "roll_die", "roll_die_multiple_times" ]
2
[ [ "roll_die_multiple_times", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ef86f3348f402eabc4d9a6f6ec29f0af6347fe3
1b1f14a4f4894c1c01a91a05aa4251e16a100002
v1.0
instruct
Filter
Filter_50235_I
I'm trying to understand how to implement a neural network from scratch using Python. Can you walk me through the basic steps and provide some code examples? I want to start with a simple feedforward neural network.
import numpy as np def sigmoid(x): """ Sigmoid activation function. """ return 1 / (1 + np.exp(-x)) def sigmoid_derivative(x): """ Derivative of the sigmoid function. """ return sigmoid(x) * (1 - sigmoid(x)) class SimpleNeuralNetwork: def __init__(self, input_size, hidden_size, ou...
import numpy as np from solution import SimpleNeuralNetwork def test_forward_propagation(): np.random.seed(42) nn = SimpleNeuralNetwork(input_size=2, hidden_size=2, output_size=1) X = np.array([[1, 2], [3, 4]]) output = nn.forward(X) assert output.shape == (2, 1) def test_backward_propagation(): ...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef sigmoid(x):\n \"\"\"\n Sigmoid activation function.\n \"\"\"\n return 1 / (1 + np.exp(-x))\n\ndef sigmoid_derivative(x):\n \"\"\"\n Derivative of th...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050235", "row_id": 50235, "seed_ids": "['Qwen2.5-72B-Instruct_104701']" }
0.313461
Filter_50235
I
[ "sigmoid", "sigmoid_derivative" ]
2
[ [ "sigmoid_derivative", "sigmoid" ] ]
1
[]
false
[ "SimpleNeuralNetwork" ]
true
pytest
true
[ "numpy" ]
false
430ae9b1932968e742f1c285f4c87a0a0c6d1349
835e8d71f215c466813f854af28df619e21b65fa
v1.0
instruct
Filter
Filter_50239_I
Write a Python program that generates a list of all prime numbers up to a given number n, and then calculates the sum of all these prime numbers. The program should also include a function to verify if a number is prime. Use efficient algorithms for both generating the list of primes and verifying if a number is prime....
def is_prime(number): """ Check if a number is a prime number. """ if number <= 1: return False if number <= 3: return True if number % 2 == 0 or number % 3 == 0: return False i = 5 while i * i <= number: if number % i == 0 or number % (i + 2) == 0: ...
from solution import is_prime, generate_primes_up_to, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(13) == True assert is_prime(1) == False asse...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { "docstring": "Generate a list of all prime numbers up to and including n.", "function_declaration": "def generate_primes_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050239", "row_id": 50239, "seed_ids": "['Qwen2.5-72B-Instruct_104706']" }
0.6917
Filter_50239
I
[ "is_prime", "generate_primes_up_to", "sum_of_primes" ]
3
[ [ "generate_primes_up_to", "is_prime" ], [ "sum_of_primes", "generate_primes_up_to" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c4f97855bd8d2f511d311629473b22180c92a12e
d801a4e89ff550a16a02f9354ffdb26c9e23f294
v1.0
instruct
Filter
Filter_50286_I
Write a Python script that calculates the sum of all prime numbers less than a given number n, and also the sum of all Fibonacci numbers less than n. The script should print both sums. Use functions to separate the prime number calculation, Fibonacci number generation, and the summation logic. Make sure to handle edge ...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def sum_of_primes(n): """ Returns the sum of all prime numbers less than n. """ return sum...
from solution import is_prime, sum_of_primes, generate_fibonacci, sum_of_fibonacci, calculate_sums def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(1) assert not is_prime(0) assert not is_prime(4) assert is_prime(5) def test_sum_of_primes(): assert sum_of_prim...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers less than n.", "function_declaration": "def sum_of_primes(n):", "function_name": ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050286", "row_id": 50286, "seed_ids": "['Qwen2.5-72B-Instruct_104780']" }
0.650136
Filter_50286
I
[ "is_prime", "sum_of_primes", "generate_fibonacci", "sum_of_fibonacci", "calculate_sums" ]
5
[ [ "calculate_sums", "sum_of_fibonacci" ], [ "calculate_sums", "sum_of_primes" ], [ "sum_of_fibonacci", "generate_fibonacci" ], [ "sum_of_primes", "is_prime" ] ]
4
[]
false
[]
false
pytest
true
[]
true
43105abb1fe8a0c625118b3337be4acd3e33f1c9
71893ac81ce62d5ca69b35a7a5a6880fcd8535f2
v1.0
instruct
Filter
Filter_50289_I
Create a Python function named `reverse_integer` that takes an integer as input and returns its reverse. For example, if the input is 1234, the function should return 4321. The function should handle negative numbers as well, so if the input is -123, the output should be -321. Ensure to import any necessary packages an...
def reverse_integer(n): """ Reverse the digits of the input integer. Handles both positive and negative numbers. """ # Check if the number is negative sign = -1 if n < 0 else 1 # Reverse the digits and apply the sign reversed_number = sign * int(str(abs(n))[::-1]) return reversed_num...
def test_reverse_integer(): from solution import reverse_integer assert reverse_integer(1234) == 4321 assert reverse_integer(-123) == -321 assert reverse_integer(0) == 0 assert reverse_integer(100) == 1 assert reverse_integer(-100) == -1 assert reverse_integer(1) == 1 assert reverse...
[ { "docstring": "Reverse the digits of the input integer.\nHandles both positive and negative numbers.", "function_declaration": "def reverse_integer(n):", "function_name": "reverse_integer", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def verify_solution():",...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def reverse_integer(n):\n \"\"\"\n Returns the reverse of the given integer n.\n Handles negative numbers as well.\n \"\"\"\n sign = -1 if n < 0 else 1\n reversed_number = in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050289", "row_id": 50289, "seed_ids": "['Qwen2.5-72B-Instruct_104787']" }
0.69548
Filter_50289
I
[ "reverse_integer", "verify_solution" ]
2
[ [ "verify_solution", "reverse_integer" ] ]
1
[]
false
[]
false
pytest
true
[]
true
36255d969319e228312610f8d68834ff25009041
d2d0e9677d11ecb6d25cd610d68f29fedd8e045e
v1.0
instruct
Filter
Filter_50293_I
Write a program that sorts an array of integers in ascending order using the Bubble Sort algorithm. Make sure to include a function to display the sorted array.
def bubble_sort(arr): """ Sorts an array of integers in ascending order using the Bubble Sort algorithm. Parameters: arr (list): A list of integers to be sorted. Returns: list: The sorted list of integers. """ n = len(arr) for i in range(n): for j in range(0, n-i-1)...
from solution import bubble_sort, display_sorted_array def test_bubble_sort_all_positive(): assert bubble_sort([64, 34, 25, 12, 22, 11, 90]) == [11, 12, 22, 25, 34, 64, 90] def test_bubble_sort_including_negative(): assert bubble_sort([-1, 64, 34, -25, 12, 22, 11, 90, -100]) == [-100, -25, -1, 11, 12, 22, 34,...
[ { "docstring": "Sorts an array of integers in ascending order using the Bubble Sort algorithm.\n\nParameters:\narr (list): A list of integers to be sorted.\n\nReturns:\nlist: The sorted list of integers.", "function_declaration": "def bubble_sort(arr):", "function_name": "bubble_sort", "parameter_li...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bubble_sort(arr):\n \"\"\"\n Sorts an array of integers in ascending order using the Bubble Sort algorithm.\n \n :param arr: List of integers to be sorted.\n :return: List o...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050293", "row_id": 50293, "seed_ids": "['Qwen2.5-72B-Instruct_104792']" }
0.54757
Filter_50293
I
[ "bubble_sort", "display_sorted_array" ]
2
[ [ "display_sorted_array", "bubble_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
53d24b16eb25e6046bff34320b76c82e3d4b7846
dab955a190b660754cc2a34096b894625189ce5f
v1.0
instruct
Filter
Filter_50338_I
How can I create a simple Python script to monitor the battery level of a laptop and send an email alert when the battery level is below a certain threshold?
import psutil import smtplib from email.mime.text import MIMEText def check_battery(threshold): """ Checks the battery level and returns True if it is below the given threshold. """ battery = psutil.sensors_battery() return battery.percent < threshold def send_email_alert(to_email, subject, messag...
from unittest.mock import patch from solution import check_battery, send_email_alert, monitor_battery def test_check_battery_below_threshold(): with patch('psutil.sensors_battery') as mock_battery: mock_battery.return_value.percent = 15 assert check_battery(20) == True def test_check_batte...
[ { "docstring": "Checks the battery level and returns True if it is below the given threshold.", "function_declaration": "def check_battery(threshold):", "function_name": "check_battery", "parameter_list": "(threshold)" }, { "docstring": "Sends an email alert.", "function_declaration": "d...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import psutil\nimport smtplib\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\n\ndef get_battery_level():\n \"\"\"\n Returns the current battery lev...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050338", "row_id": 50338, "seed_ids": "['Qwen2.5-72B-Instruct_104865']" }
0.465941
Filter_50338
I
[ "check_battery", "send_email_alert", "monitor_battery" ]
3
[ [ "monitor_battery", "check_battery" ], [ "monitor_battery", "send_email_alert" ] ]
2
[]
false
[]
false
pytest
true
[ "psutil" ]
false
98f54296efd9d9c691edb7f8ce11195c54546b7d
e59575c7885e0508426054c1e489f4e2dc6f7d11
v1.0
instruct
Filter
Filter_50339_I
Design a Python function that checks if the elements of a given list of integers are present in a specific range. The function should accept a list of integers and the range (start and end) as parameters. It should return a list of booleans indicating whether each element in the input list is within the given range (in...
def elements_in_range(int_list, start, end): """ Checks if elements of the list are within the range (inclusive). Args: int_list (list): list of integers to check. start (int): start of the range. end (int): end of the range. Returns: list: list of booleans indicating whether e...
from solution import elements_in_range, evaluate_lists # Unit tests for the elements_in_range function def test_elements_in_range_within(): assert elements_in_range([1, 5, 8], 1, 10) == [True, True, True] def test_elements_in_range_outside(): assert elements_in_range([1, 20, 8], 1, 10) == [True, False, True] ...
[ { "docstring": "Checks if elements of the list are within the range (inclusive).\n\nArgs:\nint_list (list): list of integers to check.\nstart (int): start of the range.\nend (int): end of the range.\n\nReturns:\nlist: list of booleans indicating whether each element is within the range.", "function_declarat...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_elements_in_range(elements, start, end):\n \"\"\"\n Checks if the elements of the given list are within the specified range [start, end].\n \n Args:\n elements (list o...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050339", "row_id": 50339, "seed_ids": "['Qwen2.5-72B-Instruct_104866']" }
0.61208
Filter_50339
I
[ "elements_in_range", "evaluate_lists" ]
2
[ [ "evaluate_lists", "elements_in_range" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64d17d3ff8c900fcd1bf252b4c5d0aaa84c03ce8
a64eab1ceeea734cf78297d4a123fb6c48a771a4
v1.0
instruct
Filter
Filter_50358_I
Write a program in Python that can encrypt and decrypt a message using the Caesar cipher. The program should take a message and a key (number of positions to shift each letter) as inputs and output the encrypted or decrypted message based on the user's choice. Ensure to handle both uppercase and lowercase letters and l...
def caesar_cipher(message, key, decrypt=False): """ Encrypt or decrypt a message using the Caesar cipher. :param message: The input message to be encrypted or decrypted. :param key: The number of positions to shift each letter. :param decrypt: If True, decrypt the message. If False, encrypt the...
from solution import encrypt, decrypt def test_encrypt(): assert encrypt("Hello, World!", 3) == "Khoor, Zruog!" assert encrypt("abc", 1) == "bcd" assert encrypt("ABC", 1) == "BCD" assert encrypt("xyz", 3) == "abc" assert encrypt("XYZ", 3) == "ABC" def test_decrypt(): assert decrypt("Khoor, Zru...
[ { "docstring": "Encrypt or decrypt a message using the Caesar cipher.\n\n:param message: The input message to be encrypted or decrypted.\n:param key: The number of positions to shift each letter.\n:param decrypt: If True, decrypt the message. If False, encrypt the message.\n:return: The encrypted or decrypted m...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher(message, key, encrypt=True):\n \"\"\"\n Encrypt or decrypt a message using the Caesar cipher.\n\n Parameters:\n - message: str : The message to encrypt or decrypt...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050358", "row_id": 50358, "seed_ids": "['Qwen2.5-72B-Instruct_104898']" }
0.687791
Filter_50358
I
[ "caesar_cipher", "encrypt", "decrypt" ]
3
[ [ "decrypt", "caesar_cipher" ], [ "encrypt", "caesar_cipher" ] ]
2
[]
false
[]
false
pytest
true
[]
true
af3304e0aa8eacb161c9136115b706cf1e70c9e6
57db13eddf541fdb7d33b4691ce7f8e4ec25da42
v1.0
instruct
Filter
Filter_50363_I
Write a Python function to solve a Sudoku puzzle. The function should take a 9x9 grid as input, where empty cells are represented by 0, and return the solved grid. Ensure the solution is valid and follows the Sudoku rules.
def is_valid(board, row, col, num): # Check the row for x in range(9): if board[row][x] == num: return False # Check the column for x in range(9): if board[x][col] == num: return False # Check the 3x3 subgrid startRow = row - row % 3 startCol = col -...
from solution import solve_sudoku, is_valid def test_sudoku_solver_simple(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], ...
[ { "docstring": null, "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": null, "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_list...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solve_sudoku(board):\n \"\"\"\n Solves the given Sudoku puzzle in place.\n :param board: List[List[int]]\n :return: Bool indicating whether the solution is found or not.\n \...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050363", "row_id": 50363, "seed_ids": "['Qwen2.5-72B-Instruct_104907']" }
0.456494
Filter_50363
I
[ "is_valid", "solve_sudoku", "find_empty_location" ]
3
[ [ "solve_sudoku", "find_empty_location" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5a6312593f03c82df904506dcf91bf6e9dcedcdf
f50a055114a6606a81990756470c9f5e90859758
v1.0
instruct
Filter
Filter_50370_I
Can you help me with a Python script that automates the process of checking if a website is up and running? I want to be able to specify the URL of the website and get a simple output indicating whether the site is accessible or not. It would be great if the script could also log the status and the time of the check.
import requests import datetime def check_website_status(url): """ Checks if the website at the specified URL is up and running. Parameters: - url: str, the URL of the website to check. Returns: - str, "Website is up" if the website is accessible, "Website is down" otherwis...
from solution import check_website_status, log_status def test_check_website_status_up(monkeypatch): class MockResponse: def __init__(self, status_code): self.status_code = status_code def mock_get(url): return MockResponse(200) monkeypatch.setattr('requests.get', mock...
[ { "docstring": "Checks if the website at the specified URL is up and running.\n\nParameters:\n- url: str, the URL of the website to check.\n\nReturns:\n- str, \"Website is up\" if the website is accessible,\n \"Website is down\" otherwise.", "function_declaration": "def check_website_status(url):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nimport logging\nfrom datetime import datetime\n\ndef check_website_status(url):\n \"\"\"\n Check if a website is accessible and log the status with time.\n\n Paramete...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050370", "row_id": 50370, "seed_ids": "['Qwen2.5-72B-Instruct_104916']" }
0.576181
Filter_50370
I
[ "check_website_status", "log_status" ]
2
[ [ "check_website_status", "log_status" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
6c93aff25fcfcfe1894e0da97984c98d74782c53
3d15233df1523af6cb36b90932b131c593a35c57
v1.0
instruct
Filter
Filter_50376_I
Create a Python program that performs basic arithmetic operations (addition, subtraction, multiplication, and division) using functions. The program should take two numbers as input from the user and then ask which operation they want to perform. After performing the operation, the program should display the result. Ma...
def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a * b def divide(a, b): if b == 0: return "Error! Division by zero." return a / b def perform_operation(a, b, operation): if operation == 'add': return add(a, b) elif operation == 'sub...
from solution import add, subtract, multiply, divide, perform_operation def test_add(): assert add(2, 3) == 5 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(3, 2) == 1 assert subtract(-1, -1) == 0 assert subtract(0, 3) == -3 def test_multiply(): assert m...
[ { "docstring": null, "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def subtract(a, b):", "function_name": "subtract", "parameter_list": "(a, b)" }, { "docstring": null, "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n \"\"\"\n Returns the sum of a and b.\n \"\"\"\n return a + b\n\ndef subtract(a, b):\n \"\"\"\n Returns the difference of a and b.\n \"\"\"\n return a -...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050376", "row_id": 50376, "seed_ids": "['Qwen2.5-72B-Instruct_104926']" }
0.5931
Filter_50376
I
[ "add", "subtract", "multiply", "divide", "perform_operation" ]
5
[ [ "perform_operation", "add" ], [ "perform_operation", "divide" ], [ "perform_operation", "multiply" ], [ "perform_operation", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
c2562266b3546c21d884fdb32613ad59de116ff6
98a1a51426f2776b0037d3f0bbb257515ff44669
v1.0
instruct
Filter
Filter_50400_I
How can I use Python to automate the process of checking if a website is up and running? I want to create a simple script that periodically checks a website and logs the status.
import requests import time from datetime import datetime def check_website_status(url, check_interval=60): """ Checks if the website is up and running periodically and logs the status. Parameters: url (str): The URL of the website to check. check_interval (int): The interval (in seconds) between ...
import os import requests from unittest.mock import patch from solution import check_website_status, log_status def test_log_status(): # Remove log file if exists if os.path.exists("website_status_log.txt"): os.remove("website_status_log.txt") timestamp = "2023-01-01 00:00:00" url = "h...
[ { "docstring": "Checks if the website is up and running periodically and logs the status.\n\nParameters:\nurl (str): The URL of the website to check.\ncheck_interval (int): The interval (in seconds) between checks.\n\nReturns:\nNone", "function_declaration": "def check_website_status(url, check_interval=60)...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nimport time\nfrom datetime import datetime\n\ndef check_website_status(url, check_interval=60):\n \"\"\"\n Checks if the website is up and running periodically and logs ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050400", "row_id": 50400, "seed_ids": "['Qwen2.5-72B-Instruct_104965']" }
0.584081
Filter_50400
I
[ "check_website_status", "log_status" ]
2
[ [ "check_website_status", "log_status" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
47227424aba30d1a69753d7f2374d20afb9229f6
51e47f8639fa7c4a9087dfb83b30d6060969b6f4
v1.0
instruct
Filter
Filter_50403_I
Explain the concept of dynamic scoping in programming and provide an example to illustrate how it differs from lexical scoping.
call_stack = [] def dynamic_lookup(name): """ Simulates dynamic scoping by looking up the call stack for the most recent binding of a variable. """ for scope in reversed(call_stack): if name in scope: return scope[name] raise NameError(f"Variable {name} not found") def outer():...
from solution import outer, another_outer def test_outer(): assert outer() == 10 def test_another_outer(): assert another_outer() == 20
[ { "docstring": "Simulates dynamic scoping by looking up the call stack for the most recent binding of a variable.", "function_declaration": "def dynamic_lookup(name):", "function_name": "dynamic_lookup", "parameter_list": "(name)" }, { "docstring": null, "function_declaration": "def oute...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class DyScope:\n _dynamic_scope = {}\n\n @staticmethod\n def set_var(name, value):\n DyScope._dynamic_scope[name] = value\n\n @staticmethod\n def get_var(name):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050403", "row_id": 50403, "seed_ids": "['Qwen2.5-72B-Instruct_104970']" }
0.296484
Filter_50403
I
[ "dynamic_lookup", "outer", "inner", "another_outer" ]
4
[ [ "another_outer", "inner" ], [ "inner", "dynamic_lookup" ], [ "outer", "inner" ] ]
3
[]
false
[]
false
pytest
true
[]
true
42851eb64029d398d96b2b4701cd3087b385d090
bdf5d4d6030b0fee1c109a9e5fd7ccdd78947439
v1.0
instruct
Filter
Filter_50409_I
Write a Python program that can parse a given XML string and convert it into a JSON object. The program should handle attributes and nested elements properly. Additionally, include a function to validate the input XML string to ensure it is well-formed. If the input is not a valid XML, the program should raise an appro...
import xml.etree.ElementTree as ET import json def validate_xml(xml_string): """ Validate if the provided XML string is well-formed. Raises an ET.ParseError if the XML is not well-formed. """ try: ET.fromstring(xml_string) except ET.ParseError as e: raise ValueError("Provided XM...
import pytest from solution import xml_to_json, validate_xml def test_validate_xml_well_formed(): valid_xml = "<root><child>content</child></root>" try: validate_xml(valid_xml) except ValueError: pytest.fail("validate_xml raised ValueError unexpectedly!") def test_validate_xml_not_well_for...
[ { "docstring": "Validate if the provided XML string is well-formed.\nRaises an ET.ParseError if the XML is not well-formed.", "function_declaration": "def validate_xml(xml_string):", "function_name": "validate_xml", "parameter_list": "(xml_string)" }, { "docstring": "Parse the given XML stri...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import xml.etree.ElementTree as ET\nimport json\n\ndef validate_xml(xml_string):\n \"\"\"\n Validate if the provided XML string is well-formed.\n Raises an ET.ParseError if the XML is...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050409", "row_id": 50409, "seed_ids": "['Qwen2.5-72B-Instruct_104980']" }
0.750281
Filter_50409
I
[ "validate_xml", "xml_to_json", "element_to_json" ]
3
[ [ "xml_to_json", "element_to_json" ], [ "xml_to_json", "validate_xml" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7f92e731a7be529dc19f0413131d5d57ebe70aa8
6c04e0eb1359beece10331a97bdfd9ff86d5f8e3
v1.0
instruct
Filter
Filter_50421_I
Write a Python program that prompts the user to enter their name and then prints out a greeting message that includes the name entered. If the user enters a name that contains numbers or special characters, the program should prompt the user to enter a valid name with only letters. The program should continue to prompt...
import re def is_valid_name(name): """ Check if the provided name only contains letters. """ return bool(re.fullmatch(r'[A-Za-z]+', name)) def get_valid_name(): """ Prompt the user to enter a valid name. It should only contain letters. """ while True: name = input("Please enter...
import pytest from solution import is_valid_name def test_is_valid_name(): assert is_valid_name("John") == True assert is_valid_name("johnDoe") == True assert is_valid_name("john123") == False assert is_valid_name("John_Doe") == False assert is_valid_name("John-Doe") == False assert is_valid_na...
[ { "docstring": "Check if the provided name only contains letters.", "function_declaration": "def is_valid_name(name):", "function_name": "is_valid_name", "parameter_list": "(name)" }, { "docstring": "Prompt the user to enter a valid name. It should only contain letters.", "function_decla...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_valid_name(name):\n \"\"\"\n Check if the provided name only contains letters.\n \"\"\"\n return bool(re.fullmatch(r'[A-Za-z]+', name))\n\ndef get_valid_name():...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050421", "row_id": 50421, "seed_ids": "['Qwen2.5-72B-Instruct_104996']" }
0.510786
Filter_50421
I
[ "is_valid_name", "get_valid_name", "greet_user" ]
3
[ [ "get_valid_name", "is_valid_name" ], [ "greet_user", "get_valid_name" ] ]
2
[]
false
[]
false
pytest
true
[]
true
37b67551cb242d62b343cffd257d95530f73ec64
bcf0b5b0c44d92d043cf8f161e2022df583ef4ed
v1.0
instruct
Filter
Filter_50446_I
Can you write a simple program in Python to convert Celsius to Fahrenheit and vice versa? It would be great if the program could take user input for the temperature and the unit (C for Celsius and F for Fahrenheit) and then output the converted temperature.
def celsius_to_fahrenheit(celsius): """ Convert Celsius to Fahrenheit. """ return celsius * 9/5 + 32 def fahrenheit_to_celsius(fahrenheit): """ Convert Fahrenheit to Celsius. """ return (fahrenheit - 32) * 5/9 def convert_temperature(temperature, unit): """ Convert temperature ...
from solution import celsius_to_fahrenheit, fahrenheit_to_celsius, convert_temperature def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsiu...
[ { "docstring": "Convert Celsius to Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Convert Fahrenheit to Celsius.", "function_declaration": "def fahrenheit_to_celsius(f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(c):\n \"\"\"\n Converts Celsius to Fahrenheit.\n \"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"\n Converts Fahrenheit to C...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050446", "row_id": 50446, "seed_ids": "['Qwen2.5-72B-Instruct_105034']" }
0.426529
Filter_50446
I
[ "celsius_to_fahrenheit", "fahrenheit_to_celsius", "convert_temperature" ]
3
[ [ "convert_temperature", "celsius_to_fahrenheit" ], [ "convert_temperature", "fahrenheit_to_celsius" ] ]
2
[]
false
[]
false
pytest
true
[]
true
dd1a11727afa48c3a8f6dbd55ed8ae39513ebcd9
194888dcea90fa53d7e053ecc821ea9ac5dce7cf
v1.0
instruct
Filter
Filter_50505_I
Design a Python function to calculate the product of all the prime numbers in a given list. The function should be named `product_of_primes` and should take a single argument, a list of integers. If the list contains no prime numbers, the function should return 1. Use a docstring to describe the function's purpose, par...
def is_prime(n): """ Helper function to check if a number is prime. Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: ...
from solution import product_of_primes def test_product_of_primes_with_primes(): assert product_of_primes([2, 3, 5, 7]) == 2 * 3 * 5 * 7 def test_product_of_primes_with_no_primes(): assert product_of_primes([4, 6, 8, 9]) == 1 def test_product_of_primes_with_mixed_numbers(): assert product_of_primes([2, 4...
[ { "docstring": "Helper function to check if a number is prime.\nReturns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the product of all the prime numbers in a given ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050505", "row_id": 50505, "seed_ids": "['Qwen2.5-72B-Instruct_105128']" }
0.693382
Filter_50505
I
[ "is_prime", "product_of_primes" ]
2
[ [ "product_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62157d656f507378580c8390c84fbd85304fffca
081128c26dd79f1f0986988fa1dbd959e6499443
v1.0
instruct
Filter
Filter_50534_I
Create a Python program that generates a simple quiz on basic math and science facts, suitable for elementary school students. The quiz should include 10 questions and provide feedback on whether the answer is correct or incorrect. At the end of the quiz, the program should display the number of correct answers.
import random def generate_quiz(): questions = [ {"question": "What is the sum of 2 + 2?", "answer": 4}, {"question": "What planet is known as the Red Planet?", "answer": "Mars"}, {"question": "What is the capital of France?", "answer": "Paris"}, {"question": "What is the square roo...
import pytest from solution import generate_quiz, check_answer def test_generate_quiz(): questions = generate_quiz() assert len(questions) == 10 # Ensure no duplicate questions questions_set = set(q["question"] for q in questions) assert len(questions_set) == 10 def test_check_answer_correct(): ...
[ { "docstring": null, "function_declaration": "def generate_quiz():", "function_name": "generate_quiz", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def check_answer(question, user_answer):", "function_name": "check_answer", "parameter_list": "(question,...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_quiz():\n questions = [\n {\"question\": \"What is the sum of 2 + 2?\", \"answer\": 4},\n {\"question\": \"What planet is known as the Red Planet...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050534", "row_id": 50534, "seed_ids": "['Qwen2.5-72B-Instruct_105170']" }
0.476829
Filter_50534
I
[ "generate_quiz", "check_answer", "take_quiz" ]
3
[ [ "take_quiz", "check_answer" ] ]
1
[]
false
[]
false
pytest
true
[]
true
887a8b775946d083204e709ea860a67d610a18dc
0aa452100455ec5f7cb635a41f641201c27873b8
v1.0
instruct
Filter
Filter_50536_I
Design a Python function that dynamically selects the nearest neighbors of a given point from a dataset, excluding the point itself. The function should be able to handle a dataset and a specific point, determining the 'k' nearest neighbors based on Euclidean distance. Ensure the function is self-contained, with necess...
import numpy as np def euclidean_distance(point1, point2): """Calculate the Euclidean distance between two points.""" return np.sqrt(np.sum(np.square(np.array(point1) - np.array(point2)))) def nearest_neighbors(dataset, point, k): """ Return the k nearest neighbors of a given point from the dataset us...
from solution import nearest_neighbors def test_nearest_neighbors_single_neighbor(): dataset = [ [1, 2], [2, 3], [3, 4], [5, 5], [1, 1] ] point = [2, 3] k = 1 assert nearest_neighbors(dataset, point, k) == [[1, 2]] def test_nearest_neighbors_multiple_neighbo...
[ { "docstring": "Calculate the Euclidean distance between two points.", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Return the k nearest neighbors of a given point from the da...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom scipy.spatial import distance\n\ndef k_nearest_neighbors(dataset, point, k):\n \"\"\"\n Returns the k nearest neighbors of a given point from a dataset excluding...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050536", "row_id": 50536, "seed_ids": "['Qwen2.5-72B-Instruct_105174']" }
0.718958
Filter_50536
I
[ "euclidean_distance", "nearest_neighbors" ]
2
[ [ "nearest_neighbors", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
064a4d7c6b7d18e2de71eb2a834ec6cc9a196f7c
7326ae5926425166ebc578ba7cd1477d52c0bff2
v1.0
instruct
Filter
Filter_50538_I
I want to generate a Python script to compare the performance of Bubble Sort, Quick Sort, and Merge Sort on a list of 10,000 random integers. The script should measure and print the execution time of each sorting algorithm. Can you help me with that?
import random import time def bubble_sort(arr): n = len(arr) for i in range(n): for j in range(0, n - i - 1): if arr[j] > arr[j + 1]: arr[j], arr[j + 1] = arr[j + 1], arr[j] def quick_sort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] lef...
import random from solution import bubble_sort, quick_sort, merge_sort def test_bubble_sort(): data = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5] sorted_data = sorted(data) bubble_sort(data) assert data == sorted_data def test_quick_sort(): data = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5] sorted_data = sorted(d...
[ { "docstring": null, "function_declaration": "def bubble_sort(arr):", "function_name": "bubble_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def quick_sort(arr):", "function_name": "quick_sort", "parameter_list": "(arr)" }, { "docstring...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport time\n\ndef bubble_sort(arr):\n n = len(arr)\n for i in range(n):\n for j in range(0, n - i - 1):\n if arr[j] > arr[j + 1]:\n arr[j...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050538", "row_id": 50538, "seed_ids": "['Qwen2.5-72B-Instruct_105179']" }
0.491196
Filter_50538
I
[ "bubble_sort", "quick_sort", "merge_sort", "merge" ]
4
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4d9ed7a58ec27c2fa73133311ba74f6a2570d3c6
ea67a333273555154b0ace031726374aef443743
v1.0
instruct
Filter
Filter_50577_I
Create a Python function named `generate_custom License_plate` that generates a random string formatted to represent a custom license plate. The license plate should follow this format: two random letters, a hyphen, three random numbers, another hyphen, and one random letter. For example, the output could look like "AB...
import random import string def generate_custom_license_plate(): """ Generates a custom license plate in the format: two random letters, a hyphen, three random numbers, another hyphen, and one random letter. For example: AB-123-C. """ letters = string.ascii_uppercase numbers = string.digits ...
from solution import generate_custom_license_plate def test_generate_custom_license_plate_length(): for _ in range(100): license_plate = generate_custom_license_plate() assert len(license_plate) == 8 # format is XX-XXX-X, which is 8 characters long. def test_generate_custom_license_plate_format()...
[ { "docstring": "Generates a custom license plate in the format: two random letters, a hyphen, three random numbers,\nanother hyphen, and one random letter. For example: AB-123-C.", "function_declaration": "def generate_custom_license_plate():", "function_name": "generate_custom_license_plate", "para...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_custom_license_plate():\n \"\"\"\n Generates a custom license plate following the format:\n two random letters, a hyphen, three random num...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050577", "row_id": 50577, "seed_ids": "['Qwen2.5-72B-Instruct_105233']" }
0.559041
Filter_50577
I
[ "generate_custom_license_plate", "demo_check" ]
2
[ [ "demo_check", "generate_custom_license_plate" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5df9ad1072349771e730cfd57d442f931bb5043e
3a244728c81c97c5d92afbacf683a6c749cb0f95
v1.0
instruct
Filter
Filter_50587_I
I want to write a Python script that can find all the duplicate files in a specified directory and its subdirectories. The script should compare files based on their content, not just their names. It should also be able to display the paths of the duplicate files and provide an option to delete the duplicates. Can you ...
import os import hashlib def hash_file(filepath): """ Generates an MD5 hash for the given file. """ hasher = hashlib.md5() with open(filepath, 'rb') as file: buf = file.read() hasher.update(buf) return hasher.hexdigest() def find_duplicates(directory): """ Finds and ret...
import os from solution import hash_file, find_duplicates, delete_duplicates def setup_test_files(): os.makedirs('test_dir/subdir', exist_ok=True) with open('test_dir/file1.txt', 'w') as f: f.write('File content') with open('test_dir/file2.txt', 'w') as f: f.write('Another file content') ...
[ { "docstring": "Generates an MD5 hash for the given file.", "function_declaration": "def hash_file(filepath):", "function_name": "hash_file", "parameter_list": "(filepath)" }, { "docstring": "Finds and returns a dictionary of duplicate files.\n\nParameters:\ndirectory (str): The directory to...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport hashlib\n\ndef hash_file(filepath):\n \"\"\"\n Generates an MD5 hash for the given file.\n \"\"\"\n hasher = hashlib.md5()\n with open(filepath, 'rb') as file:...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050587", "row_id": 50587, "seed_ids": "['Qwen2.5-72B-Instruct_105249']" }
0.574868
Filter_50587
I
[ "hash_file", "find_duplicates", "display_duplicates", "delete_duplicates" ]
4
[ [ "find_duplicates", "hash_file" ] ]
1
[]
false
[]
false
pytest
true
[]
true
192564e81a50c8583d4fb0c913079d25e5357406
321921994de2feab8f4578a6c0829e14697f1698
v1.0
instruct
Filter
Filter_50593_I
Design a Python function that takes a list of integers and returns a new list containing only the prime numbers found in the original list. Ensure your code is fully self-contained and imports all necessary packages. Additionally, include a function to test the correctness of your prime filter function with provided da...
def is_prime(n): """ Determines if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(lst): "...
from solution import filter_primes, is_prime def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert is_prime(13) assert not is_prime(18) assert is_prime(19) def test_filter_primes(): assert filter_prime...
[ { "docstring": "Determines if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters a list and returns only the prime numbers.", "function_declaration": "def filter_primes(lst):", "function_n...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 o...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050593", "row_id": 50593, "seed_ids": "['Qwen2.5-72B-Instruct_105257']" }
0.623476
Filter_50593
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
833cffe12033b1acdd0d2d318af416ceeae97319
e510d90d3371036638f33c8df89dec859e69d648
v1.0
instruct
Filter
Filter_50610_I
Explain how to implement a simple text classification model using BERT in PyTorch.
import torch from torch.utils.data import DataLoader, Dataset from transformers import BertTokenizer, BertForSequenceClassification, AdamW # Define a simple custom dataset class TextDataset(Dataset): def __init__(self, texts, labels, tokenizer, max_len): self.texts = texts self.labels = labels ...
from solution import TextDataset, text_classification_bert def test_text_classification_bert(): # Dummy data texts = ["I love programming", "Python is amazing", "I dislike bugs"] labels = [1, 1, 0] # 1 for positive, 0 for negative max_len = 10 epochs = 1 batch_size = 2 # Check if the ...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import torch\nfrom torch.utils.data import DataLoader, Dataset\nfrom transformers import BertTokenizer, BertForSequenceClassification, AdamW\n\nclass CustomDataset(Dataset):\n def __init__(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050610", "row_id": 50610, "seed_ids": "['Qwen2.5-72B-Instruct_105291']" }
0.416625
Filter_50610
I
[ "train_model", "text_classification_bert" ]
2
[ [ "text_classification_bert", "train_model" ] ]
1
[]
false
[ "TextDataset" ]
true
pytest
true
[ "torch", "transformers" ]
false
257584a18f36054a071fc945adcb786afeb9457a
ce144320ca85dcba552b81fa5053a2c855a13440
v1.0
instruct
Filter
Filter_50611_I
Can you write a short program in Python that adds two numbers and prints the result? I'm new to Python and would like to see how it's done.
def add_and_print(a, b): """ Adds two numbers and prints the result. """ result = add(a, b) print(result) return result def add(a, b): """ Returns the sum of a and b. """ return a + b
from solution import add, add_and_print def test_add_positive_numbers(): assert add(2, 3) == 5 def test_add_with_zero(): assert add(0, 5) == 5 assert add(5, 0) == 5 def test_add_negative_numbers(): assert add(-1, -1) == -2 def test_add_mixed_sign_numbers(): assert add(-1, 3) == 2 def test_add_a...
[ { "docstring": "Adds two numbers and prints the result.", "function_declaration": "def add_and_print(a, b):", "function_name": "add_and_print", "parameter_list": "(a, b)" }, { "docstring": "Returns the sum of a and b.", "function_declaration": "def add(a, b):", "function_name": "add"...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add_numbers(a, b):\n \"\"\"\n Returns the sum of a and b.\n \"\"\"\n return a + b\n\nif __name__ == \"__main__\":\n # Examples of usage\n result = add_numbers(3, 4)\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050611", "row_id": 50611, "seed_ids": "['Qwen2.5-72B-Instruct_105293']" }
0.709165
Filter_50611
I
[ "add_and_print", "add" ]
2
[ [ "add_and_print", "add" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b747a67167c883f5c62fc8d97238a8d13f0b80a9
7e8f5fe2eb10dfc8e7529abc6f3d4a6ba0081416
v1.0
instruct
Filter
Filter_50628_I
Design a Python program to calculate the factorial of a number using both iterative and recursive methods. Additionally, implement a method to validate the input to ensure it is a non-negative integer. The program should then compare the performance of both methods for the input number and display which method is faste...
import time def validate_input(n): """ Validates if the input n is a non-negative integer. """ if isinstance(n, int) and n >= 0: return True return False def factorial_iterative(n): """ Calculates the factorial of n using an iterative approach. """ result = 1 for i in r...
from solution import validate_input, factorial_iterative, factorial_recursive, compare_performance def test_validate_non_negative_integer(): assert validate_input(5) == True assert validate_input(0) == True assert validate_input(-1) == False assert validate_input(3.14) == False assert validate_inpu...
[ { "docstring": "Validates if the input n is a non-negative integer.", "function_declaration": "def validate_input(n):", "function_name": "validate_input", "parameter_list": "(n)" }, { "docstring": "Calculates the factorial of n using an iterative approach.", "function_declaration": "def ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\ndef validate_input(n):\n \"\"\"\n Validates if the input n is a non-negative integer.\n \"\"\"\n if isinstance(n, int) and n >= 0:\n return True\n return F...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050628", "row_id": 50628, "seed_ids": "['Qwen2.5-72B-Instruct_105317']" }
0.620211
Filter_50628
I
[ "validate_input", "factorial_iterative", "factorial_recursive", "compare_performance" ]
4
[ [ "compare_performance", "factorial_iterative" ], [ "compare_performance", "factorial_recursive" ], [ "compare_performance", "validate_input" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c576770d619b78dd63feb6110a8f65f201ac9aa3
e2b90f868dda71b56fd4c169f780e5ce7f7554d4
v1.0
instruct
Filter
Filter_50702_I
Write a Python function that simulates the rolling of two six-sided dice. The function should return the sum of the two dice rolls. Additionally, implement a method to simulate rolling these dice 1000 times and calculate the average result of these rolls.
import random def roll_dice(): """ Simulates the rolling of two six-sided dice and returns their sum. """ die1 = random.randint(1, 6) die2 = random.randint(1, 6) return die1 + die2 def roll_dice_1000_times(): """ Simulates rolling two six-sided dice 1000 times and returns the average s...
from solution import roll_dice, roll_dice_1000_times def test_roll_dice(): # Test that the result of rolling two dice is between 2 and 12 result = roll_dice() assert 2 <= result <= 12 def test_roll_dice_range_distribution(): # Test a distribution sample, usually equilibrium falls in normal dice range ...
[ { "docstring": "Simulates the rolling of two six-sided dice and returns their sum.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates rolling two six-sided dice 1000 times and returns the average sum of the rolls.",...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_two_dice():\n \"\"\"\n Simulates rolling two six-sided dice and returns the sum.\n \"\"\"\n die1 = random.randint(1, 6)\n die2 = random.randint(1, 6)\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050702", "row_id": 50702, "seed_ids": "['Qwen2.5-72B-Instruct_105436']" }
0.653735
Filter_50702
I
[ "roll_dice", "roll_dice_1000_times" ]
2
[ [ "roll_dice_1000_times", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
06c5973f4fe9ca498c9080f907f8e873f0dbd359
7bec672312d7c980b9e05a54eedf1dca781fc803
v1.0
instruct
Filter
Filter_50718_I
Write a Python program that simulates the rolling of a six-sided die. The program should ask the user if they want to roll the die. If the user answers "yes", the program should roll the die and display the result. The program should continue to prompt the user for another roll until they choose to stop by entering "no...
import random def roll_die(): return random.randint(1, 6) def simulate_rolling_dice(): while True: user_input = input("Would you like to roll the die? (yes/no): ").strip().lower() if user_input == "yes": print(f"You rolled a {roll_die()}") elif user_input == "no": ...
from solution import roll_die, simulate_rolling_dice import random def test_roll_die(): random.seed(0) # Seed random number generator for predictability result = roll_die() assert 1 <= result <= 6 # Note: Testing interactive functions (like simulate_rolling_dice with input()) would require a more advance...
[ { "docstring": null, "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def simulate_rolling_dice():", "function_name": "simulate_rolling_dice", "parameter_list": "()" } ]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_die():\n \"\"\"\n Simulates rolling a six-sided die.\n \"\"\"\n return random.randint(1, 6)\n\ndef prompt_user():\n \"\"\"\n Prompts the user if the...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050718", "row_id": 50718, "seed_ids": "['Qwen2.5-72B-Instruct_105464']" }
0.533768
Filter_50718
I
[ "roll_die", "simulate_rolling_dice" ]
2
[ [ "simulate_rolling_dice", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6b77aec0d320200a073deb6375157d69ebc1aa27
c446c000f338d9d5497bce1d8bab852be7993bf7
v1.0
instruct
Filter
Filter_50723_I
Create a Python function that can filter out numbers from a list that are greater than a specified value and also prime. The function should be optimized for performance when dealing with large lists. Additionally, provide a piece of code that could be used to test the function to ensure it works as expected.
import math def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, filter_primes_greater_than def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True def test_filter_primes_greater_than(): n...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters out primes greater than a specified threshold from a list of numbers.", "function_declaration": "def filter_primes_gre...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import isqrt\n\ndef is_prime(n):\n \"\"\"Return True if n is a prime number, else False.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050723", "row_id": 50723, "seed_ids": "['Qwen2.5-72B-Instruct_105469']" }
0.628047
Filter_50723
I
[ "is_prime", "filter_primes_greater_than" ]
2
[ [ "filter_primes_greater_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2524921dd9af474308ae1176354dff05ce906450
12d705bef802bac438270c93d4a68d36a7539b79
v1.0
instruct
Filter
Filter_50732_I
I want to create a simple web application using Python and Flask that takes user input from a form, processes it, and displays a result. How can I achieve this? Can you provide a basic example?
from flask import Flask, request, render_template_string app = Flask(__name__) @app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': user_input = request.form['user_input'] processed_input = process_input(user_input) return render_template_string(template, resu...
from solution import process_input def test_process_input_empty(): assert process_input('') == '' def test_process_input_single_character(): assert process_input('a') == 'a' def test_process_input_palindrome(): assert process_input('madam') == 'madam' def test_process_input_regular_string(): assert ...
[ { "docstring": null, "function_declaration": "def index():", "function_name": "index", "parameter_list": "()" }, { "docstring": "Processes the user input and returns a result.\nDummy processing for illustrative purposes might be reversing the string.", "function_declaration": "def proces...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, render_template_string\n\napp = Flask(__name__)\n\n@app.route('/', methods=['GET', 'POST'])\ndef index():\n if request.method == 'POST':\n user_inpu...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050732", "row_id": 50732, "seed_ids": "['Qwen2.5-72B-Instruct_105483']" }
0.480271
Filter_50732
I
[ "index", "process_input" ]
2
[ [ "index", "process_input" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[ "flask" ]
false
c76852bb48ea125258e1516da1ae64f3dc93bfe4
91cc7b8cf65d9f445716e31bf08073aed7a8cba7
v1.0
instruct
Filter
Filter_50783_I
How can I write a function in Python that not only checks if a given number is prime but also generates a list of all prime numbers up to that number? Additionally, I would like the function to return the total count of prime numbers found.
def is_prime(n): """Return True if the number is prime, otherwise False.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, generate_primes_up_to def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(11) == True assert is_prime(15) == False assert is_prime(1) == False assert is_prime(0) ...
[ { "docstring": "Return True if the number is prime, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of all prime numbers up to and including n.\nReturns a tuple containing the list of prim...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050783", "row_id": 50783, "seed_ids": "['Qwen2.5-72B-Instruct_105558']" }
0.695427
Filter_50783
I
[ "is_prime", "generate_primes_up_to" ]
2
[ [ "generate_primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
68a8d84ff6145a375460e4e94e29b7ac2832f935
7ec4e7e6ba01adec12f96b5e63985769b3c8e942
v1.0
instruct
Filter
Filter_50785_I
Could you provide a step-by-step guide on how to create a simple chatbot using Python and the Flask framework? I'm looking to understand the basics of setting up a chatbot that can respond to simple text messages.
from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/chat', methods=['POST']) def chat(): user_input = request.json.get('message') if not user_input: return jsonify({'error': 'No message provided'}), 400 response = generate_response(user_input) return jsonify({'respons...
import pytest from solution import app @pytest.fixture def client(): with app.test_client() as client: yield client def test_chat_hello_message(client): response = client.post('/chat', json={'message': 'hello'}) assert response.status_code == 200 data = response.get_json() assert data['res...
[ { "docstring": null, "function_declaration": "def chat():", "function_name": "chat", "parameter_list": "()" }, { "docstring": "Generates a simple response based on the user input.", "function_declaration": "def generate_response(user_input):", "function_name": "generate_response", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, jsonify\n\napp = Flask(__name__)\n\n@app.route('/chatbot', methods=['POST'])\ndef chatbot():\n user_message = request.json.get('message')\n \n # Basi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050785", "row_id": 50785, "seed_ids": "['Qwen2.5-72B-Instruct_105561']" }
0.409459
Filter_50785
I
[ "chat", "generate_response" ]
2
[ [ "chat", "generate_response" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
467de5d224925f7a4d68750676e3352f0aad464c
295933d6072630aca77ab9da66b593c8da432596
v1.0
instruct
Filter
Filter_50795_I
Can you write a Python script to create a basic calculator that can perform addition, subtraction, multiplication, and division? The script should be user-friendly and include error handling for division by zero. It should also allow the user to perform multiple calculations until they choose to exit.
def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a * b def divide(a, b): if b == 0: return "Error: Division by zero is undefined." return a / b def calculator(): while True: print("Options:") print("Enter 'add' to add two numbers...
from solution import add, subtract, multiply, divide def test_add(): assert add(3, 5) == 8 assert add(-1, 1) == 0 assert add(-1, -1) == -2 def test_subtract(): assert subtract(10, 5) == 5 assert subtract(-1, 1) == -2 assert subtract(-1, -1) == 0 def test_multiply(): assert multiply(3, 5) ...
[ { "docstring": null, "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def subtract(a, b):", "function_name": "subtract", "parameter_list": "(a, b)" }, { "docstring": null, "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n return a + b\n\ndef subtract(a, b):\n return a - b\n\ndef multiply(a, b):\n return a * b\n\ndef divide(a, b):\n if b == 0:\n raise ValueError(\"Cannot divid...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050795", "row_id": 50795, "seed_ids": "['Qwen2.5-72B-Instruct_105582']" }
0.574111
Filter_50795
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
5d6841d9b48af70bf43a28390e4f28604987d8f1
1ef0219667516ea0f2059fcd08103187ab52f407
v1.0
instruct
Filter
Filter_50815_I
I'm working on a project that involves generating secure passwords. Could you provide a Python function that creates a strong, random password with specific requirements? The password should include uppercase and lowercase letters, numbers, and symbols, and be of a length specified by the user. It would be great if the...
import random import string def generate_strong_password(length): """ Generates a strong random password of specified `length`. Parameters: length (int): Desired length of the password. Returns: str: The generated password. """ if length < 8: raise ValueError("Password...
from solution import generate_strong_password, is_strong_password def test_generate_strong_password(): password = generate_strong_password(12) assert len(password) == 12 assert is_strong_password(password) == True def test_is_strong_password_true_case(): password = "Ab1@def2G" assert is_strong...
[ { "docstring": "Generates a strong random password of specified `length`.\n\nParameters:\nlength (int): Desired length of the password.\n\nReturns:\nstr: The generated password.", "function_declaration": "def generate_strong_password(length):", "function_name": "generate_strong_password", "parameter...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_strong_password(length):\n \"\"\"\n Generate a strong random password of specified length.\n The password will include uppercase, lowercas...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050815", "row_id": 50815, "seed_ids": "['Qwen2.5-72B-Instruct_105613']" }
0.706002
Filter_50815
I
[ "generate_strong_password", "is_strong_password" ]
2
[ [ "generate_strong_password", "is_strong_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f83094383372789655bbb3326e4d080fa2687e8b
dc1981238fddacbdaf44473d3dafd0750f5914e3
v1.0
instruct
Filter
Filter_50816_I
I need to create a Python program that generates random user data for testing a new application. The data should include names, email addresses, and ages. How can I do this using Python?
import random import string def generate_random_name(): first_names = ["John", "Jane", "Sam", "Alice", "Tom", "Lucy"] last_names = ["Doe", "Smith", "Davis", "Johnson", "Brown", "Wilson"] first_name = random.choice(first_names) last_name = random.choice(last_names) return f"{first_name} {last_name}"...
from solution import generate_random_name, generate_random_email, generate_random_age, generate_random_user_data def test_generate_random_name(): name = generate_random_name() assert isinstance(name, str) and len(name.split()) == 2 def test_generate_random_email(): email = generate_random_email("John Doe"...
[ { "docstring": null, "function_declaration": "def generate_random_name():", "function_name": "generate_random_name", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def generate_random_email(name):", "function_name": "generate_random_email", "parameter_lis...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_random_name():\n first_names = [\"John\", \"Jane\", \"Sam\", \"Alice\", \"Bob\", \"Eva\"]\n last_names = [\"Doe\", \"Smith\", \"Brown\", \"Jo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050816", "row_id": 50816, "seed_ids": "['Qwen2.5-72B-Instruct_105615']" }
0.577611
Filter_50816
I
[ "generate_random_name", "generate_random_email", "generate_random_age", "generate_random_user_data" ]
4
[ [ "generate_random_user_data", "generate_random_age" ], [ "generate_random_user_data", "generate_random_email" ], [ "generate_random_user_data", "generate_random_name" ] ]
3
[]
false
[]
false
pytest
true
[]
true
1bfd336797eb5fc18e1b122676c2bb5673f678b1
2b353bd97ace5aff196a2045de63487b97b4abe4
v1.0
instruct
Filter
Filter_50844_I
How can I write a Python script that takes a list of URLs, checks if each one is a valid URL, and prints out the ones that are valid?
import re def is_valid_url(url): """ Checks if a URL is valid using a regular expression. Args: url (str): The URL to be checked. Returns: bool: True if the URL is valid, False otherwise. """ regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// r'(?:(?:...
from solution import is_valid_url, check_urls def test_is_valid_url(): assert is_valid_url("http://example.com") == True assert is_valid_url("https://example.com") == True assert is_valid_url("ftp://example.com") == True assert is_valid_url("http://localhost") == True assert is_valid_url("http://19...
[ { "docstring": "Checks if a URL is valid using a regular expression.\n\nArgs:\nurl (str): The URL to be checked.\n\nReturns:\nbool: True if the URL is valid, False otherwise.", "function_declaration": "def is_valid_url(url):", "function_name": "is_valid_url", "parameter_list": "(url)" }, { "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_valid_url(url):\n \"\"\"\n Returns True if the input URL is valid, False otherwise.\n \"\"\"\n url_regex = re.compile(\n r'^(?:http|ftp)s?://' # http:// ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050844", "row_id": 50844, "seed_ids": "['Qwen2.5-72B-Instruct_105658']" }
0.702614
Filter_50844
I
[ "is_valid_url", "check_urls" ]
2
[ [ "check_urls", "is_valid_url" ] ]
1
[]
false
[]
false
pytest
true
[]
true
464f177634aaf48fc61978a8d8ffb2a0b2412cb3
14364264f9e44b576d2f49c774408213e7ce1e20
v1.0
instruct
Filter
Filter_50871_I
I have a script that writes a file to a directory. The file name is based on the date and time, and I want to make sure that no two files will have the same name, even if they are created within the same second. How can I achieve this in Python?
import os import time from datetime import datetime def generate_unique_filename(basename): """ Generate a unique filename using the current date and time, down to microseconds. This ensures that even if multiple files are created within the same second, they will have different names. Parameters: ...
import os import time from solution import generate_unique_filename, write_file def test_generate_unique_filename(): basename = "testfile" filename1 = generate_unique_filename(basename) time.sleep(0.001) # Sleep for 1 millisecond to ensure a different timestamp filename2 = generate_unique_filename(bas...
[ { "docstring": "Generate a unique filename using the current date and time, down to microseconds.\nThis ensures that even if multiple files are created within the same second, they will have different names.\n\nParameters:\nbasename (str): The base name of the file (e.g., \"file\").\n\nReturns:\nstr: A unique f...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport time\nfrom datetime import datetime\n\ndef generate_unique_filename(basename):\n \"\"\"\n Generate a unique filename using the current date and time, down to microsecon...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050871", "row_id": 50871, "seed_ids": "['Qwen2.5-72B-Instruct_105703']" }
0.514123
Filter_50871
I
[ "generate_unique_filename", "write_file" ]
2
[ [ "write_file", "generate_unique_filename" ] ]
1
[]
false
[]
false
pytest
true
[]
true
afea8e1dd9ce2e950df623deee8965c0f29c6084
d6e06db6933c9dc8d5db716834ced46b9f646a56
v1.0
instruct
Filter
Filter_50877_I
Create a Python program that takes a user's input for their name and prints a personalized greeting. The program should also include a function that checks if the input is not empty and is a string. If the input is invalid, the program should prompt the user to enter their name again.
def is_valid_name(name): """ Checks if the entered name is valid. A valid name is a non-empty string. """ return isinstance(name, str) and name.strip() != "" def get_name_input(): """ Prompts the user to enter their name until a valid input is provided. """ while True: name ...
from solution import is_valid_name def test_is_valid_name_with_valid_strings(): assert is_valid_name("John") == True assert is_valid_name("Jane Doe") == True def test_is_valid_name_with_invalid_strings(): assert is_valid_name("") == False assert is_valid_name(" ") == False assert is_valid_name(N...
[ { "docstring": "Checks if the entered name is valid.\nA valid name is a non-empty string.", "function_declaration": "def is_valid_name(name):", "function_name": "is_valid_name", "parameter_list": "(name)" }, { "docstring": "Prompts the user to enter their name until a valid input is provided...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_name_input(name):\n \"\"\"\n Checks if the input is not empty and is a string.\n \"\"\"\n return isinstance(name, str) and len(name.strip()) > 0\n\ndef get_name():\n \...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050877", "row_id": 50877, "seed_ids": "['Qwen2.5-72B-Instruct_105711']" }
0.475037
Filter_50877
I
[ "is_valid_name", "get_name_input", "greet_user" ]
3
[ [ "get_name_input", "is_valid_name" ], [ "greet_user", "get_name_input" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d7d58671b6b312bfb7244539e16bca7db111851f
6e89e331b44953f511feea03deff7d6971c02055
v1.0
instruct
Filter
Filter_50894_I
Can you help me understand how to implement a basic blockchain in Python? I'm interested in creating a simple proof-of-work algorithm and a way to add new blocks to the chain.
import hashlib import time class Block: def __init__(self, index, previous_hash, timestamp, data, hash): self.index = index self.previous_hash = previous_hash self.timestamp = timestamp self.data = data self.hash = hash def calculate_hash(index, previous_hash, timestamp, da...
from solution import Block, Blockchain, create_genesis_block, create_new_block def test_blockchain_initialization(): blockchain = Blockchain() assert isinstance(blockchain, Blockchain) assert len(blockchain.chain) == 1 assert blockchain.chain[0].data == "Genesis Block" def test_create_genesis_block():...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\nimport time\n\nclass Block:\n def __init__(self, index, previous_hash, timestamp, data, nonce=0):\n self.index = index\n self.previous_hash = previous_hash\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050894", "row_id": 50894, "seed_ids": "['Qwen2.5-72B-Instruct_105734']" }
0.344704
Filter_50894
I
[ "calculate_hash", "create_genesis_block", "proof_of_work", "create_new_block" ]
4
[ [ "create_genesis_block", "calculate_hash" ], [ "create_new_block", "proof_of_work" ], [ "proof_of_work", "calculate_hash" ] ]
3
[]
false
[ "Block", "Blockchain" ]
true
pytest
true
[]
true
1ea89c22dcf608dbf54f41e60183018f2ba400e0
d4240d7805152b4e5a0c767c88e1229fa992876b
v1.0
instruct
Filter
Filter_50896_I
I need to write a Python program that generates a random number and then checks if the number is a prime number. Can you provide a code snippet for this?
import random def is_prime(n): """ Check if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += ...
from solution import is_prime, generate_random_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5...
[ { "docstring": "Check if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate a random number between lower and upper bounds and \ncheck if it's a prime.\nReturn the number and whether it's prime."...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n %...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050896", "row_id": 50896, "seed_ids": "['Qwen2.5-72B-Instruct_105737']" }
0.627024
Filter_50896
I
[ "is_prime", "generate_random_prime" ]
2
[ [ "generate_random_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8ae2aeb2d87617e7adfbdae4829519ea66f6d6aa
4906f05b74dbb1debe7bc4e66f43d1f18728d6a4
v1.0
instruct
Filter
Filter_50909_I
Design a Python program that generates random strings of a specific length, which can include uppercase and lowercase letters, numbers, and special characters. The program should also allow for the generation of a specified number of such strings and output them to a file, each string on a new line.
import random import string def generate_random_string(length): """ Generates a random string of a specific length which includes uppercase, lowercase, digits, and special characters. :param length: Length of the desired random string. :return: Randomly generated string. """ characters...
from solution import generate_random_string, generate_strings_to_file def test_generate_random_string_length(): assert len(generate_random_string(10)) == 10 assert len(generate_random_string(0)) == 0 assert len(generate_random_string(20)) == 20 def test_generate_random_string_characters(): result = ge...
[ { "docstring": "Generates a random string of a specific length which includes uppercase, lowercase,\ndigits, and special characters.\n\n:param length: Length of the desired random string.\n:return: Randomly generated string.", "function_declaration": "def generate_random_string(length):", "function_name...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_random_string(length):\n \"\"\"\n Generate a random string of specified length containing uppercase and lowercase letters,\n numbers, and ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00050909", "row_id": 50909, "seed_ids": "['Qwen2.5-72B-Instruct_105752']" }
0.784817
Filter_50909
I
[ "generate_random_string", "generate_strings_to_file" ]
2
[ [ "generate_strings_to_file", "generate_random_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8353518ec08af727da8928b3457e5ed1da64bdcd
84a9409e3076ec16e4a2c07ca380f849764ee5ec
v1.0
instruct
Filter
Filter_50920_I
Write a Python program that finds the largest palindrome made from the product of two 3-digit numbers. A palindromic number reads the same both ways. The program should print the largest palindrome found and the two 3-digit numbers that produce it. Ensure your code is well-commented for clarity.
def is_palindrome(n): """ Check if a number is a palindrome. A palindrome reads the same forwards and backwards. """ return str(n) == str(n)[::-1] def largest_palindrome_product(): """ Finds the largest palindrome made from the product of two 3-digit numbers. Returns: large...
from solution import is_palindrome, largest_palindrome_product def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(12321) == True assert is_palindrome(123) == False assert is_palindrome(1001) == True assert is_palindrome(10) == False def test_largest_palindrome_product...
[ { "docstring": "Check if a number is a palindrome.\nA palindrome reads the same forwards and backwards.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Finds the largest palindrome made from the product of two 3-...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_largest_palindrome():\n \"\"\"\n Function to find the largest palindromic number made from the product of two 3-digit numbers.\n Returns a tuple containing the palindrome and...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050920", "row_id": 50920, "seed_ids": "['Qwen2.5-72B-Instruct_105777']" }
0.695128
Filter_50920
I
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8e378d23628b0c23289ce6eaa0df83e539b3aec1
e4a88944ae8bc5da793f9bccd5b10d29f6f7e987
v1.0
instruct
Filter
Filter_50921_I
Design a simple interactive chatbot using Python that can respond to user inputs with predefined messages. The chatbot should be able to greet the user, ask for the user's name, and then respond with a personalized greeting. It should also have the ability to answer a simple question about the weather, always respondin...
def chatbot_interaction(user_input): """ Simulates basic interactions with a simple chatbot. Args: user_input (str): The input from the user. Returns: str: The chatbot's response. """ responses = { "greet": "Hello! How can I assist you today?", "ask_name": "What...
from solution import chatbot_interaction def test_chatbot_greeting(): assert chatbot_interaction("Hello") == "Hello! How can I assist you today?" assert chatbot_interaction("Hi there") == "Hello! How can I assist you today?" assert chatbot_interaction("Hey") == "Hello! How can I assist you today?" def tes...
[ { "docstring": "Simulates basic interactions with a simple chatbot.\n\nArgs:\nuser_input (str): The input from the user.\n\nReturns:\nstr: The chatbot's response.", "function_declaration": "def chatbot_interaction(user_input):", "function_name": "chatbot_interaction", "parameter_list": "(user_input)...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def chatbot_interaction(user_input):\n \"\"\"\n Simulates basic interactions with a simple chatbot.\n \n Args:\n user_input (str): The input from the user.\n \n Returns:\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00050921", "row_id": 50921, "seed_ids": "['Qwen2.5-72B-Instruct_105778']" }
0.3957
Filter_50921
I
[ "chatbot_interaction", "start_chatbot" ]
2
[ [ "start_chatbot", "chatbot_interaction" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0dfbf069450af686c4c82a5baf36dd1bdb3147cd
37c712719c60790b8bbfab227ce35d5d0d8c71d1
v1.0
instruct
Filter
Filter_50948_I
Can you write a simple Python script that converts temperatures from Celsius to Fahrenheit and vice versa? It would be great if the script can take user input for the temperature and the unit (Celsius or Fahrenheit) and then output the converted temperature.
def celsius_to_fahrenheit(celsius): """ Converts Celsius temperature to Fahrenheit. """ return (celsius * 9/5) + 32 def fahrenheit_to_celsius(fahrenheit): """ Converts Fahrenheit temperature to Celsius. """ return (fahrenheit - 32) * 5/9 def convert_temperature(temp, unit): """ ...
from solution import celsius_to_fahrenheit, fahrenheit_to_celsius, convert_temperature def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsiu...
[ { "docstring": "Converts Celsius temperature to Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Converts Fahrenheit temperature to Celsius.", "function_declaration": "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts Celsius to Fahrenheit.\n \"\"\"\n return (celsius * 9/5) + 32\n\ndef fahrenheit_to_celsius(fahrenheit):\n \"\"\"\n Con...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050948", "row_id": 50948, "seed_ids": "['Qwen2.5-72B-Instruct_105819']" }
0.405362
Filter_50948
I
[ "celsius_to_fahrenheit", "fahrenheit_to_celsius", "convert_temperature" ]
3
[ [ "convert_temperature", "celsius_to_fahrenheit" ], [ "convert_temperature", "fahrenheit_to_celsius" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2368defc7ee871352ae66efbfad605b6d0e9bb77
4328d6a49fb006ad7dff7b8400ca465c00614834
v1.0
instruct
Filter
Filter_50954_I
Design a Python function to generate a dictionary with keys as integers from 1 to n (inclusive) and values as the squares of the keys. Then, write a function to verify if the generated dictionary matches the expected output for a given n.
def generate_squares(n): """ Generates a dictionary with keys as integers from 1 to n (inclusive) and values as the squares of the keys. :param n: The upper limit of keys in the dictionary. :return: A dictionary where keys are integers from 1 to n and values are the squares of the keys...
from solution import generate_squares, verify_squares def test_generate_squares_small(): assert generate_squares(5) == {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} def test_generate_squares_zero(): assert generate_squares(0) == {} def test_generate_squares_one(): assert generate_squares(1) == {1: 1} def test_verify...
[ { "docstring": "Generates a dictionary with keys as integers from 1 to n (inclusive)\nand values as the squares of the keys.\n\n:param n: The upper limit of keys in the dictionary.\n:return: A dictionary where keys are integers from 1 to n and values\n are the squares of the keys.", "function_declar...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_squares_dict(n):\n \"\"\"\n Generate a dictionary with keys as integers from 1 to n (inclusive) and values as the squares of the keys.\n\n Parameters:\n n (int): The u...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050954", "row_id": 50954, "seed_ids": "['Qwen2.5-72B-Instruct_105828']" }
0.621301
Filter_50954
I
[ "generate_squares", "verify_squares" ]
2
[ [ "verify_squares", "generate_squares" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f10b88790829a0ef470437579ce0db8f1c3e469c
47b70bb17db595d6aef77adf9988f0bf6a9f0d89
v1.0
instruct
Filter
Filter_50955_I
Create a Python script that will find and replace a specific word in all text files within a directory and its subdirectories. The script should prompt the user to input the directory path, the word to find, and the word to replace it with. It should also provide an option to perform a case-sensitive search. Ensure the...
import os def replace_word_in_file(file_path, word_to_find, word_to_replace, case_sensitive): try: with open(file_path, 'r', encoding="utf-8") as file: content = file.read() if case_sensitive: new_content = content.replace(word_to_find, word_to_replace) else: ...
import os import pytest from solution import replace_word_in_file, find_and_replace_in_directory def test_replace_word_in_file_case_sensitive(tmp_path): file_path = tmp_path / "test.txt" file_path.write_text("Hello world! Hello People.", encoding="utf-8") result = replace_word_in_file(file_path, "Hell...
[ { "docstring": null, "function_declaration": "def replace_word_in_file(file_path, word_to_find, word_to_replace, case_sensitive):", "function_name": "replace_word_in_file", "parameter_list": "(file_path, word_to_find, word_to_replace, case_sensitive)" }, { "docstring": null, "function_de...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef find_and_replace(directory, find_word, replace_word, case_sensitive=False):\n \"\"\"\n Finds and replaces a specific word in all text files within a directory and its su...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050955", "row_id": 50955, "seed_ids": "['Qwen2.5-72B-Instruct_105830']" }
0.539236
Filter_50955
I
[ "replace_word_in_file", "find_and_replace_in_directory", "main" ]
3
[ [ "find_and_replace_in_directory", "replace_word_in_file" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0c80bd0e11f114b823de5db53ea7faf99315543f
44d69ad88596fcf5c4dfb401fd1a0f98ca5b625d
v1.0
instruct
Filter
Filter_50962_I
Write a Python function that determines whether a given year is a leap year or not. A leap year is defined as a year that is divisible by 4, except for end-of-century years, which must be divisible by 400. This means that the year 2000 was a leap year, although 1900 was not. The function should return `True` if the yea...
def is_leap_year(year): """ Determines whether a given year is a leap year. A leap year is divisible by 4, but centurial end years must be divisible by 400. Args: year: An integer representing the year. Returns: A boolean value. True if the year is a leap year, False otherw...
from solution import is_leap_year, are_leap_years def test_single_year(): assert is_leap_year(2000) == True assert is_leap_year(1900) == False assert is_leap_year(2004) == True assert is_leap_year(2001) == False assert is_leap_year(1600) == True def test_list_of_years(): years = [2000, 1900, 2...
[ { "docstring": "Determines whether a given year is a leap year.\nA leap year is divisible by 4, but centurial end years must be divisible by 400.\n\nArgs:\n year: An integer representing the year.\n\nReturns:\n A boolean value. True if the year is a leap year, False otherwise.", "function_declaration"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_leap_year(year):\n \"\"\"\n Determine whether a given year is a leap year.\n A leap year is divisible by 4, except for end-of-century years, which must be divisible by 400.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00050962", "row_id": 50962, "seed_ids": "['Qwen2.5-72B-Instruct_105850']" }
0.648089
Filter_50962
I
[ "is_leap_year", "are_leap_years" ]
2
[ [ "are_leap_years", "is_leap_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62f4c0b49e05a885502d3b06d023a936fc6dfd91
e2bbf3e44dc43592fd7791cbce1a5fed67d27453
v1.0
instruct
Filter
Filter_51011_I
Design a basic Python script that reads a CSV file, where the file contains a column with text data (e.g., customer reviews) and another column with labels (e.g., positive or negative sentiment). The script should preprocess the text data by removing punctuation, converting to lowercase, and tokenizing the text. It sho...
import pandas as pd import string from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import CountVectorizer from sklearn.naive_bayes import MultinomialNB from sklearn.metrics import accuracy_score def preprocess_text(text): """ Preprocess the given text by removing punctu...
import pytest from solution import preprocess_text, load_and_preprocess_data import pandas as pd from io import StringIO # Mock CSV data csv_data = """review,label "This is a positive review!",positive "Unfortunately, this is negative.",negative "An excellent example of a positive review.",positive "This is a terrible...
[ { "docstring": "Preprocess the given text by removing punctuation, converting to lowercase, and tokenizing.", "function_declaration": "def preprocess_text(text):", "function_name": "preprocess_text", "parameter_list": "(text)" }, { "docstring": "Load data from a CSV file and preprocess the t...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport string\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.feature_extraction.text import CountVectorizer\nfrom sklearn.naive_bayes import Multinomi...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00051011", "row_id": 51011, "seed_ids": "['Qwen2.5-72B-Instruct_105938']" }
0.576951
Filter_51011
I
[ "preprocess_text", "load_and_preprocess_data", "train_and_evaluate_model" ]
3
[ [ "load_and_preprocess_data", "preprocess_text" ], [ "train_and_evaluate_model", "load_and_preprocess_data" ] ]
2
[]
false
[]
false
pytest
true
[ "pandas", "sklearn" ]
false
dc615365cfafd2dcc39eb95b223dde1a382cd844
f2e13c00da364dcc63b513c0d8aa5fd2081ebd2d
v1.0
instruct
Filter
Filter_51027_I
Create a Python program to reverse a string and check if it's a palindrome.
def reverse_string(s): """ Returns the reversed version of the string s. """ return s[::-1] def is_palindrome(s): """ Checks if the string s is a palindrome. A string is a palindrome if it reads the same forward and backward. """ reversed_s = reverse_string(s) return s == revers...
from solution import reverse_string, is_palindrome def test_reverse_string(): assert reverse_string("hello") == "olleh" assert reverse_string("abcde") == "edcba" assert reverse_string("A") == "A" assert reverse_string("") == "" def test_is_palindrome(): assert is_palindrome("racecar") assert i...
[ { "docstring": "Returns the reversed version of the string s.", "function_declaration": "def reverse_string(s):", "function_name": "reverse_string", "parameter_list": "(s)" }, { "docstring": "Checks if the string s is a palindrome.\nA string is a palindrome if it reads the same forward and b...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def reverse_string(s):\n \"\"\"\n Returns the reversed string.\n \"\"\"\n return s[::-1]\n\ndef is_palindrome(s):\n \"\"\"\n Returns True if the string is a palindrome, else ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00051027", "row_id": 51027, "seed_ids": "['Qwen2.5-72B-Instruct_105964']" }
0.774858
Filter_51027
I
[ "reverse_string", "is_palindrome" ]
2
[ [ "is_palindrome", "reverse_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
db6972a1f3a47d5e490ff0f39ef70872eca1b52b
53c585423d4c8140fbd09996e8f609322a9d38fc
v1.0
instruct
Filter
Filter_51035_I
Design a Python program that simulates a basic version of the card game Blackjack, where the player competes against the computer. The program should allow the player to draw cards and decide whether to "hit" or "stand". The game should end when the player's hand value exceeds 21, or the player chooses to stand. At the...
import random class Card: SUITS = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] VALUES = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 10, 'Q': 10, 'K': 10, 'A': (1, 11)} def __init__(self, suit, r...
import pytest from solution import Deck, calculate_hand_value, determine_winner, Card def test_deck_creation(): deck = Deck() assert len(deck.cards) == 52 def test_deck_shuffle(): deck1 = Deck() deck2 = Deck() same_order = all(deck1.cards[i].rank == deck2.cards[i].rank and deck1.cards[i].suit == d...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\nclass Card:\n def __init__(self, suit, rank):\n self.suit = suit\n self.rank = rank\n\n def __repr__(self):\n return f\"{self.rank} of {self.suit}\"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00051035", "row_id": 51035, "seed_ids": "['Qwen2.5-72B-Instruct_105979']" }
0.54685
Filter_51035
I
[ "calculate_hand_value", "player_turn", "computer_turn", "determine_winner", "play_blackjack" ]
5
[ [ "computer_turn", "calculate_hand_value" ], [ "play_blackjack", "computer_turn" ], [ "play_blackjack", "determine_winner" ], [ "play_blackjack", "player_turn" ], [ "player_turn", "calculate_hand_value" ] ]
5
[]
false
[ "Card", "Deck" ]
true
pytest
true
[]
true
eb4251bcadc544cf49214405cae76a369b940797
016abdd77362e934cd1eea650c49478d63f83fbe
v1.0
instruct
Filter
Filter_51041_I
Can you help me with a basic Python script to convert Celsius to Fahrenheit and vice versa? It would be great if the script could take user input for the temperature and the unit (C or F) and then convert it to the other unit.
def celsius_to_fahrenheit(celsius): """ Converts Celsius to Fahrenheit. """ return (celsius * 9/5) + 32 def fahrenheit_to_celsius(fahrenheit): """ Converts Fahrenheit to Celsius. """ return (fahrenheit - 32) * 5/9 def convert_temperature(value, unit): """ Converts temperature b...
from solution import celsius_to_fahrenheit, fahrenheit_to_celsius, convert_temperature def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsiu...
[ { "docstring": "Converts Celsius to Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Converts Fahrenheit to Celsius.", "function_declaration": "def fahrenheit_to_celsius...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts Celsius to Fahrenheit.\n \"\"\"\n return celsius * 9 / 5 + 32\n\ndef fahrenheit_to_celsius(fahrenheit):\n \"\"\"\n Con...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00051041", "row_id": 51041, "seed_ids": "['Qwen2.5-72B-Instruct_105986']" }
0.421537
Filter_51041
I
[ "celsius_to_fahrenheit", "fahrenheit_to_celsius", "convert_temperature" ]
3
[ [ "convert_temperature", "celsius_to_fahrenheit" ], [ "convert_temperature", "fahrenheit_to_celsius" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5ce3767925274de3f236c3048ccd32dc1c217452
45761a20a6de9dedb57c371799765e160ecff634
v1.0
instruct
Filter
Filter_51056_I
I am working on a project and need to automate the process of checking a list of URLs for broken links. I want to do this using Python. Can you guide me on how to create a script for this purpose?
import requests def check_url(url): """ Returns True if the URL is reachable, False otherwise. """ try: response = requests.get(url) return response.status_code == 200 except requests.exceptions.RequestException: return False def check_urls(urls): """ Checks a list ...
from solution import check_url, check_urls def test_check_url_reachable(): assert check_url("https://www.example.com") def test_check_url_unreachable(): assert not check_url("https://www.thisurldoesnotexist1234567890.com") def test_check_urls_mixed(): urls = [ "https://www.example.com", "...
[ { "docstring": "Returns True if the URL is reachable, False otherwise.", "function_declaration": "def check_url(url):", "function_name": "check_url", "parameter_list": "(url)" }, { "docstring": "Checks a list of URLs and returns a dictionary with the URLs as keys and their status (reachable ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\n\ndef check_urls(urls):\n \"\"\"\n Takes a list of URLs and returns a dictionary with URLs as keys and their status ('OK' or 'Broken') as values.\n \n Parameters:\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00051056", "row_id": 51056, "seed_ids": "['Qwen2.5-72B-Instruct_106015']" }
0.595331
Filter_51056
I
[ "check_url", "check_urls" ]
2
[ [ "check_urls", "check_url" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
1cfe52ea43b11c1275e4c287b281ecb9b2814fd2
0ece72c220dae863138e1535d300a0519c9aa9d1
v1.0
instruct
Filter
Filter_51059_I
Write a Python program that performs a binary search on a sorted array. The program should ask the user to input a list of numbers separated by spaces and then a target number to search for. It should output the index of the target number if found, or indicate that the number is not in the list. Make sure to include er...
def binary_search(arr, target): """ Perform a binary search for the target in the sorted array arr. Returns the index of the target if found, else returns -1. """ left, right = 0, len(arr) - 1 while left <= right: mid = left + (right - left) // 2 if arr[mid] == target: ...
from solution import search_in_list, binary_search def test_binary_search_target_found(): arr = [1, 2, 3, 4, 5] target = 3 assert binary_search(arr, target) == 2 def test_binary_search_target_not_found(): arr = [1, 2, 3, 4, 5] target = 6 assert binary_search(arr, target) == -1 def test_binary...
[ { "docstring": "Perform a binary search for the target in the sorted array arr.\nReturns the index of the target if found, else returns -1.", "function_declaration": "def binary_search(arr, target):", "function_name": "binary_search", "parameter_list": "(arr, target)" }, { "docstring": "Pars...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def binary_search(arr, target):\n \"\"\"\n Performs binary search to find the target in a sorted array.\n \n Arguments:\n arr -- sorted list of integers\n target -- integer t...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00051059", "row_id": 51059, "seed_ids": "['Qwen2.5-72B-Instruct_106018']" }
0.750342
Filter_51059
I
[ "binary_search", "search_in_list" ]
2
[ [ "search_in_list", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d1807d0bda538da6e7b8cf4c506ddb6f6e6f5854
29ed59c37833b753528b14f12c7030859e2a4e55
v1.0
instruct
Filter
Filter_51100_I
Create a Python program to demonstrate the concept of a genetic algorithm. The program should aim to solve a simple problem, such as finding the maximum value of a quadratic function. Explain the components of the genetic algorithm used in the program and how they contribute to solving the problem.
import random import numpy as np def quadratic_function(x): """ Example quadratic function: -x^2 + 5x + 100 """ return -x**2 + 5*x + 100 def create_population(size, x_min, x_max): """ Create an initial population of individuals with random values. """ return np.random.uniform(x_min, x_...
from solution import genetic_algorithm, quadratic_function def test_genetic_algorithm_best_solution(): best_solution, best_fitness = genetic_algorithm( population_size=100, num_generations=50, x_min=0, x_max=10, num_parents=20, mutation_rate=0.1 ) a...
[ { "docstring": "Example quadratic function: -x^2 + 5x + 100", "function_declaration": "def quadratic_function(x):", "function_name": "quadratic_function", "parameter_list": "(x)" }, { "docstring": "Create an initial population of individuals with random values.", "function_declaration": ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef genetic_algorithm(fitness_function, population_size=100, generations=1000, mutation_rate=0.01):\n \"\"\"\n Solves for the maximum value of a given fitness function u...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00051100", "row_id": 51100, "seed_ids": "['Qwen2.5-72B-Instruct_106086']" }
0.380935
Filter_51100
I
[ "quadratic_function", "create_population", "fitness", "select_parents", "crossover", "mutate", "genetic_algorithm" ]
7
[ [ "fitness", "quadratic_function" ], [ "genetic_algorithm", "create_population" ], [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "fitness" ], [ "genetic_algorithm", "mutate" ], [ "genetic_algorithm", "select_parents" ] ]
6
[]
false
[]
false
pytest
true
[ "numpy" ]
false
7d2c3f7e6126322522e6971221f3f54bd042f475
a54fafc282a56602836f5ccc765137821f722482
v1.0
instruct
Filter
Filter_51126_I
Write a Python program that takes a string as input and outputs the string in reverse order. The program should also count the number of vowels in the original string and print this count. Use a function for reversing the string and another function for counting the vowels. Ensure the program is efficient and easy to r...
def reverse_string(s): """ Returns the reverse of the input string s. """ return s[::-1] def count_vowels(s): """ Returns the count of vowels in the input string s. """ vowels = "aeiouAEIOU" count = 0 for char in s: if char in vowels: count += 1 return co...
def test_reverse_string(): assert reverse_string("hello") == "olleh" assert reverse_string("Python") == "nohtyP" assert reverse_string("A") == "A" assert reverse_string("") == "" def test_count_vowels(): assert count_vowels("hello") == 2 assert count_vowels("Python") == 1 assert count_vowel...
[ { "docstring": "Returns the reverse of the input string s.", "function_declaration": "def reverse_string(s):", "function_name": "reverse_string", "parameter_list": "(s)" }, { "docstring": "Returns the count of vowels in the input string s.", "function_declaration": "def count_vowels(s):"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def reverse_string(s):\n \"\"\"\n Returns the reverse of the input string s.\n \"\"\"\n return s[::-1]\n\ndef count_vowels(s):\n \"\"\"\n Returns the number of vowels in the ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00051126", "row_id": 51126, "seed_ids": "['Qwen2.5-72B-Instruct_106125']" }
0.794838
Filter_51126
I
[ "reverse_string", "count_vowels", "process_string" ]
3
[ [ "process_string", "count_vowels" ], [ "process_string", "reverse_string" ] ]
2
[]
false
[]
false
pytest
false
[]
true
0630a6573fbcdf6088c84700b479c8078f4f5548
353e71b6af2ff71dd70ce4b19380643fae34e759
v1.0
instruct
Filter
Filter_51136_I
Design a Python function to simulate a biased coin flip, where the probability of landing on heads can be set by the user. The function should return "Heads" or "Tails" based on the outcome. Additionally, implement a check function that simulates the coin flip 1000 times and prints the percentage of times it lands on h...
import random def biased_coin_flip(probability_of_heads): """ Simulates a biased coin flip where the probability of landing on heads is specified by the user. :param probability_of_heads: The probability that the coin lands on heads. :return: "Heads" or "Tails" based on the outcome. """ ...
from solution import biased_coin_flip, check_biased_coin_flip def test_biased_coin_flip_heads(): random.seed(0) assert biased_coin_flip(1) == "Heads" assert biased_coin_flip(1) == "Heads" assert biased_coin_flip(1) == "Heads" def test_biased_coin_flip_tails(): random.seed(0) assert biased_coin...
[ { "docstring": "Simulates a biased coin flip where the probability of landing on heads\nis specified by the user.\n\n:param probability_of_heads: The probability that the coin lands on heads.\n:return: \"Heads\" or \"Tails\" based on the outcome.", "function_declaration": "def biased_coin_flip(probability_o...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef biased_coin_flip(prob_heads):\n \"\"\"\n Simulates a biased coin flip.\n \n :param prob_heads: The probability of landing on heads (0 <= prob_heads <= 1).\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00051136", "row_id": 51136, "seed_ids": "['Qwen2.5-72B-Instruct_106142']" }
0.461611
Filter_51136
I
[ "biased_coin_flip", "check_biased_coin_flip" ]
2
[ [ "check_biased_coin_flip", "biased_coin_flip" ] ]
1
[]
false
[]
false
pytest
true
[]
true
39e2e3b1e527767c355bc0dab90fe927bce1cdb6
512bfa893fc46ce4e68b5c720ce1a157139f58b9
v1.0
instruct
Filter
Filter_51138_I
I have a list of strings in Python, and I need to check if each string in the list is a palindrome. Can you provide a Python function that takes a list of strings as input and returns a dictionary with the strings as keys and boolean values indicating whether they are palindromes?
def is_palindrome(s): """ Checks if a string is palindrome. """ return s == s[::-1] def check_palindromes(lst): """ Takes a list of strings and returns a dictionary where the keys are the strings and the values are booleans indicating whether the strings are palindromes or not. """ ...
from solution import is_palindrome, check_palindromes def test_is_palindrome(): assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("madam") == True assert is_palindrome("step on no pets") == True assert is_palindrome("palindrome") == False def test_...
[ { "docstring": "Checks if a string is palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Takes a list of strings and returns a dictionary where the keys are the strings\nand the values are booleans indic...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Returns True if s is a palindrome, False otherwise.\n \"\"\"\n return s == s[::-1]\n\ndef check_palindromes(strings):\n \"\"\"\n Takes a list...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00051138", "row_id": 51138, "seed_ids": "['Qwen2.5-72B-Instruct_106145']" }
0.800823
Filter_51138
I
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
682d17821a6e97da5ab546c62072ae98a6d75556
34c0fac5255a4adf85abd4cb4923bd252d9ff17b
v1.0
instruct
Filter
Filter_51140_I
Write a Python program that simulates a simple calculator. The calculator should be able to perform addition, subtraction, multiplication, and division. The program should continue to prompt the user for operations until the user decides to exit by entering a specific command. Ensure the program handles division by zer...
def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a * b def divide(a, b): if b == 0: return "Error: Division by zero" return a / b def calculator(): while True: operation = input("Enter operation (+, -, *, /) or 'exit' to quit: ") ...
from solution import add, subtract, multiply, divide def test_add(): assert add(2, 3) == 5 assert add(-1, -1) == -2 assert add(0, 0) == 0 assert add(-1, 2) == 1 def test_subtract(): assert subtract(5, 3) == 2 assert subtract(0, 0) == 0 assert subtract(-1, -1) == 0 assert subtract(10, -...
[ { "docstring": null, "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def subtract(a, b):", "function_name": "subtract", "parameter_list": "(a, b)" }, { "docstring": null, "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n return a + b\n\ndef subtract(a, b):\n return a - b\n\ndef multiply(a, b):\n return a * b\n\ndef divide(a, b):\n if b == 0:\n return \"Error: Division by zer...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00051140", "row_id": 51140, "seed_ids": "['Qwen2.5-72B-Instruct_106151']" }
0.558288
Filter_51140
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
2bd5d4016cf7c18364e9a89e6fe81f89fdd07c63
c6d91c01e8c1c329e114ff0af33b525b91672bcd