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_44895_I
Write a Python function that implements the merge sort algorithm to sort a list of integers. The function should be named `merge_sort` and should take a single argument, a list of integers. The function should return a new list of integers sorted in ascending order. Additionally, include a simple test case within the s...
def merge_sort(arr): """ Implements the merge sort algorithm to sort a list of integers in ascending order. :param arr: List of integers to be sorted. :return: A new list of integers sorted in ascending order. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = ...
from solution import merge_sort def test_sorted_list(): assert merge_sort([34, 7, 23, 32, 5, 62]) == [5, 7, 23, 32, 34, 62] def test_empty_list(): assert merge_sort([]) == [] def test_single_element_list(): assert merge_sort([1]) == [1] def test_pre_sorted_list(): assert merge_sort([1, 2, 3, 4, 5]) ...
[ { "docstring": "Implements the merge sort algorithm to sort a list of integers in ascending order.\n:param arr: List of integers to be sorted.\n:return: A new list of integers sorted in ascending order.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(lst):\n \"\"\"\n Implements the merge sort algorithm to sort a list of integers.\n \n Parameters:\n lst (list): The list of integers to be sorted.\n\n Returns:...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00044895", "row_id": 44895, "seed_ids": "['Qwen2.5-72B-Instruct_96063']" }
0.628688
Filter_44895
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7ed9d5179232a5c2492bc184462a4f82c541f145
03e1090efaccb290f87a7263e15513b7daf80ae6
v1.0
instruct
Filter
Filter_44899_I
Write a Python script that can accept two integers as input and return their greatest common divisor (GCD). The script should also handle invalid inputs gracefully, providing a user-friendly error message. Make sure to include comments in your code for clarity.
import sys import math def gcd(a, b): """ Returns the greatest common divisor (GCD) of two integers a and b. """ return math.gcd(a, b) def get_inputs_and_compute_gcd(): """ Accepts two integers from the user and returns the GCD. Handles invalid input gracefully. """ try: # Acce...
from solution import gcd def test_gcd_with_positive_numbers(): assert gcd(48, 18) == 6 assert gcd(54, 24) == 6 def test_gcd_with_one_zero(): assert gcd(0, 10) == 10 assert gcd(10, 0) == 10 def test_gcd_with_both_zeros(): assert gcd(0, 0) == 0 # By definition, gcd(0, 0) is 0 def test_gcd_with_ne...
[ { "docstring": "Returns the greatest common divisor (GCD) of two integers a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Accepts two integers from the user and returns the GCD. Handles invalid input gracefully.", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Returns the greatest common divisor (GCD) of two integers a and b.\n Using Euclidean algorithm to find GCD.\n \"\"\"\n while b != 0:\n a, b = b,...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00044899", "row_id": 44899, "seed_ids": "['Qwen2.5-72B-Instruct_96073']" }
0.782119
Filter_44899
I
[ "gcd", "get_inputs_and_compute_gcd" ]
2
[ [ "get_inputs_and_compute_gcd", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4f0ad51aa57dde94bbfb81660c502c2fef127514
5c0c46bb4a352bb8acddfbc8f9f610c387ed55b0
v1.0
instruct
Filter
Filter_44910_I
I have a file that contains a list of email addresses, each on a new line. I need to create a Python script that reads this file, checks for valid email addresses, and then writes the valid ones to a new file. How can I do this?
import re def is_valid_email(email): """ Checks if the provided email address is valid using regex. """ email_regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$' return re.match(email_regex, email) is not None def filter_valid_emails(input_file_path, output_file_path): """ Reads a ...
from solution import is_valid_email, filter_valid_emails import os def test_is_valid_email(): assert is_valid_email("test@example.com") assert is_valid_email("user.name+tag+sorting@example.com") assert not is_valid_email("not-a-valid-email") assert not is_valid_email("plainaddress") assert not is_v...
[ { "docstring": "Checks if the provided email address is valid using regex.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Reads a file containing email addresses, checks for valid ones,\nand writes the...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_valid_email(email):\n \"\"\"\n Checks if the given email address is valid.\n \"\"\"\n email_regex = re.compile(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00044910", "row_id": 44910, "seed_ids": "['Qwen2.5-72B-Instruct_96087']" }
0.443807
Filter_44910
I
[ "is_valid_email", "filter_valid_emails" ]
2
[ [ "filter_valid_emails", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
050f8027a4cadda3d37dd083a614f5638fc230d5
f058342f653b69b759431c5ee3353c3e50ddd950
v1.0
instruct
Filter
Filter_44918_I
Can you help me with a Python code that simulates a simple dice game? The game should allow a user to roll a dice and the computer should also roll a dice. Then, the program should compare the results and declare the winner. If both roll the same number, it should be a tie.
import random def roll_dice(): """ Simulates a dice roll and returns a random integer between 1 and 6. """ return random.randint(1, 6) def dice_game(): """ Simulates a dice game where both the user and computer roll a dice. Compares the results and declares the winner or if it's a tie. ...
from solution import roll_dice, dice_game def test_roll_dice(): for _ in range(100): result = roll_dice() assert 1 <= result <= 6 def test_dice_game(): for _ in range(100): result = dice_game() assert 'user_roll' in result assert 'computer_roll' in result assert...
[ { "docstring": "Simulates a dice roll and returns a random integer between 1 and 6.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates a dice game where both the user and computer roll a dice.\nCompares the results ...
[ 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 roll_dice():\n \"\"\"\n Simulates a dice roll and returns a random integer between 1 and 6.\n \"\"\"\n return random.randint(1, 6)\n\ndef dice_game():\n \"\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00044918", "row_id": 44918, "seed_ids": "['Qwen2.5-72B-Instruct_96102']" }
0.481855
Filter_44918
I
[ "roll_dice", "dice_game" ]
2
[ [ "dice_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
979e8e5b44d057f3efbfbf77ed7754e04d200428
f5921b534ffeb790129d6eae3d2929cf931f01ef
v1.0
instruct
Filter
Filter_44984_I
Write a Python program that implements a simple Caesar cipher encryption and decryption. The program should accept a string and a shift value as inputs for encryption, and for decryption, it should accept an encrypted string and the same shift value used for encryption. The program should handle both uppercase and lowe...
def caesar_cipher_encrypt(text, shift): """ Encrypts the given text using Caesar cipher with the specified shift. """ encrypted_text = [] for char in text: if char.isalpha(): shift_base = ord('A') if char.isupper() else ord('a') encrypted_text.append(chr((ord(char) - ...
from solution import caesar_cipher_encrypt, caesar_cipher_decrypt def test_caesar_cipher_encrypt(): assert caesar_cipher_encrypt("abc", 3) == "def" assert caesar_cipher_encrypt("XYZ", 3) == "ABC" assert caesar_cipher_encrypt("Hello, World!", 5) == "Mjqqt, Btwqi!" assert caesar_cipher_encrypt("Python 3....
[ { "docstring": "Encrypts the given text using Caesar cipher with the specified shift.", "function_declaration": "def caesar_cipher_encrypt(text, shift):", "function_name": "caesar_cipher_encrypt", "parameter_list": "(text, shift)" }, { "docstring": "Decrypts the given encrypted text using Ca...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher_encrypt(text, shift):\n \"\"\"\n Encrypts the given text using Caesar cipher with the specified shift.\n \"\"\"\n encrypted_text = []\n for char in text:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00044984", "row_id": 44984, "seed_ids": "['Qwen2.5-72B-Instruct_96214']" }
0.710777
Filter_44984
I
[ "caesar_cipher_encrypt", "caesar_cipher_decrypt" ]
2
[ [ "caesar_cipher_decrypt", "caesar_cipher_encrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5d70f8cf4d1e7c90993161501a21707b134f29f1
f2f19798f058c0f21365a3cf96f841f33f8b3c60
v1.0
instruct
Filter
Filter_45018_I
I have a list of employee IDs and I want to create a function in Python that will take this list and return a dictionary where the keys are the IDs and the values are the full names of the employees. How can I do this, assuming I have a function `get_employee_name(id)` that takes an employee ID and returns the employee...
def get_employee_name(id): """ Mock function to simulate fetching an employee's full name based on their ID. In a real-world scenario, this function would retrieve data from a database or another data source. """ employee_data = { 1: "John Doe", 2: "Jane Smith", 3: "Michael B...
from solution import create_employee_dict, get_employee_name def test_create_employee_dict_with_valid_ids(): ids = [1, 2, 3] result = create_employee_dict(ids) expected = { 1: "John Doe", 2: "Jane Smith", 3: "Michael Brown" } assert result == expected def test_create_employ...
[ { "docstring": "Mock function to simulate fetching an employee's full name based on their ID.\nIn a real-world scenario, this function would retrieve data from a database or another data source.", "function_declaration": "def get_employee_name(id):", "function_name": "get_employee_name", "parameter_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_employee_name(emp_id):\n \"\"\"\n Mock function to return employee full name based on the given ID.\n \"\"\"\n employee_database = {\n 1: \"John Doe\",\n 2: \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045018", "row_id": 45018, "seed_ids": "['Qwen2.5-72B-Instruct_96287']" }
0.606895
Filter_45018
I
[ "get_employee_name", "create_employee_dict" ]
2
[ [ "create_employee_dict", "get_employee_name" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8e55efaf3d717c69e6923687ace33399a9a710fb
4c31470dd1b11585f486d50266af5a565e7ea6ad
v1.0
instruct
Filter
Filter_45037_I
Write a Python function that checks if a number is prime and returns a boolean value. Additionally, ensure the function can handle a list of numbers and return a dictionary where each number is a key and the value is a boolean indicating whether the number is prime or not. Optimize the function for performance.
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += ...
from solution import is_prime, check_primes 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(1) == False assert is_prime(0) == False...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Takes a list of numbers and returns a dictionary with the numbers as keys and values as boolean indicating whether they are p...
[ 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 Checks 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_0
{ "original_instruction": "", "prompt_id": "00045037", "row_id": 45037, "seed_ids": "['Qwen2.5-72B-Instruct_96311']" }
0.776425
Filter_45037
I
[ "is_prime", "check_primes" ]
2
[ [ "check_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
15459ae822fba0604316a8a0c7cf9471b8cbc61c
812a971f9a6a7a23b44f9802b8ef85527517f509
v1.0
instruct
Filter
Filter_45053_I
Write a python program that simulates a simple dice game. The game involves two players who each roll a six-sided die. The player with the higher roll wins. If both players roll the same number, it's a tie. The program should ask for the names of the players, simulate the dice rolls, and then print out the result of th...
import random def roll_die(): """ Simulates rolling a six-sided die and returns the result. """ return random.randint(1, 6) def dice_game(player1_name, player2_name): """ Simulates a simple dice game between two players. Args: player1_name: str, name of the first player player...
from solution import roll_die, dice_game def test_roll_die(): roll = roll_die() assert 1 <= roll <= 6, f"Die roll {roll} is out of bounds" def test_dice_game_player1_wins(monkeypatch): dice_rolls = [6, 3] def mock_roll_die(): return dice_rolls.pop(0) monkeypatch.setattr('solution.roll_die'...
[ { "docstring": "Simulates rolling a six-sided die and returns the result.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Simulates a simple dice game between two players.\n\nArgs:\nplayer1_name: str, name of the first playe...
[ 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 roll_die():\n \"\"\"\n Simulates rolling a six-sided die and returns the result.\n \"\"\"\n return random.randint(1, 6)\n\ndef dice_game(player1_name, player2_...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045053", "row_id": 45053, "seed_ids": "['Qwen2.5-72B-Instruct_96337']" }
0.529208
Filter_45053
I
[ "roll_die", "dice_game" ]
2
[ [ "dice_game", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c1fc4c5baa4ac5a92a1504d355fcefd384b18033
f25bec8da62552f582d35fdda6f3d01bdb74f65e
v1.0
instruct
Filter
Filter_45073_I
Write a code to calculate the square root of a number using the Newton-Raphson method in Python. Make sure to include a function to check the accuracy of the result against Python's built-in square root function.
def newton_raphson_sqrt(n, tolerance=1e-7, max_iterations=1000): """ Returns the square root of n using the Newton-Raphson method. """ if n < 0: raise ValueError("Cannot compute square root of a negative number.") x = n iteration = 0 while iteration < max_iterations: new...
from solution import newton_raphson_sqrt, check_sqrt_accuracy from math import isclose def test_newton_raphson_sqrt_positive(): assert isclose(newton_raphson_sqrt(4), 2.0, rel_tol=1e-7) assert isclose(newton_raphson_sqrt(9), 3.0, rel_tol=1e-7) assert isclose(newton_raphson_sqrt(16), 4.0, rel_tol=1e-7) ...
[ { "docstring": "Returns the square root of n using the Newton-Raphson method.", "function_declaration": "def newton_raphson_sqrt(n, tolerance=1e-07, max_iterations=1000):", "function_name": "newton_raphson_sqrt", "parameter_list": "(n, tolerance=1e-07, max_iterations=1000)" }, { "docstring":...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def newton_raphson_sqrt(number, tolerance=1e-10, max_iterations=1000):\n \"\"\"\n Computes the square root of a given number using the Newton-Raphson method.\n \n :param number: Th...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045073", "row_id": 45073, "seed_ids": "['Qwen2.5-72B-Instruct_96377']" }
0.571346
Filter_45073
I
[ "newton_raphson_sqrt", "check_sqrt_accuracy" ]
2
[ [ "check_sqrt_accuracy", "newton_raphson_sqrt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b3bc98a49f00c454d95313b6af1b1cdd2c6284e
d18fc7da5a16de8d648fcfd0d18077511ba3823d
v1.0
instruct
Filter
Filter_45095_I
Can you help me with a Python script to monitor the availability of a website? I need to check if a website is up and running every 5 minutes and log the status to a file.
import requests import time import logging def check_website_availability(url): """ Checks the availability of a website. Args: url (str): The URL of the website to check. Returns: bool: True if the website is up, False otherwise. """ try: response = reques...
import pytest from unittest.mock import patch from solution import check_website_availability def test_check_website_availability_success(): with patch('requests.get') as mock_get: mock_get.return_value.status_code = 200 assert check_website_availability("http://example.com") == True def test_chec...
[ { "docstring": "Checks the availability of a website.\n\nArgs:\n url (str): The URL of the website to check.\n \nReturns:\n bool: True if the website is up, False otherwise.", "function_declaration": "def check_website_availability(url):", "function_name": "check_website_availability", "par...
[ 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 time\nfrom datetime import datetime\n\ndef log_website_status(url):\n \"\"\"\n Checks if the website is up and running and logs the status to a file.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045095", "row_id": 45095, "seed_ids": "['Qwen2.5-72B-Instruct_96413']" }
0.575668
Filter_45095
I
[ "check_website_availability", "monitor_website" ]
2
[ [ "monitor_website", "check_website_availability" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
478ed0dd2ecdce205cdd78e7717de2f57575f1ae
0663d421238c25329be98b27999a802614b47fee
v1.0
instruct
Filter
Filter_45101_I
How can I implement a simple machine learning model using PyTorch to predict house prices based on a dataset with features like the number of rooms, location, and square footage? Can you provide a step-by-step guide including data preprocessing, model definition, training, and evaluation?
import torch import torch.nn as nn import torch.optim as optim from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler import pandas as pd import numpy as np # Step 1: Load and preprocess the data def load_and_preprocess_data(file_path): data = pd.read_csv(file_path) ...
from solution import load_and_preprocess_data, HousePricePredictor, train_model, evaluate_model, house_price_prediction_pipeline import numpy as np import pandas as pd import torch def test_load_and_preprocess_data(): # Creating a dummy dataset data = { 'num_rooms': [2, 3, 4], 'location': ['A',...
[]
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "import torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScale...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045101", "row_id": 45101, "seed_ids": "['Qwen2.5-72B-Instruct_96422']" }
0.406043
Filter_45101
I
[ "load_and_preprocess_data", "train_model", "evaluate_model", "house_price_prediction_pipeline" ]
4
[ [ "house_price_prediction_pipeline", "evaluate_model" ], [ "house_price_prediction_pipeline", "load_and_preprocess_data" ], [ "house_price_prediction_pipeline", "train_model" ] ]
3
[]
false
[ "HousePricePredictor" ]
true
pytest
true
[ "numpy", "pandas", "sklearn", "torch" ]
false
58fcbf87b59f667ac593768187320fc01f392d6d
9ed5df1749bf2a36dc2c5a4a1556dff24bfed750
v1.0
instruct
Filter
Filter_45113_I
How can I implement a simple version of Conway's Game of Life in Python?
def get_neighbors(board, row, col): """ Given a cell position (row, col) in the board, return the number of live neighbors """ rows, cols = len(board), len(board[0]) directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] live_neighbors = 0 for dr, dc in directio...
from solution import game_of_life def test_block_pattern(): # Block pattern (still life) board = [ [0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0] ] expected = [ [0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0] ] asser...
[ { "docstring": "Given a cell position (row, col) in the board, return the number of live neighbors", "function_declaration": "def get_neighbors(board, row, col):", "function_name": "get_neighbors", "parameter_list": "(board, row, col)" }, { "docstring": "Executes one iteration of Conway's Ga...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_neighbors(x, y, max_x, max_y):\n \"\"\"\n Returns the coordinates of the live neighbors for the cell at (x, y).\n \"\"\"\n neighbors = [\n (x - 1, y - 1), (x - 1, y)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045113", "row_id": 45113, "seed_ids": "['Qwen2.5-72B-Instruct_96445']" }
0.425826
Filter_45113
I
[ "get_neighbors", "game_of_life" ]
2
[ [ "game_of_life", "get_neighbors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e50140b592de6be4a670ed798894224fc5fcb860
2427b3fd22c29dd814daba763b662821a972ef30
v1.0
instruct
Filter
Filter_45129_I
Given a matrix, write a function to find the largest sum of a contiguous submatrix. The matrix can contain both positive and negative integers. What would be the algorithm to solve this problem, and can you provide a Python implementation?
def kadane(arr): """ Helper function to find the maximum sum of a contiguous subarray. """ max_sum = float('-inf') current_sum = 0 for x in arr: current_sum = max(x, current_sum + x) max_sum = max(max_sum, current_sum) return max_sum def largest_sum_submatrix(matrix): ""...
from solution import largest_sum_submatrix def test_empty_matrix(): assert largest_sum_submatrix([]) == 0 def test_single_element_positive(): assert largest_sum_submatrix([[42]]) == 42 def test_single_element_negative(): assert largest_sum_submatrix([[-42]]) == -42 def test_all_positive_elements(): ...
[ { "docstring": "Helper function to find the maximum sum of a contiguous subarray.", "function_declaration": "def kadane(arr):", "function_name": "kadane", "parameter_list": "(arr)" }, { "docstring": "Function to find the largest sum of a contiguous submatrix.", "function_declaration": "d...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def kadane(arr):\n \"\"\"\n Helper function to find the maximum sum of a contiguous subarray.\n \"\"\"\n max_sum = float('-inf')\n current_sum = 0\n for x in arr:\n cu...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045129", "row_id": 45129, "seed_ids": "['Qwen2.5-72B-Instruct_96471']" }
0.59502
Filter_45129
I
[ "kadane", "largest_sum_submatrix" ]
2
[ [ "largest_sum_submatrix", "kadane" ] ]
1
[]
false
[]
false
pytest
true
[]
true
49ec00d0c02949ed0ebe4df202d44ee4cc646c17
1127813f67598e2eb2efa5e4708ae41582647e85
v1.0
instruct
Filter
Filter_45148_I
How can I create a Python script to monitor the CPU usage and send an email alert if the usage exceeds a certain threshold?
import psutil import smtplib from email.mime.text import MIMEText def check_cpu_usage(threshold): """ Checks the CPU usage and sends an email alert if it exceeds the threshold. """ usage = psutil.cpu_percent(interval=1) if usage > threshold: send_email_alert(usage, threshold) def send_emai...
from unittest.mock import patch, MagicMock from solution import check_cpu_usage, send_email_alert @patch('solution.psutil.cpu_percent', return_value=95) @patch('solution.send_email_alert') def test_check_cpu_usage_above_threshold(mock_send_email, mock_cpu_percent): threshold = 90 check_cpu_usage(threshold) ...
[ { "docstring": "Checks the CPU usage and sends an email alert if it exceeds the threshold.", "function_declaration": "def check_cpu_usage(threshold):", "function_name": "check_cpu_usage", "parameter_list": "(threshold)" }, { "docstring": "Sends an email alert about high CPU usage.", "fun...
[ 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\n\ndef check_cpu_usage(threshold):\n \"\"\"\n Checks the CPU usage and sends an email alert if it exceeds the threshol...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045148", "row_id": 45148, "seed_ids": "['Qwen2.5-72B-Instruct_96506']" }
0.654824
Filter_45148
I
[ "check_cpu_usage", "send_email_alert" ]
2
[ [ "check_cpu_usage", "send_email_alert" ] ]
1
[]
false
[]
false
pytest
true
[ "psutil" ]
false
b83ee47fe69df062c8070d5123317ebbb15c8664
4e5d77fb67c550f2471c08afced86d5b4f67000f
v1.0
instruct
Filter
Filter_45161_I
I have a dataset with a column of addresses, and I need to split them into street, city, state, and zip code. Can you provide a Python code snippet to achieve this?
import re import pandas as pd def split_address(address): """ Splits an address string into street, city, state, and zip code. Parameters: address (str): The address string to split. Returns: dict: A dictionary with keys 'street', 'city', 'state', 'zip' and their corresponding values....
import pandas as pd from solution import split_address, split_addresses def test_split_address_valid(): address = "123 Main St, Springfield, IL 62704" result = split_address(address) assert result == {'street': '123 Main St', 'city': 'Springfield', 'state': 'IL', 'zip': '62704'} def test_split_address_inv...
[ { "docstring": "Splits an address string into street, city, state, and zip code.\n\nParameters:\naddress (str): The address string to split.\n\nReturns:\ndict: A dictionary with keys 'street', 'city', 'state', 'zip' and their corresponding values.", "function_declaration": "def split_address(address):", ...
[ 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 re\n\ndef split_address(address):\n \"\"\"\n Splits an address into street, city, state, and zip code.\n \"\"\"\n # Regex to match the address pattern\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045161", "row_id": 45161, "seed_ids": "['Qwen2.5-72B-Instruct_96524']" }
0.457461
Filter_45161
I
[ "split_address", "split_addresses" ]
2
[ [ "split_addresses", "split_address" ] ]
1
[]
false
[]
false
pytest
true
[ "pandas" ]
false
8e689c8b27e4598d3c030b4a2d7252b180d8d8af
60feff7a521f276e8ffd5192467f6997003e5581
v1.0
instruct
Filter
Filter_45189_I
I need to learn how to code a basic calculator in Python. Can you guide me through it?
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: raise ValueError("Cannot divide by zero") return a / b def basic_calculator(a, b, operation): if operation == 'add': return add(a, b) elif operation ...
import pytest from solution import add, subtract, multiply, divide, basic_calculator def test_add(): assert add(2, 3) == 5 assert add(-1, 1) == 0 assert add(0, 0) == 0 assert add(-2, -3) == -5 def test_subtract(): assert subtract(2, 3) == -1 assert subtract(3, 2) == 1 assert subtract(-1, 1...
[ { "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": "00045189", "row_id": 45189, "seed_ids": "['Qwen2.5-72B-Instruct_96572']" }
0.530452
Filter_45189
I
[ "add", "subtract", "multiply", "divide", "basic_calculator" ]
5
[ [ "basic_calculator", "add" ], [ "basic_calculator", "divide" ], [ "basic_calculator", "multiply" ], [ "basic_calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
1a38e77df18107ba340f91bb03243b9dde1261ec
0d93b1fab677f50110f7024f51beb7c2d6b1feec
v1.0
instruct
Filter
Filter_45212_I
Write a Python program that simulates a simple text-based calculator. The calculator should be able to perform basic arithmetic operations: addition, subtraction, multiplication, and division. The program should prompt the user to enter the first number, then the operation they would like to perform, and finally the se...
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: raise ValueError("Division by zero is not allowed.") return a / b def calculator(): while True: try: num1 = float(input("Enter the first numb...
import pytest from solution import add, subtract, multiply, divide def test_add(): assert add(1, 2) == 3 assert add(-1, -1) == -2 assert add(0, 0) == 0 assert add(5, -3) == 2 def test_subtract(): assert subtract(1, 2) == -1 assert subtract(-1, -1) == 0 assert subtract(0, 0) == 0 assert...
[ { "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, 0, 0 ]
1
medium
0.333
{ "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(\"Division by ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045212", "row_id": 45212, "seed_ids": "['Qwen2.5-72B-Instruct_96610']" }
0.551921
Filter_45212
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
7679dfdbbd5e8b0416ae3a95c276d3355a6688dd
e21267df3aaa182ca77428e692c987f3870494f6
v1.0
instruct
Filter
Filter_45214_I
Can you help me write a Python script to automate the process of downloading files from a list of URLs and saving them to a specified directory on my local machine? I want to ensure that the script can handle large files and resume downloads if they are interrupted.
import os import requests from tqdm import tqdm def download_file(url, dest_folder): if not os.path.exists(dest_folder): os.makedirs(dest_folder) local_filename = os.path.join(dest_folder, url.split('/')[-1]) temp_filename = local_filename + ".part" resume_header = {} try: ...
import os from solution import download_file, download_files def test_file_download(tmpdir): url = 'http://ipv4.download.thinkbroadband.com/5MB.zip' dest_folder = tmpdir.mkdir('downloads') download_file(url, str(dest_folder)) local_filename = os.path.join(str(dest_folder), url.split('/')[-1]) ...
[ { "docstring": null, "function_declaration": "def download_file(url, dest_folder):", "function_name": "download_file", "parameter_list": "(url, dest_folder)" }, { "docstring": null, "function_declaration": "def download_files(url_list, dest_folder):", "function_name": "download_files...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport requests\nfrom tqdm import tqdm\n\ndef download_file(url, dest_folder):\n if not os.path.exists(dest_folder):\n os.makedirs(dest_folder)\n \n local_filename =...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045214", "row_id": 45214, "seed_ids": "['Qwen2.5-72B-Instruct_96613']" }
0.616761
Filter_45214
I
[ "download_file", "download_files" ]
2
[ [ "download_files", "download_file" ] ]
1
[]
false
[]
false
pytest
true
[ "requests", "tqdm" ]
false
82c293f1ed6489aa578cd2eb3b8162b9da2aa6bf
707602719b7565458ebc8327656c8aaf2f365a8d
v1.0
instruct
Filter
Filter_45242_I
Explain the concept of mutual recursion with an example in programming.
def is_even(n): """ Returns True if n is even, False otherwise. Uses mutual recursion with is_odd. """ if n == 0: return True else: return is_odd(n - 1) def is_odd(n): """ Returns True if n is odd, False otherwise. Uses mutual recursion with is_even. """ if n...
from solution import is_even, is_odd def test_is_even(): assert is_even(0) == True assert is_even(2) == True assert is_even(4) == True assert is_even(1) == False assert is_even(3) == False def test_is_odd(): assert is_odd(0) == False assert is_odd(1) == True assert is_odd(3) == True ...
[ { "docstring": "Returns True if n is even, False otherwise.\nUses mutual recursion with is_odd.", "function_declaration": "def is_even(n):", "function_name": "is_even", "parameter_list": "(n)" }, { "docstring": "Returns True if n is odd, False otherwise.\nUses mutual recursion with is_even."...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_even(n):\n \"\"\"\n Returns True if n is even, using mutual recursion.\n \"\"\"\n if n == 0:\n return True\n else:\n return is_odd(n - 1)\n\ndef is_odd(n):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045242", "row_id": 45242, "seed_ids": "['Qwen2.5-72B-Instruct_96654']" }
0.426328
Filter_45242
I
[ "is_even", "is_odd" ]
2
[ [ "is_even", "is_odd" ], [ "is_odd", "is_even" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4963eb426bbc82d0a2a358e6e62f54b4d1e0572c
3f7e1a1565714b7f51051ac5a1c98a3f6f2fc500
v1.0
instruct
Filter
Filter_45264_I
How can I create a simple chatbot using Python and the Flask framework to respond to user messages?
from flask import Flask, request, jsonify app = Flask(__name__) def chatbot_response(user_message): """ Simple chatbot response function. Returns a response based on user messages. """ if user_message.lower() == 'hello': return "Hi there! How can I help you today?" elif user_message.lower(...
import pytest from flask import Flask from solution import app, chatbot_response @pytest.fixture def client(): with app.test_client() as client: yield client def test_chatbot_response_hello(): assert chatbot_response('hello') == "Hi there! How can I help you today?" def test_chatbot_response_how_are_...
[ { "docstring": "Simple chatbot response function. Returns a response based on user messages.", "function_declaration": "def chatbot_response(user_message):", "function_name": "chatbot_response", "parameter_list": "(user_message)" }, { "docstring": "Endpoint to handle incoming messages to the...
[ 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\ndef chatbot_response(user_message):\n \"\"\"\n Simple chatbot response function. Returns a response based on user me...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045264", "row_id": 45264, "seed_ids": "['Qwen2.5-72B-Instruct_96693']" }
0.435652
Filter_45264
I
[ "chatbot_response", "chatbot" ]
2
[ [ "chatbot", "chatbot_response" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
f20a72bbaf8af28044470cb577a3b4831047e882
fd7d040c35091431ace6ac25d0842c29e5cd0af2
v1.0
instruct
Filter
Filter_45268_I
I need to write a Python program to automate the process of checking the availability of a list of URLs. How can I do this efficiently?
import requests from concurrent.futures import ThreadPoolExecutor def check_url(url): """ Checks the availability of a given URL. Returns a tuple of the URL and its status ('Available' or 'Not Available'). """ try: response = requests.head(url, timeout=5) if response.status_code == ...
import pytest from solution import check_url, check_urls def test_check_url_available(monkeypatch): def mock_head(url, timeout): class MockResponse: status_code = 200 return MockResponse() monkeypatch.setattr('requests.head', mock_head) assert check_url('http://exa...
[ { "docstring": "Checks the availability of a given URL.\nReturns a tuple of the URL and its status ('Available' or 'Not Available').", "function_declaration": "def check_url(url):", "function_name": "check_url", "parameter_list": "(url)" }, { "docstring": "Checks the availability of a list o...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nfrom concurrent.futures import ThreadPoolExecutor\n\ndef check_url_availability(url):\n \"\"\"\n Checks the availability of a single URL.\n Returns True if the URL is...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045268", "row_id": 45268, "seed_ids": "['Qwen2.5-72B-Instruct_96701']" }
0.627339
Filter_45268
I
[ "check_url", "check_urls" ]
2
[ [ "check_urls", "check_url" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
69302f990f80bc6abb04a61b3ee7f985b47fae3f
58305b5651aa8ffa1f0ff0660cbde4bae632b9f6
v1.0
instruct
Filter
Filter_45273_I
Write a python script to parse a JSON file and print the values of all keys that contain the substring "name" in them. The script should handle nested JSON structures and print the path to each key as a list of keys leading to the value.
import json def parse_json_for_names(json_obj, path=None): """ Recursively parse the JSON object to find keys containing 'name' and print their values and paths. Args: - json_obj (dict or list): The JSON object to parse. - path (list): The current path of keys leading to the value. Returns: ...
import json from io import StringIO from solution import parse_json_for_names # Mock print to capture output from unittest.mock import patch def test_simple_json(): simple_json = '{"name": "John", "age": 30}' json_obj = json.loads(simple_json) with patch('builtins.print') as mock_print: parse...
[ { "docstring": "Recursively parse the JSON object to find keys containing 'name' and print their values and paths.\n\nArgs:\n- json_obj (dict or list): The JSON object to parse.\n- path (list): The current path of keys leading to the value.\n\nReturns:\n- None", "function_declaration": "def parse_json_for_n...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\n\ndef parse_json_for_names(json_obj, path=None):\n \"\"\"\n Recursively parse the JSON object to find keys containing 'name' and print their values and paths.\n\n Args:\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045273", "row_id": 45273, "seed_ids": "['Qwen2.5-72B-Instruct_96712']" }
0.649608
Filter_45273
I
[ "parse_json_for_names", "load_and_parse_json" ]
2
[ [ "load_and_parse_json", "parse_json_for_names" ] ]
1
[]
false
[]
false
pytest
true
[]
true
869f290d53494fc29de20b8f809a4a284a53f732
a28d89f36b75a1a2de8abb8329bf9277c78e5886
v1.0
instruct
Filter
Filter_45275_I
I need to create a Python script that can generate random names and emails for testing purposes. Can you provide me with a basic example of how to do this?
import random import string def generate_random_name(length=8): """ Generates a random name using lowercase alphabetic characters. Args: length (int): Length of the name to generate. Default is 8. Returns: str: A randomly generated name. """ return ''.join(random.c...
from solution import generate_random_name, generate_random_email def test_generate_random_name_length(): name = generate_random_name(10) assert len(name) == 10 def test_generate_random_name_characters(): name = generate_random_name() assert name.islower() def test_generate_random_email_structure(): ...
[ { "docstring": "Generates a random name using lowercase alphabetic characters.\n\nArgs:\n length (int): Length of the name to generate. Default is 8.\n \nReturns:\n str: A randomly generated name.", "function_declaration": "def generate_random_name(length=8):", "function_name": "generate_random...
[ 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 random_name(length=7):\n \"\"\"\n Generates a random name of given length.\n \"\"\"\n letters = string.ascii_lowercase\n return ''.join(rando...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045275", "row_id": 45275, "seed_ids": "['Qwen2.5-72B-Instruct_96714']" }
0.566728
Filter_45275
I
[ "generate_random_name", "generate_random_email" ]
2
[ [ "generate_random_email", "generate_random_name" ] ]
1
[]
false
[]
false
pytest
true
[]
true
97d8a01e2931a6a4802d500faca5d64e7311588b
855e7aa7f9b82de03dfd25586a6a5d4f589a559e
v1.0
instruct
Filter
Filter_45278_I
I need to create a simple web application that allows users to input a number and see if it is a prime number. I want to use Flask for the backend. Can you guide me through the process of setting up the Flask application and writing the necessary code to check if a number is prime?
from flask import Flask, request, jsonify app = Flask(__name__) 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 % (...
import pytest from solution import is_prime, app def test_is_prime_true_cases(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(7) == True assert is_prime(11) == True def test_is_prime_false_cases(): assert is_prime(1) == False assert is_pr...
[ { "docstring": "Check if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def check_prime():", "function_name": "check_prime", "parameter_list": "()" } ]
[ 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, jsonify\n\napp = Flask(__name__)\n\ndef is_prime(n):\n \"\"\"\n Check if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045278", "row_id": 45278, "seed_ids": "['Qwen2.5-72B-Instruct_96720']" }
0.576704
Filter_45278
I
[ "is_prime", "check_prime" ]
2
[ [ "check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
e6225cfc70e0cb2c2fac2a68a56f77961d55bd27
898653b21215ae49bf2ec3bae09761a21d1ae47d
v1.0
instruct
Filter
Filter_45309_I
Can you explain how to use the `map` function in Python, and provide an example of how it can be used to transform a list of numbers?
def square(number): """ Returns the square of the given number. """ return number ** 2 def transform_list(numbers): """ Applies the square function to each element in the numbers list using the map function. """ return list(map(square, numbers))
from solution import square, transform_list def test_square(): assert square(2) == 4 assert square(-3) == 9 assert square(0) == 0 def test_transform_list(): assert transform_list([1, 2, 3, 4, 5]) == [1, 4, 9, 16, 25] assert transform_list([-1, -2, -3]) == [1, 4, 9] assert transform_list([0]) =...
[ { "docstring": "Returns the square of the given number.", "function_declaration": "def square(number):", "function_name": "square", "parameter_list": "(number)" }, { "docstring": "Applies the square function to each element in the numbers list using the map function.", "function_declarat...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def square_list(numbers):\n \"\"\"\n Returns a list where each number is squared.\n \"\"\"\n return list(map(lambda x: x * x, numbers))", "test_code": "from solution import squ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045309", "row_id": 45309, "seed_ids": "['Qwen2.5-72B-Instruct_96765']" }
0.53488
Filter_45309
I
[ "square", "transform_list" ]
2
[ [ "transform_list", "square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ad3d9511b93338beca225afe0240b40a890887c8
5ea7701b01b38d7903624c8a0c52a48c5d96be88
v1.0
instruct
Filter
Filter_45328_I
Explain the concept of mutual recursion and provide an example in Python.
def is_even(n): """ Check if a number n is even using mutual recursion. """ if n == 0: return True else: return is_odd(n - 1) def is_odd(n): """ Check if a number n is odd using mutual recursion. """ if n == 0: return False else: return is_even(n ...
from solution import is_even, is_odd def test_is_even(): assert is_even(0) == True assert is_even(1) == False assert is_even(2) == True assert is_even(3) == False assert is_even(100) == True def test_is_odd(): assert is_odd(0) == False assert is_odd(1) == True assert is_odd(2) == False...
[ { "docstring": "Check if a number n is even using mutual recursion.", "function_declaration": "def is_even(n):", "function_name": "is_even", "parameter_list": "(n)" }, { "docstring": "Check if a number n is odd using mutual recursion.", "function_declaration": "def is_odd(n):", "func...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_even(n):\n \"\"\"\n Check if a number n is even using mutual recursion with is_odd function.\n \"\"\"\n if n == 0:\n return True\n else:\n return is_odd(n -...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045328", "row_id": 45328, "seed_ids": "['Qwen2.5-72B-Instruct_96799']" }
0.452087
Filter_45328
I
[ "is_even", "is_odd" ]
2
[ [ "is_even", "is_odd" ], [ "is_odd", "is_even" ] ]
2
[]
false
[]
false
pytest
true
[]
true
596bf3d4d1e4fcf8a821e8cf3c0d648d3b96e453
d544de0abecde5747987b5aac47ea6a3edd4d700
v1.0
instruct
Filter
Filter_45337_I
How can I implement a basic version of a blockchain using Python? I'm looking for a simple example that covers the core concepts.
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, calculate_hash, create_genesis_block, create_new_block def test_create_genesis_block(): genesis_block = create_genesis_block() assert genesis_block.index == 0 assert genesis_block.previous_hash == "0" assert genesis_block.data == "Genesis Block" assert isinstance(genesis...
[]
[ 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 json\nfrom time import time\n\nclass Block:\n def __init__(self, index, transactions, timestamp, previous_hash, nonce=0):\n self.index = index\n self.tr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045337", "row_id": 45337, "seed_ids": "['Qwen2.5-72B-Instruct_96812']" }
0.347341
Filter_45337
I
[ "calculate_hash", "create_genesis_block", "create_new_block" ]
3
[ [ "create_genesis_block", "calculate_hash" ], [ "create_new_block", "calculate_hash" ] ]
2
[]
false
[ "Block" ]
true
pytest
true
[]
true
3f7ddcde83746064b1536ff9cdcfa0137dd4db8e
58f99667fc4b35470972dbdc5759911a9ad34edf
v1.0
instruct
Filter
Filter_45339_I
I need to create a Python function that takes a list of words and returns a new list containing only the words that are palindromes. Can you help me with that?
def is_palindrome(word): """ Checks if a word is a palindrome. """ return word == word[::-1] def filter_palindromes(word_list): """ Returns a list of palindromes from the given word list. """ return [word for word in word_list if is_palindrome(word)]
from solution import filter_palindromes, is_palindrome def test_is_palindrome(): assert is_palindrome("radar") == True assert is_palindrome("hello") == False assert is_palindrome("level") == True assert is_palindrome("world") == False assert is_palindrome("madam") == True assert is_palindrome("...
[ { "docstring": "Checks if a word is a palindrome.", "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "docstring": "Returns a list of palindromes from the given word list.", "function_declaration": "def filter_palindrome...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(word):\n \"\"\"\n Returns True if the word is a palindrome, False otherwise.\n \"\"\"\n return word == word[::-1]\n\ndef filter_palindromes(words):\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045339", "row_id": 45339, "seed_ids": "['Qwen2.5-72B-Instruct_96815']" }
0.683091
Filter_45339
I
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86b231595579ba60de728efd8d49d0b766af9938
49b58e2cec9964b43a1dcd56a51ac90eafdc824e
v1.0
instruct
Filter
Filter_45342_I
How can I create a Python program that generates a random number between 1 and 100 and asks the user to guess it, giving hints if the guess is too high or too low, and congratulating them when they guess correctly?
import random def generate_random_number(): """ Generates a random number between 1 and 100. """ return random.randint(1, 100) def guess_number(): """ Main function to run the guessing game. """ number_to_guess = generate_random_number() guessed_correctly = False while not gue...
from solution import generate_random_number def test_generate_random_number_within_range(): random_number = generate_random_number() assert 1 <= random_number <= 100 def test_generate_random_number_multiple_runs(): # Run the random number generation multiple times and check all are within range. for _...
[ { "docstring": "Generates a random number between 1 and 100.", "function_declaration": "def generate_random_number():", "function_name": "generate_random_number", "parameter_list": "()" }, { "docstring": "Main function to run the guessing game.", "function_declaration": "def guess_number...
[ 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_random_number():\n \"\"\"\n Generates a random number between 1 and 100.\n \"\"\"\n return random.randint(1, 100)\n\ndef guess_number():\n \"\"\"\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045342", "row_id": 45342, "seed_ids": "['Qwen2.5-72B-Instruct_96818']" }
0.514438
Filter_45342
I
[ "generate_random_number", "guess_number" ]
2
[ [ "guess_number", "generate_random_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
db0d948ad1804bb8b3b7280997ac3493df9b78b8
ad91fc4ae256f74bbf0dd0c0acc4301b84351030
v1.0
instruct
Filter
Filter_45349_I
How can I create a web application using Flask that allows users to upload images and displays them on the website? I also want to store these images on the server. Can you guide me through the process?
from flask import Flask, request, redirect, url_for, render_template import os app = Flask(__name__) UPLOAD_FOLDER = 'uploads/' ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER if not os.path.exists(UPLOAD_FOLDER): os.mkdir(UPLOAD_FOLDER) def allowed_file(filename): ...
from solution import allowed_file def test_allowed_file_with_allowed_extensions(): assert allowed_file('image.png') == True assert allowed_file('image.jpg') == True assert allowed_file('image.jpeg') == True assert allowed_file('image.gif') == True def test_allowed_file_with_disallowed_extensions(): ...
[ { "docstring": null, "function_declaration": "def allowed_file(filename):", "function_name": "allowed_file", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def upload_image():", "function_name": "upload_image", "parameter_list": "()" }, { ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, redirect, url_for, render_template\nimport os\n\napp = Flask(__name__)\nUPLOAD_FOLDER = 'uploads/'\nALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}\napp.co...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045349", "row_id": 45349, "seed_ids": "['Qwen2.5-72B-Instruct_96828']" }
0.424522
Filter_45349
I
[ "allowed_file", "upload_image", "uploaded_file" ]
3
[ [ "upload_image", "allowed_file" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
d768c39ff321f17d88a2f64ed4fbc64ca913dd34
16dd7a2992a94c364c34bfea453008120cdfc893
v1.0
instruct
Filter
Filter_45360_I
Write a Python program to simulate the rolling of two six-sided dice. The program should roll the dice 1000 times and then calculate and print the frequency of each possible sum (2 through 12). Additionally, the program should print the average of all the sums obtained. Use the random module to simulate the dice rolls.
import random def roll_dice(): return random.randint(1, 6), random.randint(1, 6) def simulate_dice_rolls(num_rolls=1000): roll_frequencies = {i: 0 for i in range(2, 13)} rolls_sum = 0 for _ in range(num_rolls): die1, die2 = roll_dice() roll_sum = die1 + die2 roll_frequenci...
from solution import roll_dice, simulate_dice_rolls def test_roll_dice(): die1, die2 = roll_dice() assert 1 <= die1 <= 6 assert 1 <= die2 <= 6 def test_simulate_dice_rolls_length(): frequencies, average = simulate_dice_rolls(1000) assert len(frequencies) == 11 # Sums 2 through 12 def test_simula...
[ { "docstring": null, "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def simulate_dice_rolls(num_rolls=1000):", "function_name": "simulate_dice_rolls", "parameter_list": "(num_rolls=...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nfrom collections import Counter\n\ndef simulate_dice_rolls(num_rolls=1000):\n \"\"\"\n Simulates rolling two six-sided dice and returns a dictionary with the frequency of ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045360", "row_id": 45360, "seed_ids": "['Qwen2.5-72B-Instruct_96848']" }
0.685389
Filter_45360
I
[ "roll_dice", "simulate_dice_rolls", "print_simulation_results" ]
3
[ [ "simulate_dice_rolls", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0ebb278e014217a30a97ee877881981da860c558
2dba9193e283b90842a2be20e48403c4874c6ef5
v1.0
instruct
Filter
Filter_45365_I
Given a string and a list of strings, write a Python function to find the longest string from the list that is a subsequence of the given string. A subsequence of a string can be formed by deleting some characters of the string without changing the order of the remaining characters. If there are multiple longest string...
def is_subsequence(s1, s2): """ Helper function to check if s1 is a subsequence of s2. """ iter_s2 = iter(s2) return all(char in iter_s2 for char in s1) def find_longest_subseq(main_str, list_of_strs): """ Finds the longest string from list_of_strs that is a subsequence of main_str. If ...
from solution import find_longest_subseq def test_find_longest_subseq_exists(): assert find_longest_subseq("abppplee", ["able", "ale", "apple", "bale", "kangaroo"]) == "apple" def test_find_longest_subseq_same_length(): assert find_longest_subseq("abppplee", ["able", "apple"]) == "apple" def test_find_lo...
[ { "docstring": "Helper function to check if s1 is a subsequence of s2.", "function_declaration": "def is_subsequence(s1, s2):", "function_name": "is_subsequence", "parameter_list": "(s1, s2)" }, { "docstring": "Finds the longest string from list_of_strs that is a subsequence\nof main_str. If...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s, t):\n \"\"\"\n Helper function to check if `s` is a subsequence of `t`.\n \"\"\"\n it = iter(t)\n return all(char in it for char in s)\n\ndef find_longest_...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045365", "row_id": 45365, "seed_ids": "['Qwen2.5-72B-Instruct_96855']" }
0.699312
Filter_45365
I
[ "is_subsequence", "find_longest_subseq" ]
2
[ [ "find_longest_subseq", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
25c5339a608766a66bf0614730b1ea1a07b7b9f3
da7d1bfff36294b71b0e01240b5ddf020e51fce9
v1.0
instruct
Filter
Filter_45375_I
I need to create a Python function that can generate a random number between 1 and 100, and then check if the number is a prime number. If it is a prime number, the function should return the number; if not, it should return the string "Not a prime number". How can I do this?
import random def is_prime(n): """ Returns True if n is a prime number, 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: ...
from solution import is_prime, generate_and_check_prime def test_is_prime_with_prime_number(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(7) == True assert is_prime(11) == True assert is_prime(97) == True def test_is_prime_with_non_prime_nu...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a random number between 1 and 100 and checks if it is a prime number.\nReturns the number if i...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef 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:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045375", "row_id": 45375, "seed_ids": "['Qwen2.5-72B-Instruct_96876']" }
0.673831
Filter_45375
I
[ "is_prime", "generate_and_check_prime" ]
2
[ [ "generate_and_check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
94524a75b3b9a1c0b4ad29a9ce3f6f18bedfb4db
8426bbef7699e3b234fb236beb645167a2d54773
v1.0
instruct
Filter
Filter_45378_I
How can I use a loop to print the first 100 prime numbers in Python?
def is_prime(n): """Helper function to determine if a number is a prime.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False retu...
from solution import is_prime, first_100_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(11) == True def test_first_100_primes(): primes = first_100_primes(...
[ { "docstring": "Helper function to determine if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Function to generate the first 100 prime numbers.", "function_declaration": "def first_100_primes():"...
[ 1, 1, 0 ]
2
easy
0.667
{ "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 is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045378", "row_id": 45378, "seed_ids": "['Qwen2.5-72B-Instruct_96880']" }
0.558278
Filter_45378
I
[ "is_prime", "first_100_primes" ]
2
[ [ "first_100_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c68ea71879839871d003d462355407ae9d885b83
7b9a06ee60a3a182ec1046ac61a442c48bb78b2f
v1.0
instruct
Filter
Filter_45384_I
Can you help me write a simple script to automate the process of checking if a website is up and running using Python? I want to be able to run this script periodically to monitor the status of a few websites.
import requests def check_website_status(url): """ Checks if the website is up and running. Args: url (str): The website URL to check. Returns: bool: True if the website is up (status code 200), False otherwise. """ try: response = requests.get(url) return resp...
from solution import check_website_status, check_websites def test_check_website_status_up(monkeypatch): class MockResponse: status_code = 200 def __init__(self, url): self.url = url def mock_get(url): return MockResponse(url) monkeypatch.setat...
[ { "docstring": "Checks if the website is up and running.\n\nArgs:\nurl (str): The website URL to check.\n\nReturns:\nbool: True if the website is up (status code 200), False otherwise.", "function_declaration": "def check_website_status(url):", "function_name": "check_website_status", "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 requests\n\ndef check_website_status(url):\n \"\"\"\n Checks whether a website is up and running.\n \n Args:\n url (str): The URL of the website to check.\n \n Retu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045384", "row_id": 45384, "seed_ids": "['Qwen2.5-72B-Instruct_96895']" }
0.542343
Filter_45384
I
[ "check_website_status", "check_websites" ]
2
[ [ "check_websites", "check_website_status" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
e64ba70e81248403dd7f7b799804d9b46349a9d9
44bb71e99f29223114964845e2738d6bf68ee07e
v1.0
instruct
Filter
Filter_45411_I
How can I create a Python program to convert a list of temperatures from Celsius to Fahrenheit and display them in a simple table format?
def celsius_to_fahrenheit(celsius): """ Converts a temperature from Celsius to Fahrenheit. """ return (celsius * 9/5) + 32 def temperatures_table(celsius_list): """ Converts a list of temperatures from Celsius to Fahrenheit and displays them in a simple table format. """ table = "Celsiu...
from solution import celsius_to_fahrenheit, temperatures_table 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(37) == 98.6 def test_temperatures_table(): result = ...
[ { "docstring": "Converts a temperature from 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 and displa...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts a temperature from Celsius to Fahrenheit.\n \"\"\"\n return (celsius * 9/5) + 32\n\ndef convert_and_display_temperatures(tem...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045411", "row_id": 45411, "seed_ids": "['Qwen2.5-72B-Instruct_96940']" }
0.466061
Filter_45411
I
[ "celsius_to_fahrenheit", "temperatures_table" ]
2
[ [ "temperatures_table", "celsius_to_fahrenheit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
03df2040f52c9901d0d511aa920b615803c9be93
b675b725efb851bd06f9d0266ff531cdef0442cf
v1.0
instruct
Filter
Filter_45415_I
I'm working on a project that involves implementing a neural network from scratch in Python. I've managed to create the architecture and the forward pass, but I'm struggling with the backpropagation part, especially how to compute the gradients of the loss with respect to the weights. Can you guide me on how to do this...
import numpy as np def relu(x): return np.maximum(0, x) def relu_derivative(x): return np.where(x > 0, 1, 0) def forward_pass(X, weights, biases): # Layer 1 Z1 = np.dot(X, weights['W1']) + biases['b1'] A1 = relu(Z1) # Layer 2 (output layer) Z2 = np.dot(A1, weights['W2']) + biases['b2...
import numpy as np from solution import relu, relu_derivative, forward_pass, compute_loss, backward_pass def test_relu(): assert np.array_equal(relu(np.array([-1, 0, 1])), np.array([0, 0, 1])) def test_relu_derivative(): assert np.array_equal(relu_derivative(np.array([-1, 0, 1])), np.array([0, 0, 1])) def te...
[ { "docstring": null, "function_declaration": "def relu(x):", "function_name": "relu", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def relu_derivative(x):", "function_name": "relu_derivative", "parameter_list": "(x)" }, { "docstring": null, ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef sigmoid(x):\n return 1 / (1 + np.exp(-x))\n\ndef sigmoid_derivative(x):\n return x * (1 - x)\n\nclass SimpleNeuralNetwork:\n def __init__(self, input_size, h...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045415", "row_id": 45415, "seed_ids": "['Qwen2.5-72B-Instruct_96944']" }
0.375133
Filter_45415
I
[ "relu", "relu_derivative", "forward_pass", "compute_loss", "backward_pass" ]
5
[ [ "backward_pass", "relu_derivative" ], [ "forward_pass", "relu" ] ]
2
[]
false
[]
false
pytest
true
[ "numpy" ]
false
5337178d2042c9d25819ccfcbe16c131a8663beb
4897ad000a0991a230dc7637e69442cff005d6eb
v1.0
instruct
Filter
Filter_45416_I
Write a Python function that takes a list of integers and returns a new list containing only the elements that are prime numbers. The function should also ensure that the input is a list of integers, raising a `ValueError` if any element is not an integer. Additionally, the function should handle large numbers efficien...
def is_prime(n): """ Returns True if n is a prime number, 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 filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 9, 10]) == [] def test_filter_primes_mixed_numbers(): assert filter_primes([4, 5, 6, 7, 9, 11, 13]) == [5, ...
[ { "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 a list containing only the prime numbers from the input list of integers.\nRaises a ValueError if any...
[ 1, 1, 0 ]
2
easy
0.667
{ "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, 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": "00045416", "row_id": 45416, "seed_ids": "['Qwen2.5-72B-Instruct_96946']" }
0.705075
Filter_45416
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f639701c5bc7a9c458069c87b57f816119302563
b51cd0925228baba6c851c913044b32a77772ab4
v1.0
instruct
Filter
Filter_45423_I
How can I create a Python function that checks if a number is a perfect square? I want to use this function to filter a list of numbers and return only those that are perfect squares.
import math def is_perfect_square(n): """ Check if a given number is a perfect square. Parameters: n (int): The number to check. Returns: bool: True if n is a perfect square, False otherwise. """ if n < 0: return False sqrt_n = math.isqrt(n) return sqrt_n * sqr...
from solution import is_perfect_square, filter_perfect_squares def test_is_perfect_square(): assert is_perfect_square(0) == True assert is_perfect_square(1) == True assert is_perfect_square(4) == True assert is_perfect_square(9) == True assert is_perfect_square(16) == True assert is_perfect_squ...
[ { "docstring": "Check if a given number is a perfect square.\n\nParameters:\nn (int): The number to check.\n\nReturns:\nbool: True if n is a perfect square, False otherwise.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { ...
[ 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 is_perfect_square(n):\n \"\"\"\n Checks if a number is a perfect square.\n \"\"\"\n if n < 0:\n return False\n root = int(math.sqrt(n))\n return roo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045423", "row_id": 45423, "seed_ids": "['Qwen2.5-72B-Instruct_96956']" }
0.737701
Filter_45423
I
[ "is_perfect_square", "filter_perfect_squares" ]
2
[ [ "filter_perfect_squares", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3f9182cf3086393182183ea61acbc2445ab389a2
bba9b5cb7ba30cf2746002b274a5121d0d5c613e
v1.0
instruct
Filter
Filter_45427_I
I need to write a program that reads a text file, counts the occurrences of each word, and then outputs the top 10 most frequent words along with their counts. Can you provide a Python script to accomplish this?
from collections import Counter import re def read_file(file_path): """Reads a file and returns its content as a string""" with open(file_path, 'r') as file: return file.read() def count_words(text): """Counts the occurrences of each word in the text""" words = re.findall(r'\b\w+\b', text.lowe...
import pytest from solution import read_file, count_words, top_n_words, top_10_frequent_words from collections import Counter def test_read_file(tmp_path): file_path = tmp_path / "test.txt" file_path.write_text("Hello world! Hello!") content = read_file(file_path) assert content == "Hello world! Hello!...
[ { "docstring": "Reads a file and returns its content as a string", "function_declaration": "def read_file(file_path):", "function_name": "read_file", "parameter_list": "(file_path)" }, { "docstring": "Counts the occurrences of each word in the text", "function_declaration": "def count_wo...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\nimport re\n\ndef read_file(file_path):\n \"\"\"\n Reads the content of the given text file and returns it.\n \"\"\"\n with open(file_path, 'r') as ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045427", "row_id": 45427, "seed_ids": "['Qwen2.5-72B-Instruct_96963']" }
0.693989
Filter_45427
I
[ "read_file", "count_words", "top_n_words", "top_10_frequent_words" ]
4
[ [ "top_10_frequent_words", "count_words" ], [ "top_10_frequent_words", "read_file" ], [ "top_10_frequent_words", "top_n_words" ] ]
3
[]
false
[]
false
pytest
true
[]
true
0bd85d6329048e3d6da9916181848470416849ea
63ba31efaa7655220b44c91e6f3dd8e9609ad2fa
v1.0
instruct
Filter
Filter_45437_I
Write a code snippet in Python to print out the first 100 prime numbers.
def is_prime(n): """ Checks 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 return Tru...
from solution import is_prime, first_n_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(29) == True assert is_prime(30) == False def test_first_n_primes(): assert first_n_primes(1) == [2...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the first n prime numbers.", "function_declaration": "def first_n_primes(n):", "function_name": "first_n_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(n):\n \"\"\"\n Checks if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045437", "row_id": 45437, "seed_ids": "['Qwen2.5-72B-Instruct_96977']" }
0.595837
Filter_45437
I
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f2b79666bfc1c4f598dda0c663c39717703ee97b
671568cae484400b9b83aa43a945fba6aa4ac7f4
v1.0
instruct
Filter
Filter_45449_I
Write a Python function to simulate the rolling of two six-sided dice. The function should return the sum of the two dice. Additionally, implement a feature to simulate the roll multiple times and return a list of the sums. Use the random module for generating random numbers.
import random def roll_two_dice(): """ Simulate rolling two six-sided dice and return the sum of the two dice. """ die1 = random.randint(1, 6) die2 = random.randint(1, 6) return die1 + die2 def roll_multiple_times(n): """ Simulate rolling two six-sided dice `n` times and return a list ...
from solution import roll_two_dice, roll_multiple_times def test_roll_two_dice(): result = roll_two_dice() # The sum should be between 2 and 12 (inclusive) assert 2 <= result <= 12 def test_roll_multiple_times_single_roll(): results = roll_multiple_times(1) assert len(results) == 1 assert 2 <=...
[ { "docstring": "Simulate rolling two six-sided dice and return the sum of the two dice.", "function_declaration": "def roll_two_dice():", "function_name": "roll_two_dice", "parameter_list": "()" }, { "docstring": "Simulate rolling two six-sided dice `n` times and return a list of the sums.",...
[ 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_dice():\n \"\"\"\n Simulates the rolling of two six-sided dice and returns the sum of the two dice.\n \"\"\"\n die1 = random.randint(1, 6)\n die2 = ran...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045449", "row_id": 45449, "seed_ids": "['Qwen2.5-72B-Instruct_96995']" }
0.661391
Filter_45449
I
[ "roll_two_dice", "roll_multiple_times" ]
2
[ [ "roll_multiple_times", "roll_two_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cb9c10d206d51d389a457c97f22f5477adaea755
2fa8da3b994e0759dc9fe1d7c7e5dff6ff502e0f
v1.0
instruct
Filter
Filter_45491_I
I want to create a Python program that simulates a simple dice game. The game should involve two players who each roll a six-sided die. The player with the highest number wins the round. If both players roll the same number, it's a tie. How can I implement this game in Python?
import random def roll_dice(): """ Simulates rolling a six-sided die. """ return random.randint(1, 6) def play_dice_game(): """ Simulates a simple dice game between two players. Returns: result (str): Describes the result of the game. """ player1_roll = roll_dice() ...
from solution import roll_dice, play_dice_game def test_roll_dice(): rolls = [roll_dice() for _ in range(1000)] assert all(1 <= roll <= 6 for roll in rolls) def test_play_dice_game(): outcomes = set() for _ in range(1000): result = play_dice_game() assert "Player 1 wins" in result or "...
[ { "docstring": "Simulates rolling a six-sided die.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates a simple dice game between two players.\n\nReturns:\n result (str): Describes the result of the game.", "f...
[ 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 roll_die():\n \"\"\"\n Simulates rolling a six-sided die.\n Returns an integer between 1 and 6 (inclusive).\n \"\"\"\n return random.randint(1, 6)\n\ndef pl...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045491", "row_id": 45491, "seed_ids": "['Qwen2.5-72B-Instruct_97067']" }
0.473916
Filter_45491
I
[ "roll_dice", "play_dice_game" ]
2
[ [ "play_dice_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed6e650cb1860c2dbbee511803711f2fe5526510
3488c107551df52ac09ff638c445782c574981e5
v1.0
instruct
Filter
Filter_45494_I
Explain how to implement a basic web scraper using Python that can extract data from HTML pages, including handling of pagination and storing the data in a CSV file.
import requests from bs4 import BeautifulSoup import csv def scrape_web_page(url): """ Scrapes data from a given URL and returns it in a list of tuples. """ response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') # Assume we're extracting data from a table da...
from solution import scrape_web_page, handle_pagination def test_scrape_web_page(monkeypatch): class MockResponse: @property def content(self): return """ <html> <body> <table> <tr><td>Data 1</td><td>Data 2</td></tr> ...
[ { "docstring": "Scrapes data from a given URL and returns it in a list of tuples.", "function_declaration": "def scrape_web_page(url):", "function_name": "scrape_web_page", "parameter_list": "(url)" }, { "docstring": "Handles pagination by iterating over a range of pages.", "function_dec...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nfrom bs4 import BeautifulSoup\nimport csv\n\ndef scrape_web_page(url):\n \"\"\"\n Scrapes data from a given URL and returns it in a list of tuples.\n \"\"\"\n resp...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045494", "row_id": 45494, "seed_ids": "['Qwen2.5-72B-Instruct_97071']" }
0.687217
Filter_45494
I
[ "scrape_web_page", "handle_pagination", "save_to_csv", "main" ]
4
[ [ "handle_pagination", "scrape_web_page" ] ]
1
[]
false
[]
false
pytest
true
[ "bs4", "requests" ]
false
a772bf03c2a40b625375405805c86189be23e0d9
b47a0bb62849594f55db4287d85e692f88de598b
v1.0
instruct
Filter
Filter_45532_I
Write a Python function that takes a list of integers as input and returns a new list containing only the integers that are palindromes. A palindromic integer is an integer that remains the same when its digits are reversed. For example, 121 and 4 are palindromic integers, whereas 123 and 20 are not.
def is_palindrome(n): """ Checks if a given integer is a palindrome. """ return str(n) == str(n)[::-1] def filter_palindromes(numbers): """ Returns a list of palindromic integers from the given list of integers. """ return [num for num in numbers if is_palindrome(num)]
from solution import filter_palindromes def test_filter_palindromes_all_palindromes(): assert filter_palindromes([121, 22, 3, 4, 99]) == [121, 22, 3, 4, 99] def test_filter_palindromes_no_palindromes(): assert filter_palindromes([123, 45, 67, 89, 90]) == [] def test_filter_palindromes_mixed_list(): asser...
[ { "docstring": "Checks if a given integer is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Returns a list of palindromic integers from the given list of integers.", "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_palindrome(num):\n \"\"\"\n Helper function to check if a number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef filter_palindromes(int_list):\n \"\"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045532", "row_id": 45532, "seed_ids": "['Qwen2.5-72B-Instruct_97144']" }
0.731912
Filter_45532
I
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f1dfa72bebb1907bad0074bacd14846cfe800923
d53ae29500c689a0c9f4ca35e63ed0b7724cdba7
v1.0
instruct
Filter
Filter_45554_I
Write a Python function that generates a random integer between 1 and 100, and then checks if the number is a prime number. The function should return a tuple containing the generated number and a boolean indicating whether it is a prime number.
import random def is_prime(n): """ Determines if the 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 ...
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(11) == True assert is_prime(20) == False def test_generate_and_check_prime(): for _ in range(100): num, prime_s...
[ { "docstring": "Determines if the number n is prime.", "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 tuple of the generated number...
[ 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 math\n\ndef is_prime(n):\n \"\"\"\n Check if the number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045554", "row_id": 45554, "seed_ids": "['Qwen2.5-72B-Instruct_97180']" }
0.703906
Filter_45554
I
[ "is_prime", "generate_and_check_prime" ]
2
[ [ "generate_and_check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b6c9a4e4df5c97befc3770db8260fa95651f1159
056d9efa07c4bdbf4075876057fc96f60b57444b
v1.0
instruct
Filter
Filter_45555_I
How can I write a Python program that generates a random integer and then checks if it is a prime number? I would like the program to print the number and a message indicating whether it is prime or not.
import random def is_prime(n): """ Determines if given 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: return False ...
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(11) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(...
[ { "docstring": "Determines if given n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a random integer and checks if it is prime.\nPrints the number and a message indicating if it is prime or n...
[ 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 Determines if given n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045555", "row_id": 45555, "seed_ids": "['Qwen2.5-72B-Instruct_97182']" }
0.683705
Filter_45555
I
[ "is_prime", "generate_and_check_prime" ]
2
[ [ "generate_and_check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bad8b2395aeef584a403b7d7ab3c42c3f6bb178f
6acac34f5d11f2179de8f54bf6382adc64dbc19a
v1.0
instruct
Filter
Filter_45570_I
Can you help me with a Python script to automate the process of checking a website's uptime? I want to monitor a list of websites and log the status (up or down) every hour. The log should include the timestamp, website URL, and status.
import requests from datetime import datetime import time def check_website_status(url): """ Check the status of a website. :param url: URL of the website to check :return: tuple of URL and its status ('up' or 'down') """ try: response = requests.get(url, timeout=10) if res...
import os from datetime import datetime, timedelta from solution import check_website_status, log_status, monitor_websites def test_check_website_status_up(monkeypatch): class MockResponse: status_code = 200 monkeypatch.setattr(requests, "get", lambda url, timeout: MockResponse()) assert check_webs...
[ { "docstring": "Check the status of a website.\n\n:param url: URL of the website to check\n:return: tuple of URL and its status ('up' or 'down')", "function_declaration": "def check_website_status(url):", "function_name": "check_website_status", "parameter_list": "(url)" }, { "docstring": "L...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nfrom datetime import datetime\nimport time\nimport logging\n\ndef check_website_status(url):\n \"\"\"\n Checks the status of a given website URL.\n \"\"\"\n try:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045570", "row_id": 45570, "seed_ids": "['Qwen2.5-72B-Instruct_97208']" }
0.531401
Filter_45570
I
[ "check_website_status", "log_status", "monitor_websites" ]
3
[ [ "monitor_websites", "check_website_status" ], [ "monitor_websites", "log_status" ] ]
2
[]
false
[]
false
pytest
true
[ "requests" ]
false
852989a71a44b3ded7d16c32cd8364ba791b2433
d8c138a9e1e0bbd3605e548a61cd7d43c115eb0d
v1.0
instruct
Filter
Filter_45591_I
Write a Python program to find the nth Fibonacci number. The program should be optimized for performance and handle large values of n efficiently. It should also include a function to check the correctness of the computed Fibonacci number using the closed-form expression (Binet's formula). The program should output the...
import time import math def nth_fibonacci(n): """ Returns the nth Fibonacci number using an iterative approach for performance. """ if n <= 0: return 0 elif n == 1: return 1 a, b = 0, 1 for _ in range(2, n+1): a, b = b, a + b return b def is_fibonacci_corre...
from solution import nth_fibonacci, is_fibonacci_correct, fibonacci_with_time def test_nth_fibonacci_base_cases(): assert nth_fibonacci(0) == 0 assert nth_fibonacci(1) == 1 def test_nth_fibonacci_small_values(): assert nth_fibonacci(2) == 1 assert nth_fibonacci(3) == 2 assert nth_fibonacci(4) == 3...
[ { "docstring": "Returns the nth Fibonacci number using an iterative approach for performance.", "function_declaration": "def nth_fibonacci(n):", "function_name": "nth_fibonacci", "parameter_list": "(n)" }, { "docstring": "Checks the correctness of the nth Fibonacci number using Binet's formu...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\nimport math\n\ndef fibonacci(n):\n \"\"\"\n Returns the nth Fibonacci number using an efficient algorithm (iterative approach).\n \"\"\"\n if n <= 0:\n raise Va...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045591", "row_id": 45591, "seed_ids": "['Qwen2.5-72B-Instruct_97241']" }
0.761844
Filter_45591
I
[ "nth_fibonacci", "is_fibonacci_correct", "fibonacci_with_time" ]
3
[ [ "fibonacci_with_time", "nth_fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ab8443d299cdf0522a4492b534ecce92178b94a7
624202ad7d3add5f1a1284ab111a14da792af712
v1.0
instruct
Filter
Filter_45646_I
Write a Python program that converts a given temperature from Celsius to Fahrenheit and vice versa. The user should be able to specify the direction of conversion (Celsius to Fahrenheit or Fahrenheit to Celsius) and the temperature value. The program should then display the converted temperature.
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, direction): """ Converts a given ...
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 convert_temperature(value, to_scale):\n \"\"\"\n Converts a temperature value from Celsius to Fahrenheit or vice versa.\n \n Parameters:\n value (float): The temperature val...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045646", "row_id": 45646, "seed_ids": "['Qwen2.5-72B-Instruct_97334']" }
0.456947
Filter_45646
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
7207c91c8daa829aa73572dd42f73d7daae7bcfb
1ef4bf446751273958be39e87abeebf59b9c7d00
v1.0
instruct
Filter
Filter_45650_I
Can you help me with some coding in Python? I'm trying to create a simple program that converts temperatures from Celsius to Fahrenheit and vice versa. I want to have a menu where the user can choose the conversion direction, and then input the temperature. Can you guide me through writing this program?
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 temperature_conversion(): """ Allows the user to choose the co...
from solution import celsius_to_fahrenheit, fahrenheit_to_celsius 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_celsius(32) == 0 assert...
[ { "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_1
{ "original_instruction": "", "prompt_id": "00045650", "row_id": 45650, "seed_ids": "['Qwen2.5-72B-Instruct_97342']" }
0.449796
Filter_45650
I
[ "celsius_to_fahrenheit", "fahrenheit_to_celsius", "temperature_conversion" ]
3
[ [ "temperature_conversion", "celsius_to_fahrenheit" ], [ "temperature_conversion", "fahrenheit_to_celsius" ] ]
2
[]
false
[]
false
pytest
true
[]
true
57934dcaf397146c1984006a0c45966341028504
af78ded14590021d5a23a734bdfeb88c4e94cc22
v1.0
instruct
Filter
Filter_45665_I
I need to create a Python program that simulates a simple dice game. The game should allow a user to roll a six-sided die and compare the result with a computer's roll. The program should then declare a winner based on who rolls the higher number. How can I write this program?
import random def roll_die(): """ Simulates the roll of a six-sided die. Returns a random integer between 1 and 6. """ return random.randint(1, 6) def determine_winner(player_roll, computer_roll): """ Determines the winner of the dice game based on the rolls. Parameters: playe...
from solution import roll_die, determine_winner def test_roll_die(): for _ in range(100): # Running the dice roll multiple times to test randomness and boundary values. roll = roll_die() assert 1 <= roll <= 6 def test_determine_winner(): assert determine_winner(6, 4) == "Player wins!" ass...
[ { "docstring": "Simulates the roll of a six-sided die.\nReturns a random integer between 1 and 6.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Determines the winner of the dice game based on the rolls.\n\nParameters:\npla...
[ 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 roll_die():\n \"\"\"\n Simulates rolling a six-sided die and returns the result.\n \"\"\"\n return random.randint(1, 6)\n\ndef play_dice_game():\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045665", "row_id": 45665, "seed_ids": "['Qwen2.5-72B-Instruct_97371']" }
0.514834
Filter_45665
I
[ "roll_die", "determine_winner", "play_dice_game" ]
3
[ [ "play_dice_game", "determine_winner" ], [ "play_dice_game", "roll_die" ] ]
2
[]
false
[]
false
pytest
true
[]
true
20dcdc842b9ddd6f3e71bf4804f92e74f109bea4
248278f6e6c2f2411ff265249d0e3c79bb463f42
v1.0
instruct
Filter
Filter_45666_I
Write a Python program to implement a simple linear regression model from scratch. The program should take a set of data points, fit a line to the data using the least squares method, and then predict the value of y for a given x. Additionally, plot the fitted line along with the original data points. Use matplotlib fo...
import matplotlib.pyplot as plt def calculate_means(data): """ Calculate the means of x and y from the given dataset. """ n = len(data) mean_x = sum(x for x, _ in data) / n mean_y = sum(y for _, y in data) / n return mean_x, mean_y def calculate_coefficients(data, mean_x, mean_y): """ ...
from solution import calculate_means, calculate_coefficients, simple_linear_regression, predict, plot_data_and_regression_line def test_calculate_means(): data = [(1, 2), (2, 3), (3, 4)] mean_x, mean_y = calculate_means(data) assert mean_x == 2.0 assert mean_y == 3.0 def test_calculate_coefficients():...
[ { "docstring": "Calculate the means of x and y from the given dataset.", "function_declaration": "def calculate_means(data):", "function_name": "calculate_means", "parameter_list": "(data)" }, { "docstring": "Calculate the slope (m) and the intercept (c) for the linear regression line.", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\n\ndef simple_linear_regression(data):\n \"\"\"\n Performs simple linear regression using the least squares method.\n \n Paramet...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045666", "row_id": 45666, "seed_ids": "['Qwen2.5-72B-Instruct_97375']" }
0.630097
Filter_45666
I
[ "calculate_means", "calculate_coefficients", "simple_linear_regression", "predict", "plot_data_and_regression_line" ]
5
[ [ "plot_data_and_regression_line", "predict" ], [ "simple_linear_regression", "calculate_coefficients" ], [ "simple_linear_regression", "calculate_means" ] ]
3
[]
false
[]
false
pytest
true
[ "matplotlib" ]
false
f43548968ab269fae528396b10a0e177c52ca13f
022833d1a56e742ec15c9d7c583d5fe9d6ee35e2
v1.0
instruct
Filter
Filter_45686_I
Explain how to use the map function in Python to apply a function to all items in a list. Provide an example where the function squares the numbers in the list.
def square(x): """ Returns the square of the given number x. """ return x * x def square_numbers(numbers): """ Applies the square function to all items in the list using map. Args: numbers (list): List of integers to be squared. Returns: list: List containing squares o...
from solution import square, square_numbers def test_square(): assert square(2) == 4 assert square(-2) == 4 assert square(0) == 0 def test_square_numbers(): assert square_numbers([1, 2, 3, 4]) == [1, 4, 9, 16] assert square_numbers([-1, -2, -3, -4]) == [1, 4, 9, 16] assert square_numbers([0, 2...
[ { "docstring": "Returns the square of the given number x.", "function_declaration": "def square(x):", "function_name": "square", "parameter_list": "(x)" }, { "docstring": "Applies the square function to all items in the list using map.\n\nArgs:\nnumbers (list): List of integers to be squared...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def square(x):\n \"\"\"\n Returns the square of x.\n \"\"\"\n return x * x\n\ndef square_numbers_in_list(numbers):\n \"\"\"\n Applies the square function to all items in the ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045686", "row_id": 45686, "seed_ids": "['Qwen2.5-72B-Instruct_97407']" }
0.51822
Filter_45686
I
[ "square", "square_numbers" ]
2
[ [ "square_numbers", "square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
70ba9794504d02f403dd762ebed20699defad0df
56c4b822ea404467585459777656c35bff040f21
v1.0
instruct
Filter
Filter_45692_I
How can I create a Python program to track the stock prices of a specific company and send me an email notification when the price crosses a certain threshold?
import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart import requests import time # Function to get the current stock price def get_stock_price(api_url, symbol): response = requests.get(f"{api_url}?symbol={symbol}") data = response.json() current_price = data['p...
import pytest import requests from unittest.mock import patch from solution import get_stock_price, send_email_notification, track_stock_price @patch('solution.requests.get') def test_get_stock_price(mock_get): mock_get.return_value.json.return_value = {"price": 151.23} price = get_stock_price("https://api.exa...
[ { "docstring": null, "function_declaration": "def get_stock_price(api_url, symbol):", "function_name": "get_stock_price", "parameter_list": "(api_url, symbol)" }, { "docstring": null, "function_declaration": "def send_email_notification(from_email, from_password, to_email, subject, body)...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import smtplib\nimport requests\n\ndef send_email_notification(from_email, from_password, to_email, subject, message):\n try:\n with smtplib.SMTP_SSL('smtp.gmail.com', 465) as server...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045692", "row_id": 45692, "seed_ids": "['Qwen2.5-72B-Instruct_97415']" }
0.438005
Filter_45692
I
[ "get_stock_price", "send_email_notification", "track_stock_price" ]
3
[ [ "track_stock_price", "get_stock_price" ], [ "track_stock_price", "send_email_notification" ] ]
2
[]
false
[]
false
pytest
true
[ "requests" ]
false
90c31e8d31c7c472d35e45e4ccf5144575cdd050
00d5b93cbdb38ea6f5c9c0f4cba028314d7e9e31
v1.0
instruct
Filter
Filter_45714_I
How can I create a Python function that checks if a given number is a prime number? Also, can you show how to use this function to check a list of numbers and return a list of only the prime numbers?
def is_prime(n): """ Check if the given number n is a prime number. :param n: Integer to check for primality. :return: True if n is a prime, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 ...
from solution import is_prime, filter_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 assert is_prime(0) == False...
[ { "docstring": "Check if the given number n is a prime number.\n\n:param n: Integer to check for primality.\n:return: True if n is a prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the 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(n):\n \"\"\"\n Check if a given number is a prime number.\n \n :param n: An integer to be checked.\n :return: True if n is a prime number, False otherwise.\n \"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045714", "row_id": 45714, "seed_ids": "['Qwen2.5-72B-Instruct_97460']" }
0.784432
Filter_45714
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5e27987d0ea1dd97005dcbdf87dd2f4f2dce8d7a
1ff33561bb7b7126cc5977435052e4834a4e7230
v1.0
instruct
Filter
Filter_45719_I
I want to create a simple web application that allows users to upload an image, and the application will display the image and its metadata. I am using Python and Flask. How can I achieve this?
from flask import Flask, request, redirect, url_for, render_template from werkzeug.utils import secure_filename from PIL import Image import os app = Flask(__name__) UPLOAD_FOLDER = 'uploads' ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER def allowed_file(filename): ...
from solution import allowed_file, get_image_metadata import os from PIL import Image def test_allowed_file(): assert allowed_file("image.png") == True assert allowed_file("image.jpg") == True assert allowed_file("image.jpeg") == True assert allowed_file("image.gif") == True assert allowed_file("im...
[ { "docstring": null, "function_declaration": "def allowed_file(filename):", "function_name": "allowed_file", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def get_image_metadata(image_path):", "function_name": "get_image_metadata", "parameter_lis...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, redirect, url_for, render_template\nfrom werkzeug.utils import secure_filename\nfrom PIL import Image\nimport os\n\napp = Flask(__name__)\n\nUPLOAD_FOLDER = '...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045719", "row_id": 45719, "seed_ids": "['Qwen2.5-72B-Instruct_97465']" }
0.368162
Filter_45719
I
[ "allowed_file", "get_image_metadata", "upload_form", "upload_image", "display_uploaded_image" ]
5
[ [ "upload_image", "allowed_file" ], [ "upload_image", "get_image_metadata" ] ]
2
[]
false
[]
false
pytest
true
[ "PIL", "flask", "werkzeug" ]
false
35c76548435771391d1664a171d4656e055053ed
300348817ee0191211ba4eb592d4cc70cc7a2bd6
v1.0
instruct
Filter
Filter_45768_I
Is there a way to implement a function in Python that mimics the behavior of `strtoi` in R, which converts a string to an integer, but also handles non-numeric strings by returning `NaN` or `None`? How can this be done efficiently, and what would be the best way to apply this function to a list of strings?
def strtoi(s): """ Converts a string to an integer. If the string is not numeric, returns None. Params: s (str): The string to convert. Returns: int or None: The integer value of the string, or None if the string is not numeric. """ try: return int(s) except ValueEr...
from solution import strtoi, apply_strtoi def test_strtoi_numeric_string(): assert strtoi("123") == 123 def test_strtoi_non_numeric_string(): assert strtoi("abc") is None def test_strtoi_empty_string(): assert strtoi("") is None def test_strtoi_mixed_string(): assert strtoi("123abc") is None def te...
[ { "docstring": "Converts a string to an integer. If the string is not numeric, returns None.\n\nParams:\ns (str): The string to convert.\n\nReturns:\nint or None: The integer value of the string, or None if the string is not numeric.", "function_declaration": "def strtoi(s):", "function_name": "strtoi",...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def strtoi(s):\n \"\"\"\n Converts a string to an integer. Returns None if the string cannot be converted.\n \"\"\"\n try:\n return int(s)\n except ValueError:\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045768", "row_id": 45768, "seed_ids": "['Qwen2.5-72B-Instruct_97547']" }
0.501386
Filter_45768
I
[ "strtoi", "apply_strtoi" ]
2
[ [ "apply_strtoi", "strtoi" ] ]
1
[]
false
[]
false
pytest
true
[]
true
45df160b764fbf68051dd668b6f45f482e6b6130
bf27d64a06ac2dc949e0b1b0eb8d88987913539e
v1.0
instruct
Filter
Filter_45773_I
Write a Python program that reads a list of words from a text file and prints out the words that are palindromes. A palindrome is a word that reads the same backward as forward, like "madam" or "racecar".
def read_words_from_file(file_path): """ Reads words from a text file and returns them as a list. :param file_path: Path to the text file :return: List of words """ with open(file_path, 'r') as file: return file.read().split() def is_palindrome(word): """ Determines if a wo...
import pytest from solution import read_words_from_file, is_palindrome, find_palindromes def test_read_words_from_file(tmp_path): test_file = tmp_path / "test_file.txt" test_file.write_text("madam racecar apple banana") assert read_words_from_file(test_file) == ["madam", "racecar", "apple", "banana"] def...
[ { "docstring": "Reads words from a text file and returns them as a list.\n\n:param file_path: Path to the text file\n:return: List of words", "function_declaration": "def read_words_from_file(file_path):", "function_name": "read_words_from_file", "parameter_list": "(file_path)" }, { "docstri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_palindromes(file_path):\n \"\"\"\n Reads a list of words from a text file and prints out words that are palindromes.\n \n :param file_path: str, path to the text file.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045773", "row_id": 45773, "seed_ids": "['Qwen2.5-72B-Instruct_97556']" }
0.737305
Filter_45773
I
[ "read_words_from_file", "is_palindrome", "find_palindromes" ]
3
[ [ "find_palindromes", "is_palindrome" ], [ "find_palindromes", "read_words_from_file" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6690083430d114cf989eed5150f0735557a8c48a
00f75a5486b3291eeb66ce3e1bb43c3d8e9a87c4
v1.0
instruct
Filter
Filter_45788_I
I want to build a simple weather app that displays the current weather conditions for a user's location. I'm familiar with Python and have some experience with web development using Flask. How can I get started?
from flask import Flask, request, jsonify import requests app = Flask(__name__) API_KEY = 'your_openweathermap_api_key' # Replace with your actual OpenWeatherMap API key def get_weather(city_name): """ Fetch the weather data from OpenWeatherMap API for the given city name. """ base_url = "http://api...
import pytest from flask import Flask from solution import app, get_weather # Test the get_weather function directly def test_get_weather_valid_city(monkeypatch): class MockResponse: @staticmethod def json(): return { "main": { "temp": 285.32, ...
[ { "docstring": "Fetch the weather data from OpenWeatherMap API for the given city name.", "function_declaration": "def get_weather(city_name):", "function_name": "get_weather", "parameter_list": "(city_name)" }, { "docstring": null, "function_declaration": "def weather():", "function...
[ 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, render_template_string\nimport requests\n\napp = Flask(__name__)\n\nAPI_KEY = 'your_openweather_api_key'\nWEATHER_URL = 'http://api.openweathermap.org/data/2....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045788", "row_id": 45788, "seed_ids": "['Qwen2.5-72B-Instruct_97585']" }
0.383592
Filter_45788
I
[ "get_weather", "weather" ]
2
[ [ "weather", "get_weather" ] ]
1
[]
false
[]
false
pytest
true
[ "flask", "requests" ]
false
e3f1c16a7b868cfbbded5c4c529318dbcf863a40
ee600dba1112ca7d65ad1847d78160a0c249f355
v1.0
instruct
Filter
Filter_45797_I
I have a set of points and I need to calculate the pairwise Euclidean distances between them. I am using Python with NumPy for this task. Can you provide a code snippet that defines a function to calculate the Euclidean distance between two 1D NumPy arrays and demonstrate its usage on a given set of points?
import numpy as np def euclidean_distance(point1, point2): """ Calculate the Euclidean distance between two 1D numpy arrays. Args: point1 (np.ndarray): A 1D numpy array representing the first point. point2 (np.ndarray): A 1D numpy array representing the second point. Returns: floa...
import numpy as np from solution import euclidean_distance, pairwise_distances def test_euclidean_distance(): assert np.isclose(euclidean_distance(np.array([0, 0]), np.array([3, 4])), 5.0) assert np.isclose(euclidean_distance(np.array([1, 1]), np.array([4, 5])), 5.0) assert np.isclose(euclidean_distance(np...
[ { "docstring": "Calculate the Euclidean distance between two 1D numpy arrays.\n\nArgs:\npoint1 (np.ndarray): A 1D numpy array representing the first point.\npoint2 (np.ndarray): A 1D numpy array representing the second point.\n\nReturns:\nfloat: The Euclidean distance between point1 and point2.", "function_...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef euclidean_distance(point1, point2):\n \"\"\"\n Calculate the Euclidean distance between two 1D NumPy arrays (points).\n \n Parameters:\n point1 (np.nda...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00045797", "row_id": 45797, "seed_ids": "['Qwen2.5-72B-Instruct_97601']" }
0.697078
Filter_45797
I
[ "euclidean_distance", "pairwise_distances" ]
2
[ [ "pairwise_distances", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
701400330107c8e4ee1f398b365eae7d33a83650
bbc963c7bd295a1769d92282a576d00cbd5a750f
v1.0
instruct
Filter
Filter_45816_I
How can I convert a .wav audio file to a .mp3 file using Python? I have a large collection of .wav files and I'm looking for an efficient way to do this conversion in bulk.
from pydub import AudioSegment import os def convert_wav_to_mp3(input_path, target_path): """ Converts a .wav file to .mp3 format. :param input_path: Path to the input .wav file. :param target_path: Path to save the converted .mp3 file. """ try: audio = AudioSegment.from_wav(input_...
from solution import convert_wav_to_mp3, bulk_convert_wav_to_mp3 from pydub import AudioSegment import os def test_convert_wav_to_mp3(tmpdir): # Create a temporary .wav file wav_path = os.path.join(tmpdir, "test.wav") audio = AudioSegment.silent(duration=1000) # 1 second of silence audio.export(wav_pa...
[ { "docstring": "Converts a .wav file to .mp3 format.\n\n:param input_path: Path to the input .wav file.\n:param target_path: Path to save the converted .mp3 file.", "function_declaration": "def convert_wav_to_mp3(input_path, target_path):", "function_name": "convert_wav_to_mp3", "parameter_list": "(...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from pydub import AudioSegment\nimport os\n\ndef convert_wav_to_mp3(input_path, target_path):\n \"\"\"\n Converts a .wav file to .mp3 format.\n \n :param input_path: Path to the in...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045816", "row_id": 45816, "seed_ids": "['Qwen2.5-72B-Instruct_97630']" }
0.408307
Filter_45816
I
[ "convert_wav_to_mp3", "bulk_convert_wav_to_mp3" ]
2
[ [ "bulk_convert_wav_to_mp3", "convert_wav_to_mp3" ] ]
1
[]
false
[]
false
pytest
true
[ "pydub" ]
false
6672476a491fd473bb24d9bce5bf2ecdddc4d433
52e59085384e6ec6aaa4a20db60a504f4f7599f2
v1.0
instruct
Filter
Filter_45822_I
I need to create a web application that allows users to upload images and then uses machine learning to identify objects within those images. I'm planning to use Python for the backend and React for the frontend. Can you provide a basic outline of the steps I need to follow to build this application?
# Backend (Flask application) from flask import Flask, request, jsonify from flask_cors import CORS from PIL import Image import io app = Flask(__name__) CORS(app) @app.route('/upload', methods=['POST']) def upload_image(): if 'file' not in request.files: return jsonify({"error": "No file part in the req...
import os from io import BytesIO from PIL import Image import pytest from solution import app # Assumes the Flask app is in a file called solution.py @pytest.fixture def client(): with app.test_client() as client: yield client def test_upload_without_file(client): response = client.post('/upload', da...
[ { "docstring": null, "function_declaration": "def upload_image():", "function_name": "upload_image", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def dummy_image_recognition(image):", "function_name": "dummy_image_recognition", "parameter_list": "(image...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# Backend (Flask application)\n\nfrom flask import Flask, request, jsonify\nfrom flask_cors import CORS\nfrom PIL import Image\nimport io\n\napp = Flask(__name__)\nCORS(app)\n\n@app.route('/up...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045822", "row_id": 45822, "seed_ids": "['Qwen2.5-72B-Instruct_97639']" }
0.259349
Filter_45822
I
[ "upload_image", "dummy_image_recognition" ]
2
[ [ "upload_image", "dummy_image_recognition" ] ]
1
[]
false
[]
false
pytest
true
[ "PIL", "flask", "flask_cors" ]
false
92c8b3c76e5fa620d7a396aadc4df16a799be8d3
8fe6498cd8fb35b2965787e4bc9fd48e58773810
v1.0
instruct
Filter
Filter_45824_I
Write a Python script that takes a directory path as an argument, lists all files in the directory, and then prompts the user to select a file to delete. After the user makes a selection, the script should confirm the deletion and then delete the selected file. If the user selects a non-existent file, the script should...
import os def list_files(directory): """ List all files in the given directory and return them as a list. """ try: files = os.listdir(directory) if not files: print("The directory is empty.") return [] for i, file in enumerate(files): print(f"...
import os import pytest from unittest.mock import patch from solution import list_files, delete_file def test_list_files_empty_directory(tmpdir): files = list_files(tmpdir) assert files == [] def test_list_files_directory_not_found(): files = list_files("/non/existent/directory") assert files == [] d...
[ { "docstring": "List all files in the given directory and return them as a list.", "function_declaration": "def list_files(directory):", "function_name": "list_files", "parameter_list": "(directory)" }, { "docstring": "Deletes the file from the directory given its index in the list.", "f...
[ 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 list_files(directory):\n \"\"\"List files in the given directory\"\"\"\n try:\n files = os.listdir(directory)\n files = [f for f in files if os.path.isfile...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045824", "row_id": 45824, "seed_ids": "['Qwen2.5-72B-Instruct_97641']" }
0.547026
Filter_45824
I
[ "list_files", "delete_file", "main" ]
3
[ [ "delete_file", "list_files" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e0f7f00be6fc6a457cc3d756175e0b8d204187bf
606d66516c005359d6bfbc83dec1e3842532f658
v1.0
instruct
Filter
Filter_45837_I
How can I create a Python script to automate the process of checking the availability of a list of websites and sending an email notification if any of them are down?
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import requests def check_websites(urls): """ Checks the availability of a list of websites. :param urls: List of website URLs to check. :return: List of websites that are down. """ down_websites ...
from solution import check_websites, send_email_notification, check_and_notify import requests from unittest.mock import patch def test_check_websites_all_up(): urls = ["http://example.com", "http://example.org"] with patch('requests.get') as mocked_get: mocked_get.return_value.status_code = 200 ...
[ { "docstring": "Checks the availability of a list of websites.\n:param urls: List of website URLs to check.\n:return: List of websites that are down.", "function_declaration": "def check_websites(urls):", "function_name": "check_websites", "parameter_list": "(urls)" }, { "docstring": "Sends ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import smtplib\nimport requests\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\n\ndef check_website_availability(websites):\n \"\"\"\n Check the av...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045837", "row_id": 45837, "seed_ids": "['Qwen2.5-72B-Instruct_97662']" }
0.584671
Filter_45837
I
[ "check_websites", "send_email_notification", "check_and_notify" ]
3
[ [ "check_and_notify", "check_websites" ], [ "check_and_notify", "send_email_notification" ] ]
2
[]
false
[]
false
pytest
true
[ "requests" ]
false
1b44f6f36f513eb12b105c066a9d5967c97d0c77
c69053eccd45386bf48e1cc7343e44db90777ba8
v1.0
instruct
Filter
Filter_45851_I
Write a code to simulate a simple dice game. The game involves two players, each rolling a six-sided die. The player with the higher number wins. If both roll the same number, it's a tie. The game should be played for a specified number of rounds, and at the end, the program should display the number of wins for each p...
import random def roll_die(): """ Simulate rolling a six-sided die. Returns an integer between 1 and 6, inclusive. """ return random.randint(1, 6) def play_round(): """ Simulate a single round of the dice game. Returns a tuple with the results: (result, player1_roll, player2_roll). ...
from solution import roll_die, play_round, play_game def test_roll_die(): roll = roll_die() assert 1 <= roll <= 6 def test_play_round(): result, player1_roll, player2_roll = play_round() assert 1 <= player1_roll <= 6 assert 1 <= player2_roll <= 6 assert result in [0, 1, 2] if result == 1: ...
[ { "docstring": "Simulate rolling a six-sided die.\nReturns an integer between 1 and 6, inclusive.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Simulate a single round of the dice game.\nReturns a tuple with the results: (...
[ 1, 0, 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_dice():\n \"\"\"\n Simulates rolling a six-sided die.\n Returns a random number between 1 and 6 inclusive.\n \"\"\"\n return random.randint(1, 6)\n\nde...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045851", "row_id": 45851, "seed_ids": "['Qwen2.5-72B-Instruct_97687']" }
0.502485
Filter_45851
I
[ "roll_die", "play_round", "play_game" ]
3
[ [ "play_game", "play_round" ], [ "play_round", "roll_die" ] ]
2
[]
false
[]
false
pytest
true
[]
true
41a3e1fc81112bf230979ae58dccea403046028b
8b0f3bd607d06277de13e34062473df3b5cf859a
v1.0
instruct
Filter
Filter_45892_I
Write a Python program to simulate a simple game of rock, paper, scissors against the computer. The program should allow the user to play a single round and display the result. Use the random module to generate the computer's choice. The program should also keep track of the score and display the final result after the...
import random def get_computer_choice(): """ Randomly generate the computer's choice of 'rock', 'paper', or 'scissors'. """ choices = ['rock', 'paper', 'scissors'] return random.choice(choices) def determine_winner(user_choice, computer_choice): """ Determine the winner between the user an...
from solution import get_computer_choice, determine_winner, play_round def test_get_computer_choice(): for _ in range(100): choice = get_computer_choice() assert choice in ['rock', 'paper', 'scissors'] def test_determine_winner_tie(): assert determine_winner('rock', 'rock') == "It's a tie!" ...
[ { "docstring": "Randomly generate the computer's choice of 'rock', 'paper', or 'scissors'.", "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": "Determine the winner between the user and the computer based on...
[ 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 get_computer_choice():\n choices = [\"rock\", \"paper\", \"scissors\"]\n return random.choice(choices)\n\ndef decide_winner(user_choice, computer_choice):\n if us...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045892", "row_id": 45892, "seed_ids": "['Qwen2.5-72B-Instruct_97753']" }
0.474405
Filter_45892
I
[ "get_computer_choice", "determine_winner", "play_round" ]
3
[ [ "play_round", "determine_winner" ], [ "play_round", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
69b36d85c4e8edf440616e0f0ede1209a52d9020
cf501e2bd97f8ecfe4760b498a1ca28ae6026527
v1.0
instruct
Filter
Filter_45905_I
Write a Python function that generates a list of the first `n` prime numbers. The function should be efficient and work for any positive integer `n`. Use this function to find the 10,000th prime number.
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import is_prime, generate_primes, nth_prime def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(1) assert not is_prime(0) assert not is_prime(-1) assert is_prime(29) assert not is_prime(49) assert...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a list of the first n prime numbers.", "function_declaration": "def generate_primes(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(num):\n \"\"\"\n Helper function to 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 ==...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045905", "row_id": 45905, "seed_ids": "['Qwen2.5-72B-Instruct_97776']" }
0.645863
Filter_45905
I
[ "is_prime", "generate_primes", "nth_prime" ]
3
[ [ "generate_primes", "is_prime" ], [ "nth_prime", "generate_primes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d7a28b51a86b79f8c2266226a5e1928db6f0e034
43792016d4cbe55e06b36f830a9beab0c552b06c
v1.0
instruct
Filter
Filter_45906_I
I need to write a Python script to automate the process of copying a directory from one location to another, including all its subdirectories and files. The script should also log the start and end of the copy process, as well as any errors encountered during the process. Can you provide a Python script that accomplish...
import shutil import os import logging from datetime import datetime def setup_logging(): """ Set up the logging configuration. """ logging.basicConfig( filename='copy_directory.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', ) def copy_directo...
import os import shutil import pytest from solution import copy_directory def test_copy_directory(tmp_path): # Set up source directory src = tmp_path / "src" dst = tmp_path / "dst" src.mkdir() # Create some files and subdirectories in the source directory (src / "file1.txt").write_text("This i...
[ { "docstring": "Set up the logging configuration.", "function_declaration": "def setup_logging():", "function_name": "setup_logging", "parameter_list": "()" }, { "docstring": "Copy the contents of the directory from src to dst.\nLogs the start and end of the process and any errors encountere...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import shutil\nimport os\nimport logging\nfrom datetime import datetime\n\n# Set up logging\nlogging.basicConfig(filename='file_copy.log', level=logging.INFO, \n format='%(a...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045906", "row_id": 45906, "seed_ids": "['Qwen2.5-72B-Instruct_97783']" }
0.653276
Filter_45906
I
[ "setup_logging", "copy_directory" ]
2
[ [ "copy_directory", "setup_logging" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d9cf2c3344168925129232adf23566076d3b3319
9d8c6836bed076f4098d0598159c1ee7017d5522
v1.0
instruct
Filter
Filter_45931_I
Write a Python function that checks if a given number is even or odd. The function should return `True` if the number is even, and `False` if the number is odd. Additionally, create a function that uses the even-odd check to filter a list of integers, returning only the even numbers. Ensure your code is well-documented...
def is_even(number): """ Check if the given number is even. Args: number (int): The number to check. Returns: bool: True if the number is even, False if the number is odd. """ return number % 2 == 0 def filter_even_numbers(numbers): """ Filter the given list of numbers...
from solution import is_even, filter_even_numbers def test_is_even_even_number(): assert is_even(2) == True assert is_even(0) == True assert is_even(-4) == True def test_is_even_odd_number(): assert is_even(1) == False assert is_even(-3) == False def test_filter_even_numbers_mixed_numbers(): ...
[ { "docstring": "Check if the given number is even.\n\nArgs:\nnumber (int): The number to check.\n\nReturns:\nbool: True if the number is even, False if the number is odd.", "function_declaration": "def is_even(number):", "function_name": "is_even", "parameter_list": "(number)" }, { "docstrin...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_even(number):\n \"\"\"\n Checks if a given number is even.\n \n Parameters:\n number (int): The number to check.\n \n Returns:\n bool: True if the number is even...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045931", "row_id": 45931, "seed_ids": "['Qwen2.5-72B-Instruct_97822']" }
0.782444
Filter_45931
I
[ "is_even", "filter_even_numbers" ]
2
[ [ "filter_even_numbers", "is_even" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b78704146ceaddc5c31f94392cc5ddb4e36f544
b84eb2be800baf508a150f4c067e5189bcc6c1ef
v1.0
instruct
Filter
Filter_45946_I
Write a Python program that prompts the user to input a positive integer and then checks whether the number is a prime number. If the number is a prime, the program should print "The number is a prime number." Otherwise, it should print "The number is not a prime number." Make sure to include error handling for non-int...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False elif n <= 3: return True elif 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...
from solution import is_prime def test_is_prime_with_prime_numbers(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(13) == True assert is_prime(17) == True def test_is_prime_with_non_prime_numbers(): assert is_prime(1) == False assert is_prime(4) == False assert is_...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Prompts the user for input, checks if the input is a prime number.\nPrints appropriate message based on ...
[ 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 elif n <= 3:\n return True\n elif n % 2...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045946", "row_id": 45946, "seed_ids": "['Qwen2.5-72B-Instruct_97845']" }
0.743094
Filter_45946
I
[ "is_prime", "check_prime" ]
2
[ [ "check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f6c4604cab4280a0ec77e98c3194647fd02b4e6
a84ec9901d92076f6c8f215099bfd93d2045c88e
v1.0
instruct
Filter
Filter_45960_I
Can you help me write a Python script to find and print all prime numbers between 1 and a given number `n`? I want to use this script to better understand how prime numbers are identified and to improve my Python skills. Please include comments in the code to help me understand each step.
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while (i * i) <= num: if num % i == 0 or num % (i + 2) == 0: return False i...
from solution import is_prime, find_primes def test_is_prime(): # Test small numbers assert is_prime(1) == False assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False # Test larger prime numbers assert is_prime(29) == True assert is_prime(97) == True ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of all prime numbers from 1 to n (inclusive).", "function_declaration": "def find_primes(n):", "functi...
[ 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 Determines if a number is prime.\n Args:\n num (int): The number to check.\n \n Returns:\n bool: True if the number is prime, otherwise False...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045960", "row_id": 45960, "seed_ids": "['Qwen2.5-72B-Instruct_97864']" }
0.654286
Filter_45960
I
[ "is_prime", "find_primes" ]
2
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b43c1b811f2222d88d2215fa836aa00c61850375
d98da58b76eb3be25f8439d6d178d6a558e5f13e
v1.0
instruct
Filter
Filter_45972_I
How can I implement a basic natural language processing (NLP) pipeline using Python?
import re from collections import Counter from typing import List, Tuple def normalize_text(text: str) -> str: """ Normalize text by converting to lowercase and removing non-alphanumeric characters. """ text = text.lower() # Convert to lowercase text = re.sub(r'[^a-z0-9\s]', '', text) # Remove no...
from solution import normalize_text, tokenize, remove_stopwords, word_frequencies, nlp_pipeline from collections import Counter def test_normalize_text(): assert normalize_text("Hello, World!") == "hello world" assert normalize_text("Python is great.") == "python is great" def test_tokenize(): assert toke...
[ { "docstring": "Normalize text by converting to lowercase and removing non-alphanumeric characters.", "function_declaration": "def normalize_text(text):", "function_name": "normalize_text", "parameter_list": "(text)" }, { "docstring": "Tokenize the text into individual words.", "function...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import nltk\nfrom nltk.corpus import stopwords\nfrom nltk.tokenize import word_tokenize\nfrom nltk.stem import PorterStemmer\nfrom sklearn.feature_extraction.text import CountVectorizer\nnltk....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045972", "row_id": 45972, "seed_ids": "['Qwen2.5-72B-Instruct_97896']" }
0.470373
Filter_45972
I
[ "normalize_text", "tokenize", "remove_stopwords", "word_frequencies", "nlp_pipeline" ]
5
[ [ "nlp_pipeline", "normalize_text" ], [ "nlp_pipeline", "remove_stopwords" ], [ "nlp_pipeline", "tokenize" ], [ "nlp_pipeline", "word_frequencies" ] ]
4
[]
false
[]
false
pytest
true
[]
true
ec12ad1074ffea9607738a50c0bee286db05f5fd
6c2017956f064cdf7e5b2551db9d376412dac59f
v1.0
instruct
Filter
Filter_45975_I
Can you help me with a Python script that can convert a CSV file to a JSON file? I want to make sure it handles large files efficiently and maintains the integrity of the data.
import csv import json def csv_to_json(csv_file_path, json_file_path, chunk_size=1000): """ Converts a CSV file to a JSON file in chunks to handle large files efficiently. Args: - csv_file_path (str): The path to the CSV file. - json_file_path (str): The path to the JSON file. - chunk_size...
import os import json import pytest from solution import csv_to_json def test_csv_to_json_small_file(): csv_file_path = 'test_small.csv' json_file_path = 'test_small.json' # Create a small CSV file with open(csv_file_path, mode='w', encoding='utf-8') as file: file.write("name,age\n") ...
[ { "docstring": "Converts a CSV file to a JSON file in chunks to handle large files efficiently.\n\nArgs:\n- csv_file_path (str): The path to the CSV file.\n- json_file_path (str): The path to the JSON file.\n- chunk_size (int): The number of lines to read at a time.", "function_declaration": "def csv_to_jso...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport json\n\ndef csv_to_json(csv_file_path, json_file_path, chunk_size=1000):\n \"\"\"\n Converts a CSV file to a JSON file in chunks to handle large files efficiently.\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045975", "row_id": 45975, "seed_ids": "['Qwen2.5-72B-Instruct_97900']" }
0.704938
Filter_45975
I
[ "csv_to_json", "_read_in_chunks" ]
2
[ [ "csv_to_json", "_read_in_chunks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e0c7c9b21a3e629d73aa7e390e301be4c58909ef
d989ef5e64e33bf76a833bd05419182fe11e7940
v1.0
instruct
Filter
Filter_45988_I
Write a Python function that implements a simple spell checker using a given dictionary of correctly spelled words. The function should take a word as input and return the closest word from the dictionary if the input word is not found in the dictionary. If the input word is correctly spelled, it should return the word...
def levenshtein_distance(a, b): """ Returns the Levenshtein distance between two strings a and b. """ n, m = len(a), len(b) if n > m: a, b = b, a n, m = m, n current_row = range(n+1) for i in range(1, m+1): previous_row, current_row = current_row, [i]+[0]*n f...
from solution import closest_word def test_word_in_dictionary(): dictionary = {"apple", "banana", "orange", "pear", "grape"} assert closest_word("apple", dictionary) == "apple" assert closest_word("banana", dictionary) == "banana" def test_word_not_in_dictionary(): dictionary = {"apple", "banana", "or...
[ { "docstring": "Returns the Levenshtein distance between two strings a and b.", "function_declaration": "def levenshtein_distance(a, b):", "function_name": "levenshtein_distance", "parameter_list": "(a, b)" }, { "docstring": "Returns the closest word from the dictionary if the input word is ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import difflib\n\ndef levenshtein_distance(s1, s2):\n if len(s1) < len(s2):\n return levenshtein_distance(s2, s1)\n\n if len(s2) == 0:\n return len(s1)\n\n previous_row ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00045988", "row_id": 45988, "seed_ids": "['Qwen2.5-72B-Instruct_97921']" }
0.589266
Filter_45988
I
[ "levenshtein_distance", "closest_word" ]
2
[ [ "closest_word", "levenshtein_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e43adf25074232bba11e447df30507d4585ed806
91d45bf2e302c58b63ef3515ee6233e2eed7b9f3
v1.0
instruct
Filter
Filter_45996_I
Write a Python function to find the maximum product of two numbers in a list of integers. The function should be named `max_product_of_two` and take a single argument, a list of integers. The function should return the maximum product of any two numbers from the list. Ensure to include a docstring that briefly describe...
def max_product_of_two(nums): """ Returns the maximum product of any two numbers from the list of integers. Parameters: nums (list): A list of integers. Returns: int: The maximum product of any two numbers in nums. """ if len(nums) < 2: raise ValueError("List must conta...
from solution import max_product_of_two def test_max_product_of_two(): assert max_product_of_two([1, 2, 3, 4]) == 12 assert max_product_of_two([-10, -10, 1, 3, 2]) == 100 assert max_product_of_two([-1, -3, -4, 2, 0]) == 12 assert max_product_of_two([5, 1, 2, 6, -1, -3]) == 30 assert max_product_of_...
[ { "docstring": "Returns the maximum product of any two numbers from the list of integers.\n\nParameters:\nnums (list): A list of integers.\n\nReturns:\nint: The maximum product of any two numbers in nums.", "function_declaration": "def max_product_of_two(nums):", "function_name": "max_product_of_two", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_product_of_two(nums):\n \"\"\"\n Returns the maximum product of any two numbers from the list of integers.\n \n Parameters:\n nums (list): A list of integers.\n \n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00045996", "row_id": 45996, "seed_ids": "['Qwen2.5-72B-Instruct_97935']" }
0.762124
Filter_45996
I
[ "max_product_of_two", "verify_solution" ]
2
[ [ "verify_solution", "max_product_of_two" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9b01d474165892bceefc54475c46ded3816de535
3030801d04bc075ca9f303741cce1d04f1527655
v1.0
instruct
Filter
Filter_46022_I
I need to create a Python script that will automatically send an email when a specific condition is met. Can you guide me on how to set this up, including the necessary libraries and a basic example?
import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart def send_email(subject, body, to_email, from_email, from_password, smtp_server, smtp_port): """ Send an email with the specified subject and body to the given email address. """ msg = MIMEMultipart() ...
import pytest from unittest.mock import Mock, patch from solution import send_email, check_condition_and_send_email @pytest.fixture def email_settings(): return { "to_email": "to@example.com", "from_email": "from@example.com", "from_password": "password", "smtp_server": "smtp.exampl...
[ { "docstring": "Send an email with the specified subject and body to the given email address.", "function_declaration": "def send_email(subject, body, to_email, from_email, from_password, smtp_server, smtp_port):", "function_name": "send_email", "parameter_list": "(subject, body, to_email, from_emai...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import smtplib\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\n\ndef send_email(subject, body, to_email, from_email, smtp_server, smtp_port, username, pa...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00046022", "row_id": 46022, "seed_ids": "['Qwen2.5-72B-Instruct_97976']" }
0.534504
Filter_46022
I
[ "send_email", "check_condition_and_send_email" ]
2
[ [ "check_condition_and_send_email", "send_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
adfaff1f1821682900db58f0d0cfce3c116fc031
6bf9e9bd943d86c1a0c2101ae3f06a4ce1afe138
v1.0
instruct
Filter
Filter_46033_I
Write a Python program to implement a simple command-line calculator that can perform basic arithmetic operations: addition, subtraction, multiplication, and division. The user should be able to input two numbers and select the operation they wish to perform. The program should then display the result. Ensure the progr...
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: raise ValueError("Cannot divide by zero.") return a / b def calculator(): try: a = float(input("Enter the first number: ")) b = float(input("Ente...
import pytest from solution import add, subtract, multiply, divide def test_add(): assert add(1, 1) == 2 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(1, 1) == 0 assert subtract(1, -1) == 2 assert subtract(0, 0) == 0 def test_multiply(): assert multiply...
[ { "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...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculator():\n \"\"\"\n A simple command-line calculator that performs basic arithmetic operations.\n \"\"\"\n try:\n num1 = float(input(\"Enter the first number: \"))\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046033", "row_id": 46033, "seed_ids": "['Qwen2.5-72B-Instruct_97997']" }
0.612446
Filter_46033
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
e352fe5c167c746b555125bbe6ba2a5f4c5cb223
eb9c3724903c1a2f214dbbd0fbd738c364fe843c
v1.0
instruct
Filter
Filter_46038_I
I need to design a Python script that can read a list of URLs from a text file, download the HTML content of each URL, and then save each page as a separate file. How can I do this? I want to ensure that the script handles errors gracefully, such as when a URL is unreachable or the file cannot be written.
import os import requests def read_urls(file_path): """ Reads URLs from a given file. Each line in the file should contain one URL. """ with open(file_path, 'r') as file: urls = [line.strip() for line in file if line.strip()] return urls def download_html(url): """ Downloads the HT...
import os import pytest from unittest.mock import patch, mock_open, call from solution import read_urls, download_html, save_html, process_urls def test_read_urls(): test_data = "https://example.com\nhttps://example.org\n" with patch("builtins.open", mock_open(read_data=test_data)) as mock_file: result...
[ { "docstring": "Reads URLs from a given file. Each line in the file should contain one URL.", "function_declaration": "def read_urls(file_path):", "function_name": "read_urls", "parameter_list": "(file_path)" }, { "docstring": "Downloads the HTML content from the given URL. Returns the HTML ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport requests\n\ndef read_urls(file_path):\n \"\"\"\n Reads URLs from a given file. Each line in the file should contain one URL.\n \"\"\"\n with open(file_path, 'r') ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00046038", "row_id": 46038, "seed_ids": "['Qwen2.5-72B-Instruct_98003']" }
0.591794
Filter_46038
I
[ "read_urls", "download_html", "save_html", "process_urls" ]
4
[ [ "process_urls", "download_html" ], [ "process_urls", "read_urls" ], [ "process_urls", "save_html" ] ]
3
[]
false
[]
false
pytest
true
[ "requests" ]
false
3c1e0977f2f8ceede22f9a5453466f511c190de1
4999b09503f5f402bf06c9be633c92aae346e635
v1.0
instruct
Filter
Filter_46049_I
How can I create a Python script that generates random names and addresses for a list of 100 fictional characters? The names should be a combination of a random first name and a random last name, and the addresses should include a house number, street name, city, and country. How can I ensure that the generated names a...
import random # Sample data for realistic generation FIRST_NAMES = ["John", "Jane", "Alice", "Bob", "Charlie", "Eve", "Mallory", "Oscar", "Peggy", "Trent"] LAST_NAMES = ["Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia", "Miller", "Martinez", "Davis", "Lopez"] STREET_NAMES = ["Main St", "High St", "Broadway",...
from solution import generate_random_name, generate_random_address, generate_100_characters # Test the random name generation function def test_generate_random_name(): name = generate_random_name() assert isinstance(name, str) first_name, last_name = name.split() assert first_name in ["John", "Jane", "...
[ { "docstring": "Generates a random name by combining a random first name and a random last name.", "function_declaration": "def generate_random_name():", "function_name": "generate_random_name", "parameter_list": "()" }, { "docstring": "Generates a random address consisting of a house number...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_random_name():\n first_names = [\"John\", \"Jane\", \"Alex\", \"Emily\", \"Chris\", \"Katie\", \"Michael\", \"Sarah\", \"David\", \"Laura\"]\n last_names = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046049", "row_id": 46049, "seed_ids": "['Qwen2.5-72B-Instruct_98017']" }
0.508508
Filter_46049
I
[ "generate_random_name", "generate_random_address", "generate_random_characters", "generate_100_characters" ]
4
[ [ "generate_100_characters", "generate_random_characters" ], [ "generate_random_characters", "generate_random_address" ], [ "generate_random_characters", "generate_random_name" ] ]
3
[]
false
[]
false
pytest
true
[]
true
dbc7e1a2d72f0258fd15fd2396a93c8370c9162f
1d5abf87aeaa6436f135117f51897306fca16384
v1.0
instruct
Filter
Filter_46085_I
Write a Python function to simulate the roll of two six-sided dice. The function should return the sum of the two dice. Additionally, implement a function to simulate rolling these dice 1000 times and return the frequency of each possible sum.
import random def roll_two_dice(): """ Simulate the roll of two six-sided dice and return the sum. """ die1 = random.randint(1, 6) die2 = random.randint(1, 6) return die1 + die2 def simulate_dice_rolls(n): """ Simulate rolling two six-sided dice `n` times and return the frequency ...
from solution import roll_two_dice, simulate_dice_rolls def test_roll_two_dice(): for _ in range(100): result = roll_two_dice() assert 2 <= result <= 12 def test_simulate_dice_rolls_length(): n = 1000 frequency = simulate_dice_rolls(n) assert len(frequency) == 11 # There are 11 possib...
[ { "docstring": "Simulate the roll of two six-sided dice and return the sum.", "function_declaration": "def roll_two_dice():", "function_name": "roll_two_dice", "parameter_list": "()" }, { "docstring": "Simulate rolling two six-sided dice `n` times and return the frequency \nof each possible ...
[ 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 roll_two_dice():\n \"\"\"\n Simulates rolling two six-sided dice and returns the sum of the two dice.\n \"\"\"\n die1 = random.randint(1, 6)\n die2 = random...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00046085", "row_id": 46085, "seed_ids": "['Qwen2.5-72B-Instruct_98080']" }
0.688018
Filter_46085
I
[ "roll_two_dice", "simulate_dice_rolls" ]
2
[ [ "simulate_dice_rolls", "roll_two_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
608752bc9477a1961ba591b3e44761e7b4f5a180
75fe58a457fda7c488d72136aea8274770a14ac8
v1.0
instruct
Filter
Filter_46104_I
How can I create a Python function that checks if a given number is a prime number? I want to use this function to find all prime numbers up to a certain limit. Can you also show me how to use this function to generate a list of prime numbers up to 100?
def is_prime(n): """ Checks if a given number n is a prime number. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def primes_up_to(limit): """ Returns a list of all prime numbers up to the given limit. ...
from solution import is_prime, 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(11) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_primes_up_to(): a...
[ { "docstring": "Checks if a given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers up to the given limit.", "function_declaration": "def primes_up_to(limit...
[ 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 Checks if a given number n is a prime number.\n \n Args:\n n (int): The number to check for primality.\n \n Returns:\n bool: True if n is a ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046104", "row_id": 46104, "seed_ids": "['Qwen2.5-72B-Instruct_98107']" }
0.738739
Filter_46104
I
[ "is_prime", "primes_up_to" ]
2
[ [ "primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1ffea3715f726a653486e1160019a9b4f752360c
66e809d6d5db64f61c1ad53408ffe9bcdcda5dfc
v1.0
instruct
Filter
Filter_46116_I
Create a Python program that simulates a simple game of rock-paper-scissors. The game should allow a human player to play against the computer. The computer's choice should be randomly generated. The game should keep track of the score and allow the player to play multiple rounds until they choose to quit. After each r...
import random def get_computer_choice(): """ Randomly generates the computer's choice of 'rock', 'paper', or 'scissors'. """ return random.choice(['rock', 'paper', 'scissors']) def get_winner(player_choice, computer_choice): """ Determines the winner of a rock-paper-scissors game round. Re...
from solution import get_computer_choice, get_winner, play_round def test_get_computer_choice(): choices = ['rock', 'paper', 'scissors'] for _ in range(100): assert get_computer_choice() in choices def test_get_winner(): assert get_winner('rock', 'scissors') == 'player' assert get_winner('scis...
[ { "docstring": "Randomly generates the computer's choice of 'rock', 'paper', or 'scissors'.", "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": "Determines the winner of a rock-paper-scissors game round.\nRe...
[ 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 get_computer_choice():\n choices = ['rock', 'paper', 'scissors']\n return random.choice(choices)\n\ndef determine_winner(player_choice, computer_choice):\n if pla...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046116", "row_id": 46116, "seed_ids": "['Qwen2.5-72B-Instruct_98123']" }
0.505675
Filter_46116
I
[ "get_computer_choice", "get_winner", "play_round", "play_game" ]
4
[ [ "play_game", "play_round" ], [ "play_round", "get_computer_choice" ], [ "play_round", "get_winner" ] ]
3
[]
false
[]
false
pytest
true
[]
true
88a4082481edd76638b8b5eada5bf3ef87f21eef
287258b35854e7a2405b08a5e4dd2f7db014e0b6
v1.0
instruct
Filter
Filter_46132_I
Write a Python function that takes a list of integers and returns a new list containing only the elements that are prime numbers. The function should efficiently check for primality, especially for larger numbers. Ensure your solution is optimized for performance. Additionally, include a brief explanation of your appro...
def is_prime(n): """ Helper function to 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 r...
from solution import filter_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(30) == False assert is_prime(97) == True assert is_prime(1) == False assert is_prime(0) == Fals...
[ { "docstring": "Helper function to check if a number is prime ", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the input list.\n\n:param numbers: List[int] - a list of ...
[ 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 Checks if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046132", "row_id": 46132, "seed_ids": "['Qwen2.5-72B-Instruct_98145']" }
0.737637
Filter_46132
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ffe7cf40a3498b644c707e62f46d02acb5a4ab74
1bfae865abf9f415c80680ece146a64e8f87a78e
v1.0
instruct
Filter
Filter_46134_I
Design a Python function that, given a list of strings, returns a new list containing only the strings that are palindromes. A palindrome is a word that reads the same backward as forward, such as "radar" or "level". The function should ignore case sensitivity and any non-alphanumeric characters when determining if a s...
import re def is_palindrome(s): """ Check if the string s is a palindrome. Ignore case sensitivity and non-alphanumeric characters. """ s = re.sub(r'[^A-Za-z0-9]', '', s).lower() return s == s[::-1] def filter_palindromes(strings): """ Given a list of strings, return a new list contain...
from solution import filter_palindromes def test_empty_list(): assert filter_palindromes([]) == [] def test_no_palindromes(): assert filter_palindromes(["hello", "world"]) == [] def test_all_palindromes(): assert filter_palindromes(["radar", "level", "deified"]) == ["radar", "level", "deified"] def test...
[ { "docstring": "Check if the string s is a palindrome.\nIgnore case sensitivity and non-alphanumeric characters.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Given a list of strings, return a new list containi...
[ 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 Helper function to check if a given string is a palindrome.\n It ignores case sensitivity and any non-alphanumeric characters.\n \"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046134", "row_id": 46134, "seed_ids": "['Qwen2.5-72B-Instruct_98147']" }
0.763464
Filter_46134
I
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a47a40d31a2903d2ab7a280407645008389e0d18
e387b90e0cf4c8d88f12c47f0ccfb9a6f660cdb9
v1.0
instruct
Filter
Filter_46147_I
Write a Python function that simulates the rolling of a fair six-sided die. The function should return a random integer between 1 and 6, inclusive, each time it is called. Use the `random` module for generating the random numbers. Additionally, create a second function that rolls the die multiple times (the number of t...
import random def roll_die(): """ Simulates rolling a fair six-sided die and returns the outcome. """ return random.randint(1, 6) def roll_die_multiple(times): """ Rolls the die a specified number of times and returns a list of outcomes. Args: times (int): The number of times to r...
from solution import roll_die, roll_die_multiple def test_roll_die(): outcome = roll_die() assert 1 <= outcome <= 6 def test_roll_die_multiple_single_roll(): outcomes = roll_die_multiple(1) assert len(outcomes) == 1 assert 1 <= outcomes[0] <= 6 def test_roll_die_multiple_five_rolls(): outcome...
[ { "docstring": "Simulates rolling a fair six-sided die and returns the outcome.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Rolls the die a specified number of times and returns a list of outcomes.\n\nArgs:\ntimes (int):...
[ 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 roll_die():\n \"\"\"\n Simulates the rolling of a fair six-sided die and returns a random integer between 1 and 6, inclusive.\n \"\"\"\n return random.randint(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046147", "row_id": 46147, "seed_ids": "['Qwen2.5-72B-Instruct_98184']" }
0.62271
Filter_46147
I
[ "roll_die", "roll_die_multiple" ]
2
[ [ "roll_die_multiple", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
db7d402cb24f138542adf8938a6003a911706df3
794957aee8bf6dc4cfa91625ae17043eccf26b30
v1.0
instruct
Filter
Filter_46153_I
Write a Python script that accepts user input for a filename, then reads the content of the file, and prints the number of words in the file. Ensure to handle the case where the file does not exist.
def count_words_in_file(filename): """ Reads the content of the specified file and returns the number of words in the file. If the file does not exist, raises a FileNotFoundError. :param filename: The name of the file to read. :return: The number of words in the file. """ try: with ...
import pytest from solution import count_words_in_file def test_count_words_in_existing_file(tmpdir): # Create a temporary text file file = tmpdir.join("testfile.txt") file.write("Hello world\nThis is a test file\n") # Test the function assert count_words_in_file(str(file)) == 7 def test_coun...
[ { "docstring": "Reads the content of the specified file and returns the number of words in the file.\nIf the file does not exist, raises a FileNotFoundError.\n\n:param filename: The name of the file to read.\n:return: The number of words in the file.", "function_declaration": "def count_words_in_file(filena...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_words_in_file(filename):\n \"\"\"\n Counts the number of words in a given file.\n \n Args:\n filename (str): The name of the file to read.\n \n Returns:\n int...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00046153", "row_id": 46153, "seed_ids": "['Qwen2.5-72B-Instruct_98192']" }
0.670446
Filter_46153
I
[ "count_words_in_file", "get_filename_and_count_words" ]
2
[ [ "get_filename_and_count_words", "count_words_in_file" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7b8603913b96a908bd432e8e69b52b8e9b44d1ca
22e8620fb53fa1a6787a7f243432e7f70f2145b0
v1.0
instruct
Filter
Filter_46203_I
How can I implement a basic facial recognition system using Python and OpenCV?
import cv2 def initialize_face_detector(): """ Initialize the OpenCV face detector using the pre-trained Haar-Cascade model. """ face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml') return face_cascade def detect_faces(image, face_cascade): """ ...
import pytest import cv2 import numpy as np from solution import initialize_face_detector, detect_faces, draw_faces def test_initialize_face_detector(): face_cascade = initialize_face_detector() assert isinstance(face_cascade, cv2.CascadeClassifier), "Face detector should be an instance of cv2.CascadeClassifie...
[ { "docstring": "Initialize the OpenCV face detector using the pre-trained Haar-Cascade model.", "function_declaration": "def initialize_face_detector():", "function_name": "initialize_face_detector", "parameter_list": "()" }, { "docstring": "Detect faces in an image using the specified face ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import cv2\nimport face_recognition\n\ndef load_image(file_path):\n \"\"\"\n Loads an image file into a numpy array.\n \"\"\"\n return face_recognition.load_image_file(file_path)\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046203", "row_id": 46203, "seed_ids": "['Qwen2.5-72B-Instruct_98270']" }
0.424186
Filter_46203
I
[ "initialize_face_detector", "detect_faces", "draw_faces", "run_face_detection" ]
4
[ [ "run_face_detection", "detect_faces" ], [ "run_face_detection", "draw_faces" ], [ "run_face_detection", "initialize_face_detector" ] ]
3
[]
false
[]
false
pytest
true
[ "cv2", "numpy" ]
false
516cf42b2b5ed48ce6ff0ed755eb94bfb657aa6d
bf3faa0098a3400f1e4dbd9f344701bf9e4ef6a3
v1.0
instruct
Filter
Filter_46211_I
How can I make a simple web application using Flask that displays a form where users can input their name and email, and upon submission, the application sends a greeting email to the user's email address?
from flask import Flask, request, render_template_string import smtplib from email.mime.text import MIMEText app = Flask(__name__) @app.route('/', methods=['GET', 'POST']) def home(): if request.method == 'POST': name = request.form['name'] email = request.form['email'] send_greeting_email...
import pytest from unittest.mock import patch from solution import app, send_greeting_email @pytest.fixture def client(): with app.test_client() as client: yield client def test_home_page(client): """Test GET request to home page.""" response = client.get('/') assert response.status_code == 20...
[ { "docstring": null, "function_declaration": "def home():", "function_name": "home", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def send_greeting_email(name, email):", "function_name": "send_greeting_email", "parameter_list": "(name, email)" } ]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, render_template_string, redirect, url_for, flash\nfrom flask_mail import Mail, Message\n\napp = Flask(__name__)\n\n# Configuration for Flask-Mail\napp.config[...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046211", "row_id": 46211, "seed_ids": "['Qwen2.5-72B-Instruct_98280']" }
0.629872
Filter_46211
I
[ "home", "send_greeting_email" ]
2
[ [ "home", "send_greeting_email" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
285787fa7859b02bed97a427c5ee4a69923aa619
c8746795c01a780ee28a62a4c135719930482815
v1.0
instruct
Filter
Filter_46221_I
Design a Python program that creates a new list based on an input list of integers. For each element in the input list, if the element is a prime number, the new list should contain the next prime number. If the element is not a prime number, the new list should contain the previous prime number. The program should eff...
import math def is_prime(n): if n <= 1: return False if n == 2 or 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 return True def next_prime(n): ...
from solution import transform_list def test_mixed_elements(): assert transform_list([4, 5, 6, 7, 8]) == [3, 7, 5, 11, 7] def test_primes_only(): assert transform_list([2, 3, 5, 7]) == [3, 5, 7, 11] def test_non_primes_only(): assert transform_list([4, 6, 8, 9, 10]) == [3, 5, 7, 7, 7] def test_non_integ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def next_prime(n):", "function_name": "next_prime", "parameter_list": "(n)" }, { "docstring": null, "...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Returns True if n is a prime number, else False.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046221", "row_id": 46221, "seed_ids": "['Qwen2.5-72B-Instruct_98298']" }
0.658902
Filter_46221
I
[ "is_prime", "next_prime", "previous_prime", "transform_list" ]
4
[ [ "next_prime", "is_prime" ], [ "previous_prime", "is_prime" ], [ "transform_list", "is_prime" ], [ "transform_list", "next_prime" ], [ "transform_list", "previous_prime" ] ]
5
[]
false
[]
false
pytest
true
[]
true
15097a15151f20ac29c3f73c19ba2426f7eaaf14
f36b376c58799572e8a3fe7bc5330e4450df3f83
v1.0
instruct
Filter
Filter_46235_I
Design a Python program to check if a given number is a prime number. The program should also include a function to generate a list of all prime numbers up to a given number. The solution should be efficient and well-commented for clarity.
def is_prime(n): """ Check if the given number is a prime number. Parameters: n (int): Number to be checked Returns: bool: 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 ...
from solution import is_prime, generate_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_generate_primes():...
[ { "docstring": "Check if the given number is a prime number.\n\nParameters:\nn (int): Number to be checked\n\nReturns:\nbool: True if n is a prime number, False otherwise", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Gen...
[ 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 given number n is a prime number.\n A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046235", "row_id": 46235, "seed_ids": "['Qwen2.5-72B-Instruct_98317']" }
0.780014
Filter_46235
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5cc4727c2acf7dc4c6e91086ed319ed79058afcc
b025c6e60fd9d6bb0c32cb003d5f54bc44a69d99
v1.0
instruct
Filter
Filter_46238_I
Explain how to create a simple web application using Flask, a Python micro web framework, for displaying a list of books. Include how to set up the environment, create the Flask app, and the necessary routes to display the list and add new books to the list.
from flask import Flask, request, render_template_string app = Flask(__name__) # List to store the books books = ["The Great Gatsby", "1984", "To Kill a Mockingbird"] @app.route('/') def home(): return render_template_string(''' <h1>Book List</h1> <ul> {% for book in books %} ...
import pytest # Test setup code from solution import app, books @pytest.fixture def client(): with app.test_client() as client: yield client def test_home_page(client): rv = client.get('/') assert rv.status_code == 200 assert b"Book List" in rv.data assert b"The Great Gatsby" in rv.data ...
[ { "docstring": null, "function_declaration": "def home():", "function_name": "home", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def add_book():", "function_name": "add_book", "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, render_template, redirect, url_for\n\napp = Flask(__name__)\n\n# In-memory list of books\nbooks = [\n {'title': 'The Great Gatsby', 'author': 'F. Scott Fit...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046238", "row_id": 46238, "seed_ids": "['Qwen2.5-72B-Instruct_98320']" }
0.41676
Filter_46238
I
[ "home", "add_book" ]
2
[ [ "add_book", "home" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
f08e68002f5304bbd5b08330904cc551979175c7
4e07e70f18073e5004f409070adb3a3c8c2d9b93
v1.0
instruct
Filter
Filter_46279_I
Create a Python function that can split a given string into a list of substrings, each of which is a palindrome. A palindrome is a word that reads the same backward as forward, such as "madam" or "racecar". The function should return all possible ways to partition the string such that each substring is a palindrome. Th...
def is_palindrome(s): return s == s[::-1] def partition(s): result = [] current_partition = [] def dfs(start): if start >= len(s): result.append(list(current_partition)) return for end in range(start, len(s)): substring = s[start:end + 1] ...
from solution import partition def test_single_character(): assert partition("a") == [["a"]] def test_basic_palindrome(): assert partition("aa") == [["a", "a"], ["aa"]] def test_two_palindromes(): assert partition("abba") == [["a", "b", "b", "a"], ["a", "bb", "a"], ["abba"]] def test_mixed_cases(): ...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def partition(s):", "function_name": "partition", "parameter_list": "(s)" }, { "docstring": nul...
[ 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 return s == s[::-1]\n\ndef partition(s):\n \"\"\"\n Returns all possible palindrome partitions of the string s.\n \"\"\"\n result = []\n current_parti...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046279", "row_id": 46279, "seed_ids": "['Qwen2.5-72B-Instruct_98378']" }
0.738549
Filter_46279
I
[ "is_palindrome", "partition" ]
2
[ [ "partition", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
851e7831e66e1a1405fe2b0dcf3f77a5e7b62cce
5273d0103672375721e888f0982802b67fdc0864
v1.0
instruct
Filter
Filter_46288_I
Design a Python function that generates a list of `n` random integers between 1 and 100, inclusive. Then, using this function, create a pandas DataFrame with one column named 'Random Numbers'. The DataFrame should display these `n` random numbers. Ensure your code snippet is self-contained, with all necessary imports i...
import pandas as pd import random def generate_random_numbers(n): """ Generates a list of `n` random integers between 1 and 100, inclusive. """ return [random.randint(1, 100) for _ in range(n)] def create_dataframe(n): """ Creates a pandas DataFrame with one column named 'Random Numbers' c...
import pandas as pd from solution import generate_random_numbers, create_dataframe def test_generate_random_numbers_length(): numbers = generate_random_numbers(5) assert len(numbers) == 5 def test_generate_random_numbers_range(): numbers = generate_random_numbers(1000) for number in numbers: a...
[ { "docstring": "Generates a list of `n` random integers between 1 and 100, inclusive.", "function_declaration": "def generate_random_numbers(n):", "function_name": "generate_random_numbers", "parameter_list": "(n)" }, { "docstring": "Creates a pandas DataFrame with one column named 'Random N...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport numpy as np\n\ndef generate_random_numbers(n):\n \"\"\"\n Generates a list of `n` random integers between 1 and 100, inclusive.\n \"\"\"\n return list(n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046288", "row_id": 46288, "seed_ids": "['Qwen2.5-72B-Instruct_98388']" }
0.639254
Filter_46288
I
[ "generate_random_numbers", "create_dataframe" ]
2
[ [ "create_dataframe", "generate_random_numbers" ] ]
1
[]
false
[]
false
pytest
true
[ "pandas" ]
false
10162f43a447bfc75a979fe3a5e589848bc22169
d462eb4be28105c6dcc9d44ccaecf6f025102ddc
v1.0
instruct
Filter
Filter_46299_I
Create a Python function that converts a string to a float, handling possible exceptions if the conversion is not possible. Return a user-defined message for these cases. Use the function to convert a list of strings to a list of floats, applying the exception handling for each item. Ensure the function can handle both...
def to_float(value): """ Converts a given value to a float. Args: value (str): The string to be converted to float. Returns: float: The converted float value, if conversion is possible. str: An error message, if conversion is not possible. """ try: return float(value) ...
from solution import to_float, convert_list_to_floats def test_to_float_with_valid_string(): assert to_float("123.456") == 123.456 assert to_float("0") == 0.0 def test_to_float_with_invalid_string(): assert to_float("abc") == "Conversion to float not possible" assert to_float("123abc") == "Conversion ...
[ { "docstring": "Converts a given value to a float.\n\nArgs:\nvalue (str): The string to be converted to float.\n\nReturns:\nfloat: The converted float value, if conversion is possible.\nstr: An error message, if conversion is not possible.", "function_declaration": "def to_float(value):", "function_name...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def str_to_float(value):\n \"\"\"\n Converts a string to a float. If conversion is not possible, returns a user-defined error message.\n \n Parameters:\n value (str or list): A ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00046299", "row_id": 46299, "seed_ids": "['Qwen2.5-72B-Instruct_98402']" }
0.582065
Filter_46299
I
[ "to_float", "convert_list_to_floats" ]
2
[ [ "convert_list_to_floats", "to_float" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e1df5542b91fcc138b7d32668ed4b9e7c75d1a6
5ede7cd3d5280b810158477892e7c0466fa3f1e8
v1.0
instruct
Filter
Filter_46306_I
Write a Python function to convert a decimal number to a hexadecimal number without using the built-in `hex` function. The function should handle both positive and negative integers. For negative numbers, the function should return a two's complement hexadecimal representation assuming a 32-bit integer.
def decimal_to_hexadecimal(num): """ Converts a decimal number to its hexadecimal representation. Handles both positive and negative integers. For negative numbers, returns the two's complement hexadecimal for a 32-bit integer. """ if num >= 0: return hex_positive(num) else: ...
from solution import decimal_to_hexadecimal def test_positive_number(): assert decimal_to_hexadecimal(10) == "0xa" assert decimal_to_hexadecimal(255) == "0xff" assert decimal_to_hexadecimal(4096) == "0x1000" def test_zero(): assert decimal_to_hexadecimal(0) == "0x0" def test_negative_number(): as...
[ { "docstring": "Converts a decimal number to its hexadecimal representation.\nHandles both positive and negative integers.\nFor negative numbers, returns the two's complement hexadecimal for a 32-bit integer.", "function_declaration": "def decimal_to_hexadecimal(num):", "function_name": "decimal_to_hexa...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def decimal_to_hexadecimal(n):\n \"\"\"\n Converts a decimal number n to its hexadecimal representation.\n Handles both positive and negative integers.\n For negative numbers, it r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046306", "row_id": 46306, "seed_ids": "['Qwen2.5-72B-Instruct_98409']" }
0.674744
Filter_46306
I
[ "decimal_to_hexadecimal", "hex_positive", "hex_negative" ]
3
[ [ "decimal_to_hexadecimal", "hex_negative" ], [ "decimal_to_hexadecimal", "hex_positive" ], [ "hex_negative", "hex_positive" ] ]
3
[]
false
[]
false
pytest
true
[]
true
2577f0f751b051323c5249cfa48537bee5305cc6
7326f29e8d5799c3edd9f9bcc7b83ce862e57586
v1.0
instruct
Filter
Filter_46324_I
Write a Python script that takes a list of domain names as input and checks if each domain has a valid SSL certificate. The script should print the domain name and the validity status (valid or invalid) for each domain.
import ssl import socket def check_ssl(domain): """ Checks if a domain has a valid SSL certificate. Args: domain (str): The domain name to check. Returns: str: 'valid' if the SSL certificate is valid, otherwise 'invalid'. """ try: ctx = ssl.create_default_context() wit...
from solution import check_ssl, check_domains_ssl def test_check_ssl_valid(): # Assuming example.com has a valid SSL certificate assert check_ssl("example.com") == "valid" def test_check_ssl_invalid(): # Assuming invalid.example is a domain with no SSL certificate assert check_ssl("invalid.example") =...
[ { "docstring": "Checks if a domain has a valid SSL certificate.\n\nArgs:\ndomain (str): The domain name to check.\n\nReturns:\nstr: 'valid' if the SSL certificate is valid, otherwise 'invalid'.", "function_declaration": "def check_ssl(domain):", "function_name": "check_ssl", "parameter_list": "(doma...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import ssl\nimport socket\n\ndef check_ssl(domain):\n \"\"\"\n Checks if a domain has a valid SSL certificate.\n\n Args:\n domain (str): The domain name to check.\n\n Returns:\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00046324", "row_id": 46324, "seed_ids": "['Qwen2.5-72B-Instruct_98435']" }
0.691547
Filter_46324
I
[ "check_ssl", "check_domains_ssl" ]
2
[ [ "check_domains_ssl", "check_ssl" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d90734fa2808c6308969af4f3bc1ea822d21b969
453e322e41e9a6778362c157a940625082db0ea1
v1.0
instruct
Filter
Filter_46333_I
I have a list of Python functions and I want to create a system to categorize them based on their functionality. How can I do this in an efficient way, possibly using machine learning?
import re import numpy as np from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.naive_bayes import MultinomialNB from sklearn.pipeline import make_pipeline from sklearn.model_selection import train_test_split # Example function data: List of (function_name, docstring, code) tuples and function la...
import pytest from solution import preprocess_code, create_categorizing_model, categorize_function def test_preprocess_code(): code = ''' def add(a, b): """Returns the sum of a and b.""" # Adding two numbers return a + b ''' assert preprocess_code(code) == "def add(a, b): return...
[ { "docstring": "Preprocess code by removing comments and non-essential parts.", "function_declaration": "def preprocess_code(code):", "function_name": "preprocess_code", "parameter_list": "(code)" }, { "docstring": "Create and train a text classification model using the function data and lab...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.cluster import KMeans\nimport inspect\n\ndef categorize_functions(func_list, n_clusters=3):\n \"\"\"\n Categoriz...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046333", "row_id": 46333, "seed_ids": "['Qwen2.5-72B-Instruct_98451']" }
0.45482
Filter_46333
I
[ "preprocess_code", "create_categorizing_model", "categorize_function" ]
3
[ [ "categorize_function", "preprocess_code" ], [ "create_categorizing_model", "preprocess_code" ] ]
2
[]
false
[]
false
pytest
true
[ "numpy", "sklearn" ]
false
7b0e8629c0694879bd491c7557182afd4eea9776
e6b9fb79c6eff74b0b9d5b9505cdfb322f71eb13
v1.0
instruct
Filter
Filter_46352_I
Please write a simple program in Python that prints the first 10 Fibonacci numbers.
def fibonacci(n): """ Returns the first n Fibonacci numbers. """ fib_sequence = [] a, b = 0, 1 while len(fib_sequence) < n: fib_sequence.append(a) a, b = b, a + b return fib_sequence def print_first_10_fibonacci(): """ Prints the first 10 Fibonacci numbers. """ ...
from solution import fibonacci, print_first_10_fibonacci def test_fibonacci_first_10(): expected = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] assert fibonacci(10) == expected def test_fibonacci_first_5(): expected = [0, 1, 1, 2, 3] assert fibonacci(5) == expected def test_fibonacci_first_0(): assert fibon...
[ { "docstring": "Returns the first n Fibonacci numbers.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Prints the first 10 Fibonacci numbers.", "function_declaration": "def print_first_10_fibonacci():", "function...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def first_10_fibonacci_numbers():\n \"\"\"\n Returns the first 10 Fibonacci numbers in a list.\n \"\"\"\n fibonacci_sequence = [0, 1] # Starting with the first two Fibonacci numbe...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046352", "row_id": 46352, "seed_ids": "['Qwen2.5-72B-Instruct_98477']" }
0.725256
Filter_46352
I
[ "fibonacci", "print_first_10_fibonacci" ]
2
[ [ "print_first_10_fibonacci", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
44d71bbbba47424bd84cc11cc6744507df342c7d
7029a851ec208de7a0882b809f75a1fffbfb365e
v1.0
instruct
Filter
Filter_46365_I
Write a python program that generates a random 6-digit number and checks if it is a palindrome. If it is, the program should print "Palindrome found: [number]", otherwise, it should print "Not a palindrome: [number]".
import random def generate_random_number(): return random.randint(100000, 999999) def is_palindrome(number): str_number = str(number) return str_number == str_number[::-1] def check_palindrome(): number = generate_random_number() if is_palindrome(number): print(f"Palindrome found: {number...
from solution import is_palindrome def test_is_palindrome_with_palindrome(): assert is_palindrome(123321) == True assert is_palindrome(122221) == True assert is_palindrome(456654) == True def test_is_palindrome_with_non_palindrome(): assert is_palindrome(123456) == False assert is_palindrome(65432...
[ { "docstring": null, "function_declaration": "def generate_random_number():", "function_name": "generate_random_number", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(numb...
[ 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 generate_random_6_digit_number():\n \"\"\"\n Generates a random 6-digit number.\n \"\"\"\n return random.randint(100000, 999999)\n\ndef is_palindrome(number):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00046365", "row_id": 46365, "seed_ids": "['Qwen2.5-72B-Instruct_98502']" }
0.697524
Filter_46365
I
[ "generate_random_number", "is_palindrome", "check_palindrome" ]
3
[ [ "check_palindrome", "generate_random_number" ], [ "check_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ff43032cef6b6c20573e2e0889935c73b77edf37
f5c471a48013ebed3f47cf1073b145d6b2b10294