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_38341_I
Write a code to create a 4 x 4 matrix containing all 0s, but the matrix must be initialized using a recursive algorithm instead of a simple loop. Additionally, the recursive algorithm should use a depth-first search approach to fill the matrix, where each element is randomly assigned either 0 or 1.
import random def initialize_matrix(matrix, row, col, n): """ Recursively initializes a n x n matrix with 0s and 1s using a depth-first search approach. """ if row >= n: return matrix if col >= n: return initialize_matrix(matrix, row + 1, 0, n) matrix[row][col] = random.choice...
from solution import create_matrix def test_create_matrix_shape(): matrix = create_matrix(4) assert len(matrix) == 4 assert all(len(row) == 4 for row in matrix) def test_create_matrix_content(): matrix = create_matrix(4) for row in matrix: for element in row: assert element in ...
[ { "docstring": "Recursively initializes a n x n matrix with 0s and 1s using a depth-first search approach.", "function_declaration": "def initialize_matrix(matrix, row, col, n):", "function_name": "initialize_matrix", "parameter_list": "(matrix, row, col, n)" }, { "docstring": null, "fun...
[ 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 create_matrix(size, matrix=None, row=0, col=0):\n \"\"\"\n Creates a size x size matrix filled with 0s, using a recursive depth-first approach.\n \"\"\"\n if m...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038341", "row_id": 38341, "seed_ids": "['Qwen2-72B-Instruct_84682']" }
0.481934
Filter_38341
I
[ "initialize_matrix", "create_matrix" ]
2
[ [ "create_matrix", "initialize_matrix" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8d79b21d3832e7076284483dfe4eb4832c8b33ed
5eee33a78916454ebf2652c7221a6352c106e1fb
v1.0
instruct
Filter
Filter_38346_I
I need to create a Flask application that can process a given input string and return the string with all duplicate characters removed. Can you provide a code solution for this using the Python Flask framework?
from flask import Flask, request, jsonify app = Flask(__name__) def remove_duplicates(input_str): """ Removes duplicate characters from the input string. """ seen = set() result = [] for char in input_str: if char not in seen: seen.add(char) result.append(char) ...
import pytest from flask import json from solution import app, remove_duplicates def test_remove_duplicates(): assert remove_duplicates("aabc") == "abc" assert remove_duplicates("abcdef") == "abcdef" assert remove_duplicates("aabbcc") == "abc" assert remove_duplicates("hello world") == "helo wrd" @pyt...
[ { "docstring": "Removes duplicate characters from the input string.", "function_declaration": "def remove_duplicates(input_str):", "function_name": "remove_duplicates", "parameter_list": "(input_str)" }, { "docstring": null, "function_declaration": "def process():", "function_name": ...
[ 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 remove_duplicates(input_str):\n \"\"\"\n Removes duplicate characters from the input string.\n \"\"\"\n se...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038346", "row_id": 38346, "seed_ids": "['Qwen2-72B-Instruct_84692']" }
0.590482
Filter_38346
I
[ "remove_duplicates", "process" ]
2
[ [ "process", "remove_duplicates" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
71f3dd10b3f0fdb6d362b705118a5327159d24f8
2f108ebb3de405cd31d66a2e8d4ed053a6f5db17
v1.0
instruct
Filter
Filter_38350_I
How do you find the LCM of two numbers using a Python program? Can you provide an example code snippet for this?
def gcd(a, b): """ Returns the Greatest Common Divisor (GCD) of a and b using the Euclidean algorithm. """ while b: a, b = b, a % b return a def lcm(a, b): """ Returns the Least Common Multiple (LCM) of a and b. """ return abs(a * b) // gcd(a, b) # Example usage: # print(lc...
from solution import lcm def test_lcm_of_coprime_numbers(): assert lcm(3, 7) == 21 def test_lcm_of_same_numbers(): assert lcm(5, 5) == 5 def test_lcm_with_one(): assert lcm(1, 10) == 10 assert lcm(25, 1) == 25 def test_lcm_of_common_multiples(): assert lcm(4, 6) == 12 assert lcm(6, 8) == 24 ...
[ { "docstring": "Returns the Greatest Common Divisor (GCD) of a and b using the Euclidean algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the Least Common Multiple (LCM) of a and b.", "function_declaratio...
[ 1, 0, 0 ]
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 a and b using the Euclidean algorithm.\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038350", "row_id": 38350, "seed_ids": "['Qwen2-72B-Instruct_84700']" }
0.794242
Filter_38350
I
[ "gcd", "lcm" ]
2
[ [ "lcm", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64cffe14141661d04c338b7b9e0c6737506b6d94
22f48334c640be0a6bfe87264ffff1c512e847b7
v1.0
instruct
Filter
Filter_38353_I
Create a Python code for a rock, paper, scissors game that allows multiple rounds and keeps track of the score. Add a validation for the user's input and a loop to continue playing until the user decides to quit. Also, implement a delay of one second before displaying the result of each round to enhance the suspense.
import random import time def get_computer_choice(): """ Randomly returns one of 'rock', 'paper', or 'scissors'. """ return random.choice(['rock', 'paper', 'scissors']) def determine_winner(player, computer): """ Determines the winner of a rock-paper-scissors game. Parameters: pla...
from solution import get_computer_choice, determine_winner, validate_user_choice def test_get_computer_choice(): choice = get_computer_choice() assert choice in ['rock', 'paper', 'scissors'] def test_determine_winner(): assert determine_winner('rock', 'scissors') == 'player' assert determine_winner('r...
[ { "docstring": "Randomly returns one 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.\n\nParameters:\nplayer (str):...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\nimport random\n\ndef play_round():\n choices = ['rock', 'paper', 'scissors']\n user_choice = ''\n \n while user_choice not in choices:\n user_choice = input(\"E...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038353", "row_id": 38353, "seed_ids": "['Qwen2-72B-Instruct_84704']" }
0.502563
Filter_38353
I
[ "get_computer_choice", "determine_winner", "validate_user_choice", "play_round", "play_game" ]
5
[ [ "play_game", "play_round" ], [ "play_round", "determine_winner" ], [ "play_round", "get_computer_choice" ], [ "play_round", "validate_user_choice" ] ]
4
[]
false
[]
false
pytest
true
[]
true
b7c11ff915caf1c7c5b9579ddb8a327fb23ecb57
23600700107a59e599bf4b5654a5baceade0f007
v1.0
instruct
Filter
Filter_38365_I
code a genetic algorithm for maximizing a given function, with the following constraints: variable x must be a vector of binary values of length 10.
import random def fitness_function(x): """ The fitness function to maximize. For simplicity, let's define it as the sum of the binary values in the vector. """ return sum(x) def generate_individual(length): """ Generates a random individual represented by a vector of binary values of t...
from solution import fitness_function, generate_individual, crossover, mutate, genetic_algorithm def test_generate_individual(): individual = generate_individual(10) assert len(individual) == 10 assert all(gene in [0, 1] for gene in individual) def test_fitness_function(): assert fitness_function([0, ...
[ { "docstring": "The fitness function to maximize. For simplicity, let's define it as\nthe sum of the binary values in the vector.", "function_declaration": "def fitness_function(x):", "function_name": "fitness_function", "parameter_list": "(x)" }, { "docstring": "Generates a random individua...
[ 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 fitness(x):\n \"\"\"\n Example fitness function to maximize.\n Here we simply assume the fitness function sums up the binary vector.\n \"\"\"\n return sum(x...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038365", "row_id": 38365, "seed_ids": "['Qwen2-72B-Instruct_84726']" }
0.465045
Filter_38365
I
[ "fitness_function", "generate_individual", "crossover", "mutate", "genetic_algorithm" ]
5
[ [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "generate_individual" ], [ "genetic_algorithm", "mutate" ] ]
3
[]
false
[]
false
pytest
true
[]
true
eb52c7828e7949ce9977f82952a93b3c771956b5
ef2a6368da97bde46912a97ca999ddc4dcd1fc5f
v1.0
instruct
Filter
Filter_38383_I
Write a code to reverse a stack without using any auxiliary stack, queue or array for holding the data temporarily. You may utilise recursion for this purpose, but be aware of the stack overflow in case of very deep recursion (large stack).
def insert_at_bottom(stack, item): """ Inserts an item at the bottom of a stack using recursion. Args: stack (list): The stack to insert the item into. item: The item to be inserted at the bottom. """ if not stack: stack.append(item) else: top = stack.pop() i...
from solution import reverse_stack def test_reverse_empty_stack(): stack = [] reverse_stack(stack) assert stack == [] def test_reverse_single_element_stack(): stack = [1] reverse_stack(stack) assert stack == [1] def test_reverse_two_element_stack(): stack = [1, 2] reverse_stack(stack)...
[ { "docstring": "Inserts an item at the bottom of a stack using recursion.\n\nArgs:\nstack (list): The stack to insert the item into.\nitem: The item to be inserted at the bottom.", "function_declaration": "def insert_at_bottom(stack, item):", "function_name": "insert_at_bottom", "parameter_list": "(...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def insert_at_bottom(stack, item):\n \"\"\"\n A helper function that inserts an element at the bottom of a stack.\n\n :param stack: List representing the stack.\n :param item: The ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038383", "row_id": 38383, "seed_ids": "['Qwen2-72B-Instruct_84747']" }
0.400789
Filter_38383
I
[ "insert_at_bottom", "reverse_stack" ]
2
[ [ "reverse_stack", "insert_at_bottom" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9cf6af2fa1efe01907324471de2a860e26c5f822
ebe602e97a34dec132552eeff4617aa21950f273
v1.0
instruct
Filter
Filter_38389_I
Create a function that generates a random phone number based on given country code, area code and valid number combination. The function should also validate if the produced phone number is valid based on common phone number rules of the specified country. For instance, for U.S. phone numbers, no area code can begin wi...
import random def validate_us_phone_number(phone_number: str) -> bool: """ Validate if the given phone number follows the common US phone number rules. """ if phone_number[0] in ['0', '1']: return False if phone_number[1] == '1': return False return True def generate_us_phone_n...
from solution import generate_phone_number, validate_us_phone_number, generate_us_phone_number import pytest def test_validate_us_phone_number(): assert validate_us_phone_number("234") == True assert validate_us_phone_number("014") == False assert validate_us_phone_number("114") == False assert validat...
[ { "docstring": "Validate if the given phone number follows the common US phone number rules.", "function_declaration": "def validate_us_phone_number(phone_number):", "function_name": "validate_us_phone_number", "parameter_list": "(phone_number)" }, { "docstring": "Generate a random US phone ...
[ 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 generate_random_phone_number(country_code, area_code):\n \"\"\"\n Generates a random phone number based on the provided country code and area code.\n Assumes U.S....
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038389", "row_id": 38389, "seed_ids": "['Qwen2-72B-Instruct_84757']" }
0.449884
Filter_38389
I
[ "validate_us_phone_number", "generate_us_phone_number", "generate_phone_number" ]
3
[ [ "generate_phone_number", "generate_us_phone_number" ], [ "generate_us_phone_number", "validate_us_phone_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
079a1fa226c21d60f779546dc9be8364f41f9f6b
331b2f01c221bfaf93611dd7b3468e29e3be7a75
v1.0
instruct
Filter
Filter_38410_I
Debug this code snippet to print a list of all 6-digit numbers, where each digit must be unique. Additionally, the first digit cannot be 0, the sum of the digits must be a prime number, and the third digit must be a square of an integer.
def is_prime(n): """Return 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 += 6 ...
from solution import generate_unique_digit_numbers, is_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(28) == False assert is_prime(29) == True def test_generate_unique_digit_numbers(): ...
[ { "docstring": "Return True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate all 6-digit numbers where each digit is unique, \nthe first digit is non-zero, the sum of the digits ...
[ 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 \"\"\"Return True if n is a prime number, else False.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038410", "row_id": 38410, "seed_ids": "['Qwen2-72B-Instruct_84802']" }
0.587892
Filter_38410
I
[ "is_prime", "generate_unique_digit_numbers" ]
2
[ [ "generate_unique_digit_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8e74c88bc3620738790569118289197c3cedc49
a4451cdc6f97a16f332a175cd8a0457d79207a69
v1.0
instruct
Filter
Filter_38421_I
Create an algorithm in python to sort a list of numbers using merge sort.
def merge_sort(arr): """ Sorts a list of numbers using merge sort algorithm. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = merge_sort(arr[:mid]) right_half = merge_sort(arr[mid:]) return merge(left_half, right_half) def merge(left, right): """ ...
from solution import merge_sort def test_merge_sort_empty_list(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_two_elements(): assert merge_sort([2, 1]) == [1, 2] def test_merge_sort_multiple_elements(): assert merge_sort([4, 2, ...
[ { "docstring": "Sorts a list of numbers using merge sort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two halves in sorted order.", "function_declaration": "def merge(left, right):", "f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts a list of numbers using merge sort algorithm.\n :param arr: List of numbers to be sorted\n :return: Sorted list of numbers\n \"\"\"\n if...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038421", "row_id": 38421, "seed_ids": "['Qwen2-72B-Instruct_84820']" }
0.664993
Filter_38421
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8806176616f40e300e4eb7387bd9575b47deb73f
a573cc9ee8fd7dc350de2fe2432c6fc45b95340f
v1.0
instruct
Filter
Filter_38435_I
Create a Python function that converts decimal numbers to ternary (base 3) representation for a given range, and returns the results in a dictionary format.
def decimal_to_ternary(n): """ Converts a decimal number to its ternary (base 3) representation. """ if n == 0: return '0' ternary = '' while n: ternary = str(n % 3) + ternary n //= 3 return ternary def convert_range_to_ternary(start, end): """ Converts ...
from solution import decimal_to_ternary, convert_range_to_ternary def test_decimal_to_ternary(): assert decimal_to_ternary(0) == '0' assert decimal_to_ternary(1) == '1' assert decimal_to_ternary(2) == '2' assert decimal_to_ternary(3) == '10' assert decimal_to_ternary(4) == '11' assert decimal_t...
[ { "docstring": "Converts a decimal number to its ternary (base 3) representation.", "function_declaration": "def decimal_to_ternary(n):", "function_name": "decimal_to_ternary", "parameter_list": "(n)" }, { "docstring": "Converts decimal numbers in the given range [start, end] to their ternar...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def decimal_to_ternary(n):\n \"\"\"\n Helper function to convert a decimal number n to ternary (base 3) representation.\n \"\"\"\n if n == 0:\n return \"0\"\n \n terna...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038435", "row_id": 38435, "seed_ids": "['Qwen2-72B-Instruct_84841']" }
0.604969
Filter_38435
I
[ "decimal_to_ternary", "convert_range_to_ternary" ]
2
[ [ "convert_range_to_ternary", "decimal_to_ternary" ] ]
1
[]
false
[]
false
pytest
true
[]
true
14d0f78791d6e651f8214b4f1bbfde7138d2faaf
ffb1bddd5b5c63e8ab2605d0e6b849491978e5bc
v1.0
instruct
Filter
Filter_38441_I
Envision that you are handling a classification task utilising PyTorch. You've successfully designed your neural network model and are in the process of refining your training loop. At this juncture, you require instructions for incorporating a customised loss function instead of reverting to the standard PyTorch Cross...
import torch import torch.nn as nn import torch.optim as optim # Step 1: Define a custom loss function def custom_loss(output, target): # Example custom loss: Mean Squared Error between output and target return torch.mean((output - target) ** 2) # Step 2: Integrate the custom loss function into the training l...
import torch from solution import custom_loss, SimpleModel, train_model, advanced_train_model def test_custom_loss(): output = torch.tensor([0.5, 0.6, 0.7]) target = torch.tensor([0.5, 0.6, 0.8]) expected_loss = 0.0033 computed_loss = custom_loss(output, target).item() assert abs(computed_loss...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import torch\nimport torch.nn as nn\nimport torch.optim as optim\n\n# Custom Loss Function\ndef custom_loss(output, target):\n \"\"\"\n Custom loss function for a classification task.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038441", "row_id": 38441, "seed_ids": "['Qwen2-72B-Instruct_84857']" }
0.414827
Filter_38441
I
[ "custom_loss", "train_model", "advanced_train_model" ]
3
[ [ "advanced_train_model", "custom_loss" ], [ "train_model", "custom_loss" ] ]
2
[]
false
[ "SimpleModel" ]
true
pytest
true
[ "torch" ]
false
a052a832b2f3f8546fa20fdbfa6ab9d0c03ba6cf
a0a4952b9a74b7695849a755712f9f619dee910b
v1.0
instruct
Filter
Filter_38451_I
Develop a more complex code, which not only extracts the numerical values from the given nested series of alphanumeric characters, but also calculates and returns the variance and mean of these numbers. Every sequence is comprised of a string, an array, or a mix of both.
import re import numpy as np def extract_numbers(data): """ This function takes a nested structure (lists and strings) and extracts all numerical values. """ numbers = [] if isinstance(data, str): # Extract numbers from string numbers += list(map(int, re.findall(r'\d+', data)))...
from solution import extract_numbers, calculate_mean_and_variance def test_extract_numbers_from_string(): data = "ab1cd2ef3" assert extract_numbers(data) == [1, 2, 3] def test_extract_numbers_from_list_of_strings(): data = ["ab1", "cd2ef3", "gh4"] assert extract_numbers(data) == [1, 2, 3, 4] def test...
[ { "docstring": "This function takes a nested structure (lists and strings) and extracts all numerical values.", "function_declaration": "def extract_numbers(data):", "function_name": "extract_numbers", "parameter_list": "(data)" }, { "docstring": "This function calculates the mean and varian...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nimport numpy as np\n\ndef extract_and_calculate(data):\n \"\"\"\n Extracts numerical values from nested alphanumeric data and returns their mean and variance.\n \n Param...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038451", "row_id": 38451, "seed_ids": "['Qwen2-72B-Instruct_84881']" }
0.580788
Filter_38451
I
[ "extract_numbers", "calculate_mean_and_variance" ]
2
[ [ "calculate_mean_and_variance", "extract_numbers" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
2904e534db96ab80260fea0506c1b30e8065d1ae
b06a7621a1e666fcd0a796c278c04dc38fea1957
v1.0
instruct
Filter
Filter_38454_I
The training log file "tf.sg.log" of a TensorFlow model cannot be found. Your task is to create a Python script that will search for and identify this file in a specified directory and its subdirectories. However, you must exclude all other log files created by TensorFlow, which have names ending with ".log". Additiona...
import os import hashlib import datetime def find_log_file(directory, filename="tf.sg.log", expected_hash=None): """ Searches for a specific log file in a directory and verifies its integrity using SHA-256 hash. Args: directory (str): The directory to search in. filename (str): The name of the log...
import os import pytest from solution import find_log_file, verify_file_hash def test_find_log_file_not_found(tmp_path): result = find_log_file(tmp_path) assert result == "File not found." def test_find_log_file_found(tmp_path): log_file_path = tmp_path / "tf.sg.log" log_file_path.write_text("This is ...
[ { "docstring": "Searches for a specific log file in a directory and verifies its integrity using SHA-256 hash.\n\nArgs:\ndirectory (str): The directory to search in.\nfilename (str): The name of the log file to search for. Default is \"tf.sg.log\".\nexpected_hash (str): The expected SHA-256 hash value to verify...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport hashlib\nimport datetime\n\n# Expected SHA-256 hash value of the file \"tf.sg.log\"\nexpected_hash = \"expected_sha256_hash_value_of_the_file\" # Replace with actual hash va...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038454", "row_id": 38454, "seed_ids": "['Qwen2-72B-Instruct_84885']" }
0.503786
Filter_38454
I
[ "find_log_file", "verify_file_hash" ]
2
[ [ "find_log_file", "verify_file_hash" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0329533127387633a87b0a1e1f1a3c74a86489ec
7f90a1980d1273be5b22a9d81791b8612850801d
v1.0
instruct
Filter
Filter_38465_I
Write a program that generates a random matrix of size n by m and ensures that the sum of each row is a prime number. Additionally, the program should allow the user to input the size of the matrix and the range of values for the matrix elements.
import random import sympy # A library that can be used to find prime numbers and perform symbolic mathematics def is_prime(n): """ Check if a number is prime. """ return sympy.isprime(n) def generate_prime_row(n, value_range): """ Generate a row of n elements such that their sum is a prime n...
from solution import is_prime, generate_prime_row, generate_matrix 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 def test_generate_prime_row(): row1 = generate_prime_row(3, (1, 10)...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate a row of n elements such that their sum is a prime number.", "function_declaration": "def generate_prime_row(n, value...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nfrom sympy import isprime\n\ndef generate_prime_row_sum_matrix(n, m, value_range):\n def generate_prime_row(row_length, value_range):\n while True:\n row = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038465", "row_id": 38465, "seed_ids": "['Qwen2-72B-Instruct_84902']" }
0.465041
Filter_38465
I
[ "is_prime", "generate_prime_row", "generate_matrix" ]
3
[ [ "generate_matrix", "generate_prime_row" ], [ "generate_prime_row", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[ "sympy" ]
false
ebcd3c5bb26fd0089472a57146d6a4f86ff55e05
19b5fc1cd8bd779eac4b2647ed8e9e4a20dfa687
v1.0
instruct
Filter
Filter_38479_I
Given the code snippet below which attempts to solve a Sudoku problem using backtracking, explain why it fails to work correctly and correct the code. Also, describe the reasons why backtracking is a suitable algorithm for solving Sudoku.
def solve_sudoku(board): empty = find_empty(board) if not empty: return True else: row, col = empty for num in range(1, 10): if is_valid(board, num, row, col): board[row][col] = num if solve_sudoku(board): return True ...
def test_find_empty(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, 0, 0, 0, 2, 8, 0], [0, 0, 0, 4, 1, ...
[ { "docstring": null, "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def find_empty(board):", "function_name": "find_empty", "parameter_list": "(board)" }, { ...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solve_sudoku(board):\n def is_valid(board, r, c, num):\n for i in range(9):\n if board[r][i] == num or board[i][c] == num:\n return False\n\n box...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038479", "row_id": 38479, "seed_ids": "['Qwen2-72B-Instruct_84929']" }
0.41358
Filter_38479
I
[ "solve_sudoku", "find_empty", "is_valid" ]
3
[ [ "solve_sudoku", "find_empty" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
false
[]
true
925326e21c2b7b05a85e2b9cd7dc0393267858c1
5b3476b7e1243a965fe68170cf66c9106ac262be
v1.0
instruct
Filter
Filter_38483_I
Write a python function to find the kth smallest element using the quick sort algorithm. The implementation should not rely on built-in or imported sorting methods. Additionally, ensure the function is timed upon execution and have it return an overall response time. Provide a set of test cases as well to vet the funct...
import time def partition(arr, low, high): """ Helper function to partition the array on the basis of pivot element. """ pivot = arr[high] i = low - 1 for j in range(low, high): if arr[j] <= pivot: i = i + 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[hig...
from solution import kth_smallest def test_kth_smallest_middle(): arr = [7, 10, 4, 3, 20, 15] result, _ = kth_smallest(arr, 3) assert result == 7 def test_kth_smallest_first(): arr = [7, 10, 4, 3, 20, 15] result, _ = kth_smallest(arr, 1) assert result == 3 def test_kth_smallest_last(): ar...
[ { "docstring": "Helper function to partition the array on the basis of pivot element.", "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": "Quick Select function to find the kth smallest element.", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\ndef partition(arr, low, high):\n pivot = arr[high]\n i = low - 1\n for j in range(low, high):\n if arr[j] < pivot:\n i = i + 1\n arr[i], ar...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038483", "row_id": 38483, "seed_ids": "['Qwen2-72B-Instruct_84935']" }
0.589446
Filter_38483
I
[ "partition", "quick_select", "kth_smallest" ]
3
[ [ "kth_smallest", "quick_select" ], [ "quick_select", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f29beb7e7308a54391fd17b222a3067767ce139d
75e6a4ae448fdac443c07890996c0d45b34b8232
v1.0
instruct
Filter
Filter_38490_I
Given a list of integers, sort it in descending order without using any built-in sorting functions or methods. Additionally, you cannot use any external libraries or modules for sorting. You are only allowed to use basic data structures and control flow statements. Implement the sorting algorithm yourself and ensure th...
def merge_sort_desc(arr): """ Sorts a list of integers in descending order using the merge sort algorithm. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] return merge(merge_sort_desc(left_half), merge_sort_desc(right_ha...
from solution import sort_descending def test_sort_descending_regular_case(): assert sort_descending([4, 2, 5, 3, 1]) == [5, 4, 3, 2, 1] def test_sort_descending_with_duplicates(): assert sort_descending([4, 2, 5, 3, 3, 1]) == [5, 4, 3, 3, 2, 1] def test_sort_descending_with_all_negatives(): assert sort_...
[ { "docstring": "Sorts a list of integers in descending order using the merge sort algorithm.", "function_declaration": "def merge_sort_desc(arr):", "function_name": "merge_sort_desc", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted lists into one sorted list in descending orde...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quicksort_descending(arr):\n \"\"\"\n Sorts the provided list of integers in descending order using QuickSort.\n \"\"\"\n if len(arr) <= 1:\n return arr\n pivot = arr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038490", "row_id": 38490, "seed_ids": "['Qwen2-72B-Instruct_84945']" }
0.664626
Filter_38490
I
[ "merge_sort_desc", "merge", "sort_descending" ]
3
[ [ "merge_sort_desc", "merge" ], [ "sort_descending", "merge_sort_desc" ] ]
2
[]
false
[]
false
pytest
true
[]
true
75ce211d6e457d95fb2fd92008c997bd88bedb4a
16983f7c1a3195b797a2358aae67e64e553b03c0
v1.0
instruct
Filter
Filter_38520_I
Construct a regex pattern to match a valid IP address and validate each component of the IP address separately. Additionally, implement a function that checks if a given IP address is within a certain range. The range is defined by two IP addresses: a start IP and an end IP. The function should return true if the given...
import re def is_valid_ip(ip): """ Returns True if the given IP address is valid, otherwise False. """ pattern = re.compile(r"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\." r"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\." r"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)...
from solution import is_valid_ip, is_ip_in_range, ip_to_int def test_is_valid_ip(): assert is_valid_ip("192.168.0.1") assert is_valid_ip("255.255.255.255") assert is_valid_ip("0.0.0.0") assert not is_valid_ip("256.256.256.256") assert not is_valid_ip("192.168.0") assert not is_valid_ip("192.168...
[ { "docstring": "Returns True if the given IP address is valid, otherwise False.", "function_declaration": "def is_valid_ip(ip):", "function_name": "is_valid_ip", "parameter_list": "(ip)" }, { "docstring": "Converts an IP address to an integer.", "function_declaration": "def ip_to_int(ip)...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_valid_ip(ip):\n \"\"\"\n Validate if the given string is a valid IPV4 address.\n \"\"\"\n pattern = re.compile(r\"^(\\d{1,3}\\.){3}\\d{1,3}$\")\n \n if pa...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038520", "row_id": 38520, "seed_ids": "['Qwen2-72B-Instruct_84995']" }
0.643789
Filter_38520
I
[ "is_valid_ip", "ip_to_int", "is_ip_in_range" ]
3
[ [ "is_ip_in_range", "ip_to_int" ], [ "is_ip_in_range", "is_valid_ip" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ca78580a49a0e111591babc5744d2dec0bb56fcf
a7c8a3470f0f77ba8145957aa9db679b0b95753a
v1.0
instruct
Filter
Filter_38552_I
Write a Python program that reads a series of integers from stdin and prints the count of prime numbers among the provided integers. Only prime numbers should be counted, and prime number 2 should be included in the count. Input integers are given in a comma-separated list on a single line.
def is_prime(n): """ Determines 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 retu...
from solution import is_prime, count_primes_from_input 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(6) == False assert is_prime(13) == True assert is_prime(1) == False assert is_prime(-5...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Counts the number of prime numbers in a comma-separated list of integers.", "function_declaration": "def count_primes_fro...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines 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_0
{ "original_instruction": "", "prompt_id": "00038552", "row_id": 38552, "seed_ids": "['Qwen2-72B-Instruct_85037']" }
0.709271
Filter_38552
I
[ "is_prime", "count_primes_from_input" ]
2
[ [ "count_primes_from_input", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b97f98ce682b35cc209ff107809d0dd84785ab6
92e5f3ce11e168f9b10606ebfcfa224525d3c839
v1.0
instruct
Filter
Filter_38560_I
Sort the given list in descending order using the bubble sort algorithm. Additionally, implement the bubble sort algorithm in a recursive manner and compare the runtimes of the iterative and recursive approaches.
import time def bubble_sort_iterative(arr): """ Sorts a list in descending order using the bubble sort algorithm iteratively. """ n = len(arr) for i in range(n-1): for j in range(n-1, i, -1): if arr[j] > arr[j-1]: arr[j], arr[j-1] = arr[j-1], arr[j] return a...
from solution import bubble_sort_iterative, bubble_sort_recursive, compare_runtimes def test_bubble_sort_iterative(): arr = [64, 34, 25, 12, 22, 11, 90] sorted_arr = [90, 64, 34, 25, 22, 12, 11] assert bubble_sort_iterative(arr) == sorted_arr def test_bubble_sort_recursive(): arr = [64, 34, 25, 12, ...
[ { "docstring": "Sorts a list in descending order using the bubble sort algorithm iteratively.", "function_declaration": "def bubble_sort_iterative(arr):", "function_name": "bubble_sort_iterative", "parameter_list": "(arr)" }, { "docstring": "Sorts a list in descending order using the bubble ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\n\ndef bubble_sort_iterative(arr):\n \"\"\"\n Sorts a list in descending order using the bubble sort algorithm iteratively.\n \"\"\"\n n = len(arr)\n for i in rang...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038560", "row_id": 38560, "seed_ids": "['Qwen2-72B-Instruct_85046']" }
0.52107
Filter_38560
I
[ "bubble_sort_iterative", "bubble_sort_recursive", "compare_runtimes" ]
3
[ [ "compare_runtimes", "bubble_sort_iterative" ], [ "compare_runtimes", "bubble_sort_recursive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
24e7cce746f3a68d25726aaed25f07a58df264ac
b585a1061c91e42a77ea5a7161b8e40385b44f20
v1.0
instruct
Filter
Filter_38577_I
Write me a Python function to calculate the number of weekends (full and partial) between two dates. Your solution should make use of the Zeller's congruence algorithm for calculating the day of the week for any given date.
import datetime def zellers_congruence(day, month, year): """ Zeller's Congruence Algorithm to calculate the day of the week. Day of week: 0 = Saturday, 1 = Sunday, ..., 6 = Friday. """ if month < 3: month += 12 year -= 1 K = year % 100 J = year // 100 f = day + ((13 * (...
from solution import number_of_weekends def test_no_weekends(): assert number_of_weekends('2023-10-02', '2023-10-06') == 0 # Monday to Friday def test_one_weekend(): assert number_of_weekends('2023-10-06', '2023-10-08') == 2 # Friday to Sunday def test_multiple_weekends(): assert number_of_weekends('20...
[ { "docstring": "Zeller's Congruence Algorithm to calculate the day of the week.\nDay of week: 0 = Saturday, 1 = Sunday, ..., 6 = Friday.", "function_declaration": "def zellers_congruence(day, month, year):", "function_name": "zellers_congruence", "parameter_list": "(day, month, year)" }, { "...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\n\ndef zellers_congruence(year, month, day):\n \"\"\"\n Zeller's Congruence algorithm to calculate the day of the week.\n Returns 0 for Saturday, 1 for Sunday, ..., 6 ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038577", "row_id": 38577, "seed_ids": "['Qwen2-72B-Instruct_85070']" }
0.622613
Filter_38577
I
[ "zellers_congruence", "number_of_weekends" ]
2
[ [ "number_of_weekends", "zellers_congruence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a8481e942e58cfc78ddfe9b7c3b68469422cd7bc
12ea7f9a4ab59a07a5114f2fea26f969852c4d04
v1.0
instruct
Filter
Filter_38588_I
In Python, write a script to sort the list items in descending order. Additionally, implement a function that removes duplicates from the sorted list. The solution should not use any built-in Python functions for sorting or removing duplicates.
def sort_descending(lst): """ Sorts the list items in descending order without using built-in sorting functions. """ # Simple implementation of bubble sort in descending order n = len(lst) for i in range(n): for j in range(0, n - i - 1): if lst[j] < lst[j + 1]: ...
from solution import sort_and_remove_duplicates, sort_descending, remove_duplicates_sorted def test_sort_descending(): assert sort_descending([4, 2, 5, 3, 1]) == [5, 4, 3, 2, 1] assert sort_descending([3, 3, 4, 2, 1]) == [4, 3, 3, 2, 1] assert sort_descending([]) == [] assert sort_descending([1]) == [1...
[ { "docstring": "Sorts the list items in descending order without using built-in sorting functions.", "function_declaration": "def sort_descending(lst):", "function_name": "sort_descending", "parameter_list": "(lst)" }, { "docstring": "Removes duplicates from a sorted list without using set o...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bubble_sort_desc(lst):\n \"\"\"\n Sorts the list items in descending order using bubble sort algorithm.\n \"\"\"\n n = len(lst)\n for i in range(n):\n for j in range(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038588", "row_id": 38588, "seed_ids": "['Qwen2-72B-Instruct_85089']" }
0.637428
Filter_38588
I
[ "sort_descending", "remove_duplicates_sorted", "sort_and_remove_duplicates" ]
3
[ [ "sort_and_remove_duplicates", "remove_duplicates_sorted" ], [ "sort_and_remove_duplicates", "sort_descending" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a11f9ca7bb350eaf66e08add0a80b2fa6a80d0b3
f397fd07158190b1bb0f311d4c11bcd251760195
v1.0
instruct
Filter
Filter_38615_I
Given a list of integers, write a Python function to find the index of the smallest odd prime number using binary search. The list may contain duplicates and may not be sorted. However, you can assume that the list contains at least one odd prime number. You should also return the smallest odd prime number found. If th...
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...
from solution import find_smallest_odd_prime_index def test_single_odd_prime_number(): assert find_smallest_odd_prime_index([3]) == (0, 3) def test_multiple_odd_prime_numbers(): assert find_smallest_odd_prime_index([10, 3, 5, 7, 11, 3]) == (1, 3) def test_with_duplicates(): assert find_smallest_odd_prime...
[ { "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 the index of the smallest odd prime number in the given list.\nAlso returns the smallest odd prime numb...
[ 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 if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038615", "row_id": 38615, "seed_ids": "['Qwen2-72B-Instruct_85130']" }
0.607233
Filter_38615
I
[ "is_prime", "find_smallest_odd_prime_index" ]
2
[ [ "find_smallest_odd_prime_index", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
363740a825e419d75a7c4a69d81f03cdaa4806b6
c303348abd401aec904abbcf7037679c9632dbf2
v1.0
instruct
Filter
Filter_38627_I
Compose a python algorithm to predict the next day's cryptocurrency prices based on the last seven days' prices. Additionally, differentiate your prediction if the cryptocurrency market is in a bullish or bearish phase. Implementing this prediction involves two main parts: first, we need to determine whether the market...
def determine_market_phase(prices): """ Determines if the market is in a bullish or bearish phase based on the last seven days' prices. A simple way to determine this is by looking at the overall trend from the first to the last price. If the last price is higher than the first, we consider it bull...
from solution import determine_market_phase, predict_next_day_price def test_determine_market_phase_bullish(): prices = [1, 2, 3, 4, 5, 6, 7] assert determine_market_phase(prices) == 'bullish' def test_determine_market_phase_bearish(): prices = [7, 6, 5, 4, 3, 2, 1] assert determine_market_phase(price...
[ { "docstring": "Determines if the market is in a bullish or bearish phase based on the last seven days' prices.\n\nA simple way to determine this is by looking at the overall trend from the first to the last price.\nIf the last price is higher than the first, we consider it bullish. Otherwise, we consider it be...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_bullish_or_bearish(prices):\n \"\"\"\n Determines if the market is bullish or bearish.\n Market is considered bullish if the last price is greater than the first price of the p...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038627", "row_id": 38627, "seed_ids": "['Qwen2-72B-Instruct_85148']" }
0.477111
Filter_38627
I
[ "determine_market_phase", "predict_next_day_price" ]
2
[ [ "predict_next_day_price", "determine_market_phase" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6585aef5f3a7de13d91f49a8603cdede21e6b127
d9dfd35dfd70da64a934277f0c8f04448591adbf
v1.0
instruct
Filter
Filter_38631_I
Write a Python program that implements a Wilson primality test to determine if a given number, N, is prime or not. Then, modify this program to check a list of numbers for primality, and optimize it to be as fast as possible. Remember, Wilson's theorem states that a number N is prime if and only if (N-1)! + 1 is divisi...
def is_prime_wilson(n): """ Checks if a number n is prime using Wilson's theorem. Wilson's theorem states that a number n > 1 is prime if and only if (n-1)! + 1 is divisible by n. """ if n <= 1: return False factorial = 1 for i in range(2, n): factorial *= i return (facto...
from solution import is_prime_wilson, check_primality_list def test_is_prime_wilson(): assert is_prime_wilson(2) == True assert is_prime_wilson(3) == True assert is_prime_wilson(4) == False assert is_prime_wilson(5) == True assert is_prime_wilson(6) == False assert is_prime_wilson(17) == True ...
[ { "docstring": "Checks if a number n is prime using Wilson's theorem.\nWilson's theorem states that a number n > 1 is prime if and only if (n-1)! + 1 is divisible by n.", "function_declaration": "def is_prime_wilson(n):", "function_name": "is_prime_wilson", "parameter_list": "(n)" }, { "docs...
[ 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_prime_wilson(n):\n \"\"\"\n Determines if a given number n is prime using Wilson's theorem.\n \"\"\"\n if n <= 1:\n return False\n return (math.fact...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038631", "row_id": 38631, "seed_ids": "['Qwen2-72B-Instruct_85154']" }
0.709556
Filter_38631
I
[ "is_prime_wilson", "check_primality_list" ]
2
[ [ "check_primality_list", "is_prime_wilson" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b3150d346f9998837dcbc68ea2638f6e84570d52
26b3201e96635f30b8f7fa54cb99ac5b50c45f97
v1.0
instruct
Filter
Filter_38642_I
Create a Python script to validate if multiple pairs of specific character sequences are anagrams, including cases that consist of Unicode characters. Ensure the solution efficiency is at least O(n log n) and supports an interactive mode where users can input character sequences to check.
def is_anagram(s1, s2): """ Check if two strings s1 and s2 are anagrams, including Unicode characters. """ # Remove any white spaces and convert to lower case s1 = ''.join(s1.split()).lower() s2 = ''.join(s2.split()).lower() # Sort both the strings and compare return sorted(s1) == s...
from solution import is_anagram def test_basic_anagrams(): assert is_anagram("listen", "silent") assert is_anagram("Triangle", "Integral") def test_unicode_anagrams(): assert is_anagram("déjà vu", "vu déjà") assert is_anagram("São Paulo", "Paulo São") def test_not_anagrams(): assert not is_anagra...
[ { "docstring": "Check if two strings s1 and s2 are anagrams, including Unicode characters.", "function_declaration": "def is_anagram(s1, s2):", "function_name": "is_anagram", "parameter_list": "(s1, s2)" }, { "docstring": null, "function_declaration": "def interactive_mode():", "func...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def are_anagrams(s1, s2):\n \"\"\"\n Check if two strings are anagrams, including support for Unicode characters.\n \n :param s1: First string\n :param s2: Second string\n :r...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038642", "row_id": 38642, "seed_ids": "['Qwen2-72B-Instruct_85170']" }
0.587693
Filter_38642
I
[ "is_anagram", "interactive_mode" ]
2
[ [ "interactive_mode", "is_anagram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
933e256c53cb1900dfdff98fbb7d38e34838a83f
19ebcc329e439e10c6329934212dd80c983add60
v1.0
instruct
Filter
Filter_38667_I
Create a Python program that takes an integer as input and prints the first n prime numbers.
def is_prime(num): """ 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 False i += 6...
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(17) == True assert is_prime(18) == False def test_first_n_primes(): assert first_n_primes(0) == [] assert first_n_primes(1) =...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the first n prime numbers.", "function_declaration": "def first_n_primes(n):", "function_name": "first_n_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(num):\n \"\"\"\n Returns True if the number is prime, else False.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038667", "row_id": 38667, "seed_ids": "['Qwen2-72B-Instruct_85206']" }
0.695242
Filter_38667
I
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0ff54aac9789962ec537714f279cd503ae26835
af18a27b143a8801ce418f043a5f69f1efda2a74
v1.0
instruct
Filter
Filter_38671_I
Can someone help me with Python code to find prime numbers in a given range (e.g., 1 to 100)? Can you explain the logic behind the function?
def is_prime(n): """ Check if a number 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 find_primes_in_range(start, end): """ Returns a list of prime numbers in the given range [sta...
from solution import is_prime, find_primes_in_range 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(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_find_primes_i...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers in the given range [start, end].", "function_declaration": "def find_primes_in_range(...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_primes_in_range(start, end):\n \"\"\"\n Returns a list of prime numbers in the given range (inclusive).\n \"\"\"\n def is_prime(n):\n \"\"\"\n Helper functio...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038671", "row_id": 38671, "seed_ids": "['Qwen2-72B-Instruct_85213']" }
0.659608
Filter_38671
I
[ "is_prime", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0a12febbf7cf42a75a92523c2d2dabcbc9d219a9
fcb72705ea5253217dacfdc39c3fd4e49fae53ae
v1.0
instruct
Filter
Filter_38684_I
Create a Flask application with a simple CRUD system. The application should include endpoints for listing all records, creating a new record, updating an existing record, and deleting a record.
from flask import Flask, request, jsonify app = Flask(__name__) # In-memory database records = [] def find_record(record_id): return next((record for record in records if record['id'] == record_id), None) @app.route('/records', methods=['GET']) def list_records(): return jsonify(records) @app.route('/recor...
import pytest from flask import Flask, json from solution import app, records @pytest.fixture def client(): with app.test_client() as client: yield client # Cleanup the records after each test records.clear() def test_list_records(client): response = client.get('/records') assert response....
[ { "docstring": null, "function_declaration": "def find_record(record_id):", "function_name": "find_record", "parameter_list": "(record_id)" }, { "docstring": null, "function_declaration": "def list_records():", "function_name": "list_records", "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\n# Sample in-memory 'database'\nrecords = {}\n\n@app.route('/records', methods=['GET'])\ndef list_records():\n return js...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038684", "row_id": 38684, "seed_ids": "['Qwen2-72B-Instruct_85232']" }
0.480725
Filter_38684
I
[ "find_record", "list_records", "create_record", "update_record", "delete_record" ]
5
[ [ "delete_record", "find_record" ], [ "update_record", "find_record" ] ]
2
[]
false
[]
false
pytest
true
[ "flask" ]
false
caaf0d5a0d309031955bdcf7de58efbcafe20d99
a9c96cab329352815c22566d287f89fa97ab6516
v1.0
instruct
Filter
Filter_38727_I
Develop an interactive Python program with a GUI that uses Natural Language Processing techniques to extract key details such as ingredients and quantities from a local recipe database and automatically create a formatted and detailed shopping list based on user input for a specific recipe.
def extract_ingredients(recipe): """ Parses ingredients from a recipe and returns a dictionary where keys are ingredients and values are quantities. """ ingredients = {} for line in recipe.split('\n'): if line.strip() and ':' in line: item, qty = map(str.strip, line.split(':')) ...
from solution import extract_ingredients, generate_shopping_list def test_extract_ingredients(): recipe = "Flour: 2 cups\nMilk: 1 liter\nEggs: 4" expected_output = { "Flour": "2 cups", "Milk": "1 liter", "Eggs": "4" } assert extract_ingredients(recipe) == expected_output def te...
[ { "docstring": "Parses ingredients from a recipe and returns a dictionary where keys are ingredients and values are quantities.", "function_declaration": "def extract_ingredients(recipe):", "function_name": "extract_ingredients", "parameter_list": "(recipe)" }, { "docstring": "Generates a sh...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import nltk\nfrom nltk.tokenize import word_tokenize\nfrom nltk.tag import pos_tag\nfrom tkinter import *\nfrom tkinter import messagebox\n\n# Define a simple local recipe database\nrecipes = ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038727", "row_id": 38727, "seed_ids": "['Qwen2-72B-Instruct_85302']" }
0.444231
Filter_38727
I
[ "extract_ingredients", "generate_shopping_list" ]
2
[ [ "generate_shopping_list", "extract_ingredients" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a49a7b16692755f6703f6770cedbf7e5a6c72da
e4e751deac0804e2220b5439211ac7695d40268a
v1.0
instruct
Filter
Filter_38736_I
Craft a Python script to reverse a string composed of ASCII characters only, including extended ASCII characters. Also, the script must include a function to check if the reversed string is a palindrome. The solution should consider Unicode characters, ensuring accurate reversal and palindrome detection, even in string...
def reverse_string(s): """ Returns the reversed version of the string s. """ return s[::-1] def is_palindrome(s): """ Checks if the string s is a palindrome. A string is considered a palindrome if it reads the same forwards and backwards. """ reversed_s = reverse_string(s) retur...
from solution import reverse_string, is_palindrome def test_reverse_string(): assert reverse_string("hello") == "olleh" assert reverse_string("A man, a plan, a canal, Panama") == "amanaP ,lanac a ,nalp a ,nam A" assert reverse_string("1234567890") == "0987654321" assert reverse_string("racecar") == "ra...
[ { "docstring": "Returns the reversed version of the string s.", "function_declaration": "def reverse_string(s):", "function_name": "reverse_string", "parameter_list": "(s)" }, { "docstring": "Checks if the string s is a palindrome. A string is considered a palindrome\nif it reads the same fo...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def reverse_string(s):\n \"\"\"\n Reverses the given string.\n \"\"\"\n return s[::-1]\n\ndef is_palindrome(s):\n \"\"\"\n Checks if the given string is a palindrome.\n \"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038736", "row_id": 38736, "seed_ids": "['Qwen2-72B-Instruct_85320']" }
0.780848
Filter_38736
I
[ "reverse_string", "is_palindrome" ]
2
[ [ "is_palindrome", "reverse_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20dae2a9135614af7b277cafcb4114b49c332bc7
8c4f7a2a73ff2ccc1b4887d0af95b00251093329
v1.0
instruct
Filter
Filter_38756_I
Generate a random UUID in Python and validate it using a regular expression. Furthermore, implement a function to generate multiple unique UUIDs without collision.
import uuid import re def generate_uuid(): """ Generates a single random UUID. """ return str(uuid.uuid4()) def validate_uuid(uuid_string): """ Validates that a given string is a proper UUID. """ regex = re.compile( r'^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-...
import re from solution import generate_uuid, validate_uuid, generate_multiple_uuids def test_generate_uuid(): uuid = generate_uuid() assert validate_uuid(uuid) == True def test_validate_uuid(): valid_uuid = '123e4567-e89b-12d3-a456-426614174000' invalid_uuid = 'invalid-uuid-1234' assert vali...
[ { "docstring": "Generates a single random UUID.", "function_declaration": "def generate_uuid():", "function_name": "generate_uuid", "parameter_list": "()" }, { "docstring": "Validates that a given string is a proper UUID.", "function_declaration": "def validate_uuid(uuid_string):", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import uuid\nimport re\n\ndef generate_uuid():\n \"\"\"\n Generates a random UUID and returns it as a string.\n \"\"\"\n return str(uuid.uuid4())\n\ndef validate_uuid(uuid_str):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038756", "row_id": 38756, "seed_ids": "['Qwen2-72B-Instruct_85354']" }
0.543838
Filter_38756
I
[ "generate_uuid", "validate_uuid", "generate_multiple_uuids" ]
3
[ [ "generate_multiple_uuids", "generate_uuid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7abfb16c9588254e56c982ae4fc5447bb096ed5c
c7150906161ce0d272d14ec853fb5a025bd19c46
v1.0
instruct
Filter
Filter_38758_I
Develop a Python function that outputs a string of a specified length, n, populated with asterisk characters, but every prime-numbered position (1-based index) on the string is changed to an underscore character. It should gracefully handle cases where n is less than 2 by returning an empty string. In addition, modify ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def c...
from solution import create_pattern_string def test_create_pattern_string_small_lengths(): assert create_pattern_string(0) == [] assert create_pattern_string(1) == [] assert create_pattern_string(2) == [[1, '*', False], [2, '_', True]] def test_create_pattern_string_length_5(): expected_output = [ ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to create a string of length n with asterisk characters,\nbut every prime-numbered position (1-bas...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Helper function to check if a number is prime\"\"\"\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038758", "row_id": 38758, "seed_ids": "['Qwen2-72B-Instruct_85356']" }
0.556894
Filter_38758
I
[ "is_prime", "create_pattern_string" ]
2
[ [ "create_pattern_string", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c11125f66c65ecb74c197cfc56e1f228eb14bbba
1387faee70e952aa557de5b4fbdc2753ad9377bb
v1.0
instruct
Filter
Filter_38763_I
you a beautiful shiny keyboard paired with a matching mouse with a smooth scroll wheel. Your job is to generate the Semaphore code for the message: "SOS". Here's the catch: every time you type one of the three letters in the message, the scroll wheel on the mouse needs to be scrolled smoothly and at the exact same spee...
def scroll_wheel(): """ Simulates the action of scrolling the wheel for blinking semaphore signal. """ print("Scrolling...") def semaphore_sos(): """ Generates the semaphore code for the message "SOS". """ message = "SOS" semaphore_code = "" for char in message: if char...
from solution import semaphore_sos def test_semaphore_sos(): assert semaphore_sos() == "... --- ..."
[ { "docstring": "Simulates the action of scrolling the wheel for blinking semaphore signal.", "function_declaration": "def scroll_wheel():", "function_name": "scroll_wheel", "parameter_list": "()" }, { "docstring": "Generates the semaphore code for the message \"SOS\".", "function_declara...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def semaphore_sos():\n \"\"\"\n Returns the Semaphore code for 'SOS' as well as simulates the mouse scroll.\n The semaphore code for 'SOS' is:\n S -> ...\n O -> ---\n S -> .....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038763", "row_id": 38763, "seed_ids": "['Qwen2-72B-Instruct_85364']" }
0.335965
Filter_38763
I
[ "scroll_wheel", "semaphore_sos" ]
2
[ [ "semaphore_sos", "scroll_wheel" ] ]
1
[]
false
[]
false
pytest
true
[]
true
37dee484bba6b0d764bbb99f747911142ca3e955
09038d394e349c82a8017518d5155a339e856bf7
v1.0
instruct
Filter
Filter_38773_I
Write a Python function that takes a list of numbers and classifies them into prime and composite numbers. The function should return the list of prime numbers and the list of composite numbers as a tuple (primeList, compositeList). The prime and composite lists should be sorted in ascending order.
from math import isqrt def is_prime(n): if n <= 1: return False for i in range(2, isqrt(n) + 1): if n % i == 0: return False return True def classify_numbers(numbers): primes = [] composites = [] for number in numbers: if is_prime(number): p...
from solution import classify_numbers def test_empty_list(): assert classify_numbers([]) == ([], []) def test_all_primes(): assert classify_numbers([2, 3, 5, 7, 11]) == ([2, 3, 5, 7, 11], []) def test_all_composites(): assert classify_numbers([4, 6, 8, 9, 12]) == ([], [4, 6, 8, 9, 12]) def test_mixed_nu...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def classify_numbers(numbers):", "function_name": "classify_numbers", "parameter_list": "(numbers)" } ]
[ 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 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": "00038773", "row_id": 38773, "seed_ids": "['Qwen2-72B-Instruct_85376']" }
0.678333
Filter_38773
I
[ "is_prime", "classify_numbers" ]
2
[ [ "classify_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0873f9d90cce01178d019b70002b9be7f27b0384
768c1e2d2e123f55d1d461c9e90dd919585ff088
v1.0
instruct
Filter
Filter_38778_I
Write a Python script that takes in a positive integer as input from a user and determines if it's a prime number or not. If the number is prime, it should print "The number is prime." If it's not prime, it should print "The number is not prime.". Assume the user only inputs positive integers.
def is_prime(n): """ Determines if the input number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime def test_is_prime_small_primes(): assert is_prime(2) == True assert is_prime(3) == True def test_is_prime_small_non_primes(): assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False assert is_prime(4) == False def test_is_prime_large_...
[ { "docstring": "Determines if the input number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Checks if a user-input number is prime and prints the result.", "function_declaration": "def check_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 the given number is a prime number.\n \n Parameters:\n n (int): The number to check.\n \n Returns:\n bool: True if the number is pr...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038778", "row_id": 38778, "seed_ids": "['Qwen2-72B-Instruct_85383']" }
0.797513
Filter_38778
I
[ "is_prime", "check_prime" ]
2
[ [ "check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81f8978c561b381f0d109b12737f94a0c0eb05d6
26b3a5aacf6aab2c5a3d8e8733715146cb56e0e6
v1.0
instruct
Filter
Filter_38788_I
Write a function that takes in a matrix (a list of lists) as input and returns a new matrix where each element is the maximum of its neighbors (including itself) in the original matrix. Note that the neighbors of an element are the elements sharing a common edge. Assume the input matrix is non-empty and has the same nu...
def get_max_neighbor(matrix, row, col): """ Helper function to get the maximum neighbor value for a given cell (row, col) in the matrix. """ rows = len(matrix) cols = len(matrix[0]) max_val = float('-inf') for i in range(max(0, row-1), min(rows, row+2)): for j in range(max(0, co...
from solution import max_neighbors_matrix def test_single_element_matrix(): assert max_neighbors_matrix([[10]]) == [[10]] def test_two_by_two_matrix(): assert max_neighbors_matrix([[1, 2], [3, 4]]) == [[4, 4], [4, 4]] def test_three_by_three_matrix(): assert max_neighbors_matrix([ [1, 2, 3], ...
[ { "docstring": "Helper function to get the maximum neighbor value for a given cell (row, col) in the matrix.", "function_declaration": "def get_max_neighbor(matrix, row, col):", "function_name": "get_max_neighbor", "parameter_list": "(matrix, row, col)" }, { "docstring": "Returns a new matri...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_neighbor_matrix(matrix):\n \"\"\"\n Return a new matrix where each element is the maximum of its neighbors (including itself)\n in the original matrix.\n \"\"\"\n rows =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038788", "row_id": 38788, "seed_ids": "['Qwen2-72B-Instruct_85407']" }
0.549254
Filter_38788
I
[ "get_max_neighbor", "max_neighbors_matrix" ]
2
[ [ "max_neighbors_matrix", "get_max_neighbor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
21a8a48e1101016e0215eba61d367779c2b4e670
6a50f91e2e945799f8c5299b22510652edde202d
v1.0
instruct
Filter
Filter_38801_I
Switch the position of the first and last element of the given list. However, you are not allowed to use any built-in swap or list manipulation functions, and you must implement the solution using a recursive function. Additionally, ensure that the solution has a time complexity of O(n) and does not use any extra space...
def swap_first_last_recursive(lst, start, end): """ Recursively swaps the first and last elements of the list. """ if start >= end: return lst # Manually swapping the elements without using built-in functions temp = lst[start] lst[start] = lst[end] lst[end] = temp return ls...
from solution import swap_first_last def test_swap_first_last_single_element(): assert swap_first_last([1]) == [1] def test_swap_first_last_empty_list(): assert swap_first_last([]) == [] def test_swap_first_last_two_elements(): assert swap_first_last([1, 2]) == [2, 1] def test_swap_first_last_multiple_e...
[ { "docstring": "Recursively swaps the first and last elements of the list.", "function_declaration": "def swap_first_last_recursive(lst, start, end):", "function_name": "swap_first_last_recursive", "parameter_list": "(lst, start, end)" }, { "docstring": "Helper function to initialize recursi...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def swap_first_last_recursive(lst, n=0):\n \"\"\"\n Switch the position of the first and last element of the given list using recursion.\n \"\"\"\n def helper(lst, start, end):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038801", "row_id": 38801, "seed_ids": "['Qwen2-72B-Instruct_85428']" }
0.700268
Filter_38801
I
[ "swap_first_last_recursive", "swap_first_last" ]
2
[ [ "swap_first_last", "swap_first_last_recursive" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a4f94367aeeeac06b5053cd8b844f7a89b5c0899
e208b6703198012e099d8af4852618956f73ac75
v1.0
instruct
Filter
Filter_38803_I
Write two Python functions: `is_palindrome` and `make_palindrome`. The `is_palindrome` function should check if a given string is a palindrome, taking into consideration alphanumeric characters and ignoring cases. It should return a boolean value. The `make_palindrome` function should generate the shortest palindrome b...
def is_palindrome(s): """ Checks if the input string s is a palindrome, considering only alphanumeric characters and ignoring cases. """ filtered_chars = [c.lower() for c in s if c.isalnum()] return filtered_chars == filtered_chars[::-1] def make_palindrome(s): """ Generates the shortes...
from solution import is_palindrome, make_palindrome def test_is_palindrome(): assert is_palindrome("A man, a plan, a canal, Panama") == True assert is_palindrome("No 'x' in Nixon") == True assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("12321") =...
[ { "docstring": "Checks if the input string s is a palindrome, considering only\nalphanumeric characters and ignoring cases.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Generates the shortest palindrome by app...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Checks if the input string s is a palindrome, considering only\n alphanumeric characters and ignoring cases.\n \"\"\"\n filtered_chars = [c.lowe...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038803", "row_id": 38803, "seed_ids": "['Qwen2-72B-Instruct_85430']" }
0.826858
Filter_38803
I
[ "is_palindrome", "make_palindrome" ]
2
[ [ "make_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1fc79853f23891f2dda995adf7c7c6312c0990ec
92c1f95923e5926cf2982d72ab3a3bde32a79037
v1.0
instruct
Filter
Filter_38805_I
Create a while loop using Python programming language to display all prime numerical values that are lesser than or exactly equal to N, where N is an integer input provided by the user. You should also implement error handling for cases where the input is not a positive integer or exceeds a predetermined threshold. Con...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def primes_up_to_N(N)...
from solution import primes_up_to_N, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False def test_primes_up_to_10(): ...
[ { "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 prime numbers up to and including N.", "function_declaration": "def primes_up_to_N(N):", "function_...
[ 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 if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038805", "row_id": 38805, "seed_ids": "['Qwen2-72B-Instruct_85436']" }
0.586362
Filter_38805
I
[ "is_prime", "primes_up_to_N" ]
2
[ [ "primes_up_to_N", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3b824a929b2be047efbf2b3ae84418f03eb42941
9584fa9b7f811d5a9e855f7cd7db6088fdc873e7
v1.0
instruct
Filter
Filter_38816_I
Create a for loop that sums up the first 1000 prime numbers and prints the sum at the end. Additionally, implement a function to check if a given number is prime and use it within the loop to determine the prime numbers.
def is_prime(n): """ Check if a given number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ret...
from solution import is_prime, sum_first_1000_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(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(-5)...
[ { "docstring": "Check if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sum the first 1000 prime numbers.", "function_declaration": "def sum_first_1000_primes():", "function_name": "sum_...
[ 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 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_0
{ "original_instruction": "", "prompt_id": "00038816", "row_id": 38816, "seed_ids": "['Qwen2-72B-Instruct_85456']" }
0.605512
Filter_38816
I
[ "is_prime", "sum_first_1000_primes" ]
2
[ [ "sum_first_1000_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6c88d2a252d2ab93efc4cbbdd2cba09d24ba383e
ff058b65853baa5dd6a5b12f047651d620454e5b
v1.0
instruct
Filter
Filter_38837_I
Generate a program to determine the shortest path between two nodes in an undirected, weighted graph with positive edge weights. The program should also be able to handle graphs with negative edge weights and detect if a negative cycle exists in the graph. Additionally, the program should be able to handle a graph with...
import heapq import math def dijkstra(graph, start): """ Performs Dijkstra's algorithm to find the shortest path from the start node to all other nodes in the graph. Assumes all weights are non-negative. """ distances = {node: math.inf for node in graph} distances[start] = 0 priority_queue...
import pytest from solution import dijkstra, bellman_ford, shortest_path @pytest.fixture def sample_graph(): return { 'A': [('B', 1), ('C', 4)], 'B': [('C', 2), ('D', 5)], 'C': [('D', 1)], 'D': [] } @pytest.fixture def graph_with_negative_weights(): return { 'A': [...
[ { "docstring": "Performs Dijkstra's algorithm to find the shortest path from the start node \nto all other nodes in the graph. Assumes all weights are non-negative.", "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport math\n\ndef dijkstra(graph, start):\n \"\"\"\n Performs Dijkstra's algorithm to find the shortest path from the start node \n to all other nodes in the graph. Ass...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038837", "row_id": 38837, "seed_ids": "['Qwen2-72B-Instruct_85500']" }
0.640942
Filter_38837
I
[ "dijkstra", "bellman_ford", "shortest_path" ]
3
[ [ "shortest_path", "bellman_ford" ], [ "shortest_path", "dijkstra" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b5df06e743300f589e4ac06b91defe385e493912
b062290fde7faf90cb26e69619ea42ae2653d18e
v1.0
instruct
Filter
Filter_38875_I
Execute the undermentioned Python instructions and analyse the outcome of the process. Specifically, we have an array of integers named 'arr' that includes [3, 4, 5, 6, 7]. Create a loop mechanism that goes through and showcases each element within 'arr'. However, there is an essential condition: their existence as a p...
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def display_primes_from_array(arr): """ Goes through the array and displays elements that are prime num...
from solution import is_prime, display_primes_from_array 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(0) == False assert is_prime(1) == False assert is_prime(-1) == False def test_display_p...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Goes through the array and displays elements that are prime numbers.", "function_declaration": "def display_primes_from_arr...
[ 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 Function to determine if a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038875", "row_id": 38875, "seed_ids": "['Qwen2-72B-Instruct_85574']" }
0.567018
Filter_38875
I
[ "is_prime", "display_primes_from_array" ]
2
[ [ "display_primes_from_array", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
565399d8341192a658d8a88bc97dae47a9167d49
2cbf172193bc65cb7b7aa7efceabb6eac8c201da
v1.0
instruct
Filter
Filter_38880_I
Write a python program to create a list of prime numbers between 1 to n.
def is_prime(num): """ Determines if the given number is a prime number. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def list_primes(n): """ Generates a list of prime numbers between 1 and n ...
from solution import is_prime, list_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 def test_list_primes(): assert list_primes(10) == [2, 3, 5, 7] assert list_primes(1) == ...
[ { "docstring": "Determines if the given number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a list of prime numbers between 1 and n (inclusive).", "function_declaration": "def list_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 Determines if the given number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038880", "row_id": 38880, "seed_ids": "['Qwen2-72B-Instruct_85588']" }
0.698529
Filter_38880
I
[ "is_prime", "list_primes" ]
2
[ [ "list_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
677cf553bf183004a825dd76fc9cb3a8c85cf95a
60840937598126d1cdb73a9b25e990a9dd5a1a47
v1.0
instruct
Filter
Filter_38885_I
Design a code that removes redundant values while keeping the order of the elements in a list. Additionally, implement an algorithm whose complexity does not exceed O(n). Also, apply this function to a multidimensional list and maintain the original structure.
def remove_redundant(lst): """ Removes redundant values while keeping the order of the elements in a list. """ seen = set() result = [] for item in lst: if item not in seen: seen.add(item) result.append(item) return result def remove_redundant_multidimensiona...
from solution import remove_redundant, remove_redundant_multidimensional def test_remove_redundant_empty_list(): assert remove_redundant([]) == [] def test_remove_redundant_single_element(): assert remove_redundant([1]) == [1] def test_remove_redundant_no_redundant_values(): assert remove_redundant([1, 2...
[ { "docstring": "Removes redundant values while keeping the order of the elements in a list.", "function_declaration": "def remove_redundant(lst):", "function_name": "remove_redundant", "parameter_list": "(lst)" }, { "docstring": "Applies the remove_redundant function to each sub-list in a mu...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import Union, List\n\ndef remove_redundant_values(data: Union[List[Union[int, float, str]], List[List[Union[int, float, str]]]]) -> Union[List[Union[int, float, str]], List[List[Un...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038885", "row_id": 38885, "seed_ids": "['Qwen2-72B-Instruct_85595']" }
0.594526
Filter_38885
I
[ "remove_redundant", "remove_redundant_multidimensional" ]
2
[ [ "remove_redundant_multidimensional", "remove_redundant" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f6e57f37d9c51ab94643e46f82e9d8c7fb2bce56
8acfffcb1234b199a0dcc2018deafe741bd3f3e6
v1.0
instruct
Filter
Filter_38929_I
Write a Python program that takes a list of strings as input from the user. The program should have a function that returns the longest palindrome in the list. If there are multiple strings of the same maximum length that are palindromes, return the one that comes first lexicographically (i.e., as it would appear first...
def is_palindrome(s): """ Check if the given string is a palindrome. """ return s == s[::-1] def longest_palindrome(strings): """ Returns the longest palindrome in the list of strings. If there are multiple strings of the same maximum length, returns the one that comes first lexicograp...
from solution import longest_palindrome def test_longest_palindrome_single_palindrome(): assert longest_palindrome(["abc", "aba", "xyz"]) == "aba" def test_longest_palindrome_multiple_candidates(): assert longest_palindrome(["abc", "aba", "xyx", "bcb"]) == "aba" def test_longest_palindrome_no_palindrome(...
[ { "docstring": "Check if the given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns the longest palindrome in the list of strings.\nIf there are multiple strings of the same maximum...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindrome(strings):\n \"\"\"\n Returns the longest palindrome in the list of strings.\n If there are multiple palindromes of the same length, returns the lexicographicall...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038929", "row_id": 38929, "seed_ids": "['Qwen2-72B-Instruct_85673']" }
0.752898
Filter_38929
I
[ "is_palindrome", "longest_palindrome" ]
2
[ [ "longest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c94625d82b65833b6c87be2f8a87335af50815fc
5782bcad7ab809ba073da3cf481205b15cf76ce0
v1.0
instruct
Filter
Filter_38934_I
In the context of programming, develop a simple compiler for a hypothetical programming language. This language should only have basic functionality: it should be able to perform integer addition and contain 'if' statements. Explain how your compiler works, what each part does, and how it translates source code written...
import re # Lexer def lexer(source_code): token_specification = [ ('NUMBER', r'\d+'), ('IF', r'if'), ('THEN', r'then'), ('ENDIF', r'endif'), ('PLUS', r'\+'), ('EQ', r'=='), ('WS', r'\s+'), ('ID', r'[A-Za-z]\w*'), ] ...
import pytest from solution import lexer, parse, generate_code, compile def test_lexer(): assert lexer('if 1 + 2 then 3 endif') == [ ('IF', 'if'), ('NUMBER', 1), ('PLUS', '+'), ('NUMBER', 2), ('THEN', 'then'), ('NUMBER', 3), ('ENDIF', 'endif') ] def test...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\n# Lexer\ndef lexer(source_code):\n token_specification = [\n ('NUMBER', r'\\d+'),\n ('IF', r'if'),\n ('THEN', r'then'),\n ('ENDIF', r'end...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038934", "row_id": 38934, "seed_ids": "['Qwen2-72B-Instruct_85683']" }
0.364993
Filter_38934
I
[ "lexer", "parse", "generate_code", "compile" ]
4
[ [ "compile", "generate_code" ], [ "compile", "lexer" ], [ "compile", "parse" ] ]
3
[]
false
[ "ASTNode", "BinOp", "Num", "If" ]
true
pytest
true
[]
true
74810899f03167f04ce752fa5045bbb843150abc
3c69d17506ccc6db3c15a4588835aebe0d0bd28f
v1.0
instruct
Filter
Filter_38941_I
Formulate a serverless computing model in Python targeting AWS Lambda, designed to manage and process real-time data streams from IoT (Internet of Things) devices. This model must encompass error handling, integration with AWS services like DynamoDB for storing data, and Kinesis for data streaming. The code should also...
import json import boto3 from botocore.exceptions import ClientError def lambda_handler(event, context): """ AWS Lambda function to process real-time data streams from IoT devices. """ # Initialize the necessary clients dynamodb = boto3.client('dynamodb') kinesis = boto3.client('kinesis') ...
import json import pytest from unittest.mock import Mock, patch from solution import lambda_handler, is_authorized, store_in_dynamodb def test_is_authorized(): headers = {'Authorization': 'your-secure-token'} unauthorized_headers = {'Authorization': 'incorrect-token'} assert is_authorized(headers) == ...
[ { "docstring": "AWS Lambda function to process real-time data streams from IoT devices.", "function_declaration": "def lambda_handler(event, context):", "function_name": "lambda_handler", "parameter_list": "(event, context)" }, { "docstring": null, "function_declaration": "def is_authori...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\nimport boto3\nfrom botocore.exceptions import ClientError\n\n# Initialize clients for DynamoDB and Kinesis\ndynamodb_client = boto3.client('dynamodb')\nkinesis_client = boto3.clie...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038941", "row_id": 38941, "seed_ids": "['Qwen2-72B-Instruct_85695']" }
0.384267
Filter_38941
I
[ "lambda_handler", "is_authorized", "store_in_dynamodb" ]
3
[ [ "lambda_handler", "is_authorized" ], [ "lambda_handler", "store_in_dynamodb" ] ]
2
[]
false
[]
false
pytest
true
[ "boto3", "botocore" ]
false
7a38ad1e0a713baa86826e7bd7808371798313a2
d2fbe1e9128d7156b6dc0057912523df48045b7c
v1.0
instruct
Filter
Filter_38971_I
I want you to create a valid and compressible JSON string that includes an array with thirty elements, each element being a unique random number, and an object called 'metadata' that includes a timestamp of when the array was generated, your name, and an array of your three favorite programming languages. Additionally,...
import json import random import time from sympy import isprime def generate_prime_numbers(count): primes = [] num = 2 while len(primes) < count: if isprime(num): primes.append(num) num += 1 random.shuffle(primes) return primes def generate_json_string(): primes = g...
from solution import generate_json_string import json import time from sympy import isprime def test_generate_json_string(): json_string = generate_json_string() data = json.loads(json_string) assert len(data["numbers"]) == 30, "The 'numbers' array must have 30 elements" assert all(isprime(num) fo...
[ { "docstring": null, "function_declaration": "def generate_prime_numbers(count):", "function_name": "generate_prime_numbers", "parameter_list": "(count)" }, { "docstring": null, "function_declaration": "def generate_json_string():", "function_name": "generate_json_string", "param...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\nimport random\nimport time\nfrom datetime import datetime\n\ndef is_prime(n):\n \"\"\"Return True if n is a prime number, else False.\"\"\"\n if n <= 1:\n return Fals...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038971", "row_id": 38971, "seed_ids": "['Qwen2-72B-Instruct_85738']" }
0.487641
Filter_38971
I
[ "generate_prime_numbers", "generate_json_string" ]
2
[ [ "generate_json_string", "generate_prime_numbers" ] ]
1
[]
false
[]
false
pytest
true
[ "sympy" ]
false
104c41acf7a89f178efe241cb6666a8e0bb9fe8c
1c1152f90cb32d5cf68c26ea0504e7124d5e91ee
v1.0
instruct
Filter
Filter_38984_I
Write a Python script that generates random integers within a user-specified range, but only those that are prime numbers. The script should accept two arguments from the command line: the lower and upper bounds of the range (inclusive). It should then print all the prime numbers within that range in ascending order.
import sys from math import isqrt def is_prime(n): """ Determines if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: ...
from solution import is_prime, generate_primes_in_range 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(25) == False assert is_prime(29) == True def test_generate_primes_in_range(): assert ge...
[ { "docstring": "Determines if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of prime numbers within the specified inclusive range.", "function_declaration": "def generate_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nimport math\n\ndef is_prime(n):\n \"\"\"\n Check if a number is a prime\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038984", "row_id": 38984, "seed_ids": "['Qwen2-72B-Instruct_85761']" }
0.556155
Filter_38984
I
[ "is_prime", "generate_primes_in_range" ]
2
[ [ "generate_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
97ba2160bcdab4d76a0b76a70f432859713e626b
b5d4613ddd32d5fc43b8541b8cdc93c6ec40e36e
v1.0
instruct
Filter
Filter_38996_I
Write a program that takes an integer N as input, and then prints out the first N prime numbers. Note: N will be less than 100.
def is_prime(num): """ Check if a number is a prime number. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def first_n_primes(N): """ Returns a list of the first N prime numbers. """ prime...
from solution import is_prime, first_n_primes 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) def test_first_n_primes(): assert first_n_primes(1) == [2] assert...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of the first N prime numbers.", "function_declaration": "def first_n_primes(N):", "function_na...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038996", "row_id": 38996, "seed_ids": "['Qwen2-72B-Instruct_85780']" }
0.653728
Filter_38996
I
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
babaaa4c102c60118aad7b696d2cf131ad69a73a
204e0e76f762c1bd325ce38256de4f4558fa7c33
v1.0
instruct
Filter
Filter_38997_I
Write FizzBuzz code in any programming language, but add an extra feature. If the number is a prime number, print "Prime". Consider optimising your code for prime number detection to make it efficient up to the range of 10,000.
def is_prime(n): """ Checks if a given number n is prime. """ 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 +...
from solution import is_prime, fizzbuzz_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(13) == True assert is_prime(10007) == True def test_fizzbuzz_prime():...
[ { "docstring": "Checks if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns Fizz, Buzz, FizzBuzz, Prime, or the number itself based on FizzBuzz rules and prime-check.", "function_declar...
[ 1, 0, 0 ]
1
medium
0.333
{ "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 prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n return True\n if n % 2 == 0 or n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038997", "row_id": 38997, "seed_ids": "['Qwen2-72B-Instruct_85781']" }
0.605074
Filter_38997
I
[ "is_prime", "fizzbuzz_prime" ]
2
[ [ "fizzbuzz_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d5132dfd5dd0baafb0d648e08b5ef2610105f876
0415b46e05a60110820652508cdd030a14914786
v1.0
instruct
Filter
Filter_39006_I
Write a basic Python function to return the first n prime numbers
def is_prime(num): """ Determines if a given number is prime. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def first_n_primes(n): """ Returns the first n prime numbers as a list. """ p...
from solution import first_n_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(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(0) == Fal...
[ { "docstring": "Determines if a given number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the first n prime numbers as a list.", "function_declaration": "def first_n_primes(n):", "function_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n return...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039006", "row_id": 39006, "seed_ids": "['Qwen2-72B-Instruct_85800']" }
0.695864
Filter_39006
I
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e039fb28869bfc4c73415e41c165ee770271d49a
00cb076ce7b5afecefc4875d5af4f4ac21b00784
v1.0
instruct
Filter
Filter_39028_I
Implement a Rao-Blackwellized particle filter for simultaneous localization and mapping (SLAM) task where observations are coming from a 2D laser scanner mounted on a mobile robot traveling through an area with many obstacles. The particles should represent a list of landmarks compared to the map. Since we will simulat...
import numpy as np class Landmark: def __init__(self, x, y): self.x = x self.y = y class Particle: def __init__(self, x, y, theta, num_landmarks): self.x = x self.y = y self.theta = theta self.landmarks = [Landmark(0, 0) for _ in range(num_landmarks)] # initial...
from solution import Landmark, Particle, simulate_motion, measure_distance from solution import rao_blackwellized_particle_filter, get_true_pose def test_simulate_motion(): x, y, theta = simulate_motion(0, 0, 0, 1.0, 1.0, np.pi / 4, 0.1) assert x != 0 or y != 0 or theta != 0 def test_measure_distance(): d...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom matplotlib import pyplot as plt\n\nclass Particle:\n def __init__(self, pose, landmarks):\n self.pose = np.array(pose)\n self.landmarks = {landmark: (...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039028", "row_id": 39028, "seed_ids": "['Qwen2-72B-Instruct_85839']" }
0.31469
Filter_39028
I
[ "simulate_motion", "measure_distance", "rao_blackwellized_particle_filter", "get_true_pose" ]
4
[ [ "rao_blackwellized_particle_filter", "measure_distance" ], [ "rao_blackwellized_particle_filter", "simulate_motion" ] ]
2
[]
false
[ "Landmark", "Particle" ]
true
pytest
true
[ "numpy" ]
false
800b79acb1d42735e3d9d1e86704077d3a52dc25
2b64383e11b2f3b77a49b4fd9139506644d8feb8
v1.0
instruct
Filter
Filter_39046_I
Write a Python program that takes a list of numbers as input and returns a list of all numbers in the original list that are Fibonacci numbers. A Fibonacci number is a number that appears in the Fibonacci sequence, where each subsequent number is the sum of the previous two. For instance, 0, 1, 1, 2, 3, 5, 8, 13, 21, a...
def is_fibonacci(n): """ Determines if a number is a Fibonacci number by checking if one of 5*n^2 + 4 or 5*n^2 - 4 is a perfect square. """ def is_perfect_square(x): s = int(x**0.5) return s*s == x return is_perfect_square(5*n*n + 4) or is_perfect_square(5*n*n - 4) def find...
from solution import find_fibonacci_numbers, is_fibonacci def test_is_fibonacci(): assert is_fibonacci(0) == True assert is_fibonacci(1) == True assert is_fibonacci(2) == True assert is_fibonacci(3) == True assert is_fibonacci(4) == False assert is_fibonacci(5) == True assert is_fibonacci(8...
[ { "docstring": "Determines if a number is a Fibonacci number by checking if one of\n5*n^2 + 4 or 5*n^2 - 4 is a perfect square.", "function_declaration": "def is_fibonacci(n):", "function_name": "is_fibonacci", "parameter_list": "(n)" }, { "docstring": "Returns a list of all Fibonacci number...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_fibonacci(n):\n \"\"\"\n Helper function to check if a number is a Fibonacci number.\n A number is a Fibonacci number if and only if one (or both) of (5*n^2 + 4) or (5*n^2 - 4)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039046", "row_id": 39046, "seed_ids": "['Qwen2-72B-Instruct_85865']" }
0.804283
Filter_39046
I
[ "is_fibonacci", "find_fibonacci_numbers" ]
2
[ [ "find_fibonacci_numbers", "is_fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b3659420b07e3019b36c4c1ce672910759e897b0
b6038132a5faf95506b58d9a7ba8bcdb95bcbbb2
v1.0
instruct
Filter
Filter_39062_I
Construct a 4D hypercube using numpy, and generate a 3D visualization of this hypercube. Also, implement a function that can perform n-dimensional rotations on this hypercube.
import numpy as np def construct_hypercube(dimensions=4): """ Constructs a 4D hypercube using numpy. """ points = np.array([[int(j) for j in format(i, f'0{dimensions}b')] for i in range(2**dimensions)]) return points def rotation_matrix(axis1, axis2, theta): """ Crea...
from solution import construct_hypercube, rotate_hypercube import numpy as np def test_construct_hypercube(): # Test the 4D hypercube construction points = construct_hypercube(4) assert points.shape == (16, 4) expected_points = np.array([ [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]...
[ { "docstring": "Constructs a 4D hypercube using numpy.", "function_declaration": "def construct_hypercube(dimensions=4):", "function_name": "construct_hypercube", "parameter_list": "(dimensions=4)" }, { "docstring": "Create a rotation matrix that rotates across the plane defined by axis1 and...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nimport itertools\n\ndef generate_4d_hypercube():\n \"\"\"\n Generate vertices of a 4D hyperc...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039062", "row_id": 39062, "seed_ids": "['Qwen2-72B-Instruct_85885']" }
0.505643
Filter_39062
I
[ "construct_hypercube", "rotation_matrix", "rotate_hypercube" ]
3
[ [ "rotate_hypercube", "rotation_matrix" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
571c59e14033277e61150a46749e8fcc7392f0cf
52946c9e6a1d7fd6acd90a212ad29922045c2680
v1.0
instruct
Filter
Filter_39063_I
Customize a Python program to print out a multiplication table for the first n prime numbers.
import math def is_prime(num): """Check if a number is a prime number.""" if num < 2: return False for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: return False return True def first_n_primes(n): """Return a list of the first n prime numbers.""" primes =...
from solution import is_prime, first_n_primes, prime_multiplication_table 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(0) == False assert is_prime(1) == False de...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Return a list of the first n prime numbers.", "function_declaration": "def first_n_primes(n):", "function_nam...
[ 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 Return True if the number is a prime number, else False.\n \"\"\"\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039063", "row_id": 39063, "seed_ids": "['Qwen2-72B-Instruct_85886']" }
0.545076
Filter_39063
I
[ "is_prime", "first_n_primes", "prime_multiplication_table", "print_prime_multiplication_table" ]
4
[ [ "first_n_primes", "is_prime" ], [ "prime_multiplication_table", "first_n_primes" ], [ "print_prime_multiplication_table", "first_n_primes" ], [ "print_prime_multiplication_table", "prime_multiplication_table" ] ]
4
[]
false
[]
false
pytest
true
[]
true
4c03ad3df727b9ca7d62639f1826a4885fce3380
4e8fcfb75172ed96c84f010eb1c124870096b1b5
v1.0
instruct
Filter
Filter_39071_I
Generate a URL-shortening service using the Flask web framework.
from flask import Flask, request, jsonify, redirect import string import random app = Flask(__name__) # Dictionary to store short and long URLs url_mapping = {} # Generate a random string of length 6 def generate_short_id(length=6): characters = string.ascii_letters + string.digits return ''.join(random.choi...
import pytest from solution import app, url_mapping, generate_short_id @pytest.fixture def client(): with app.test_client() as client: yield client def test_shorten_url(client): response = client.post('/shorten', json={'long_url': 'http://example.com'}) assert response.status_code == 200 respo...
[ { "docstring": null, "function_declaration": "def generate_short_id(length=6):", "function_name": "generate_short_id", "parameter_list": "(length=6)" }, { "docstring": null, "function_declaration": "def shorten_url():", "function_name": "shorten_url", "parameter_list": "()" }, ...
[ 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, redirect, jsonify\nimport string\nimport random\n\napp = Flask(__name__)\n\n# In-memory URL store\nurl_store = {}\nreverse_url_store = {}\n\n# Simple base62 e...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039071", "row_id": 39071, "seed_ids": "['Qwen2-72B-Instruct_85902']" }
0.480352
Filter_39071
I
[ "generate_short_id", "shorten_url", "redirect_url" ]
3
[ [ "shorten_url", "generate_short_id" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
15fd98384683d44047d7a794ae6e867c0194c115
581aa5d544439c558a516dd659e42ae3071165b6
v1.0
instruct
Filter
Filter_39098_I
Enhance the MinMax function such that it can handle an array of 'n' integers, a list of queries Q, where each query is a tuple containing two integers, L & R (1 ≤ L ≤ R ≤ n). For each query, the function should print the maximum and minimum element in the range from index L to R in the array. Try to optimize the functi...
def preprocess(arr): """ Preprocess the array to generate both min and max sparse tables. """ import math n = len(arr) log = math.floor(math.log2(n)) + 1 min_table = [[0] * log for _ in range(n)] max_table = [[0] * log for _ in range(n)] for i in range(n): min_table...
from solution import min_max_in_ranges def test_single_query(): arr = [1, 2, 3, 4, 5] queries = [(1, 3)] assert min_max_in_ranges(arr, queries) == [(1, 3)] def test_multiple_queries(): arr = [4, 2, 6, 8, 1, 9, 5] queries = [(1, 3), (2, 5), (1, 7)] assert min_max_in_ranges(arr, queries) == [(2,...
[ { "docstring": "Preprocess the array to generate both min and max sparse tables.", "function_declaration": "def preprocess(arr):", "function_name": "preprocess", "parameter_list": "(arr)" }, { "docstring": "Answer the range query (L, R) using the precomputed sparse tables.", "function_de...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class MinMax:\n def __init__(self, array):\n self.array = array\n self.precomputed_min = self._precompute_min()\n self.precomputed_max = self._precompute_max()\n\n d...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039098", "row_id": 39098, "seed_ids": "['Qwen2-72B-Instruct_85951']" }
0.612244
Filter_39098
I
[ "preprocess", "range_query", "min_max_in_ranges" ]
3
[ [ "min_max_in_ranges", "preprocess" ], [ "min_max_in_ranges", "range_query" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f48d88e40ecc54d9a777a5462e328a9f8221e15a
a8f14a8ff73ad23cba234cc60da5f56b8f770956
v1.0
instruct
Filter
Filter_39137_I
Design a function that prints all the unique paths, including left and right turns, in a binary tree and calculates the sum of node values along each path. In addition, identify the path with the maximum sum.
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def all_paths(root): def dfs(node, current_path, path_sum): if not node: return current_path.append(node.value) path_su...
import pytest from solution import TreeNode, all_paths, path_with_max_sum def test_all_paths(): root = TreeNode(5) root.left = TreeNode(4) root.right = TreeNode(8) root.left.left = TreeNode(11) root.left.left.left = TreeNode(7) root.left.left.right = TreeNode(2) root.right.left = TreeNode(1...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef find_paths_and_max_sum(root):\n d...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039137", "row_id": 39137, "seed_ids": "['Qwen2-72B-Instruct_86018']" }
0.596041
Filter_39137
I
[ "all_paths", "path_with_max_sum" ]
2
[ [ "path_with_max_sum", "all_paths" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
c0da5a63aa8058144610e52c358b172c4751247c
8ec0641313b82a1eae7b66ed1c6dce4b8d849d6a
v1.0
instruct
Filter
Filter_39161_I
How can I create a Python code that returns the largest palindrome closest in value to a given integer n?
def is_palindrome(num): """ Check if a number is a palindrome. """ return str(num) == str(num)[::-1] def closest_palindrome(n): """ Returns the largest palindrome closest in value to a given integer n. """ if n < 0: return -1 # assuming negative numbers do not have palindromes ...
from solution import is_palindrome, closest_palindrome def test_is_palindrome(): assert is_palindrome(121) assert is_palindrome(1221) assert not is_palindrome(123) assert not is_palindrome(1231) def test_closest_palindrome(): assert closest_palindrome(123) == 121 assert closest_palindrome(...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Returns the largest palindrome closest in value to a given integer n.", "function_declaration": "def clos...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(num):\n \"\"\"\n Check if a number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef closest_palindrome(n):\n \"\"\"\n Returns the larges...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039161", "row_id": 39161, "seed_ids": "['Qwen2-72B-Instruct_86063']" }
0.723168
Filter_39161
I
[ "is_palindrome", "closest_palindrome" ]
2
[ [ "closest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
50fd1ea0d84bedb5246efcec520fbc3d2591da3a
0c90643386a4c9d2d20c440422396dccb5e88ff7
v1.0
instruct
Filter
Filter_39171_I
Write a Python-based software module that executes the conversion of temperatures from Fahrenheit to Celsius, particularly focusing on the freezing temperature of water.
def fahrenheit_to_celsius(fahrenheit): """ Converts a temperature from Fahrenheit to Celsius. Parameters: fahrenheit (float): Temperature in Fahrenheit Returns: float: Temperature in Celsius """ return (fahrenheit - 32) * 5 / 9 def freezing_point_of_water_fahrenheit(): """...
import pytest from solution import fahrenheit_to_celsius, freezing_point_of_water_fahrenheit, freezing_point_of_water_celsius def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsius(32) == 0 assert fahrenheit_to_celsius(212) == 100 assert fahrenheit_to_celsius(98.6) == pytest.approx(37, 0.1) ass...
[ { "docstring": "Converts a temperature from Fahrenheit to Celsius.\n\nParameters:\nfahrenheit (float): Temperature in Fahrenheit\n\nReturns:\nfloat: Temperature in Celsius", "function_declaration": "def fahrenheit_to_celsius(fahrenheit):", "function_name": "fahrenheit_to_celsius", "parameter_list": ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fahrenheit_to_celsius(fahrenheit):\n \"\"\"\n Converts a temperature from Fahrenheit to Celsius.\n \n :param fahrenheit: Temperature in Fahrenheit\n :return: Temperature in ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039171", "row_id": 39171, "seed_ids": "['Qwen2-72B-Instruct_86084']" }
0.391128
Filter_39171
I
[ "fahrenheit_to_celsius", "freezing_point_of_water_fahrenheit", "freezing_point_of_water_celsius" ]
3
[ [ "freezing_point_of_water_celsius", "fahrenheit_to_celsius" ], [ "freezing_point_of_water_celsius", "freezing_point_of_water_fahrenheit" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cb15550bc4d6eb7d7d3e118f0cee4ebafb657ace
d19fe886b97d0d0a6cc47846028b40361dcfecad
v1.0
instruct
Filter
Filter_39174_I
Develop a Python program that not only determines the nearest prime number less than a specified input but also checks whether the input itself is prime. Further, add functionality to ensure that the input is a positive integer greater than 1. Implement the most efficient method for determining the prime number.
def is_prime(n): """ Check if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return Tr...
from solution import is_prime, nearest_prime def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(11) def test_nearest_prime(): assert nearest_prime(10) == 7 assert nearest...
[ { "docstring": "Check if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the nearest prime number less than n.", "function_declaration": "def nearest_prime(n):", "function_name": "neare...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if 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 == 0:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039174", "row_id": 39174, "seed_ids": "['Qwen2-72B-Instruct_86088']" }
0.655283
Filter_39174
I
[ "is_prime", "nearest_prime" ]
2
[ [ "nearest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
166f918aae16e46d438f7796876fd887dd1e42dd
5a007b1246f3775e75b4cf4b629db496807b470b
v1.0
instruct
Filter
Filter_39180_I
Develop a piece of functional code that is designed to evaluate whether a given year is a century year and if that century year is a leap year according to the rules of the Gregorian calendar. Also, provide a consideration check for negative and non-numeric inputs. Adding to it, code should be able to handle an array o...
def is_century_leap_year(year): """ Evaluates whether a given year is a century year and if that century year is a leap year according to the rules of the Gregorian calendar. For handling multiple years, we define a function to handle arrays of years. - A century year is a year that is divisible by 100...
from solution import evaluate_years, is_century_leap_year def test_century_leap_year(): assert is_century_leap_year(1600) == True assert is_century_leap_year(2000) == True assert is_century_leap_year(2023) == False assert is_century_leap_year(1900) == False assert is_century_leap_year(2100) == Fals...
[ { "docstring": "Evaluates whether a given year is a century year and if that century year is a leap year according to\nthe rules of the Gregorian calendar. For handling multiple years, we define a function to handle arrays of years.\n\n- A century year is a year that is divisible by 100.\n- A century year is a ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_century_year(year):\n \"\"\"\n Returns True if the year is a century year, otherwise False.\n \"\"\"\n return year % 100 == 0\n\ndef is_leap_year(year):\n \"\"\"\n Ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039180", "row_id": 39180, "seed_ids": "['Qwen2-72B-Instruct_86102']" }
0.569435
Filter_39180
I
[ "is_century_leap_year", "evaluate_years" ]
2
[ [ "evaluate_years", "is_century_leap_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
864f79cee27560d14398a541f8927d3af65ec0f7
ee07188976092aa0a3eccc816ed85113dc9c74c3
v1.0
instruct
Filter
Filter_39203_I
Can you draw me a snowflake in Python using the turtle module?
import turtle import random def draw_branch(turtle, length, level): if level == 0: turtle.forward(length) turtle.backward(length) return length /= 3.0 draw_branch(turtle, length, level-1) turtle.left(60) draw_branch(turtle, length, level-1) turtle.right(120) draw_br...
# Tests for the turtle drawing function are not typical unit tests and can't be automated # without a visual check because turtle operations are graphical. # Here we would manually test the graphical output instead. def test_visual_output(): # Graphical output can only be tested by visually verifying that a snowfla...
[ { "docstring": null, "function_declaration": "def draw_branch(turtle, length, level):", "function_name": "draw_branch", "parameter_list": "(turtle, length, level)" }, { "docstring": null, "function_declaration": "def draw_snowflake():", "function_name": "draw_snowflake", "paramet...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import turtle\n\ndef draw_snowflake_side(length, levels):\n if levels == 0:\n turtle.forward(length)\n return\n length /= 3.0\n draw_snowflake_side(length, levels-1)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039203", "row_id": 39203, "seed_ids": "['Qwen2-72B-Instruct_86140']" }
0.558972
Filter_39203
I
[ "draw_branch", "draw_snowflake" ]
2
[ [ "draw_snowflake", "draw_branch" ] ]
1
[]
false
[]
false
pytest
false
[]
true
df6195fa8c7eedede829973145c098c68b1452b7
cdbc61bf2c9368fceaee8f1d077dfc5ef8dc9987
v1.0
instruct
Filter
Filter_39215_I
Write a function in Python that checks if a given number is a palindrome or not and also checks if the palindrome number is a prime number. Try to optimise the function in terms of time and space complexity.
def is_palindrome(number): """ Check if a given number is a palindrome. """ str_num = str(number) return str_num == str_num[::-1] def is_prime(number): """ Check if a given number is a prime number. """ if number <= 1: return False if number <= 3: return True ...
from solution import is_palindrome_and_prime, is_palindrome, is_prime def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1221) == True assert is_palindrome(12321) == True assert is_palindrome(10) == False def test_is_prime(): ass...
[ { "docstring": "Check if a given number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Check if a given number is a prime number.", "function_declaration": "def is_prime(number):",...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Checks if a number is a palindrome.\n \"\"\"\n original = str(n)\n reversed_number = original[::-1]\n return original == reversed_number\n\nd...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039215", "row_id": 39215, "seed_ids": "['Qwen2-72B-Instruct_86164']" }
0.666245
Filter_39215
I
[ "is_palindrome", "is_prime", "is_palindrome_and_prime" ]
3
[ [ "is_palindrome_and_prime", "is_palindrome" ], [ "is_palindrome_and_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c74e0ccb8ec20b66b852cee8fba5f6b689089103
c9456deb2212e9be4d2c866eba02c6a5eac7b62c
v1.0
instruct
Filter
Filter_39238_I
I want to find the kth smallest element of an array using the median of medians algorithm, but I'm not exactly sure how it works. Could you demonstrate with a coding example?
def partition(arr, low, high): pivot = arr[high] i = low for j in range(low, high): if arr[j] < pivot: arr[i], arr[j] = arr[j], arr[i] i += 1 arr[i], arr[high] = arr[high], arr[i] return i def median_of_medians(arr): if len(arr) < 10: arr.sort() r...
from solution import kth_smallest def test_single_element(): assert kth_smallest([7], 1) == 7 def test_two_elements(): assert kth_smallest([3, 2], 1) == 2 assert kth_smallest([3, 2], 2) == 3 def test_multiple_elements(): assert kth_smallest([7, 10, 4, 3, 20, 15], 3) == 7 assert kth_smallest([7, 1...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def median_of_medians(arr):", "function_name": "median_of_medians", "parameter_list":...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def partition(arr, low, high, pivot):\n pivot_value = arr[pivot]\n arr[pivot], arr[high] = arr[high], arr[pivot]\n store_index = low\n for i in range(low, high):\n if arr[i]...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039238", "row_id": 39238, "seed_ids": "['Qwen2-72B-Instruct_86212']" }
0.686711
Filter_39238
I
[ "partition", "median_of_medians", "kth_smallest" ]
3
[ [ "kth_smallest", "median_of_medians" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f37a1dd7f5d97d0ffb56a117a61a704b47b90d4e
6572ddc94a36390e7ad4a61e16f3bfeffa510295
v1.0
instruct
Filter
Filter_39240_I
Develop a Python script to calculate the surface area and volume of a given sphere. In addition to this, add functionality to determine the amount of paint needed to coat the sphere given that one gallon of paint covers 350 square feet. The script should accept the sphere's diameter and the paint type (different paint ...
import math def sphere_surface_area(radius): """ Calculate the surface area of a sphere given its radius. """ return 4 * math.pi * (radius ** 2) def sphere_volume(radius): """ Calculate the volume of a sphere given its radius. """ return (4/3) * math.pi * (radius ** 3) def paint_neede...
from solution import calculate_sphere_properties, sphere_surface_area, sphere_volume, paint_needed def test_sphere_surface_area(): assert math.isclose(sphere_surface_area(1), 4 * math.pi, rel_tol=1e-9) assert math.isclose(sphere_surface_area(0), 0, rel_tol=1e-9) def test_sphere_volume(): assert math.isclo...
[ { "docstring": "Calculate the surface area of a sphere given its radius.", "function_declaration": "def sphere_surface_area(radius):", "function_name": "sphere_surface_area", "parameter_list": "(radius)" }, { "docstring": "Calculate the volume of a sphere given its radius.", "function_de...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef sphere_surface_area(diameter):\n \"\"\"\n Calculates the surface area of a sphere given its diameter.\n \"\"\"\n radius = diameter / 2\n return 4 * math.pi * ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039240", "row_id": 39240, "seed_ids": "['Qwen2-72B-Instruct_86214']" }
0.499089
Filter_39240
I
[ "sphere_surface_area", "sphere_volume", "paint_needed", "calculate_sphere_properties" ]
4
[ [ "calculate_sphere_properties", "paint_needed" ], [ "calculate_sphere_properties", "sphere_surface_area" ], [ "calculate_sphere_properties", "sphere_volume" ] ]
3
[]
false
[]
false
pytest
true
[]
true
1dd991f7abc2904e530d68a78ca7fb739e717739
5943e266bce66e5a20accf85e5dbd2c04f507278
v1.0
instruct
Filter
Filter_39242_I
Write a Python program to filter out the prime numbers from a given list of integers and return the sum of the prime numbers.
def is_prime(n): """ Helper function to check if a number is 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 i in range(3, max_divisor, 2): if n % i == 0: return False ...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_sum_of_primes_with_mi...
[ { "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 the sum of prime numbers in the given list.", "function_declaration": "def sum_of_primes(lst):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number 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 == 0:\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039242", "row_id": 39242, "seed_ids": "['Qwen2-72B-Instruct_86219']" }
0.678636
Filter_39242
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
537484af919ecd40e673149ab1246c8246c270d4
fdb4fe007219b5ce9c5923c200365cf0fca4c6a1
v1.0
instruct
Filter
Filter_39248_I
Create a Python code that takes in an input integer and checks if it is a prime number. The code should also output the smallest prime number that is larger than the input integer. The code should only use basic arithmetic operations and loops, without relying on any pre-built functions or libraries for prime number ca...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def next_p...
from solution import is_prime, next_prime, prime_check_and_next 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(15) == False assert is_prime(1) == False assert is_prime(0) == False assert ...
[ { "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": "Returns the smallest prime number that is larger than n.", "function_declaration": "def next_prime(n...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n 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_2
{ "original_instruction": "", "prompt_id": "00039248", "row_id": 39248, "seed_ids": "['Qwen2-72B-Instruct_86227']" }
0.67615
Filter_39248
I
[ "is_prime", "next_prime", "prime_check_and_next" ]
3
[ [ "next_prime", "is_prime" ], [ "prime_check_and_next", "is_prime" ], [ "prime_check_and_next", "next_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
1c0d46c93456a3f76a416d1fbaac2e933ac4f2ac
7a8821278dc12bed83f483a811d3162c8dfc1f8a
v1.0
instruct
Filter
Filter_39257_I
Code a Python program that accepts three integers and prints their least common multiple (LCM). Additionally, ensure your solution handles input validation for non-integer and negative values, but does not use libraries or inbuilt functions for calculating the LCM.
def gcd(a, b): """ Helper function to compute the greatest common divisor of a and b. """ while b: a, b = b, a % b return a def lcm(a, b): """ Helper function to compute the least common multiple of a and b. """ return a * b // gcd(a, b) def lcm_of_three(a, b, c): """ ...
from solution import lcm_of_three def test_lcm_of_three_positive_integers(): assert lcm_of_three(4, 5, 6) == 60 assert lcm_of_three(3, 4, 5) == 60 def test_lcm_of_three_identical_integers(): assert lcm_of_three(5, 5, 5) == 5 def test_lcm_of_three_with_pairwise_lcm(): assert lcm_of_three(3, 4, 6) == 1...
[ { "docstring": "Helper function to compute the greatest common divisor of a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Helper function to compute the least common multiple of a and b.", "function_declaration": ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Helper function to compute the Greatest Common Divisor (GCD).\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039257", "row_id": 39257, "seed_ids": "['Qwen2-72B-Instruct_86245']" }
0.668309
Filter_39257
I
[ "gcd", "lcm", "lcm_of_three" ]
3
[ [ "lcm", "gcd" ], [ "lcm_of_three", "lcm" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b31616fb379d87c2c9caa49502ffb7768b7b0dea
d07fa1a1a558fea90b1e621ddd14ba78fc952fdb
v1.0
instruct
Filter
Filter_39275_I
Create a hashtable in Python of size 10^7 and insert 10^6 randomly generated elements, each element being a string of length 10. Then, search for 10^5 randomly generated elements in the hashtable, measuring and reporting the average search time.
import string import random import time import hashlib class SimpleHashTable: def __init__(self, size): self.size = size self.table = [None] * size def _hash(self, key): # Using hashlib to generate a hash for consistent results hash_object = hashlib.sha256(key.encode()) ...
from solution import SimpleHashTable, generate_random_string, measure_search_time def test_insertion_and_search(): table_size = 100 num_elements = 10 hash_table = SimpleHashTable(table_size) elements = [generate_random_string() for _ in range(num_elements)] for element in elements: hash_t...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\nimport time\nimport hashli\n\ndef generate_random_string(length=10):\n return ''.join(random.choices(string.ascii_letters + string.digits, k=length))\n\ndef cr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039275", "row_id": 39275, "seed_ids": "['Qwen2-72B-Instruct_86275']" }
0.512505
Filter_39275
I
[ "generate_random_string", "measure_search_time", "hashtable_performance_test" ]
3
[ [ "hashtable_performance_test", "generate_random_string" ], [ "hashtable_performance_test", "measure_search_time" ] ]
2
[]
false
[ "SimpleHashTable" ]
true
pytest
true
[]
true
6a1f2dc168e78a38c69c0e345aece1cd34f6e847
6be3d58dc50c401a142682a6f1cb45f87e6a068b
v1.0
instruct
Filter
Filter_39281_I
Write a function that accepts username and password as parameters, checks if the password meets all of the following criteria: 8 characters length, one uppercase letter, one lowercase letter, one number and one special character. Also, check if the username has already been taken in your database mockup; if it exists, ...
import re import hashlib # Database mockup for usernames and their hashed passwords DATABASE = {} def is_password_valid(password): """ Validates that the password meets the criteria: - At least 8 characters long - Contains at least one uppercase letter - Contains at least one lowercase letter ...
from solution import register_user, DATABASE, is_password_valid # Reset the DATABASE for testing purposes DATABASE.clear() def test_password_validity(): assert is_password_valid('Password123!') == True assert is_password_valid('Pass123') == False assert is_password_valid('password123!') == False asser...
[ { "docstring": "Validates that the password meets the criteria:\n- At least 8 characters long\n- Contains at least one uppercase letter\n- Contains at least one lowercase letter\n- Contains at least one number\n- Contains at least one special character", "function_declaration": "def is_password_valid(passwo...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nimport hashlib\n\n# Mock database\nusers_db = {}\n\ndef is_valid_password(password):\n \"\"\"\n Checks if password meets the criteria: 8 characters length, one uppercase lette...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039281", "row_id": 39281, "seed_ids": "['Qwen2-72B-Instruct_86285']" }
0.534435
Filter_39281
I
[ "is_password_valid", "register_user" ]
2
[ [ "register_user", "is_password_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1a3fc062fc496f4190f431fb0ce3d06b5c17ecb9
afcdd5dd1b5a818ce27f797da5244ee3e631ed27
v1.0
instruct
Filter
Filter_39289_I
Create a JSON string from the provided dictionary in Python. The final JSON string should only include key-value pairs where the value is a prime number. Additionally, the JSON string should not include any leading zeros in the numeric values. Only include keys that start with a lowercase letter and have a length of mo...
import json def is_prime(n): """Check if a number is a prime number.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def dictionary_to_filt...
from solution import dictionary_to_filtered_json def test_dictionary_to_filtered_json_all_constraints(): input_dict = { 'apple': 11, # Valid 'banana': 4, # Invalid, not a prime 'cherry': 23, # Valid 'pear': 5, # Valid 'melon': 10, # Invali...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Converts a dictionary to a JSON string including only:\n- Keys that start with a lowercase letter and have more than 3 ch...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\n\ndef is_prime(num):\n \"\"\"Check if a number is prime.\"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n ret...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039289", "row_id": 39289, "seed_ids": "['Qwen2-72B-Instruct_86298']" }
0.545637
Filter_39289
I
[ "is_prime", "dictionary_to_filtered_json" ]
2
[ [ "dictionary_to_filtered_json", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e07da509b0765643a5052bea502a119941659c9e
b8f92b9bd198cb2062ee8e0c22a3a99449d624f8
v1.0
instruct
Filter
Filter_39294_I
Write a Python function which accepts an array of integers and a value 'n'. The function should return a hash where keys are the integers from the given array which are greater than 'n' and the key's value is the number of divisors of that key. Remember to consider only positive integers as your divisior pool.
def count_divisors(num): """ Returns the number of positive divisors of num. """ count = 0 for i in range(1, num + 1): if num % i == 0: count += 1 return count def filter_and_count_divisors(arr, n): """ Filters the integers from the array 'arr' which are greater than...
from solution import filter_and_count_divisors def test_filter_and_count_divisors_basic(): assert filter_and_count_divisors([1, 2, 3, 4, 5], 2) == {3: 2, 4: 3, 5: 2} def test_filter_and_count_divisors_no_elements_greater(): assert filter_and_count_divisors([1, 2, 3], 5) == {} def test_filter_and_count_diviso...
[ { "docstring": "Returns the number of positive divisors of num.", "function_declaration": "def count_divisors(num):", "function_name": "count_divisors", "parameter_list": "(num)" }, { "docstring": "Filters the integers from the array 'arr' which are greater than 'n',\nand returns a dictionar...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_divisors_greater_than_n(arr, n):\n \"\"\"\n Returns a dictionary where keys are integers from the input array that \n are greater than n, and values are the number of positi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039294", "row_id": 39294, "seed_ids": "['Qwen2-72B-Instruct_86304']" }
0.68013
Filter_39294
I
[ "count_divisors", "filter_and_count_divisors" ]
2
[ [ "filter_and_count_divisors", "count_divisors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
73e31e058d7de7a11db8c1e67617ec876cb23a72
58378514308774cf657ece0b92f0a2997c030dd6
v1.0
instruct
Filter
Filter_39296_I
Write a recursive function in Python that takes as input an array of integers and returns the product of all prime integers in the array. The function should return 1 if there are no primes in the array. Your solution should not use any external libraries for checking prime numbers.
def is_prime(n): """ Helper function to determine if a number n is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False # exclude other even numbers for i in range(3, int(n**0.5) + 1, 2): if ...
from solution import product_of_primes def test_product_of_primes_empty(): assert product_of_primes([]) == 1 def test_product_of_primes_no_primes(): assert product_of_primes([4, 6, 8, 9, 10]) == 1 def test_product_of_primes_all_primes(): assert product_of_primes([2, 3, 5, 7]) == 210 def test_product_of_...
[ { "docstring": "Helper function to determine if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Recursive function that returns the product of all prime integers in the input array.", "function_dec...
[ 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 whether a given number n is a prime number or not.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039296", "row_id": 39296, "seed_ids": "['Qwen2-72B-Instruct_86306']" }
0.668207
Filter_39296
I
[ "is_prime", "product_of_primes" ]
2
[ [ "product_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
08b5b4894d26985f6219d20114978e2e01f247dc
eb5f7135302548c90ba5c66ec7e625387395c1f1
v1.0
instruct
Filter
Filter_39318_I
Expand the given program to include functionality for converting temperatures from negative Celsius to positive Fahrenheit, with a margin of error of at most 0.1 degree. This program should accept a list of temperatures in negative Celsius and for each, it should output the equivalent temperature in positive Fahrenheit...
def celsius_to_fahrenheit(c): """ Converts Celsius to Fahrenheit. Parameters: c (float): Temperature in Celsius. Returns: float: Temperature in Fahrenheit. """ if c >= 0: raise ValueError("Temperature must be negative in Celsius.") f = (c * 9/5) + 32 return roun...
from solution import celsius_to_fahrenheit, convert_temperatures import pytest def test_convert_single_negative_celsius(): assert celsius_to_fahrenheit(-40) == -40.0 assert celsius_to_fahrenheit(-10) == 14.0 assert celsius_to_fahrenheit(-5) == 23.0 def test_convert_temperatures(): celsius_list = [-10,...
[ { "docstring": "Converts Celsius to Fahrenheit.\n\nParameters:\nc (float): Temperature in Celsius.\n\nReturns:\nfloat: Temperature in Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(c):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(c)" }, { "docstring": "Co...
[ 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(temp_celsius):\n \"\"\"\n Converts a temperature from Celsius to Fahrenheit.\n \"\"\"\n if temp_celsius >= 0:\n raise ValueError(\"Input temperatur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039318", "row_id": 39318, "seed_ids": "['Qwen2-72B-Instruct_86338']" }
0.471419
Filter_39318
I
[ "celsius_to_fahrenheit", "convert_temperatures" ]
2
[ [ "convert_temperatures", "celsius_to_fahrenheit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dfdd6108bb6cccb1221711ac9dbb50f1c98e53a1
683b35ac216a823ab65bc6425171cd8ce38b6741
v1.0
instruct
Filter
Filter_39320_I
Write a code that performs an insertion sort on a list of both integers and floating-point numbers, then Resorts the odd and even numbers separately in two different lists: one in ascending and the other in descending order.
def insertion_sort(arr): """ Performs insertion sort on a list of integers and floating-point numbers. """ for i in range(1, len(arr)): key = arr[i] j = i - 1 while j >= 0 and key < arr[j]: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key return arr...
from solution import insertion_sort, sort_odd_and_even def test_insertion_sort(): assert insertion_sort([3, 1, 4, 1, 5, 9, 2, 6]) == [1, 1, 2, 3, 4, 5, 6, 9] assert insertion_sort([6.7, 3.1, 2.4, 9.0, 7.2]) == [2.4, 3.1, 6.7, 7.2, 9.0] assert insertion_sort([]) == [] assert insertion_sort([5]) == [5] ...
[ { "docstring": "Performs insertion sort on a list of integers and floating-point numbers.", "function_declaration": "def insertion_sort(arr):", "function_name": "insertion_sort", "parameter_list": "(arr)" }, { "docstring": "Sorts a list of integers and floating-point numbers using insertion ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def insertion_sort(arr):\n \"\"\"\n Performs insertion sort on the given list.\n \"\"\"\n for i in range(1, len(arr)):\n key = arr[i]\n j = i - 1\n while j >= ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039320", "row_id": 39320, "seed_ids": "['Qwen2-72B-Instruct_86341']" }
0.652486
Filter_39320
I
[ "insertion_sort", "sort_odd_and_even" ]
2
[ [ "sort_odd_and_even", "insertion_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
def5a7fa3eb6421a180add91de83681a58273417
f2d7c63eb88a45371f0d3be1494049b1bdb8b8a1
v1.0
instruct
Filter
Filter_39330_I
Using argparse in Python, I need to add a functionality that allows the program to accept a single argument in different formats such as email, date, or phone number. However, the program should automatically detect the format of the input argument without the user having to specify it explicitly. How can I modify my e...
import argparse import re from datetime import datetime def is_email(input_string): # Regex pattern for validating an email email_pattern = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$' return re.match(email_pattern, input_string) def is_date(input_string): # Try to parse the date try: ...
import pytest from solution import is_email, is_date, is_phone, detect_format def test_is_email(): assert is_email("test@example.com") assert not is_email("not-an-email") def test_is_date(): assert is_date("2023-10-02") assert not is_date("10-02-2023") def test_is_phone(): assert is_phone("+12345...
[ { "docstring": null, "function_declaration": "def is_email(input_string):", "function_name": "is_email", "parameter_list": "(input_string)" }, { "docstring": null, "function_declaration": "def is_date(input_string):", "function_name": "is_date", "parameter_list": "(input_string)"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import argparse\nimport re\nfrom datetime import datetime\n\ndef is_email(input_string):\n # Regex pattern for validating an email\n email_pattern = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039330", "row_id": 39330, "seed_ids": "['Qwen2-72B-Instruct_86363']" }
0.355487
Filter_39330
I
[ "is_email", "is_date", "is_phone", "detect_format", "parse_argument" ]
5
[ [ "detect_format", "is_date" ], [ "detect_format", "is_email" ], [ "detect_format", "is_phone" ] ]
3
[]
false
[]
false
pytest
true
[]
true
16d3ee5e13e5259e1f07c0a82975f275d0d75f46
28693f5ccf3c3a8667a3c9c1c868e99e24eb2769
v1.0
instruct
Filter
Filter_39366_I
Develop a simple game using Python. Describe the steps you followed to create it. In order to ensure your instructions are easy to follow, arrange them in a numbered list and include code snippets for clarity. Additionally, create a table showing possible player choices, and explain your decision to use certain element...
import random def get_computer_choice(): """ Randomly selects and returns a choice for the computer from 'rock', 'paper', or 'scissors'. """ choices = ["rock", "paper", "scissors"] return random.choice(choices) def determine_winner(player_choice, computer_choice): """ Determines the winner...
from solution import determine_winner, rock_paper_scissors def test_determine_winner(): assert determine_winner("rock", "scissors") == "Player wins" assert determine_winner("scissors", "paper") == "Player wins" assert determine_winner("paper", "rock") == "Player wins" assert determine_winner("rock", "p...
[ { "docstring": "Randomly selects and returns a choice for the computer from '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...
[ 1, 1 ]
2
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 \"\"\"\n Randomly selects and returns a choice for the computer from 'rock', 'paper', or 'scissors'.\n \"\"\"\n choices = [\"rock\", \...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039366", "row_id": 39366, "seed_ids": "['Qwen2-72B-Instruct_86421']" }
0.463202
Filter_39366
I
[ "get_computer_choice", "determine_winner", "rock_paper_scissors" ]
3
[ [ "rock_paper_scissors", "determine_winner" ], [ "rock_paper_scissors", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4edcd2ab623a98c5584b947301f379a6b3a4f075
8ffc59f26da0c377ee4c9cde1657e385f58bcf32
v1.0
instruct
Filter
Filter_39381_I
I want to write a Python code to simulate a dice game using random numbers. In this game, two players are rolling a standard 6-sided die. The player with the higher roll wins. If it's a tie, they roll the dice again until there's a winner. Can you help me write the code for this game?
import random def roll_die(): """ Simulates rolling a standard 6-sided die. """ return random.randint(1, 6) def simulate_dice_game(): """ Simulates a dice game where two players roll a die. The player with the higher roll wins. If it's a tie, they roll the dice again until there's a wi...
from solution import roll_die, simulate_dice_game import pytest def test_roll_die(): roll = roll_die() assert 1 <= roll <= 6, f"Die roll out of range: {roll}" def test_simulate_dice_game_winner(): winner, player1_roll, player2_roll = simulate_dice_game() assert winner in [1, 2], f"Invalid winner: {win...
[ { "docstring": "Simulates rolling a standard 6-sided die.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Simulates a dice game where two players roll a die.\nThe player with the higher roll wins.\nIf it's a tie, they roll t...
[ 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 standard 6-sided die.\n \"\"\"\n return random.randint(1, 6)\n\ndef simulate_dice_game():\n \"\"\"\n Simulates...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039381", "row_id": 39381, "seed_ids": "['Qwen2-72B-Instruct_86442']" }
0.52248
Filter_39381
I
[ "roll_die", "simulate_dice_game" ]
2
[ [ "simulate_dice_game", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bac6237d67ad1e1161920a035cf786a1afa1bccd
2455ca1d8f42ce1b5353e58e64c24068bb8b41e1
v1.0
instruct
Filter
Filter_39390_I
Now in Python, write a function that performs operations on two inputs. Use if-else constructs to evaluate certain conditions regarding the operations. Firstly, if the operation is division, the function should check whether the second number is zero or not. If it’s zero, the function should raise a custom warning inst...
import math class DivisionByZeroWarning(Warning): pass def perform_operation(a, b, operation): """ Performs the given operation on two inputs. If the operation is division, checks if the second number is zero. Raises a custom warning if the second number is zero. If the operation is multiplication and...
from solution import perform_operation, DivisionByZeroWarning def test_division_by_zero(): try: perform_operation(8, 0, "division") except DivisionByZeroWarning: pass else: assert False, "DivisionByZeroWarning not raised" def test_division(): assert perform_operation(8, 4, "div...
[]
[ 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 custom_warning(message):\n raise Warning(message)\n\ndef perform_operation(a, b, operation):\n \"\"\"\n Performs the specified operation on two inputs a and b.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039390", "row_id": 39390, "seed_ids": "['Qwen2-72B-Instruct_86466']" }
0.634915
Filter_39390
I
[ "perform_operation", "is_perfect_square" ]
2
[ [ "perform_operation", "is_perfect_square" ] ]
1
[]
false
[ "DivisionByZeroWarning" ]
true
pytest
true
[]
true
83f9953fd1f9d55bd1b23a654f90a2f40e189dd7
91dbd4642af29255ebb134b924fa2278df708d81
v1.0
instruct
Filter
Filter_39392_I
Write a python code for a for loop that iterates over a list of numbers and prints the square of each number, but only if the number is prime. The program should also keep track of the count of prime numbers found and print it at the end.
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def print_squares_of_primes(numbers): """ Iterates over a list of numbers and prints the square of each nu...
from solution import is_prime, print_squares_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(6) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0)...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Iterates over a list of numbers and prints the square of each number \nonly if the number is prime. Also keeps track of the count ...
[ 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 Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039392", "row_id": 39392, "seed_ids": "['Qwen2-72B-Instruct_86474']" }
0.700397
Filter_39392
I
[ "is_prime", "print_squares_of_primes" ]
2
[ [ "print_squares_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
223d018a54b727b1f616935e21221d2d16f96636
f458c6f6b62ac53ca09d94a390c117854b4a0139
v1.0
instruct
Filter
Filter_39393_I
Write code to generate the power set of a given list of unique words, then organize the subsets in a text file, one subset per line, in lexicographical and non-descending order, maintaining alphabetical order within each subset.
from itertools import chain, combinations def powerset(iterable): """ Generate the power set of the given list of words. """ s = list(iterable) result = list(chain.from_iterable(combinations(s, r) for r in range(len(s)+1))) return result def write_powerset_to_file(words, filename): """ ...
from solution import powerset, write_powerset_to_file import os def test_powerset(): words = ['apple', 'banana', 'cherry'] expected_power_set = [ (), ('apple',), ('banana',), ('cherry',), ('apple', 'banana'), ('apple', 'cherry'), ('banana', 'cherry'), ...
[ { "docstring": "Generate the power set of the given list of words.", "function_declaration": "def powerset(iterable):", "function_name": "powerset", "parameter_list": "(iterable)" }, { "docstring": "Generate the powerset of the given list of words and write it to a file.\nEach subset is writ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import chain, combinations\n\ndef powerset(iterable):\n \"\"\"\n Generate the power set of the given list of words.\n \"\"\"\n s = list(iterable)\n result = list(...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039393", "row_id": 39393, "seed_ids": "['Qwen2-72B-Instruct_86475']" }
0.509807
Filter_39393
I
[ "powerset", "write_powerset_to_file" ]
2
[ [ "write_powerset_to_file", "powerset" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62d639fb1669179c6edcc8001e46327cffaf0f15
5cf21e9a825d3cd24958d1171bb62c2e4e54d934
v1.0
instruct
Filter
Filter_39398_I
Given 2 URLs, write a Python program to find out if they lead to the same webpage or not. Along with domain names, consider path, query parameters and anchor parts in comparison.
from urllib.parse import urlparse, parse_qs, urlunparse def canonicalize(url): """ Parses a URL and returns a canonical form. """ parsed_url = urlparse(url) # Sort query parameters to have a consistent order query = parse_qs(parsed_url.query) sorted_query = '&'.join( f'{key}={"&".jo...
from solution import compare_urls def test_urls_with_same_domain_and_path(): url1 = "http://example.com/path" url2 = "http://example.com/path" assert compare_urls(url1, url2) is True def test_urls_with_different_domains(): url1 = "http://example.com/path" url2 = "http://different.com/path" ass...
[ { "docstring": "Parses a URL and returns a canonical form.", "function_declaration": "def canonicalize(url):", "function_name": "canonicalize", "parameter_list": "(url)" }, { "docstring": "Compare two URLs and check if they lead to the same webpage.", "function_declaration": "def compare...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from urllib.parse import urlparse, parse_qs\n\ndef are_urls_equal(url1, url2):\n \"\"\"\n Returns True if url1 and url2 are considered to lead to the same webpage, otherwise False.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039398", "row_id": 39398, "seed_ids": "['Qwen2-72B-Instruct_86483']" }
0.563995
Filter_39398
I
[ "canonicalize", "compare_urls" ]
2
[ [ "compare_urls", "canonicalize" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0e8abc7e2a224b5163d16bcf8fde78d72f587ecd
07fb512f0a10c4c200ccc12544a5c1d7d589f05d
v1.0
instruct
Filter
Filter_39412_I
Construct a Python program that not only converts temperatures from Fahrenheit to Celsius but also predicts the time in which given water will freeze based on the given temperature in Fahrenheit. Take into consideration the average heat loss of the water to the environment, and include a simple validation for the input...
def fahrenheit_to_celsius(fahrenheit): """ Converts a temperature from Fahrenheit to Celsius. """ try: fahrenheit = float(fahrenheit) except ValueError: raise ValueError("Invalid input: Temperature must be a numeric value.") if fahrenheit < -459.67: raise ValueError(...
from solution import fahrenheit_to_celsius, predict_freeze_time def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsius(32) == 0 assert fahrenheit_to_celsius(212) == 100 assert fahrenheit_to_celsius(-40) == -40 assert fahrenheit_to_celsius(0) == -17.77777777777778 def test_fahrenheit_to_celsius...
[ { "docstring": "Converts a temperature from Fahrenheit to Celsius.", "function_declaration": "def fahrenheit_to_celsius(fahrenheit):", "function_name": "fahrenheit_to_celsius", "parameter_list": "(fahrenheit)" }, { "docstring": "Predicts the time it will take for water to freeze based on the...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fahrenheit_to_celsius(fahrenheit):\n \"\"\"\n Converts Fahrenheit to Celsius.\n \"\"\"\n return (fahrenheit - 32) * 5.0/9.0\n\ndef time_to_freeze_water(fahrenheit):\n \"\"\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039412", "row_id": 39412, "seed_ids": "['Qwen2-72B-Instruct_86506']" }
0.401591
Filter_39412
I
[ "fahrenheit_to_celsius", "predict_freeze_time" ]
2
[ [ "predict_freeze_time", "fahrenheit_to_celsius" ] ]
1
[]
false
[]
false
pytest
true
[]
true
66f0b88daf7f87f29a4050a4b162179e51461992
d9012564dd38332f457deae752e5f6eabd02deac
v1.0
instruct
Filter
Filter_39419_I
I am looking to optimize the control parameters of a PID controller for a system. I have a set of performance metrics that I want to minimize. How can I use the genetic algorithm to achieve this goal in Python? Provide an example code snippet.
import numpy as np import random class PIDController: def __init__(self, Kp, Ki, Kd): self.Kp = Kp self.Ki = Ki self.Kd = Kd def control(self, setpoint, pv): # Placeholder for actual control logic # This would normally produce a control output based on setpoint and pv (...
from solution import PIDController, evaluate_performance, genetic_algorithm def test_pid_controller_initialization(): pid = PIDController(1.0, 0.5, 0.1) assert pid.Kp == 1.0 assert pid.Ki == 0.5 assert pid.Kd == 0.1 def test_pid_control_output(): pid = PIDController(1.0, 0.5, 0.1) output = pid...
[]
[ 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 numpy as np\n\n# Define the PID controller class\nclass PID:\n def __init__(self, Kp, Ki, Kd):\n self.Kp = Kp\n self.Ki = Ki\n self.Kd = Kd\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039419", "row_id": 39419, "seed_ids": "['Qwen2-72B-Instruct_86516']" }
0.35306
Filter_39419
I
[ "evaluate_performance", "genetic_algorithm" ]
2
[ [ "genetic_algorithm", "evaluate_performance" ] ]
1
[]
false
[ "PIDController" ]
true
pytest
true
[ "numpy" ]
false
7e476ef0461bf4e27818702106d295bab2307b44
d2862306405560188171f4b030164f7b8a385925
v1.0
instruct
Filter
Filter_39444_I
Write a function in Python that takes in a list of integers and returns the sum of all the prime numbers in the list. However, your function should be optimized to have a time complexity of O(n), where n is the length of the input list. In addition, your function should not use any built-in primality testing functions ...
import random def is_prime(n, k=5): # number of tests 'k' for probabilistic prime checking """ Miller-Rabin primality test to check if a number is prime """ if n <= 1: return False if n in (2, 3): return True if n % 2 == 0: return False s, d = 0, n - 1 whil...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_is_prime_large(): assert is_prime(1000000007) == True assert is_prime(100000...
[ { "docstring": "Miller-Rabin primality test to check if a number is prime", "function_declaration": "def is_prime(n, k=5):", "function_name": "is_prime", "parameter_list": "(n, k=5)" }, { "docstring": "Returns the sum of all prime numbers in the list, treating negatives as positives and excl...
[ 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 Perform a probabilistic primality test on an integer `n`.\n Use Fermat's little theorem to test for primality.\n \"\"\"\n if n <= 1:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039444", "row_id": 39444, "seed_ids": "['Qwen2-72B-Instruct_86562']" }
0.682862
Filter_39444
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a5d78071737fa9044556997bd28ef11203f8d327
57fceefed1ef1047659d1a4304c7e67ea1715c3b
v1.0
instruct
Filter
Filter_39465_I
Given three strings, create a new string that is their reverse-concatenation. In addition, check if any of the initial strings are palindromes and, if so, do not include them in the final string. Implement this in a programming language of your choice.
def is_palindrome(s): """ Checks if a string is a palindrome. """ return s == s[::-1] def reverse_concatenate(a, b, c): """ Returns the reverse-concatenation of strings a, b, and c, excluding any palindromes. """ strings = [a, b, c] non_palindromes = [s for s in strings if not is_pa...
from solution import is_palindrome, reverse_concatenate def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("") == True assert is_palindrome("a") == True def test_reverse_concatenate_all...
[ { "docstring": "Checks if a string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns the reverse-concatenation of strings a, b, and c, excluding any palindromes.", "function_declaration...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Returns True if the string s is a palindrome, False otherwise.\n \"\"\"\n return s == s[::-1]\n\ndef reverse_concatenate(s1, s2, s3):\n \"\"\"\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039465", "row_id": 39465, "seed_ids": "['Qwen2-72B-Instruct_86592']" }
0.717209
Filter_39465
I
[ "is_palindrome", "reverse_concatenate" ]
2
[ [ "reverse_concatenate", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b99662f4f86d467687b9ed7a8eabc8fb2e3407f9
41296e00c292b7b48b379f5552b7adb19aaecab8
v1.0
instruct
Filter
Filter_39475_I
How would you use a while loop and recursion together to print the first 50 Fibonacci numbers in Python? Provide a code snippet as an example.
def fibonacci_recursive(n, first=0, second=1): """ Utilizes recursion to generate Fibonacci numbers. Prints the first 50 Fibonacci numbers. """ if n > 0: print(first, end=' ') fibonacci_recursive(n - 1, second, first + second) def print_first_50_fibonacci(): """ Initiates th...
from io import StringIO import sys from solution import print_first_50_fibonacci def test_print_first_50_fibonacci(): expected_output = ('0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 ' '1597 2584 4181 6765 10946 17711 28657 46368 75025 ' '121393 196418 317811 5142...
[ { "docstring": "Utilizes recursion to generate Fibonacci numbers.\nPrints the first 50 Fibonacci numbers.", "function_declaration": "def fibonacci_recursive(n, first=0, second=1):", "function_name": "fibonacci_recursive", "parameter_list": "(n, first=0, second=1)" }, { "docstring": "Initiate...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci_sequence(n, current_seq=None):\n if current_seq is None:\n current_seq = [0, 1]\n if len(current_seq) >= n:\n return current_seq[:n]\n current_seq.append(c...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039475", "row_id": 39475, "seed_ids": "['Qwen2-72B-Instruct_86610']" }
0.614856
Filter_39475
I
[ "fibonacci_recursive", "print_first_50_fibonacci" ]
2
[ [ "print_first_50_fibonacci", "fibonacci_recursive" ] ]
1
[]
false
[]
false
pytest
true
[]
true
284d6201354c68fef4c98db0487ebc688f75f381
09b323d79c9708ed2bf4c7dc5546378957b47273
v1.0
instruct
Filter
Filter_39481_I
Create a Python program that simulates an infinite motion machine, using the concept of generators. The generator should generate a sequence that counts up from 0 indefinitely, returning a new number every time it's called. However, every 5th number should be a special sequence instead of the current counter value - th...
def infinite_motion_machine(): """ A generator that counts up from 0 indefinitely but returns a special Fibonacci sequence every 5th number instead of the counter value. """ fib_sequence = [0, 1, 1, 2, 3] count = 0 index = 0 while True: if count % 5 == 4: yield fib_s...
from solution import infinite_motion_machine, fetch_first_15 def test_first_15_numbers(): expected_result = [0, 1, 2, 3, 0, 5, 6, 7, 8, 1, 10, 11, 12, 13, 1] assert fetch_first_15() == expected_result def test_fibonacci_sequence_in_positions(): generator = infinite_motion_machine() for _ in range(4): ...
[ { "docstring": "A generator that counts up from 0 indefinitely but returns a special Fibonacci sequence\nevery 5th number instead of the counter value.", "function_declaration": "def infinite_motion_machine():", "function_name": "infinite_motion_machine", "parameter_list": "()" }, { "docstri...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def infinite_motion_machine():\n \"\"\"\n A generator that counts up from 0 indefinitely but returns a special Fibonacci sequence\n every 5th number instead of the counter value.\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039481", "row_id": 39481, "seed_ids": "['Qwen2-72B-Instruct_86621']" }
0.593731
Filter_39481
I
[ "infinite_motion_machine", "fetch_first_15" ]
2
[ [ "fetch_first_15", "infinite_motion_machine" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cca07fbe71a0d271eea2149b888c6ca2fd656094
7e812fecf36239f6a5604eed6fd2321467180e6f
v1.0
instruct
Filter
Filter_39498_I
Develop a(n) Python program that accepts two string inputs from the user. It then needs to incorporate multiple steps in creating a function which determines if these two inputs are anagrams of each other, disregarding any spaces, special characters, punctuation, and case. The program must also output a sample message ...
import re def clean_string(s): """ Cleans the string by removing spaces, special characters, punctuation, and converting to lowercase. """ return re.sub(r'[^a-zA-Z0-9]', '', s).lower() def are_anagrams(str1, str2): """ Returns True if str1 and str2 are anagrams, otherwise False. """ ...
from solution import clean_string, are_anagrams, anagram_message def test_clean_string(): assert clean_string("Hello, World!") == "helloworld" assert clean_string("Python 3.8") == "python38" assert clean_string("123@!! 456") == "123456" def test_are_anagrams(): assert are_anagrams("Listen", "Silent") ...
[ { "docstring": "Cleans the string by removing spaces, special characters, punctuation,\nand converting to lowercase.", "function_declaration": "def clean_string(s):", "function_name": "clean_string", "parameter_list": "(s)" }, { "docstring": "Returns True if str1 and str2 are anagrams, other...
[ 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 clean_string(s):\n \"\"\"\n Cleans the string by removing spaces, special characters, punctuation,\n and converting to lowercase.\n \"\"\"\n return re.sub(r'[^a...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039498", "row_id": 39498, "seed_ids": "['Qwen2-72B-Instruct_86648']" }
0.621297
Filter_39498
I
[ "clean_string", "are_anagrams", "anagram_message" ]
3
[ [ "anagram_message", "are_anagrams" ], [ "are_anagrams", "clean_string" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ce14a25f4ef925f94ad10d6c0022514db0ae8224
6a82c25f383248394743bef36256169064d28491
v1.0
instruct
Filter
Filter_39516_I
Procure all the elements from a Python dictionary whose key values are prime numbers under 20 but return these values in a new dictionary with keys as 'even' and 'odd' based on whether the element in the original dictionary is even or odd. Include exception handling for any potential errors.
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def filter_and_classify_elements(input_dict): """ Filter elements from the input dictionary whose ...
from solution import filter_and_classify_elements def test_filter_and_classify_elements_basic(): input_dict = {2: 4, 3: 9, 5: 6, 7: 7, 11: 8, 13: 1} expected_output = {'even': [4, 6, 8], 'odd': [9, 7, 1]} assert filter_and_classify_elements(input_dict) == expected_output def test_filter_and_classify_eleme...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Filter elements from the input dictionary whose keys are prime numbers under 20,\nand classify the values into 'even' and 'odd...
[ 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(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039516", "row_id": 39516, "seed_ids": "['Qwen2-72B-Instruct_86688']" }
0.605595
Filter_39516
I
[ "is_prime", "filter_and_classify_elements" ]
2
[ [ "filter_and_classify_elements", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7fcd389a082954d3510a0620e577c6a7dd171249
1570beaf3362208ba39edbd8f646d7949aec43c1
v1.0
instruct
Filter
Filter_39534_I
Describe the logic behind the quicksort algorithm. Then, implement this algorithm in the programming language of your choice, further optimize it using the 'median of three' pivot selection method, and compare its performance to the regular implementation.
import random def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[random.randint(0, len(arr) - 1)] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quicksort(left) + middle + quicksort(right) def median_o...
import random from solution import quicksort, quicksort_median_of_three def test_quicksort_empty(): assert quicksort([]) == [] def test_quicksort_single_element(): assert quicksort([1]) == [1] def test_quicksort_sorted(): assert quicksort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_quicksort_reverse_so...
[ { "docstring": null, "function_declaration": "def quicksort(arr):", "function_name": "quicksort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def median_of_three(arr, low, high):", "function_name": "median_of_three", "parameter_list": "(arr, low, hi...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quicksort(arr):\n \"\"\"\n Regular Quicksort implementation.\n \"\"\"\n if len(arr) <= 1:\n return arr\n pivot = arr[0]\n less = [x for x in arr[1:] if x <= pivot]...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039534", "row_id": 39534, "seed_ids": "['Qwen2-72B-Instruct_86716']" }
0.43277
Filter_39534
I
[ "quicksort", "median_of_three", "quicksort_median_of_three" ]
3
[ [ "quicksort_median_of_three", "median_of_three" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aabf94eadb7c3d8baf3152117a98a6d91406627a
2740187bb15a34bda5d43c2a5a0a7724053cf31e
v1.0
instruct
Filter
Filter_39536_I
Create a game of tic-tac-toe in Python with a user-friendly interface allowing two players to input their moves in console.
def print_board(board): """ Prints the current state of the board in a user-friendly format. """ for row in board: print(" | ".join(row)) print("-" * 5) def check_winner(board, player): """ Checks if a player has won the game. """ # Check rows for row in board: ...
from solution import print_board, check_winner, check_draw def test_check_winner(): winning_board_rows = [ ["X", "X", "X"], ["O", "X", "O"], ["O", "O", "X"] ] assert check_winner(winning_board_rows, "X") winning_board_cols = [ ["X", "O", " "], ["X", "O", " "], ...
[ { "docstring": "Prints the current state of the board in a user-friendly format.", "function_declaration": "def print_board(board):", "function_name": "print_board", "parameter_list": "(board)" }, { "docstring": "Checks if a player has won the game.", "function_declaration": "def check_w...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_board(board):\n \"\"\"\n Prints the current state of the board.\n \"\"\"\n for row in board:\n print(\"|\".join(row))\n print(\"-\" * 5)\n\ndef check_winner...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039536", "row_id": 39536, "seed_ids": "['Qwen2-72B-Instruct_86720']" }
0.433235
Filter_39536
I
[ "print_board", "check_winner", "check_draw", "tic_tac_toe" ]
4
[ [ "tic_tac_toe", "check_draw" ], [ "tic_tac_toe", "check_winner" ], [ "tic_tac_toe", "print_board" ] ]
3
[]
false
[]
false
pytest
true
[]
true
39debfb68ac9b267338793052a76ee40b0ef55ad
4e71a4bd16a86f4e9dece8602a10f3c6bfc5d6df
v1.0
instruct
Filter
Filter_39539_I
Given a list of numeric strings, write a Python function to calculate the sum of the numerical values in the list. The catch is, some of the strings could be in Roman numeral format. Your function must be able to parse and convert Roman numerals to integers before summing them up. For example, for the given list ["123"...
def roman_to_int(s): roman_map = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } total = 0 prev_value = 0 for char in reversed(s): if roman_map[char] >= prev_value: total += roman_map[char] else: total -= roman_map[char] ...
from solution import sum_of_numeric_strings, roman_to_int def test_roman_to_int(): assert roman_to_int("I") == 1 assert roman_to_int("IV") == 4 assert roman_to_int("VI") == 6 assert roman_to_int("X") == 10 assert roman_to_int("L") == 50 assert roman_to_int("C") == 100 assert roman_to_int("D...
[ { "docstring": null, "function_declaration": "def roman_to_int(s):", "function_name": "roman_to_int", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def sum_of_numeric_strings(lst):", "function_name": "sum_of_numeric_strings", "parameter_list": "(lst)" ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def roman_to_int(roman):\n roman_values = {\n 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000\n }\n total = 0\n prev_value = 0\n for char in reversed(roma...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039539", "row_id": 39539, "seed_ids": "['Qwen2-72B-Instruct_86727']" }
0.637141
Filter_39539
I
[ "roman_to_int", "sum_of_numeric_strings" ]
2
[ [ "sum_of_numeric_strings", "roman_to_int" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a6ce621476a5c20e337d91877944100175e57e3f
a3221acc157c5f3f791f77db25adc87873b8402c
v1.0
instruct
Filter
Filter_39544_I
Write a program that implements the sieve of Eratosthenes algorithm to find all prime numbers between 2 and 5000, but with an additional feature to check the time consumption between two operations compared. Using Python, first implement the basic algorithm, then improve it using the Numba library and compare the time ...
import numpy as np from numba import jit import time def sieve_basic(n): """ Returns a list of prime numbers from 2 to n using the basic sieve of Eratosthenes. """ is_prime = np.ones(n + 1, dtype=bool) is_prime[:2] = False # 0 and 1 are not primes for i in range(2, int(n ** 0.5) + 1): ...
from solution import sieve_basic, sieve_optimized, compare_time import numpy as np def test_sieve_basic(): expected_primes = np.array( [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 1...
[ { "docstring": "Returns a list of prime numbers from 2 to n using the basic sieve of Eratosthenes.", "function_declaration": "def sieve_basic(n):", "function_name": "sieve_basic", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from 2 to n using an optimized sieve ...
[ 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\nfrom numba import jit\nimport time\n\ndef sieve_of_eratosthenes(n):\n \"\"\"\n Implements the sieve of Eratosthenes to find all primes up to n.\n \"\"\"\n is_pr...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00039544", "row_id": 39544, "seed_ids": "['Qwen2-72B-Instruct_86735']" }
0.539833
Filter_39544
I
[ "sieve_basic", "sieve_optimized", "compare_time" ]
3
[ [ "compare_time", "sieve_basic" ], [ "compare_time", "sieve_optimized" ] ]
2
[]
false
[]
false
pytest
true
[ "numba", "numpy" ]
false
050e6bf66a8c5692904451c56f17fa7e6d457604
7e8af210bc8bf97b342c411d24a97139bdc6053a
v1.0
instruct
Filter
Filter_39545_I
Please write a function in Python to calculate the sum of all prime numbers within a given range. The function should take two arguments, the start and end of the range, and return the sum of all prime numbers within that range. Please make sure to include proper documentation for your function.
def is_prime(n): """ Check if a number is prime. Parameters: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(-5) == False def test_sum_of_primes(): ...
[ { "docstring": "Check if a number is prime.\n\nParameters:\nn (int): The number to check.\n\nReturns:\nbool: True if the number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculate the sum o...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n\n :param n: Integer to check for primality.\n :return: True if n is a prime number, False otherwise.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039545", "row_id": 39545, "seed_ids": "['Qwen2-72B-Instruct_86736']" }
0.667107
Filter_39545
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f81c5df54c3bd475894fac8a8c1b560d42512711
fe9d295b01be3cce508c6b1012caef5311f2ac03
v1.0
instruct
Filter
Filter_39568_I
Given a list of airline flight timings, write a code to find the earliest and latest flights. Also, extend the functionality to sort the flights based on departure times and return a unique list of sorted flight timings.
from datetime import datetime def parse_flight_time(time_str): """ Parses a flight time string to a datetime object assuming the format 'HH:MM'. """ return datetime.strptime(time_str, '%H:%M') def find_earliest_and_latest_flights(flights): """ Finds the earliest and latest flight timings from ...
from solution import find_earliest_and_latest_flights, get_sorted_unique_flights def test_find_earliest_and_latest_flights(): flights = ['12:30', '06:15', '23:45', '08:00', '04:50'] earliest, latest = find_earliest_and_latest_flights(flights) assert earliest == '04:50' assert latest == '23:45' ...
[ { "docstring": "Parses a flight time string to a datetime object assuming the format 'HH:MM'.", "function_declaration": "def parse_flight_time(time_str):", "function_name": "parse_flight_time", "parameter_list": "(time_str)" }, { "docstring": "Finds the earliest and latest flight timings fro...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_earliest_flight(flights):\n \"\"\"\n Returns the earliest flight timing from the provided list of flights.\n \"\"\"\n if not flights:\n return None\n return min(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00039568", "row_id": 39568, "seed_ids": "['Qwen2-72B-Instruct_86777']" }
0.426832
Filter_39568
I
[ "parse_flight_time", "find_earliest_and_latest_flights", "get_sorted_unique_flights" ]
3
[ [ "find_earliest_and_latest_flights", "parse_flight_time" ], [ "get_sorted_unique_flights", "parse_flight_time" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f4cfa45e85d161e05a25b3d17cbac0e291694162
a05c45c1ea247e7e6d3fdff93ff33ce011aed897
v1.0
instruct
Filter
Filter_39569_I
I WANT TO BUILD A PYTHON BASED PLATFORM THAT CAN MANAGE MY SONOGRAPHY PRACTICE, WITH PATIENT MANAGEMENT, SCHEDULING, CLINICAL ANALYSIS, PROJECTING AN ESTIMATED RECOVERY TIME etc. WRITE THE PSEUDOCODE FOR THE CORE FUNCTION THAT CAN TAKE IN PATIENT BIO DATA, ANALYZE THEM, PREDICT DURATION TO CHRONICITY, AND PRINT A RECOM...
def analyze_patient(bio_data): """ Analyzes patient biodata to predict duration to chronicity and recommend a recovery program. Parameters: bio_data (dict): Dictionary containing patient biodata including age, medical history, symptoms, etc. Returns: dict: Dictionary containing estimated recov...
from solution import analyze_patient def test_analyze_patient_chronic_disease(): bio_data = { 'age': 45, 'medical_history': ['chronic_disease'], 'symptoms': ['mild_symptoms'] } result = analyze_patient(bio_data) assert result['chronicity_duration'] == 6 assert result['recove...
[ { "docstring": "Analyzes patient biodata to predict duration to chronicity and recommend a recovery program.\n\nParameters:\nbio_data (dict): Dictionary containing patient biodata including age, medical history, symptoms, etc.\n\nReturns:\ndict: Dictionary containing estimated recovery time and recommended reco...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def analyze_patient(bio_data):\n \"\"\"\n Analyzes patient biodata to predict duration to chronicity and recommend a recovery program.\n\n Parameters:\n bio_data (dict): Dictionary...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00039569", "row_id": 39569, "seed_ids": "['Qwen2-72B-Instruct_86778']" }
0.366355
Filter_39569
I
[ "analyze_patient", "predict_chronicity_duration", "formulate_recovery_program", "estimate_doctor_intervention_time" ]
4
[ [ "analyze_patient", "estimate_doctor_intervention_time" ], [ "analyze_patient", "formulate_recovery_program" ], [ "analyze_patient", "predict_chronicity_duration" ] ]
3
[]
false
[]
false
pytest
true
[]
true
9eb3672cb33f2ee1835065dc19514ddb0a898e1d
f5e82700140e2195ad0977c12a54fc9840577c2d