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_1642_I
def check_duplicates(file_path): with open(file_path, 'r') as file: content = file.read() lines = content.splitlines() if len(lines) != len(set(lines)): return True return False def remove_duplicates(file_path): with open(file_path, 'r') as file: content = fi...
def check_duplicates(file_path): """ Check if there are duplicate lines in the file. :param file_path: Path to the file to be checked. :return: True if duplicates are found, False otherwise. """ with open(file_path, 'r') as file: content = file.read() lines = content.splitlines(...
import os import tempfile import pytest from solution import check_duplicates, remove_duplicates, remove_duplicates_from_file def test_check_duplicates_no_duplicates(): with tempfile.NamedTemporaryFile(delete=False, mode='w') as temp_file: temp_file.write("line1\nline2\nline3\n") temp_file_path = t...
[ { "docstring": "Check if there are duplicate lines in the file.\n\n:param file_path: Path to the file to be checked.\n:return: True if duplicates are found, False otherwise.", "function_declaration": "def check_duplicates(file_path):", "function_name": "check_duplicates", "parameter_list": "(file_pa...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_duplicates(file_path):\n with open(file_path, 'r') as file:\n content = file.read()\n lines = content.splitlines()\n if len(lines) != len(set(lines)):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001642", "row_id": 1642, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5119']" }
0.650241
Filter_1642
I
[ "check_duplicates", "remove_duplicates", "remove_duplicates_from_file" ]
3
[ [ "remove_duplicates_from_file", "check_duplicates" ], [ "remove_duplicates_from_file", "remove_duplicates" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ff10d88a63b39f7dc3eb53b5b89261a294891bda
14fd1d2ffe1f2c73857bb6cfb5d64a8a67103d7c
v1.0
instruct
Filter
Filter_1667_I
def modify_list_elements(lst, modification_function): """ This function takes a list and a modification function as input. It applies the modification function to each element in the list and returns the modified list. Args: lst (list): The input list to be modified. modification_f...
def modify_list_elements(lst, modification_function): """ This function takes a list and a modification function as input. It applies the modification function to each element in the list and returns the modified list. Args: lst (list): The input list to be modified. modification_f...
from solution import modify_list_elements, double_elements, square_elements def test_modify_list_elements_doubling(): assert modify_list_elements([1, 2, 3], lambda x: x * 2) == [2, 4, 6] assert modify_list_elements([-1, -2, -3], lambda x: x * 2) == [-2, -4, -6] assert modify_list_elements([0, 1, 0], lambda...
[ { "docstring": "This function takes a list and a modification function as input. \nIt applies the modification function to each element in the list and returns the modified list.\n\nArgs:\n lst (list): The input list to be modified.\n modification_function (function): A function that takes one argument an...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def modify_list_elements(lst, modification_function):\n \"\"\"\n This function takes a list and a modification function as input. \n It applies the modification function to each eleme...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001667", "row_id": 1667, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5208']" }
0.659936
Filter_1667
I
[ "modify_list_elements", "double_elements", "square_elements" ]
3
[ [ "double_elements", "modify_list_elements" ], [ "square_elements", "modify_list_elements" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8102507e0520c4ef2c9cd54b4d6ebe0d0fa9dcd2
ad66c347d5769f6218d0784ac635c3cc6705d902
v1.0
instruct
Filter
Filter_1689_I
This is a Python program that implements a simple binary search algorithm. ```python def binary_search(arr, target): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 guess = arr[mid] if guess == target: return mid elif guess > target: ...
def is_sorted(arr): return all(arr[i] <= arr[i + 1] for i in range(len(arr) - 1)) def binary_search(arr, target): if not is_sorted(arr): raise ValueError("Input array must be sorted.") low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 guess = arr[mid] ...
from solution import binary_search def test_binary_search_sorted_array(): arr = [1, 2, 3, 4, 5] assert binary_search(arr, 3) == 2 assert binary_search(arr, 1) == 0 assert binary_search(arr, 5) == 4 def test_binary_search_target_not_in_array(): arr = [1, 2, 3, 4, 5] assert binary_search(arr, 6)...
[ { "docstring": null, "function_declaration": "def is_sorted(arr):", "function_name": "is_sorted", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def binary_search(arr, target):", "function_name": "binary_search", "parameter_list": "(arr, target)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_sorted(arr):\n return all(arr[i] <= arr[i + 1] for i in range(len(arr) - 1))\n\ndef binary_search(arr, target):\n if not is_sorted(arr):\n raise ValueError(\"Input array mu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001689", "row_id": 1689, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5274']" }
0.64388
Filter_1689
I
[ "is_sorted", "binary_search" ]
2
[ [ "binary_search", "is_sorted" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ae88af3843f179d661d62b503cf8963d4717a786
54ccf9fb68dd47d2c4f46712f0cac0964ad3a887
v1.0
instruct
Filter
Filter_1691_I
def is_prime(n): """Return True if a given number is prime, False otherwise.""" if n < 2: return False for i in range(2, n): if n % i == 0: return False return True def is_prime_list(nums): """Return a list of boolean values where each value corresponds to whether the nu...
def is_prime(n): """Return True if a given number is prime, False otherwise.""" if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def is_prime_list(nums): """Return a list of boolean values where each value corresponds to ...
from solution import is_prime, is_prime_list def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(0) == False assert is_prime(1) == False assert is_prime(13) == True assert is_prime(25) == False def test_is_prime_list(): ...
[ { "docstring": "Return True if a given number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return a list of boolean values where each value corresponds to whether the number at the same index ...
[ 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 Return True if a given number is prime, False otherwise.\n \"\"\"\n if n < 2:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001691", "row_id": 1691, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5280']" }
0.894745
Filter_1691
I
[ "is_prime", "is_prime_list" ]
2
[ [ "is_prime_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0fd96b1e0e6247bf7e68eb471ee0356635906f8c
84119fd3a029e5d10de352a7ce56312282faca88
v1.0
instruct
Filter
Filter_1707_I
# Genetic Algorithm in Python A Genetic Algorithm (GA) is a heuristic search algorithm inspired by Charles Darwin’s theory of natural evolution. This algorithm reflects the process of natural selection where the fittest individuals are selected for reproduction in order to produce the offspring of the next generation....
import random import numpy as np def create_individual(length): """Create a random individual with specified length""" return [random.randint(0,1) for _ in range(length)] def create_population(size, length): """Create a population of random individuals""" return [create_individual(length) for _ in ran...
from solution import create_individual, create_population, fitness, mutation, crossover, selection, genetic_algorithm def test_create_individual(): individual = create_individual(10) assert len(individual) == 10 assert all(bit in [0, 1] for bit in individual) def test_create_population(): population =...
[ { "docstring": "Create a random individual with specified length", "function_declaration": "def create_individual(length):", "function_name": "create_individual", "parameter_list": "(length)" }, { "docstring": "Create a population of random individuals", "function_declaration": "def crea...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport numpy as np\n\ndef create_individual(length):\n \"\"\"Create a random individual with specified length\"\"\"\n return [random.randint(0,1) for _ in range(length)]\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001707", "row_id": 1707, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5323']" }
0.466167
Filter_1707
I
[ "create_individual", "create_population", "fitness", "mutation", "crossover", "selection", "genetic_algorithm" ]
7
[ [ "create_population", "create_individual" ], [ "genetic_algorithm", "create_population" ], [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "mutation" ], [ "genetic_algorithm", "selection" ], [ "selection", "fitness" ] ]
6
[]
false
[]
false
pytest
true
[ "numpy" ]
false
2aabab43570e0bb37ff8a32fca6364161b540398
c16f4c40fdcda589d9966a16dc1b8d8452880e88
v1.0
instruct
Filter
Filter_1718_I
def multiply_numbers(list_of_numbers): result = 1 for number in list_of_numbers: result *= number return result def double_numbers(list_of_numbers): return [n * 2 for n in list_of_numbers] def list_operations(list_of_numbers, operation): if operation == "multiply": return multiply_...
def multiply_numbers(list_of_numbers): result = 1 for number in list_of_numbers: result *= number return result def double_numbers(list_of_numbers): return [n * 2 for n in list_of_numbers] def list_operations(list_of_numbers, operation): if operation == "multiply": return multiply_...
def test_multiply_numbers(): assert multiply_numbers([1, 2, 3, 4, 5]) == 120 assert multiply_numbers([1, -2, 3, -4, 5]) == 120 assert multiply_numbers([1, 2, 3, 0, 5]) == 0 assert multiply_numbers([]) == 1 def test_double_numbers(): assert double_numbers([1, 2, 3, 4, 5]) == [2, 4, 6, 8, 10] ass...
[ { "docstring": null, "function_declaration": "def multiply_numbers(list_of_numbers):", "function_name": "multiply_numbers", "parameter_list": "(list_of_numbers)" }, { "docstring": null, "function_declaration": "def double_numbers(list_of_numbers):", "function_name": "double_numbers",...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def multiply_numbers(list_of_numbers):\n result = 1\n for number in list_of_numbers:\n result *= number\n return result\n\ndef double_numbers(list_of_numbers):\n return [n *...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001718", "row_id": 1718, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5345']" }
0.700645
Filter_1718
I
[ "multiply_numbers", "double_numbers", "list_operations" ]
3
[ [ "list_operations", "double_numbers" ], [ "list_operations", "multiply_numbers" ] ]
2
[]
false
[]
false
pytest
false
[]
true
26658470425293e739629ce02d52d96b1c6cc627
ead7cc3a729ed48c2f37f4f9872abb11afa1c7fc
v1.0
instruct
Filter
Filter_1766_I
def function_with_condition(func, condition): def inner_function(*args, **kwargs): if condition(*args, **kwargs): return func(*args, **kwargs) return "Condition not met" return inner_function @function_with_condition def add(a, b): return a + b
def function_with_condition(condition): def decorator(func): def inner_function(*args, **kwargs): if condition(*args, **kwargs): return func(*args, **kwargs) return "Condition not met" return inner_function return decorator @function_with_condition(lambda...
from solution import add def test_add_positive_numbers(): assert add(2, 3) == 5 def test_add_with_negative_numbers(): assert add(-1, 3) == "Condition not met" assert add(3, -1) == "Condition not met" assert add(-1, -1) == "Condition not met" def test_add_zero(): assert add(0, 3) == "Condition not...
[ { "docstring": null, "function_declaration": "def function_with_condition(condition):", "function_name": "function_with_condition", "parameter_list": "(condition)" }, { "docstring": null, "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)"...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def function_with_condition(func, condition):\n \"\"\"\n A decorator that executes the function only if the condition is met.\n \n Parameters:\n func (function): the function to...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001766", "row_id": 1766, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5478']" }
0.575516
Filter_1766
I
[ "function_with_condition", "add" ]
2
[ [ "add", "function_with_condition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
060c7f15800c573186a1dcd8ef01ed982ac45ec4
76cb8df3f93ad256047b1f3d0548f0d0bc85ad70
v1.0
instruct
Filter
Filter_1784_I
This is a Python solution to the problem using a linked list. However, in the problem statement, it has been mentioned that each list node should contain at least a boolean flag done that will be used to track whether the node has been visited before or not. However, the solution does not account for this flag. How can...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next self.done = False def merge_two_sorted_lists(l1, l2): dummy = ListNode() curr = dummy while l1 and l2: if l1.val < l2.val: curr.next = l1 l1 = l1.next e...
from solution import ListNode, merge_two_sorted_lists, sortList def list_to_python_list(head): """ Helper function to convert ListNode to Python list for easy comparison and checking """ result = [] while head: result.append(head.val) head = head.next return result def test_merge_two_s...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n self.done = False # Initialize the done flag to False\n\ndef merge_two_so...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001784", "row_id": 1784, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5551']" }
0.445939
Filter_1784
I
[ "merge_two_sorted_lists", "sortList" ]
2
[ [ "sortList", "merge_two_sorted_lists" ] ]
1
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
f930b7a525412aa51e7418e6a3a936bd6333b163
bd8e157043414815a3872a54fefcc2611367a9ec
v1.0
instruct
Filter
Filter_1787_I
def is_palindrome(n): return str(n) == str(n)[::-1] def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False i = 3 while i * i <= n: if n % i == 0: return False i += 2 return True def largest_palindrome_...
def is_palindrome(n): """ Check if the given number is a palindrome. """ return str(n) == str(n)[::-1] def is_prime(n): """ Check if the given number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False i = 3 ...
from solution import is_palindrome, is_prime, largest_palindrome_prime def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1221) == True assert is_palindrome(10) == False def test_is_prime(): assert is_prime(2) == True assert is_p...
[ { "docstring": "Check if the given number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Check if the given number is a prime.", "function_declaration": "def is_prime(n):", "function_nam...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Check if the given number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef is_prime(n):\n \"\"\"\n Check if the given number ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001787", "row_id": 1787, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5560']" }
0.66501
Filter_1787
I
[ "is_palindrome", "is_prime", "largest_palindrome_prime" ]
3
[ [ "largest_palindrome_prime", "is_palindrome" ], [ "largest_palindrome_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
af0189a607b368b65aa97ac3c467fd270d0f5198
2c3ae2f9b00b24112dfb08ab4ad72b1c0e65fe68
v1.0
instruct
Filter
Filter_1789_I
// This is the implementation of a basic calculator using Python3 ```python def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): if y == 0: return "Error: Division by zero is not allowed" else: return x / y def calculat...
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): if y == 0: return "Error: Division by zero is not allowed" else: return x / y def calculator(): while True: print("This is a simple calculator") pri...
from solution import add, subtract, multiply, divide def test_add(): assert add(3, 2) == 5 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(3, 2) == 1 assert subtract(-1, 1) == -2 assert subtract(0, 0) == 0 def test_multiply(): assert multiply(3, 2) == 6 ...
[ { "docstring": null, "function_declaration": "def add(x, y):", "function_name": "add", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def subtract(x, y):", "function_name": "subtract", "parameter_list": "(x, y)" }, { "docstring": null, "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(x, y):\n return x + y\n\ndef subtract(x, y):\n return x - y\n\ndef multiply(x, y):\n return x * y\n\ndef divide(x, y):\n if y == 0:\n return \"Error: Division by zer...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001789", "row_id": 1789, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5574']" }
0.566835
Filter_1789
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
7f406d6c77d3d52b45ba7360b455a5b66f3c66e0
b0629db4e4fd04bf961da34904683e79fd813b0e
v1.0
instruct
Filter
Filter_1791_I
# The Caesar Cipher is one of the simplest (and easiest cracked) encryption methods. It is a Substitution Cipher that involves replacing each letter with the 3rd letter after it in the alphabet. Thus, the letter 'b' becomes 'e', 'c' becomes 'f', etc. Write a Python program that can both encrypt and decrypt using this m...
def caesar_cipher(text, shift=3): """ Encrypt or decrypt the given text using a Caesar cipher with the provided shift. """ alphabet = "abcdefghijklmnopqrstuvwxyz" transformed_text = "" for char in text: if char.isalpha(): position = alphabet.index(char.lower()) n...
from solution import caesar_cipher, caesar_cipher_decrypt def test_caesar_cipher_encrypt(): assert caesar_cipher("abc") == "def" assert caesar_cipher("xyz") == "abc" assert caesar_cipher("ABC") == "DEF" assert caesar_cipher("Hello, World!") == "Khoor, Zruog!" def test_caesar_cipher_decrypt(): asse...
[ { "docstring": "Encrypt or decrypt the given text using a Caesar cipher with the provided shift.", "function_declaration": "def caesar_cipher(text, shift=3):", "function_name": "caesar_cipher", "parameter_list": "(text, shift=3)" }, { "docstring": "Decrypt the given text using a Caesar ciphe...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher(text, mode='encrypt'):\n \"\"\"\n Encrypt or decrypt the text using Caesar Cipher method based on the mode.\n \n :param text: string, input text to be encrypted o...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001791", "row_id": 1791, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5582']" }
0.701195
Filter_1791
I
[ "caesar_cipher", "caesar_cipher_decrypt", "main" ]
3
[ [ "caesar_cipher_decrypt", "caesar_cipher" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2999b3269f8adb083134b6ab97a792ca82fcee6d
e04a613711a1b37bc0a9c714c6f19d960ec259d6
v1.0
instruct
Filter
Filter_1793_I
import os def calculate_total_cost(prices): return sum(prices) def calculate_average_cost(prices): return calculate_total_cost(prices) / len(prices) def find_cheapest_item(prices): return min(prices) def find_expensive_item(prices): return max(prices) def find_items_in_budget(prices, budget): r...
def calculate_total_cost(prices): """ Returns the total cost of all items in the list. """ return sum(prices) def calculate_average_cost(prices): """ Returns the average cost of items in the list. """ return calculate_total_cost(prices) / len(prices) if prices else 0 def find_cheapest_...
from solution import ( calculate_total_cost, calculate_average_cost, find_cheapest_item, find_expensive_item, find_items_in_budget, calculate_total_cost_within_budget ) def test_calculate_total_cost(): assert calculate_total_cost([10.99, 5.99, 7.99, 3.99, 12.99]) == 41.95 assert calcula...
[ { "docstring": "Returns the total cost of all items in the list.", "function_declaration": "def calculate_total_cost(prices):", "function_name": "calculate_total_cost", "parameter_list": "(prices)" }, { "docstring": "Returns the average cost of items in the list.", "function_declaration"...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_total_cost_of_items_in_budget(prices, budget):\n \"\"\"\n Calculate the total cost of items within a certain budget.\n \n Parameters:\n prices (list of float): Lis...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001793", "row_id": 1793, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5591']" }
0.53476
Filter_1793
I
[ "calculate_total_cost", "calculate_average_cost", "find_cheapest_item", "find_expensive_item", "find_items_in_budget", "calculate_total_cost_within_budget" ]
6
[ [ "calculate_average_cost", "calculate_total_cost" ], [ "calculate_total_cost_within_budget", "calculate_total_cost" ], [ "calculate_total_cost_within_budget", "find_items_in_budget" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e14f96097c909ec4c802ef2a2527629390822925
80ecb48d6f01cee6b0d20dbd2608399d04062512
v1.0
instruct
Filter
Filter_1803_I
import csv import os # Read the csv file def read_csv(filename): with open(filename, 'r') as file: reader = csv.reader(file) return [row for row in reader] # Write to a csv file def write_csv(filename, data): with open(filename, 'w', newline='') as file: writer = csv.writer(file) ...
import csv import os # Read the csv file def read_csv(filename): with open(filename, 'r') as file: reader = csv.reader(file) return [row for row in reader] # Write to a csv file def write_csv(filename, data): with open(filename, 'w', newline='') as file: writer = csv.writer(file) ...
import os import csv from solution import read_csv, write_csv, get_csv_files, search_string_in_csv_files def create_test_csv(directory, filename, data): os.makedirs(directory, exist_ok=True) write_csv(os.path.join(directory, filename), data) def test_create_read_csv(): filename = 'test.csv' data = [['...
[ { "docstring": null, "function_declaration": "def read_csv(filename):", "function_name": "read_csv", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def write_csv(filename, data):", "function_name": "write_csv", "parameter_list": "(filename, data)"...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport os\n\n# Read the csv file\ndef read_csv(filename):\n with open(filename, 'r') as file:\n reader = csv.reader(file)\n return [row for row in reader]\n\n# Wri...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001803", "row_id": 1803, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5612']" }
0.695075
Filter_1803
I
[ "read_csv", "write_csv", "get_csv_files", "search_string_in_csv_files" ]
4
[ [ "search_string_in_csv_files", "get_csv_files" ], [ "search_string_in_csv_files", "read_csv" ] ]
2
[]
false
[]
false
pytest
true
[]
true
49f2b9e9351657dd219e06cc13cbc2a11108c98f
7d89fd81bd461a71c65cec7ef1971515dfc14dc8
v1.0
instruct
Filter
Filter_1809_I
from raychorn 1. Write a program that prints a tic-tac-toe board 2. Update the program to also handle user input and switch between two players 3. Update the program to check for a winner after each move Here are the requirements: The board should be a 3x3 grid of numbers 1 to 9 The players should be 'X' and 'O' The...
def print_board(board): print(f'{board[0]} | {board[1]} | {board[2]}') print('---------') print(f'{board[3]} | {board[4]} | {board[5]}') print('---------') print(f'{board[6]} | {board[7]} | {board[8]}') def check_winner(board): # check rows for i in range(0, 7, 3): if board[i] == bo...
import pytest def test_check_winner(): from solution import check_winner # Test horizontal winners assert check_winner(['X', 'X', 'X', '4', 'O', '6', 'O', '8', 'O']) == 'X' assert check_winner(['1', '2', '3', 'O', 'O', 'O', '7', 'X', 'X']) == 'O' # Test vertical winners assert check_w...
[ { "docstring": null, "function_declaration": "def print_board(board):", "function_name": "print_board", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def check_winner(board):", "function_name": "check_winner", "parameter_list": "(board)" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_board(board):\n print(f'{board[0]} | {board[1]} | {board[2]}')\n print('---------')\n print(f'{board[3]} | {board[4]} | {board[5]}')\n print('---------')\n print(f'{bo...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001809", "row_id": 1809, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5640']" }
0.55586
Filter_1809
I
[ "print_board", "check_winner", "is_full", "game" ]
4
[ [ "game", "check_winner" ], [ "game", "is_full" ], [ "game", "print_board" ] ]
3
[]
false
[]
false
pytest
true
[]
true
9954017dc1b9eaf2dff2807ab1984bec5e620c97
f4c2f16f8e723f733e5e2c307c416c54d23fc849
v1.0
instruct
Filter
Filter_1810_I
def extract_numbers(text): numbers = set() temp = "" for char in text: if char.isdigit(): temp += char elif temp: numbers.add(int(temp)) temp = "" if temp: numbers.add(int(temp)) return numbers def find_largest_number(text): return max...
def extract_numbers(text): """ Extracts all unique numbers from the given text. Args: text (str): The input text containing words and numbers. Returns: set: A set containing all unique numbers found in the text. """ numbers = set() temp = "" for char in text: if...
from solution import extract_numbers, find_largest_number def test_extract_numbers(): assert extract_numbers("abc123def45gh6") == {123, 45, 6} assert extract_numbers("7 apples and 3 oranges") == {7, 3} assert extract_numbers("no numbers here!") == set() assert extract_numbers("9876543210") == {98765432...
[ { "docstring": "Extracts all unique numbers from the given text.\n\nArgs:\ntext (str): The input text containing words and numbers.\n\nReturns:\nset: A set containing all unique numbers found in the text.", "function_declaration": "def extract_numbers(text):", "function_name": "extract_numbers", "pa...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def extract_numbers(text):\n \"\"\"\n Extracts numbers from a given text and returns them as a set of integers.\n \"\"\"\n numbers = set()\n temp = \"\"\n for char in text:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001810", "row_id": 1810, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5642']" }
0.678381
Filter_1810
I
[ "extract_numbers", "find_largest_number" ]
2
[ [ "find_largest_number", "extract_numbers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b9e0fedfb325a0164ea96a092c4e8174f9de9fb1
81e056a17d8776be8fd1f7fda5c0254f03c504ec
v1.0
instruct
Filter
Filter_1828_I
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def primes_in_range(start, end): primes = [] for num in range(start, end + 1): if is_prime(num): primes.append(num) return primes ...
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def primes_in_range(start, end): primes = [] for num in range(start, end + 1): if is_prime(num): primes.append(num) return primes ...
from solution import is_prime, primes_in_range, sum_of_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(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False def ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def primes_in_range(start, end):", "function_name": "primes_in_range", "parameter_list": "(start, end)" }, { ...
[ 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 Determines if a number n is prime.\n \"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001828", "row_id": 1828, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5710']" }
0.76033
Filter_1828
I
[ "is_prime", "primes_in_range", "sum_of_primes_in_range" ]
3
[ [ "primes_in_range", "is_prime" ], [ "sum_of_primes_in_range", "primes_in_range" ] ]
2
[]
false
[]
false
pytest
true
[]
true
908a87c036629ed509e6f801eda001a409174066
2041930cb8a29b1e882d62557b41f5637a7b888d
v1.0
instruct
Filter
Filter_1894_I
def check_prime(n): """Check if a number is prime or not.""" if n <= 1: return False elif n <= 3: return True elif n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return ...
def check_prime(n): """ Check if a number is prime or not. """ if n <= 1: return False elif n <= 3: return True elif n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import check_prime, is_prime, print_primes def test_check_prime(): assert check_prime(1) == False assert check_prime(2) == True assert check_prime(3) == True assert check_prime(4) == False assert check_prime(5) == True assert check_prime(9) == False assert check_prime(11) == T...
[ { "docstring": "Check if a number is prime or not.", "function_declaration": "def check_prime(n):", "function_name": "check_prime", "parameter_list": "(n)" }, { "docstring": "Check if all numbers in the input list are prime or not.", "function_declaration": "def is_prime(*args):", "f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_prime(n):\n \"\"\"\n Check if a number is prime or not.\n\n Parameters:\n n (int): The number to be checked.\n\n Returns:\n bool: True if n is a prime number, False...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001894", "row_id": 1894, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5933']" }
0.818187
Filter_1894
I
[ "check_prime", "is_prime", "print_primes" ]
3
[ [ "is_prime", "check_prime" ], [ "print_primes", "check_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3c4e82d027c8ff6f5346041e1b35727b27141fac
4fc6f72b04dea697f41203039b07bb78c83ce170
v1.0
instruct
Filter
Filter_1909_I
Design a simple program to simulate a game of Hangman. Here's a simple implementation of a Hangman game in Python: **Hangman Game** ================ **Game Description** ------------------- Hangman is a guessing game where one player thinks of a word, and the other player tries to guess the word by suggesting lette...
import random HANGMAN_PICS = [''' +---+ | | | | | | =========''', ''' +---+ | | O | | | | =========''', ''' +---+ | | O | | | | | =========''', ''' +---+ | | O | /| | | | =========''', ''' +---+ | | O ...
from solution import getRandomWord, displayBoard, getGuess, playAgain, HANGMAN_PICS, WORDS def test_getRandomWord(): word = getRandomWord(WORDS) assert word in WORDS def test_displayBoard(): displayBoard(HANGMAN_PICS, "aeiou", "bcdf", "badger") # Since displayBoard prints output, this is a placeholder...
[ { "docstring": null, "function_declaration": "def getRandomWord(wordList):", "function_name": "getRandomWord", "parameter_list": "(wordList)" }, { "docstring": null, "function_declaration": "def displayBoard(HANGMAN_PICS, missedLetters, correctLetters, secretWord):", "function_name":...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\nHANGMAN_PICS = ['''\n +---+\n | |\n |\n |\n |\n |\n=========''', '''\n +---+\n | |\n O |\n |\n |\n |\n=========''', '''\n +---+\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001909", "row_id": 1909, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6002']" }
0.481217
Filter_1909
I
[ "getRandomWord", "displayBoard", "getGuess", "playAgain", "hangman" ]
5
[ [ "hangman", "displayBoard" ], [ "hangman", "getGuess" ], [ "hangman", "getRandomWord" ], [ "hangman", "playAgain" ] ]
4
[]
false
[]
false
pytest
true
[]
true
e79fea348cb6f968f1bbe2b49e4ef165d29dae93
c3a86a8e35cc96b49c0062ae1448b6fa90a98611
v1.0
instruct
Filter
Filter_1940_I
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def coincidence_index(numbers): prime_numbers = [n for n in numbers if is_prime(n)] return sum(prime_numbers) / len(prime_numbers) if prime_numbers else 0
def is_prime(n): """ Check if a number is a prime number. """ if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def coincidence_index(numbers): """ Calculate the average of prime numbers in the given list of nu...
from solution import is_prime, coincidence_index 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 assert is_prime(-3) == F...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculate the average of prime numbers in the given list of numbers.", "function_declaration": "def coincidence_index...
[ 0, 0, 1 ]
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 Returns True if n is a prime number, else False.\n \"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001940", "row_id": 1940, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6099']" }
0.680888
Filter_1940
I
[ "is_prime", "coincidence_index" ]
2
[ [ "coincidence_index", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
79ad2126617faae1f984348ab1a51518e8f3e0cb
429a9738db6b3b4ef7e4c988f023f9da24ed552c
v1.0
instruct
Filter
Filter_1946_I
import tkinter as tk from tkinter import filedialog import csv import pandas as pd def import_csv_data(): global file_path file_path = filedialog.askopenfilename() print(file_path) df = pd.read_csv(file_path) return df def generate_csv(): print(file_path) df = pd.read_csv(file_path) df...
import tkinter as tk from tkinter import filedialog import csv import pandas as pd import os file_path = "" def import_csv_data(): global file_path file_path = filedialog.askopenfilename() print(file_path) df = pd.read_csv(file_path) return df def generate_csv(): global file_path print(fi...
def test_get_new_file_path(): assert get_new_file_path("test.csv") == "test_with_discount.csv" assert get_new_file_path("example/file/path/data.csv") == "example/file/path/data_with_discount.csv" assert get_new_file_path("data.backup.csv") == "data.backup_with_discount.csv"
[ { "docstring": null, "function_declaration": "def import_csv_data():", "function_name": "import_csv_data", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def generate_csv():", "function_name": "generate_csv", "parameter_list": "()" }, { "docstring...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import tkinter as tk\nfrom tkinter import filedialog\nimport csv\nimport pandas as pd\nimport os\n\ndef import_csv_data():\n global file_path\n file_path = filedialog.askopenfilename()\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001946", "row_id": 1946, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6112']" }
0.587316
Filter_1946
I
[ "import_csv_data", "generate_csv", "get_new_file_path", "main" ]
4
[ [ "generate_csv", "get_new_file_path" ] ]
1
[]
false
[]
false
pytest
false
[ "pandas" ]
false
e849b4e42bd928d687a516e3142e19b1d9b7ecc7
8e32914fa2f166abdbcf68f436d9f64177b80ad6
v1.0
instruct
Filter
Filter_1957_I
# Problem Given a 2D array or matrix, find the longest increasing subsequence (LIS) of the first column and the last column. The LIS is a subsequence where every element is greater than its previous element. The problem is to write a printing function that prints all the elements in the increasing order as per the lon...
def longest_increasing_subsequence(arr): """ Returns the longest increasing subsequence in arr. """ if len(arr) == 0: return [] n = len(arr) lis = [1] * n prev_index = [-1] * n for i in range(1, n): for j in range(0, i): if arr[i] > arr[j]: ...
from solution import longest_increasing_subsequence, print_solution def test_longest_increasing_subsequence(): assert longest_increasing_subsequence([10, 10, 10, 10, 10]) == [10] assert longest_increasing_subsequence([80, 80, 80, 80, 80]) == [80] assert longest_increasing_subsequence([1, 2, 3, 4, 5]) == [1...
[ { "docstring": "Returns the longest increasing subsequence in arr.", "function_declaration": "def longest_increasing_subsequence(arr):", "function_name": "longest_increasing_subsequence", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def print_solution(matrix...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_increasing_subsequence(arr):\n \"\"\"\n Returns the longest increasing subsequence in arr.\n \"\"\"\n if len(arr) == 0:\n return []\n \n n = len(arr)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001957", "row_id": 1957, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6157']" }
0.669573
Filter_1957
I
[ "longest_increasing_subsequence", "print_solution" ]
2
[ [ "print_solution", "longest_increasing_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
03bcb0f16b71525642fb34e019812d606ba63013
0e72fd637ba2a1f9cbc28f0ab5f6f967d13bb7be
v1.0
instruct
Filter
Filter_1958_I
def is_prime(n): """Check if a number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def prim...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
def test_is_prime_number(): assert is_prime_number(2) == True assert is_prime_number(3) == True assert is_prime_number(4) == False assert is_prime_number(5) == True assert is_prime_number(0) == False assert is_prime_number(1) == False assert is_prime_number(-5) == False assert is_prime_n...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Compute the prime factors of a number.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors"...
[ 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_0
{ "original_instruction": "", "prompt_id": "00001958", "row_id": 1958, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6160']" }
0.783843
Filter_1958
I
[ "is_prime", "prime_factors", "is_prime_number", "get_prime_factors" ]
4
[ [ "get_prime_factors", "prime_factors" ], [ "is_prime_number", "is_prime" ] ]
2
[]
false
[]
false
pytest
false
[]
true
aa528924e9914e5fff81eec83492f00c0e30face
4b05abe1bb61354759bc27da9508a2c2670d3129
v1.0
instruct
Filter
Filter_1984_I
def check_prime(n): """Check if a number is prime.""" if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def solve(n): """Solve the problem.""" primes = [num for num in range(2, n + 1) if check_prime(num)] return ...
def check_prime(n): """ Check if a number is prime. """ if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def solve(n): """ Return the maximum prime number less than or equal to n. """ primes = [num f...
from solution import check_prime, solve def test_check_prime(): assert check_prime(2) == True assert check_prime(3) == True assert check_prime(4) == False assert check_prime(5) == True assert check_prime(1) == False assert check_prime(0) == False assert check_prime(-1) == False assert c...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def check_prime(n):", "function_name": "check_prime", "parameter_list": "(n)" }, { "docstring": "Return the maximum prime number less than or equal to n.", "function_declaration": "def solve(n):", "function_name":...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n < 2:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001984", "row_id": 1984, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6282']" }
0.807279
Filter_1984
I
[ "check_prime", "solve" ]
2
[ [ "solve", "check_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bd45731994c2040f45ca01b59c22f5a58a90ba1f
d31d2d8b3ab459809e31ebe9845a2e1a933e100a
v1.0
instruct
Filter
Filter_1994_I
def create_sequence(n): return [i for i in range(1, n+1) if i % 2 == 0] def is_prime(n): 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 ...
def create_sequence(n): """ Creates a list of even numbers from 1 to n (inclusive if n is even). """ return [i for i in range(1, n+1) if i % 2 == 0] def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 ==...
def test_create_sequence(): assert create_sequence(10) == [2, 4, 6, 8, 10] assert create_sequence(1) == [] assert create_sequence(0) == [] assert create_sequence(5) == [2, 4] def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is...
[ { "docstring": "Creates a list of even numbers from 1 to n (inclusive if n is even).", "function_declaration": "def create_sequence(n):", "function_name": "create_sequence", "parameter_list": "(n)" }, { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def create_sequence(n):\n \"\"\"\n Creates a list of even numbers from 1 to n (inclusive if n is even).\n \"\"\"\n return [i for i in range(1, n+1) if i % 2 == 0]\n\ndef is_prime(n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001994", "row_id": 1994, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6315']" }
0.750866
Filter_1994
I
[ "create_sequence", "is_prime", "filter_primes", "solve" ]
4
[ [ "filter_primes", "is_prime" ], [ "solve", "create_sequence" ], [ "solve", "filter_primes" ] ]
3
[]
false
[]
false
pytest
false
[]
true
351d81dd257792170d5b10e3edfdc2c2e1680759
88fb882e1a9fa96cb39360921d58b7730d19fd5b
v1.0
instruct
Filter
Filter_1998_I
This is the end of the third week of our first month of learning Python. We have covered variables, data types, basic operations, functions, if-else statements, and loops. We've written a program that takes user input and decides whether it's a perfect square. Currently, our program is not very user-friendly - the user...
import math def is_perfect_square(n): """ Returns True if n is a perfect square, otherwise False. """ if n < 0: return False root = math.isqrt(n) return root * root == n def guessing_game(): """ Runs a guessing game where the user keeps guessing until they correctly guess a per...
from solution import is_perfect_square def test_is_perfect_square(): assert is_perfect_square(0) == True assert is_perfect_square(1) == True assert is_perfect_square(4) == True assert is_perfect_square(9) == True assert is_perfect_square(16) == True assert is_perfect_square(25) == True def tes...
[ { "docstring": "Returns True if n is a perfect square, otherwise False.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Runs a guessing game where the user keeps guessing until they correctly guess a perf...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(n):\n \"\"\"\n Returns True if n is a perfect square, otherwise False.\n \"\"\"\n if n < 0:\n return False\n root = math.isqrt(n)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001998", "row_id": 1998, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6324']" }
0.683151
Filter_1998
I
[ "is_perfect_square", "guessing_game" ]
2
[ [ "guessing_game", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e8ef722e6fc6f573673256c306e14cff2691dd5f
6b2213e414ee080b8a2341317fc3c94e234b7f6b
v1.0
instruct
Filter
Filter_2009_I
This is a simple implementation of merge sort algorithm using recursion in Python. ```python def merge_sort(arr): 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)...
def merge_sort(arr, compare): if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = merge_sort(arr[:mid], compare) right_half = merge_sort(arr[mid:], compare) return merge(left_half, right_half, compare) def merge(left, right, compare): merged = [] left_index = 0 right_in...
def test_merge_sort_ascending(): arr = [4, 2, 7, 1, 9, 3] sorted_arr = merge_sort(arr, ascending_compare) assert sorted_arr == [1, 2, 3, 4, 7, 9] def test_merge_sort_descending(): arr = [4, 2, 7, 1, 9, 3] sorted_arr = merge_sort(arr, descending_compare) assert sorted_arr == [9, 7, 4, 3, 2, 1] ...
[ { "docstring": null, "function_declaration": "def merge_sort(arr, compare):", "function_name": "merge_sort", "parameter_list": "(arr, compare)" }, { "docstring": null, "function_declaration": "def merge(left, right, compare):", "function_name": "merge", "parameter_list": "(left, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr, key=None, reverse=False):\n if key is None:\n key = lambda x: x\n \n comparator = (lambda x, y: x <= y) if not reverse else (lambda x, y: x >= y)\n \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002009", "row_id": 2009, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6348']" }
0.61186
Filter_2009
I
[ "merge_sort", "merge", "ascending_compare", "descending_compare" ]
4
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
false
[]
true
728c833ef0c4f90a2abf901ccd2b7e9acff8fc4d
1a610afa0edf48f96b4135c6d458cb08ed92dfb2
v1.0
instruct
Filter
Filter_2035_I
from collections import defaultdict def dfs(t, graph): stack = [t] visited = set() while stack: node = stack.pop() if node not in visited: visited.add(node) if t == 3: print(f"visited {node}") stack += [x for x in graph[node] if x not in v...
from collections import defaultdict def dfs(t, graph, visited): stack = [t] while stack: node = stack.pop() if node not in visited: visited.add(node) stack += [x for x in graph[node] if x not in visited] def createGraph(edges): graph = defaultdict(list) for i, j...
from solution import createGraph, traverse_graph def test_graph_traversal(): edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 5), (4, 6), (3, 6)] graph = createGraph(edges) visited = traverse_graph(graph) assert visited == {1, 2, 3, 4, 5, 6} def test_graph_traversal_disconnected(): edges = [(1, 2), (1...
[ { "docstring": null, "function_declaration": "def dfs(t, graph, visited):", "function_name": "dfs", "parameter_list": "(t, graph, visited)" }, { "docstring": null, "function_declaration": "def createGraph(edges):", "function_name": "createGraph", "parameter_list": "(edges)" }, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef dfs(t, graph, visited=set()):\n stack = [t]\n while stack:\n node = stack.pop()\n if node not in visited:\n visited.ad...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002035", "row_id": 2035, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6445']" }
0.480111
Filter_2035
I
[ "dfs", "createGraph", "traverse_graph", "main" ]
4
[ [ "traverse_graph", "dfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5d5f3c51608c98da5e2416c076470f068c88d74e
5d2f629506e876f4db476c4509197e07b0d26176
v1.0
instruct
Filter
Filter_2046_I
def binary_search(arr, target): low, high = 0, len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] < target: low = mid + 1 else: high = mid - 1 return -1 def rotated_binary_search(arr, ta...
def binary_search(arr, target): """ Conduct a binary search on a sorted array. :param arr: List of sorted elements :param target: Target element to find :return: Index of target element if found, otherwise -1 """ low, high = 0, len(arr) - 1 while low <= high: mid = (low + hi...
from solution import binary_search, rotated_binary_search, is_sorted def test_binary_search(): assert binary_search([1, 2, 3, 4, 5], 3) == 2 assert binary_search([1, 2, 3, 4, 5], 1) == 0 assert binary_search([1, 2, 3, 4, 5], 5) == 4 assert binary_search([1, 2, 3, 4, 5], 6) == -1 assert binary_searc...
[ { "docstring": "Conduct a binary search on a sorted array.\n\n:param arr: List of sorted elements\n:param target: Target element to find\n:return: Index of target element if found, otherwise -1", "function_declaration": "def binary_search(arr, target):", "function_name": "binary_search", "parameter_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def binary_search(arr, target):\n \"\"\"\n Performs binary search on a sorted array.\n\n Parameters:\n arr (list): Sorted list of elements.\n target: Element to search for in th...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002046", "row_id": 2046, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6481']" }
0.61106
Filter_2046
I
[ "binary_search", "rotated_binary_search", "is_sorted" ]
3
[ [ "rotated_binary_search", "is_sorted" ] ]
1
[]
false
[]
false
pytest
true
[]
true
235a4db8d1b5d912f5bd820596b39c28f931c865
208863d5a3003da64163662fce199b1a14627da2
v1.0
instruct
Filter
Filter_2062_I
def is_prime(n): """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 d in range(3, max_divisor, 2): if n % d == 0: return False return True def nth_prime(n)...
def is_prime(n): """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 d in range(3, max_divisor, 2): if n % d == 0: return False return True def nth_prime(n)...
def test_is_prime(): assert is_prime(2) == True, "2 should be prime" assert is_prime(3) == True, "3 should be prime" assert is_prime(4) == False, "4 should not be prime" assert is_prime(5) == True, "5 should be prime" assert is_prime(17) == True, "17 should be prime" assert is_prime(18) == False...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return the nth prime number.", "function_declaration": "def nth_prime(n):", "function_name": "nth_prime", "parameter_l...
[ 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 \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n max_divi...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002062", "row_id": 2062, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6550']" }
0.872777
Filter_2062
I
[ "is_prime", "nth_prime" ]
2
[ [ "nth_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2cbd0629eea04a7c4d9e9d44e338d242bd76ed32
2228dfecd80e2179df9c371144bf86e5cc313a9f
v1.0
instruct
Filter
Filter_2076_I
from datetime import datetime from enum import Enum from typing import Optional class Day(Enum): MONDAY = 1 TUESDAY = 2 WEDNESDAY = 3 THURSDAY = 4 FRIDAY = 5 SATURDAY = 6 SUNDAY = 7 def greet(day: Day) -> str: return f"Hello, {day.name}!" def get_todays_date() -> Optional[datetime]: ...
from datetime import datetime from enum import Enum from typing import Optional class Day(Enum): MONDAY = 1 TUESDAY = 2 WEDNESDAY = 3 THURSDAY = 4 FRIDAY = 5 SATURDAY = 6 SUNDAY = 7 def greet(day: Day) -> str: return f"Hello, {day.name}!" def get_todays_date() -> Optional[datetime]: ...
from solution import greet, Day, get_todays_date, get_current_day import pytest from unittest.mock import patch from datetime import datetime def test_greet_monday(): assert greet(Day.MONDAY) == "Hello, MONDAY!" def test_get_todays_date(): result = get_todays_date() assert isinstance(result, datetime) de...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\nfrom enum import Enum\nfrom typing import Optional\n\nclass Day(Enum):\n MONDAY = 1\n TUESDAY = 2\n WEDNESDAY = 3\n THURSDAY = 4\n FRIDAY = 5\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002076", "row_id": 2076, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6616']" }
0.586499
Filter_2076
I
[ "greet", "get_todays_date", "get_current_day", "greet_today" ]
4
[ [ "get_current_day", "get_todays_date" ], [ "greet_today", "get_current_day" ], [ "greet_today", "get_todays_date" ], [ "greet_today", "greet" ] ]
4
[]
false
[ "Day" ]
true
pytest
true
[]
true
ca37aac5510aaad594e2202f2081124a8914907d
476faf3b1d5b660a03bb2172843d5f0625b54c74
v1.0
instruct
Filter
Filter_2080_I
import random # Function to get a random character from a string def getRandomCharacter(string): return random.choice(string) # Function to get all permutations of a string def getPermutations(string): # Base case: if the string is of length 1 or less, return a list containing the string if len(string) <=...
import random def getRandomCharacter(string): """ Function to get a random character from a string. """ return random.choice(string) def getPermutations(string): """ Function to get all permutations of a string. """ if len(string) <= 1: return [string] permutations = [] ...
import pytest from solution import getRandomCharacter, getPermutations, generatePassword, generatePasswordFromPermutations def test_getRandomCharacter(): string = "abcdef" assert getRandomCharacter(string) in string def test_getPermutations(): string = "abc" expected = sorted(["abc", "acb", "bac", "bc...
[ { "docstring": "Function to get a random character from a string.", "function_declaration": "def getRandomCharacter(string):", "function_name": "getRandomCharacter", "parameter_list": "(string)" }, { "docstring": "Function to get all permutations of a string.", "function_declaration": "d...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef getRandomCharacter(string):\n \"\"\"\n Function to get a random character from a string\n \"\"\"\n return random.choice(string)\n\ndef getPermutations(string):...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002080", "row_id": 2080, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6628']" }
0.76015
Filter_2080
I
[ "getRandomCharacter", "getPermutations", "generatePassword", "generatePasswordFromPermutations" ]
4
[ [ "generatePassword", "getRandomCharacter" ], [ "generatePasswordFromPermutations", "getPermutations" ] ]
2
[]
false
[]
false
pytest
true
[]
true
da157d2ac3b1b799797e60638a5c80a65fe9389b
2b9d86e7dfa20579188531440b6636649f10668b
v1.0
instruct
Filter
Filter_2099_I
import socket import select def read_from_socket(sock): return sock.recv(4096) def write_to_socket(sock, data): return sock.sendall(data) def echo_server(): # Create a socket object server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket server_socket.bind(('12...
import socket import select def read_from_socket(sock): return sock.recv(4096) def write_to_socket(sock, data): return sock.sendall(data) def echo_server(): # Create a socket object server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket server_socket.bind(('12...
import socket import threading from solution import start_server, read_from_socket, write_to_socket def echo_server_thread(): server_thread = threading.Thread(target=start_server) server_thread.daemon = True server_thread.start() def test_echo_server(): echo_server_thread() client_socket = socket...
[ { "docstring": null, "function_declaration": "def read_from_socket(sock):", "function_name": "read_from_socket", "parameter_list": "(sock)" }, { "docstring": null, "function_declaration": "def write_to_socket(sock, data):", "function_name": "write_to_socket", "parameter_list": "(...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import socket\nimport select\n\n\ndef read_from_socket(sock):\n return sock.recv(4096)\n\n\ndef write_to_socket(sock, data):\n return sock.sendall(data)\n\n\ndef echo_server():\n # Cr...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002099", "row_id": 2099, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6687']" }
0.702888
Filter_2099
I
[ "read_from_socket", "write_to_socket", "echo_server", "start_server" ]
4
[ [ "echo_server", "read_from_socket" ], [ "echo_server", "write_to_socket" ], [ "start_server", "echo_server" ] ]
3
[]
false
[]
false
pytest
true
[]
true
aad9c3520328280cb57bf1902d0e882ba67353b8
622c8a9c6ef4154ce96f5dbb67fcd5ac5a41f8cb
v1.0
instruct
Filter
Filter_2109_I
This is a Python code that generates a random puzzle with three sub-puzzles, each with a different theme. The puzzle has a chance to be "correct" or "incorrect". ```python import random # Define the themes for the sub-puzzles THEMES = ["Math", "Science", "History"] # Define the math sub-puzzle def math_sub_puzzle(): ...
import random # Define the themes for the sub-puzzles THEMES = ["Math", "Science", "History"] # Define the math sub-puzzle def math_sub_puzzle(): num1 = random.randint(1, 10) num2 = random.randint(1, 10) operator = random.choice(["+", "-", "*"]) correct_answer = eval(f"{num1} {operator} {num2}") ...
import pytest from solution import math_sub_puzzle, science_sub_puzzle, history_sub_puzzle, generate_puzzle def test_math_sub_puzzle(): num1, operator, num2, answer = math_sub_puzzle() correct_answer = eval(f"{num1} {operator} {num2}") incorrect = answer != correct_answer assert (answer == correct_answ...
[ { "docstring": null, "function_declaration": "def math_sub_puzzle():", "function_name": "math_sub_puzzle", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def science_sub_puzzle():", "function_name": "science_sub_puzzle", "parameter_list": "()" }, { ...
[ 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\n# Define the themes for the sub-puzzles\nTHEMES = [\"Math\", \"Science\", \"History\"]\n\n# Define the math sub-puzzle\ndef math_sub_puzzle():\n num1 = random.randint(1, 10...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002109", "row_id": 2109, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6717']" }
0.492149
Filter_2109
I
[ "math_sub_puzzle", "science_sub_puzzle", "history_sub_puzzle", "generate_puzzle" ]
4
[ [ "generate_puzzle", "history_sub_puzzle" ], [ "generate_puzzle", "math_sub_puzzle" ], [ "generate_puzzle", "science_sub_puzzle" ] ]
3
[]
false
[]
false
pytest
true
[]
true
4269dbfea8204206045fff3db6ec6039b8d83026
43590cbbf551f18f907acfff5d997fde1abfa93d
v1.0
instruct
Filter
Filter_2145_I
import os import re import numpy as np from . import utils def get_freqs(file): freqs = [] for line in open(file): match = re.search(r'\d+', line) if match: freqs.append(int(match.group())) return freqs def get_freqs_sum(file): freqs = get_freqs(file) return sum(freqs) ...
import os import re import numpy as np from functools import partial def get_freqs(file): freqs = [] for line in open(file): match = re.search(r'\d+', line) if match: freqs.append(int(match.group())) return freqs def apply_stat(file, stat_func): freqs = get_freqs(file) ...
import numpy as np from solution import get_freqs_sum, get_freqs_mean, get_freqs_median, get_freqs_std def write_test_file(file_path, content): with open(file_path, 'w') as f: f.write(content) def test_get_freqs_sum(tmp_path): file_path = tmp_path / "test_file.txt" content = "value: 4\nvalue: 5\nv...
[ { "docstring": null, "function_declaration": "def get_freqs(file):", "function_name": "get_freqs", "parameter_list": "(file)" }, { "docstring": null, "function_declaration": "def apply_stat(file, stat_func):", "function_name": "apply_stat", "parameter_list": "(file, stat_func)" ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nimport numpy as np\n\ndef get_freqs(file):\n freqs = []\n with open(file) as f:\n for line in f:\n match = re.search(r'\\d+', line)\n if match:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002145", "row_id": 2145, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6831']" }
0.503703
Filter_2145
I
[ "get_freqs", "apply_stat" ]
2
[ [ "apply_stat", "get_freqs" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
59a4564ffa199d6e502948e2c72f4d5dd532453e
c22203a3dc8578b6aa58e3ec30dc2444328e93f8
v1.0
instruct
Filter
Filter_2155_I
def calculate_gcd(num1, num2): while num2: num1, num2 = num2, num1 % num2 return num1 def find_gcd_of_list(numbers): result = numbers[0] for num in numbers[1:]: result = calculate_gcd(result, num) return result numbers = [48, 18, 36, 24] print(find_gcd_of_list(numbers))
def calculate_gcd(num1, num2): """ Returns the greatest common divisor of num1 and num2. """ while num2: num1, num2 = num2, num1 % num2 return num1 def find_gcd_of_list(numbers): """ Returns the greatest common divisor of a list of numbers. """ result = numbers[0] for nu...
from solution import calculate_gcd, find_gcd_of_list def test_calculate_gcd(): assert calculate_gcd(48, 18) == 6 assert calculate_gcd(18, 48) == 6 assert calculate_gcd(100, 25) == 25 assert calculate_gcd(7, 5) == 1 assert calculate_gcd(0, 5) == 5 assert calculate_gcd(5, 0) == 5 def test_find_g...
[ { "docstring": "Returns the greatest common divisor of num1 and num2.", "function_declaration": "def calculate_gcd(num1, num2):", "function_name": "calculate_gcd", "parameter_list": "(num1, num2)" }, { "docstring": "Returns the greatest common divisor of a list of numbers.", "function_de...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_gcd(num1, num2):\n while num2:\n num1, num2 = num2, num1 % num2\n return num1\n\ndef find_gcd_of_list(numbers):\n \"\"\"\n Returns the GCD of a list of numbers...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002155", "row_id": 2155, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6859']" }
0.765709
Filter_2155
I
[ "calculate_gcd", "find_gcd_of_list" ]
2
[ [ "find_gcd_of_list", "calculate_gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4f94149ade6cacc6f2ababd1f160e8c0e75076a1
9ca440e1fd83d30390beaa9dd7b82a89b7d68604
v1.0
instruct
Filter
Filter_2165_I
def name_to_number(name): if name == 'rock': return 0 elif name == 'Spock': return 1 elif name == 'paper': return 2 elif name == 'lizard': return 3 elif name == 'scissors': return 4 else: return -1 def number_to_name(number): if number == 0: ...
def name_to_number(name): """ Convert name to number. """ name_to_num = { 'rock': 0, 'Spock': 1, 'paper': 2, 'lizard': 3, 'scissors': 4 } return name_to_num.get(name, -1) def number_to_name(number): """ Convert number to name. """ num_to...
from solution import name_to_number, number_to_name, rpsls def test_name_to_number(): assert name_to_number("rock") == 0 assert name_to_number("Spock") == 1 assert name_to_number("paper") == 2 assert name_to_number("lizard") == 3 assert name_to_number("scissors") == 4 assert name_to_number("inv...
[ { "docstring": "Convert name to number.", "function_declaration": "def name_to_number(name):", "function_name": "name_to_number", "parameter_list": "(name)" }, { "docstring": "Convert number to name.", "function_declaration": "def number_to_name(number):", "function_name": "number_to...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "def name_to_number(name):\n \"\"\"\n Convert name to number.\n \"\"\"\n name_to_num = {\n 'rock': 0,\n 'Spock': 1,\n 'paper': 2,\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002165", "row_id": 2165, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6888']" }
0.567311
Filter_2165
I
[ "name_to_number", "number_to_name", "rpsls" ]
3
[ [ "rpsls", "name_to_number" ], [ "rpsls", "number_to_name" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c9ba19a5a5772b79534862b5b89a35a45bf39e3b
695fac2e6c2c56da1ded5caad889be845da5229a
v1.0
instruct
Filter
Filter_2169_I
# This program uses a while loop to generate prime numbers up to a given limit. There is a function to check if a number is prime. The current code is able to print the prime numbers. However, instead of printing the prime numbers, I want to count the number of prime numbers and the sum of the primes up to the given l...
def isPrime(n): """Check if number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def count_a...
from solution import isPrime, count_and_sum_primes def test_isPrime(): assert isPrime(2) == True assert isPrime(3) == True assert isPrime(4) == False assert isPrime(5) == True assert isPrime(10) == False def test_count_and_sum_primes_below_10(): count, total_sum = count_and_sum_primes(10) ...
[ { "docstring": "Check if number is prime.", "function_declaration": "def isPrime(n):", "function_name": "isPrime", "parameter_list": "(n)" }, { "docstring": "Count the number of prime numbers and the sum of the primes up to the given limit.", "function_declaration": "def count_and_sum_pr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def isPrime(n):\n \"\"\"Check if number is prime.\"\"\"\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 ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002169", "row_id": 2169, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6898']" }
0.658209
Filter_2169
I
[ "isPrime", "count_and_sum_primes" ]
2
[ [ "count_and_sum_primes", "isPrime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fdaf384c908c57a5309c14da1a0d742b0f1da4e6
9c34577009361d65cfe9f52aa123a9eff37c3b49
v1.0
instruct
Filter
Filter_2171_I
print on each line a letter of the word "hello" using recursion
def print_hello_recursively(word, index=0): """ Prints each letter of the word "hello" on a new line using recursion. Parameters: word (str): The word to print. index (int): The current index of the word to print. """ if index < len(word): print(word[index]) print_hello_...
from solution import print_hello, print_hello_recursively import io import sys def test_print_hello_output(monkeypatch): # Capture the output of the print_hello function captured_output = io.StringIO() monkeypatch.setattr(sys, 'stdout', captured_output) print_hello() # Verify the output m...
[ { "docstring": "Prints each letter of the word \"hello\" on a new line using recursion.\n\nParameters:\nword (str): The word to print.\nindex (int): The current index of the word to print.", "function_declaration": "def print_hello_recursively(word, index=0):", "function_name": "print_hello_recursively"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_word(word, index=0):\n \"\"\"\n Recursively prints each letter of the given word on a new line.\n \n Args:\n word (str): The word to print.\n index (int): Current i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002171", "row_id": 2171, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6903']" }
0.473342
Filter_2171
I
[ "print_hello_recursively", "print_hello" ]
2
[ [ "print_hello", "print_hello_recursively" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bc51757826ed32e23d429dd5ad17b206a2abdb3a
c28940eef4a98b72ae2f7cba76142fd3f09d4a56
v1.0
instruct
Filter
Filter_2183_I
import random import math def gen_list_of_even(): return [i for i in range(100) if i % 2 == 0] def gen_list_of_odd(): return [i for i in range(100) if i % 2 != 0] def check_prime(num): if num < 2: return False for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: re...
import random import math def gen_list_of_even(): return [i for i in range(100) if i % 2 == 0] def gen_list_of_odd(): return [i for i in range(100) if i % 2 != 0] def check_prime(num): if num < 2: return False for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: re...
from solution import gen_list_of_even, gen_list_of_odd, check_prime, gen_list_of_primes def test_gen_list_of_even(): evens = gen_list_of_even() assert evens == [i for i in range(100) if i % 2 == 0] def test_gen_list_of_odd(): odds = gen_list_of_odd() assert odds == [i for i in range(100) if i % 2 != 0...
[ { "docstring": null, "function_declaration": "def gen_list_of_even():", "function_name": "gen_list_of_even", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def gen_list_of_odd():", "function_name": "gen_list_of_odd", "parameter_list": "()" }, { "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport math\n\ndef gen_list_of_even():\n return [i for i in range(100) if i % 2 == 0]\n\ndef gen_list_of_odd():\n return [i for i in range(100) if i % 2 != 0]\n\ndef check...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002183", "row_id": 2183, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6934']" }
0.589434
Filter_2183
I
[ "gen_list_of_even", "gen_list_of_odd", "check_prime", "gen_list_of_primes", "get_random_prime", "main" ]
6
[ [ "gen_list_of_primes", "check_prime" ], [ "get_random_prime", "gen_list_of_primes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fd4bb7365755e1a65f38a7a8c94e0f59f779f889
62d9d73d82b2a7fc719d6ff9227eddd6398e53c1
v1.0
instruct
Filter
Filter_2193_I
# Allow the user to enter their name and then call them by it throughout one of the following games: Blackjack, Rock-Paper-Scissors, or Tic Tac Toe. ## Step 1: Determine the Games to be Created The problem requires creating one of the games Blackjack, Rock-Paper-Scissors, or Tic Tac Toe and addressing the user by thei...
import random def get_user_name(): """ Prompts the user to enter their name and returns it. """ return input("Please enter your name: ") def get_computer_choice(): """ Randomly selects 'rock', 'paper', or 'scissors' and returns it. """ choices = ['rock', 'paper', 'scissors'] return...
import pytest from unittest.mock import patch from solution import get_computer_choice, determine_winner def test_get_computer_choice(): choices = ['rock', 'paper', 'scissors'] computer_choice = get_computer_choice() assert computer_choice in choices def test_determine_winner_tie(): assert determine_w...
[ { "docstring": "Prompts the user to enter their name and returns it.", "function_declaration": "def get_user_name():", "function_name": "get_user_name", "parameter_list": "()" }, { "docstring": "Randomly selects 'rock', 'paper', or 'scissors' and returns it.", "function_declaration": "de...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_user_name():\n \"\"\"\n Prompts the user to enter their name and returns it.\n \"\"\"\n return input(\"Please enter your name: \")\n\ndef get_computer_choi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002193", "row_id": 2193, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_6966']" }
0.555739
Filter_2193
I
[ "get_user_name", "get_computer_choice", "determine_winner", "play_game" ]
4
[ [ "play_game", "determine_winner" ], [ "play_game", "get_computer_choice" ], [ "play_game", "get_user_name" ] ]
3
[]
false
[]
false
pytest
true
[]
true
a1fc1bbe7353f73181e6e4087f7feb828f2cdba6
1ee8004ffa5f204128d29a8f2d759421cd6b1329
v1.0
instruct
Filter
Filter_2213_I
import time import random def the_game(): print("Welcome to the Guessing Game!") number = random.randint(1, 100) guess = None while guess != number: guess = int(input("Make a guess between 1 and 100: ")) if guess < number: print("Too low!") elif guess > number: ...
import time import random def guessing_game(): print("Welcome to the Guessing Game!") number = random.randint(1, 100) guess = None while guess != number: guess = int(input("Make a guess between 1 and 100: ")) if guess < number: print("Too low!") elif guess > number: ...
def test_guessing_game(monkeypatch): inputs = iter([50, 50]) monkeypatch.setattr('builtins.input', lambda _: next(inputs)) monkeypatch.setattr('random.randint', lambda x, y: 50) import solution solution.guessing_game() def test_the_game_play(monkeypatch): inputs = iter(['1', 50, 50, '2']) ...
[ { "docstring": null, "function_declaration": "def guessing_game():", "function_name": "guessing_game", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def the_game():", "function_name": "the_game", "parameter_list": "()" } ]
[ 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 the_game():\n print(\"Welcome to the Guessing Game!\")\n \n while True:\n choice = input(\"Enter '1' to play the game or '2' to exit: \")\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002213", "row_id": 2213, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7022']" }
0.510996
Filter_2213
I
[ "guessing_game", "the_game" ]
2
[ [ "the_game", "guessing_game" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2a9142e042d2329cac5d3e0c2522f9f21acc5a2c
09be9e8502bbbaaaa51b8a7fb40bf05115e539ce
v1.0
instruct
Filter
Filter_2214_I
import math import random def roll_dice(): """Simulate the roll of a single six-sided die.""" return random.randint(1, 6) def are_friends(a, b): """Check whether two numbers are 'friends' (share an factor).""" return math.gcd(a, b) > 1 def roll_to_match(): """Simulate the roll of two six-sided di...
import math import random def roll_dice(): """Simulate the roll of a single six-sided die.""" return random.randint(1, 6) def are_friends(a, b): """Check whether two numbers are 'friends' (share a factor).""" return math.gcd(a, b) > 1 def roll_to_match(): """Simulate the roll of two six-sided dic...
from solution import roll_dice, are_friends, roll_to_match, simulate_until_threshold def test_roll_dice(): for _ in range(100): result = roll_dice() assert 1 <= result <= 6 def test_are_friends(): assert are_friends(2, 4) == True assert are_friends(3, 6) == True assert are_friends(5, 1...
[ { "docstring": "Simulate the roll of a single six-sided die.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Check whether two numbers are 'friends' (share a factor).", "function_declaration": "def are_friends(a, b):",...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nimport random\n\ndef roll_dice():\n \"\"\"Simulate the roll of a single six-sided die.\"\"\"\n return random.randint(1, 6)\n\ndef are_friends(a, b):\n \"\"\"Check whether...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002214", "row_id": 2214, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7023']" }
0.538853
Filter_2214
I
[ "roll_dice", "are_friends", "roll_to_match", "simulate_until_threshold" ]
4
[ [ "roll_to_match", "are_friends" ], [ "roll_to_match", "roll_dice" ], [ "simulate_until_threshold", "roll_to_match" ] ]
3
[]
false
[]
false
pytest
true
[]
true
b5ad1c1d567a4454de5ac964c9ab15587c2fab7a
78081ec2db2f9a632f0bbb8ae0cc622964548a00
v1.0
instruct
Filter
Filter_2225_I
def calculate_prime_factors(n): i = 2 factors = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(i) if n > 1: factors.append(n) return factors def generate_random_prime(n): import random prime_factors = [] whi...
def calculate_prime_factors(n): i = 2 factors = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(i) if n > 1: factors.append(n) return factors def generate_random_prime(n): import random prime_factors = [] whi...
def test_calculate_prime_factors_small_number(): assert calculate_prime_factors(6) == [2, 3] assert calculate_prime_factors(28) == [2, 2, 7] def test_calculate_prime_factors_large_number(): assert calculate_prime_factors(13195) == [5, 7, 13, 29] def test_calculate_prime_factors_prime_number(): assert ...
[ { "docstring": null, "function_declaration": "def calculate_prime_factors(n):", "function_name": "calculate_prime_factors", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def generate_random_prime(n):", "function_name": "generate_random_prime", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_prime_factors(n):\n \"\"\"\n Returns the prime factors of a given number n.\n \"\"\"\n i = 2\n factors = []\n while i * i <= n:\n if n % i:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002225", "row_id": 2225, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7054']" }
0.756164
Filter_2225
I
[ "calculate_prime_factors", "generate_random_prime" ]
2
[ [ "generate_random_prime", "calculate_prime_factors" ] ]
1
[]
false
[]
false
pytest
false
[]
true
eff111a8f03752b7d4a11143d14ace83559b6050
e50a901800069c1b3960a300d59062a87a6cf292
v1.0
instruct
Filter
Filter_2228_I
# Example code for the problem Here is a code that implements the solution to the problem: ``` def calculate_distance(point1, point2): return ((point2[0] - point1[0]) ** 2 + (point2[1] - point1[1]) ** 2) ** 0.5 def main(): points = [(1, 2), (3, 4), (5, 6)] for i in range(len(points) - 1): point1 =...
def calculate_distance(point1, point2): """ Calculate the Euclidean distance between two 2D points. """ return ((point2[0] - point1[0]) ** 2 + (point2[1] - point1[1]) ** 2) ** 0.5 def calculate_all_distances(points): """ Calculate distances between all pairs of 2D points. :param points...
from solution import calculate_distance, calculate_all_distances def test_calculate_distance(): assert calculate_distance((0, 0), (3, 4)) == 5.0 assert calculate_distance((1, 2), (4, 6)) == 5.0 assert calculate_distance((2, 3), (5, 7)) == 5.0 assert calculate_distance((1, 1), (1, 5)) == 4.0 def test_c...
[ { "docstring": "Calculate the Euclidean distance between two 2D points.", "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Calculate distances between all pairs of 2D points.\n\n:...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_distance(point1, point2):\n \"\"\"\n Returns the Euclidean distance between two points in 2D space.\n \"\"\"\n return ((point2[0] - point1[0]) ** 2 + (point2[1] - poi...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002228", "row_id": 2228, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7071']" }
0.750281
Filter_2228
I
[ "calculate_distance", "calculate_all_distances", "main" ]
3
[ [ "calculate_all_distances", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec2997766eb65123ff3967bef219c50e931d9636
df585d3646b3b549dadf52770a5ae8a288bc25ce
v1.0
instruct
Filter
Filter_2229_I
def generate_table(rows, cols): return [[0 for _ in range(cols)] for _ in range(rows)] def print_table(table): for row in table: print(' '.join(map(str, row))) def multiply_tables(table1, table2): if len(table1[0]) != len(table2): raise ValueError("Incompatible tables for multiplication") ...
def generate_table(rows, cols): """ Generates a table (2D list) with given number of rows and columns, initialized to 0. """ return [[0 for _ in range(cols)] for _ in range(rows)] def print_table(table): """ Prints the table (2D list) in a formatted manner. """ for row in table: ...
from solution import generate_table, print_table, multiply_tables def test_generate_table(): assert generate_table(2, 3) == [[0, 0, 0], [0, 0, 0]] assert generate_table(1, 1) == [[0]] def test_print_table(capsys): table = [[1, 2], [3, 4]] print_table(table) captured = capsys.readouterr() asser...
[ { "docstring": "Generates a table (2D list) with given number of rows and columns, initialized to 0.", "function_declaration": "def generate_table(rows, cols):", "function_name": "generate_table", "parameter_list": "(rows, cols)" }, { "docstring": "Prints the table (2D list) in a formatted m...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_table(rows, cols):\n \"\"\"\n Generates a table (2D list) with given number of rows and columns, initialized to 0.\n \"\"\"\n return [[0 for _ in range(cols)] for _ in...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002229", "row_id": 2229, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7075']" }
0.53213
Filter_2229
I
[ "generate_table", "print_table", "multiply_tables" ]
3
[ [ "multiply_tables", "generate_table" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41b65fff4e4072195b09b2828c98273a9931a6e1
6085fda8b9eb9edcfe950bbd6fbd703b653c234b
v1.0
instruct
Filter
Filter_2245_I
# Build a simple text adventure game in Python. The game is set in a fantasy world where magic exists, players have to collect gold and treasures and fight battles. The command line interface will be used to navigate and interact with the game world. Here is the start of the code: ``` import random # Define the pla...
import random # Define the player player = { 'gold': 0, 'health': 100, 'inventory': [], 'location': 'village' } # Define a list of treasures treasures = ['sword', 'shield', 'potion', 'magic scroll'] # Define a list of locations locations = ['forest', 'mountain', 'cave', 'village'] # Define a list of...
# Unit tests for the game functionality import pytest from io import StringIO from unittest.mock import patch from solution import player, move_location, collect_treasure, fight_enemy def test_initial_status(): assert player['gold'] == 0 assert player['health'] == 100 assert player['inventory'] == [] ...
[ { "docstring": null, "function_declaration": "def display_status():", "function_name": "display_status", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def display_locations():", "function_name": "display_locations", "parameter_list": "()" }, { "d...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\n# Define the player\nplayer = {\n 'gold': 0,\n 'health': 100,\n 'inventory': [],\n 'location': 'village'\n}\n\n# Define a list of treasures\ntreasures = ['sword', ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002245", "row_id": 2245, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7116']" }
0.488214
Filter_2245
I
[ "display_status", "display_locations", "move_location", "collect_treasure", "fight_enemy", "main" ]
6
[ [ "move_location", "display_locations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e7d4029e22fde1083773db6ade98a879f0bc8966
0a80abe66d734954455356ff120c46136a388f6a
v1.0
instruct
Filter
Filter_2253_I
import random def generate_ticket(n): return [random.randint(0, 1) for _ in range(n)] def check_ticket(ticket): for i in range(len(ticket)): if ticket[i] == 0: return False return True def lottery(): ticket = generate_ticket(6) if check_ticket(ticket): return "You won!...
import random def generate_ticket(n): return [random.randint(0, 1) for _ in range(n)] def check_ticket(ticket): return all(num == 1 for num in ticket) def lottery_ticket(n): wins = 0 losses = 0 for _ in range(n): ticket = generate_ticket(6) if check_ticket(ticket): win...
from solution import generate_ticket, check_ticket, lottery_ticket, lottery_with_jackpot def test_generate_ticket_length(): assert len(generate_ticket(6)) == 6 def test_generate_ticket_content(): ticket = generate_ticket(6) assert all(num in [0, 1] for num in ticket) def test_check_ticket_all_ones(): ...
[ { "docstring": null, "function_declaration": "def generate_ticket(n):", "function_name": "generate_ticket", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def check_ticket(ticket):", "function_name": "check_ticket", "parameter_list": "(ticket)" }, { ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_ticket(n):\n return [random.randint(0, 1) for _ in range(n)]\n\ndef check_ticket(ticket):\n return all(num == 1 for num in ticket)\n\ndef lottery(n, jackpot...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002253", "row_id": 2253, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7144']" }
0.586206
Filter_2253
I
[ "generate_ticket", "check_ticket", "lottery_ticket", "lottery_with_jackpot", "main" ]
5
[ [ "lottery_ticket", "check_ticket" ], [ "lottery_ticket", "generate_ticket" ], [ "lottery_with_jackpot", "lottery_ticket" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5d4dfd3f91e1aeb853f6788877a11b0dced9217f
269ef1cb627f2785d2aec4cba49486d4b56e869b
v1.0
instruct
Filter
Filter_2269_I
def is_not_prime(n): """Return True if n is not prime.""" if n < 2: return True for i in range(2, n): if n % i == 0: return True return False def next_prime(n): """Return the smallest prime number greater than n.""" n += 1 while is_not_prime(n): n += 1 ...
def is_not_prime(n): """ Returns True if n is not prime, else False. """ if n < 2: return True for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return True return False def next_prime(n): """ Returns the smallest prime number greater than n. """ n...
def test_is_not_prime(): assert is_not_prime(1) == True assert is_not_prime(2) == False assert is_not_prime(3) == False assert is_not_prime(4) == True assert is_not_prime(9) == True assert is_not_prime(13) == False def test_next_prime(): assert next_prime(1) == 2 assert next_prime(2) ==...
[ { "docstring": "Returns True if n is not prime, else False.", "function_declaration": "def is_not_prime(n):", "function_name": "is_not_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number greater 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_not_prime(n):\n \"\"\"Return True if n is not prime.\"\"\"\n if n < 2:\n return True\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return Tr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002269", "row_id": 2269, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7208']" }
0.847673
Filter_2269
I
[ "is_not_prime", "next_prime" ]
2
[ [ "next_prime", "is_not_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
fd8d51c53de6a042bf8e4946278797cf4844791f
7ff2036722e6be2f3f5e91be639362dbe05065b8
v1.0
instruct
Filter
Filter_2282_I
def get_depth(str): open_brackets = 0 depth = 0 for char in str: if char == '(': open_brackets += 1 elif char == ')': open_brackets -= 1 depth = max(depth, open_brackets) return depth def get_max_depth(s): return get_depth(s.replace(" ", ""))
def get_depth(str): """ Calculate the maximum nesting depth of parentheses in a given string. """ open_brackets = 0 depth = 0 for char in str: if char == '(': open_brackets += 1 elif char == ')': open_brackets -= 1 depth = max(depth, open_brackets)...
from solution import get_max_depth def test_simple_case(): assert get_max_depth("(())") == 2 def test_no_parentheses(): assert get_max_depth("abc def") == 0 assert get_max_depth("") == 0 def test_single_parentheses(): assert get_max_depth("()") == 1 def test_nested_parentheses(): assert get_max_...
[ { "docstring": "Calculate the maximum nesting depth of parentheses in a given string.", "function_declaration": "def get_depth(str):", "function_name": "get_depth", "parameter_list": "(str)" }, { "docstring": "Calculate the maximum nesting depth of parentheses in a given string,\nignoring an...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_depth(s):\n \"\"\"\n Computes the maximum depth of nested parentheses in the input string s.\n \"\"\"\n open_brackets = 0\n depth = 0\n for char in s:\n if cha...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002282", "row_id": 2282, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7250']" }
0.708523
Filter_2282
I
[ "get_depth", "get_max_depth" ]
2
[ [ "get_max_depth", "get_depth" ] ]
1
[]
false
[]
false
pytest
true
[]
true
47d5d0091984834dc990b2fd294674680eea7cc5
ba13a3781a16458233d22ab7baf50a56bc5f0e22
v1.0
instruct
Filter
Filter_2292_I
import os import re import sys def find_files_with_extension(directory, extension): """Return a list of files with the specified extension.""" file_list = [] for root, dirs, files in os.walk(directory): for file in files: if file.endswith(extension): file_list.append(os....
import os import re import sys def find_files_with_extension(directory, extension): """Return a list of files with the specified extension.""" file_list = [] for root, dirs, files in os.walk(directory): for file in files: if file.endswith(extension): file_list.append(os....
import os import shutil import tempfile from solution import (find_files_with_extension, get_file_extension, replace_extension, find_and_replace_text, get_file_size, get_file_size_in_kb, get_file_size_in_mb, get_file_size_in_gb, move_files_to_directory) def create_temp_files...
[ { "docstring": "Return a list of files with the specified extension.", "function_declaration": "def find_files_with_extension(directory, extension):", "function_name": "find_files_with_extension", "parameter_list": "(directory, extension)" }, { "docstring": "Return the file extension, everyt...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef find_files_with_extension(directory, extension):\n \"\"\"Return a list of files with the specified extension.\"\"\"\n file_list = []\n for root, dirs, files in os.wal...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002292", "row_id": 2292, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7288']" }
0.609813
Filter_2292
I
[ "find_files_with_extension", "get_file_extension", "replace_extension", "find_and_replace_text", "get_file_size", "get_file_size_in_kb", "get_file_size_in_mb", "get_file_size_in_gb", "move_files_to_directory", "main" ]
10
[ [ "find_and_replace_text", "find_files_with_extension" ], [ "get_file_size_in_gb", "get_file_size" ], [ "get_file_size_in_kb", "get_file_size" ], [ "get_file_size_in_mb", "get_file_size" ], [ "move_files_to_directory", "find_files_with_extension" ] ]
5
[]
false
[]
false
pytest
true
[]
true
12049487149a6821d0c89d58f52e89b9f6e278f9
2c11aeeba8e6341d41cd9ccbb41170f32b2ef047
v1.0
instruct
Filter
Filter_2298_I
def max_difference(numbers): return max(numbers) - min(numbers) def is_prime(num): if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def prime_difference(numbers): primes = [num for num in numbers if is_prime(num)...
from typing import List def max_difference(numbers: List[int]) -> int: """ Returns the maximum difference between the largest and smallest number in the list. """ return max(numbers) - min(numbers) def is_prime(num: int) -> bool: """ Returns True if the given number is a prime number, else ret...
from solution import max_difference, is_prime, prime_difference def test_max_difference(): assert max_difference([3, 4, 7, 9, 11, 13]) == 10 assert max_difference([10, 2, 8, 4]) == 8 assert max_difference([1, 1, 1, 1]) == 0 def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True...
[ { "docstring": "Returns the maximum difference between the largest and smallest number in the list.", "function_declaration": "def max_difference(numbers):", "function_name": "max_difference", "parameter_list": "(numbers)" }, { "docstring": "Returns True if the given number is a prime number...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_difference(numbers):\n \"\"\"\n Returns the difference between the maximum and minimum numbers in a list.\n \"\"\"\n return max(numbers) - min(numbers)\n\ndef is_prime(num)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002298", "row_id": 2298, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7302']" }
0.663649
Filter_2298
I
[ "max_difference", "is_prime", "prime_difference" ]
3
[ [ "prime_difference", "is_prime" ], [ "prime_difference", "max_difference" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fe571fbed7a4bb609880b0a4ad307b30b0a2bac6
0cbf567549fe78485693532242aa4abb78377e5f
v1.0
instruct
Filter
Filter_2342_I
def is_greater(x, y): """Return True if x is greater than y, False otherwise.""" return x > y def is_lesser(x, y): """Return True if x is lesser than y, False otherwise.""" return x < y def is_equal(x, y): """Return True if x is equal to y, False otherwise.""" return x == y def check_relation...
def is_greater(x, y): """Return True if x is greater than y, False otherwise.""" return x > y def is_lesser(x, y): """Return True if x is lesser than y, False otherwise.""" return x < y def is_equal(x, y): """Return True if x is equal to y, False otherwise.""" return x == y def check_relation...
from solution import is_greater, is_lesser, is_equal, check_relation def test_is_greater(): assert is_greater(10, 5) == True assert is_greater(5, 10) == False assert is_greater(-1, 0) == False assert is_greater(0, -1) == True assert is_greater(1, 1) == False def test_is_lesser(): assert is_les...
[ { "docstring": "Return True if x is greater than y, False otherwise.", "function_declaration": "def is_greater(x, y):", "function_name": "is_greater", "parameter_list": "(x, y)" }, { "docstring": "Return True if x is lesser than y, False otherwise.", "function_declaration": "def is_lesse...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_greater(x, y):\n \"\"\"Return True if x is greater than y, False otherwise.\"\"\"\n return x > y\n\ndef is_lesser(x, y):\n \"\"\"Return True if x is lesser than y, False otherw...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002342", "row_id": 2342, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7454']" }
0.667007
Filter_2342
I
[ "is_greater", "is_lesser", "is_equal", "check_relation" ]
4
[ [ "check_relation", "is_greater" ], [ "check_relation", "is_lesser" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8d6935ab09cb77f7f909da8794c865dd6353c2cd
bd63f8e466403ee6438f76a36cfb47c3536a2e63
v1.0
instruct
Filter
Filter_2353_I
Some code might be needed to solve this problem. I want to create a guessing game written in Python. In the game, the computer thinks of a number between 1 and 100, inclusive, and the player has to guess the number within 6 attempts. After each guess, the computer tells the player if their guess was higher or lower tha...
import random MAX_ATTEMPTS = 6 MIN_NUMBER = 1 MAX_NUMBER = 100 def get_random_number(min_num=MIN_NUMBER, max_num=MAX_NUMBER): return random.randint(min_num, max_num) def get_user_guess(): while True: try: guess = int(input(f"Guess a number between {MIN_NUMBER} and {MAX_NUMBER}: ")) ...
import pytest from io import StringIO from unittest.mock import patch from solution import get_random_number, guessing_game def test_get_random_number(): num = get_random_number() assert MIN_NUMBER <= num <= MAX_NUMBER @patch('builtins.input', side_effect=['50', '75', '60', '70', '65', '66']) @patch('solution...
[ { "docstring": null, "function_declaration": "def get_random_number(min_num=MIN_NUMBER, max_num=MAX_NUMBER):", "function_name": "get_random_number", "parameter_list": "(min_num=MIN_NUMBER, max_num=MAX_NUMBER)" }, { "docstring": null, "function_declaration": "def get_user_guess():", "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_user_guess():\n \"\"\"\n Prompts the user for a guess and returns it.\n \"\"\"\n user_guess = input(\"Guess a number between 1 and 100: \")\n if user_gu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002353", "row_id": 2353, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7512']" }
0.599215
Filter_2353
I
[ "get_random_number", "get_user_guess", "guessing_game" ]
3
[ [ "guessing_game", "get_random_number" ], [ "guessing_game", "get_user_guess" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0b6ec1ec13274754da2ca70acdb745b3d0cf5578
6c4dafa81df857d99a9c985fcfb46997335ad52a
v1.0
instruct
Filter
Filter_2356_I
import math def isPrime(n): for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def findTwinPrimes(n): twinPrimes = [] for i in range(2, n): if isPrime(i) and isPrime(i + 2): twinPrimes.append((i, i + 2)) return twinPrimes print...
import math def is_prime(n): if n <= 1: return False for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def find_first_k_twin_primes(k): twin_primes = [] i = 2 while len(twin_primes) < k: if is_prime(i) and is_prime(i + 2): ...
from solution import is_prime, find_first_k_twin_primes def test_is_prime(): assert is_prime(2) is True assert is_prime(11) is True assert is_prime(15) is False assert is_prime(1) is False def test_find_first_k_twin_primes_k_0(): assert find_first_k_twin_primes(0) == [] def test_find_first_k_twin...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_first_k_twin_primes(k):", "function_name": "find_first_k_twin_primes", "parameter_list": "(k)" } ]
[ 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 isPrime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(math.sqrt(n)) + 1):\n if n % i ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002356", "row_id": 2356, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7523']" }
0.594069
Filter_2356
I
[ "is_prime", "find_first_k_twin_primes" ]
2
[ [ "find_first_k_twin_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
19a0626fc48fb6ab2bbfe956df16c7ad828898d8
b6d7ce14a36c2874bda63aba847c019628bbb240
v1.0
instruct
Filter
Filter_2365_I
This code is a program to solve the infinite monkey theorem. It attempts to generate a list of random characters that eventually matches a given target string, simulating a monkey typing randomly at a keyboard. The code can currently generate random characters, but I need help to modify the code to continue generating ...
import random import string def generate_random_string(length): """ Generates a random string of specified length. """ return ''.join(random.choice(string.ascii_lowercase + ' ') for _ in range(length)) def infinite_monkey(target): """ Continues to generate random strings until one of them matc...
import random from solution import generate_random_string, infinite_monkey def test_generate_random_string_length(): length = 10 result = generate_random_string(length) assert len(result) == length def test_infinite_monkey(): # To ensure this test is not running forever, we'll use a very short or like...
[ { "docstring": "Generates a random string of specified length.", "function_declaration": "def generate_random_string(length):", "function_name": "generate_random_string", "parameter_list": "(length)" }, { "docstring": "Continues to generate random strings until one of them matches the target...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_random_string(length):\n \"\"\"\n Generates a random string of the given length using uppercase letters,\n lowercase letters, and spaces.\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002365", "row_id": 2365, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7552']" }
0.595128
Filter_2365
I
[ "generate_random_string", "infinite_monkey" ]
2
[ [ "infinite_monkey", "generate_random_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d2ac33f2b0f343495a347140583e942b08eb4e7c
be0e56750499d591128bcbc9996a19bd19a98298
v1.0
instruct
Filter
Filter_2372_I
def dist_sq(x1, y1, x2, y2): return (x1 - x2)**2 + (y1 - y2)**2 def dist(x1, y1, x2, y2): return dist_sq(x1, y1, x2, y2)**0.5 def point_on_line(p1, p2, r): x1, y1 = p1 x2, y2 = p2 return (x1 + (x2 - x1) * r, y1 + (y2 - y1) * r) def solve(p1, p2, r): x1, y1 = p1 x2, y2 = p2 r2 = r**2 param_t = ((x...
import math def dist_sq(x1, y1, x2, y2): return (x1 - x2)**2 + (y1 - y2)**2 def dist(x1, y1, x2, y2): return dist_sq(x1, y1, x2, y2)**0.5 def point_on_line(p1, p2, r): x1, y1 = p1 x2, y2 = p2 return (x1 + (x2 - x1) * r, y1 + (y2 - y1) * r) def solve(p1, p2, r): x1, y1 = p1 x2, y2 = p2 ...
from solution import solve def test_intersection_with_origin(): result = solve((0, 0), (3, 4), 5) assert result == (3, 4) or result == (0, 0), f"Unexpected result: {result}" def test_no_intersection(): result = solve((10, 10), (20, 20), 5) assert result is None, f"Expected None, but got {result}" def...
[ { "docstring": null, "function_declaration": "def dist_sq(x1, y1, x2, y2):", "function_name": "dist_sq", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def dist(x1, y1, x2, y2):", "function_name": "dist", "parameter_list": "(x1, y1, x2, y2)"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def dist_sq(x1, y1, x2, y2):\n return (x1 - x2)**2 + (y1 - y2)**2\n\ndef dist(x1, y1, x2, y2):\n return dist_sq(x1, y1, x2, y2)**0.5\n\ndef point_on_line(p1, p2, r):\n x1, y1 = p1\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002372", "row_id": 2372, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7570']" }
0.493973
Filter_2372
I
[ "dist_sq", "dist", "point_on_line", "solve", "is_point_on_segment" ]
5
[ [ "dist", "dist_sq" ], [ "solve", "is_point_on_segment" ] ]
2
[]
false
[]
false
pytest
true
[]
true
822129d909484a1a290e549f12d8a8c49bea4f32
3f5f32f8db4278df5d1d5cf6cbc173274fb7427c
v1.0
instruct
Filter
Filter_2381_I
import random def random_contractor(): contractors = ["Bob", "Sally", "Sue", "John", "Mike"] return random.choice(contractors) def random_service(): services = ["plumbing", "electric", "HVAC", "roofing", "landscaping", "drywall", "painting", "cabinetry"] return random.choice(services) def random_mont...
import random def random_contractor(): contractors = ["Bob", "Sally", "Sue", "John", "Mike"] return random.choice(contractors) def random_service(): services = ["plumbing", "electric", "HVAC", "roofing", "landscaping", "drywall", "painting", "cabinetry"] return random.choice(services) def random_mont...
from solution import random_appointment def test_random_appointment_format(): appointment = random_appointment() parts = appointment.split(" ") assert len(parts) == 7 # Should be in the form of "Contractor for service scheduled for Month Day" def test_random_appointment_contains_valid_month_and_day(): ...
[ { "docstring": null, "function_declaration": "def random_contractor():", "function_name": "random_contractor", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def random_service():", "function_name": "random_service", "parameter_list": "()" }, { "d...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef random_contractor():\n contractors = [\"Bob\", \"Sally\", \"Sue\", \"John\", \"Mike\"]\n return random.choice(contractors)\n\ndef random_service():\n services = [...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002381", "row_id": 2381, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7595']" }
0.566212
Filter_2381
I
[ "random_contractor", "random_service", "random_month", "random_day", "random_appointment" ]
5
[ [ "random_appointment", "random_contractor" ], [ "random_appointment", "random_day" ], [ "random_appointment", "random_month" ], [ "random_appointment", "random_service" ] ]
4
[]
false
[]
false
pytest
true
[]
true
5177fe4b3b8dfd62b06b5f7469ed304d87b2aaa8
d96c6dd1aa9da4d22cecc916cd8a2ab91734132e
v1.0
instruct
Filter
Filter_2393_I
def calculate_prime_factors(n): """Returns a dictionary with the prime factors of a number as keys and their powers as values.""" i = 2 factors = {} while i * i <= n: if n % i: i += 1 else: n //= i factors[i] = factors.get(i, 0) + 1 if n > 1: ...
def calculate_prime_factors(n): """ Returns a dictionary with the prime factors of a number as keys and their powers as values. """ i = 2 factors = {} while i * i <= n: if n % i: i += 1 else: n //= i factors[i] = factors.get(i, 0) + 1 if n ...
import pytest from solution import calculate_prime_factors, solve def test_calculate_prime_factors(): assert calculate_prime_factors(1) == {} assert calculate_prime_factors(2) == {2: 1} assert calculate_prime_factors(3) == {3: 1} assert calculate_prime_factors(4) == {2: 2} assert calculate_prime_fa...
[ { "docstring": "Returns a dictionary with the prime factors of a number as keys and their powers as values.", "function_declaration": "def calculate_prime_factors(n):", "function_name": "calculate_prime_factors", "parameter_list": "(n)" }, { "docstring": "Finds the smallest number that is a ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_prime_factors(n):\n \"\"\"Returns a dictionary with the prime factors of a number as keys and their powers as values.\"\"\"\n i = 2\n factors = {}\n while i * i <= n:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002393", "row_id": 2393, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7635']" }
0.809295
Filter_2393
I
[ "calculate_prime_factors", "solve" ]
2
[ [ "solve", "calculate_prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
95140e6b4f9693ca2cc69c9b8e68322468de4dd6
006088123edb5281df2edfb90860c6df7d085311
v1.0
instruct
Filter
Filter_2400_I
import re def check_luhn(card_number): # compute the sum of digits at the odd places sum_odd = sum(int(digit) for i, digit in enumerate(card_number) if i % 2 != 0) # compute the sum of digits at the even places even_places = (int(digit) for i, digit in enumerate(card_number) if i % 2 == 0) double...
import re def check_luhn(card_number): """ Validates the credit card number using the Luhn algorithm. """ card_number = list(map(int, card_number)) check_sum = 0 # We start from the right, with the last odd indexed digit (1-based index) for i in range(len(card_number)): digit =...
from solution import check_luhn, validate_card_number def test_check_luhn_valid_card(): assert check_luhn("4532015112830366") == True assert check_luhn("6011111111111117") == True assert check_luhn("378282246310005") == True def test_check_luhn_invalid_card(): assert check_luhn("4532015112830367") == ...
[ { "docstring": "Validates the credit card number using the Luhn algorithm.", "function_declaration": "def check_luhn(card_number):", "function_name": "check_luhn", "parameter_list": "(card_number)" }, { "docstring": "Validates the card number by length and using the Luhn algorithm.", "fu...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef check_luhn(card_number):\n \"\"\"\n Validates the credit card number using the Luhn algorithm.\n \"\"\"\n card_number = list(map(int, card_number))\n check_sum ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002400", "row_id": 2400, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7651']" }
0.556698
Filter_2400
I
[ "check_luhn", "validate_card_number", "main" ]
3
[ [ "validate_card_number", "check_luhn" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d00a0621668b04cf399917a14ef6ab232522456b
90151ea86ccbc8435656b60b659ea3121fc9c9ec
v1.0
instruct
Filter
Filter_2413_I
def intersection(lst1, lst2): return list(set(lst1) & set(lst2)) def union(lst1, lst2): return list(set(lst1) | set(lst2)) def difference(lst1, lst2): return list(set(lst1) - set(lst2)) def sorted_union(lst1, lst2): return sorted(union(lst1, lst2)) def sorted_intersection(lst1, lst2): return sor...
def intersection(lst1, lst2): """ Returns the intersection of two lists. """ return list(set(lst1) & set(lst2)) def union(lst1, lst2): """ Returns the union of two lists. """ return list(set(lst1) | set(lst2)) def difference(lst1, lst2): """ Returns the difference of two lists ...
from solution import intersection, union, difference, sorted_union, sorted_intersection, sorted_difference def test_intersection(): assert intersection([1, 2, 3], [2, 3, 4]) == [2, 3] assert intersection([1, 2, 3], [4, 5, 6]) == [] assert intersection([1, 2], [1, 2, 3, 4]) == [1, 2] def test_union(): ...
[ { "docstring": "Returns the intersection of two lists.", "function_declaration": "def intersection(lst1, lst2):", "function_name": "intersection", "parameter_list": "(lst1, lst2)" }, { "docstring": "Returns the union of two lists.", "function_declaration": "def union(lst1, lst2):", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def intersection(lst1, lst2):\n return list(set(lst1) & set(lst2))\n\ndef union(lst1, lst2):\n return list(set(lst1) | set(lst2))\n\ndef difference(lst1, lst2):\n return list(set(lst1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002413", "row_id": 2413, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7701']" }
0.610755
Filter_2413
I
[ "intersection", "union", "difference", "sorted_union", "sorted_intersection", "sorted_difference" ]
6
[ [ "sorted_difference", "difference" ], [ "sorted_intersection", "intersection" ], [ "sorted_union", "union" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e27eeacba6e0846157236069b687b1918aaf106c
281240306a397ac0d4b16f24544405af83af5338
v1.0
instruct
Filter
Filter_2422_I
Here is what I want to do. I want to take a list of html pages and make a new page that lists these pages with clickable links to each one. I am using python with beautifulsoup to parse the html of the pages (the pages are all in the same directory). Here's what I have so far: ``` import os from bs4 import Beautifu...
import os from bs4 import BeautifulSoup def parse_html_file(file): """ Parse an HTML file to extract the title. :param file: Path to the HTML file :return: Title of the page """ try: with open(file, 'r') as f: soup = BeautifulSoup(f, 'html.parser') return soup.ti...
import pytest import os from solution import parse_html_file, create_links, main def test_parse_html_file(monkeypatch): test_html = "<html><head><title>Test Page</title></head><body>Content</body></html>" test_file = 'test.html' # Create a temporary HTML file with open(test_file, 'w') as f: ...
[ { "docstring": "Parse an HTML file to extract the title.\n:param file: Path to the HTML file\n:return: Title of the page", "function_declaration": "def parse_html_file(file):", "function_name": "parse_html_file", "parameter_list": "(file)" }, { "docstring": "Create HTML links for a list of H...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nfrom bs4 import BeautifulSoup\n\n# List of pages\npages = ['file1.html', 'file2.html', 'file3.html']\n\ndef parse_html_file(file):\n try:\n with open(file, 'r') as f:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002422", "row_id": 2422, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7750']" }
0.612239
Filter_2422
I
[ "parse_html_file", "create_links", "main" ]
3
[ [ "create_links", "parse_html_file" ] ]
1
[]
false
[]
false
pytest
true
[ "bs4" ]
false
0e04211c6a69aa6e2bc1cdceddd28aaace1b8473
1e834c498c5fbbee93b6b05efe106d23df1458eb
v1.0
instruct
Filter
Filter_2424_I
import os import subprocess import sys def create_template_py(path, name): template = f"""#!/usr/bin/env python3 # coding: utf-8 \'\'\' Author: {name} Email: {name}@yourdomain.com \'\'\' # Program Information __version__ = "0.0.1" # Import Statements import os import sys # Main Function def main(): pass i...
import os import sys import re from datetime import datetime def is_valid_email(email): """ Check if the provided email is valid. """ email_regex = r"[^@]+@[^@]+\.[^@]+" return re.match(email_regex, email) is not None def create_template_py(path, name, author, email): """ Create a python s...
import os import pytest from solution import create_template_py, is_valid_email def test_is_valid_email(): assert is_valid_email("test@domain.com") assert not is_valid_email("invalid-email") assert not is_valid_email("invalid@domain") assert not is_valid_email("invalid@domain.") assert not is_valid...
[ { "docstring": "Check if the provided email is valid.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Create a python script template with the provided details.", "function_declaration": "def create...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport sys\nimport re\nfrom datetime import datetime\n\ndef is_valid_email(email):\n \"\"\"\n Check if the provided email is valid.\n \"\"\"\n email_regex = r\"[^@]+@[^@...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002424", "row_id": 2424, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7754']" }
0.637472
Filter_2424
I
[ "is_valid_email", "create_template_py", "main" ]
3
[ [ "create_template_py", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a5945b6ac4b2acd63a6fce5a78aebd4af1d3aba9
33598d6ece76dc876451969a9ff8b9957e067be5
v1.0
instruct
Filter
Filter_2450_I
Here is a problem from the book "Introduction to Computer Science using Python": The mission is to write a program that prints the first 50 prime numbers.
def is_prime(n): """ Returns True if n is a prime number, otherwise returns False. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def first_50_primes(): """ Returns a list containing the first 50 prime ...
from solution import is_prime, first_50_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(0) == Fa...
[ { "docstring": "Returns True if n is a prime number, otherwise returns False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing the first 50 prime numbers.", "function_declaration": "def first_5...
[ 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_1
{ "original_instruction": "", "prompt_id": "00002450", "row_id": 2450, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7846']" }
0.580014
Filter_2450
I
[ "is_prime", "first_50_primes" ]
2
[ [ "first_50_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d564b9518bb443e91e671bced710dec9d9195678
97d6f447e2e50163d9a4b69ddb012ac4d2fcbe7d
v1.0
instruct
Filter
Filter_2491_I
# Challenge: Create an example of a Python function that can be used to sort an array of integers in ascending order using the Merge Sort algorithm.
def merge_sort(arr): """ Sorts an array of integers in ascending order using the 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 merg...
from solution import merge_sort def test_merge_sort_empty_array(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_sorted_array(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_sorted_array(): ass...
[ { "docstring": "Sorts an array of integers in ascending order using the Merge Sort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted arrays into one sorted array.", "function_declarat...
[ 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 Function to perform merge sort on a list of integers.\n \"\"\"\n if len(arr) > 1:\n mid = len(arr) // 2\n left_half = arr[:mid]\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002491", "row_id": 2491, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_7989']" }
0.669527
Filter_2491
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4015d760b5854fb9ea5b5526609963b66a67f8db
db5e10b705b68d4005fc9a6ce978c1a0b4ff0ee9
v1.0
instruct
Filter
Filter_2495_I
import random def random_time(): return random.randint(0, 23) def random_date(): year = random.randint(1900, 2024) month = random.randint(1, 12) day = random.randint(1, 31) return f'{year}-{month:02d}-{day:02d}' def random_datetime(): return f'{random_date()} {random_time():02d}:00:00' print...
import random from datetime import datetime, timedelta def random_date(): start_date = datetime(1900, 1, 1) end_date = datetime(2024, 12, 31) random_date = start_date + timedelta(days=random.randint(0, (end_date - start_date).days)) return random_date.strftime('%Y-%m-%d') def random_time(): return...
from solution import random_date, random_time, random_datetime from datetime import datetime, timedelta def test_random_date(): for _ in range(100): date_str = random_date() date = datetime.strptime(date_str, '%Y-%m-%d') assert datetime(1900, 1, 1) <= date <= datetime(2024, 12, 31) def tes...
[ { "docstring": null, "function_declaration": "def random_date():", "function_name": "random_date", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def random_time():", "function_name": "random_time", "parameter_list": "()" }, { "docstring": null, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nfrom datetime import datetime, timedelta\n\ndef random_time():\n return random.randint(0, 23)\n\ndef random_date():\n start_date = datetime(1900, 1, 1)\n end_date = dat...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002495", "row_id": 2495, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8003']" }
0.638028
Filter_2495
I
[ "random_date", "random_time", "random_datetime" ]
3
[ [ "random_datetime", "random_date" ], [ "random_datetime", "random_time" ] ]
2
[]
false
[]
false
pytest
true
[]
true
46edd7ad1082f152e4b6ed184740a8ba6f4ae93d
ed3e3c0e9eedd854ee0f2be9230a66e996525095
v1.0
instruct
Filter
Filter_2503_I
# Build a simple calculator with a menu-driven program in python import math def calculator(): print("Simple Calculator") print("1. Addition") print("2. Subtraction") print("3. Multiplication") print("4. Division") choice = input("Enter your choice (1/2/3/4): ") if choice == '1': ...
def add(a, b): """ Returns the sum of a and b. """ return a + b def subtract(a, b): """ Returns the difference of a and b. """ return a - b def multiply(a, b): """ Returns the product of a and b. """ return a * b def divide(a, b): """ Returns the quotient of a ...
from solution import add, subtract, multiply, divide, calculator_menu def test_add(): assert add(3, 5) == 8 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(10, 5) == 5 assert subtract(-1, 1) == -2 assert subtract(0, 0) == 0 def test_multiply(): assert mul...
[ { "docstring": "Returns the sum of a and b.", "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": "Returns the difference of a and b.", "function_declaration": "def subtract(a, b):", "function_name": "subtract", "paramete...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def addition(num1, num2):\n return num1 + num2\n\ndef subtraction(num1, num2):\n return num1 - num2\n\ndef multiplication(num1, num2):\n return num1 * num2\n\ndef division(num1, num2)...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002503", "row_id": 2503, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8029']" }
0.469854
Filter_2503
I
[ "add", "subtract", "multiply", "divide", "calculator_menu" ]
5
[ [ "calculator_menu", "add" ], [ "calculator_menu", "divide" ], [ "calculator_menu", "multiply" ], [ "calculator_menu", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
aad5f0a36c449e56b1483c621d96351b155033c5
8361484a08e6decce62b25cbee5e091d8cf7bd50
v1.0
instruct
Filter
Filter_2507_I
# Mini Project: Rock, Paper, Scissors ========================== **Objective:** Create a Rock, Paper, Scissors game in Python. The game should allow two players to play against each other, or a player to play against the computer. ## Step 1: Define the Game Rules Rock, Paper, Scissors is a game where two players sim...
import random def get_player_move(prompt="Enter your move (rock, paper, or scissors): "): while True: move = input(prompt).lower() if move in ['rock', 'paper', 'scissors']: return move print("Invalid move. Please try again.") def get_computer_move(): moves = ['rock', 'paper...
import pytest from unittest.mock import patch from solution import get_player_move, get_computer_move, determine_winner def test_get_player_move(): with patch('builtins.input', return_value='rock'): assert get_player_move() == 'rock' with patch('builtins.input', return_value='paper'): assert ge...
[ { "docstring": null, "function_declaration": "def get_player_move(prompt='Enter your move (rock, paper, or scissors): '):", "function_name": "get_player_move", "parameter_list": "(prompt='Enter your move (rock, paper, or scissors): ')" }, { "docstring": null, "function_declaration": "def...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_player_move(prompt=\"Enter your move (rock, paper, or scissors): \"):\n while True:\n move = input(prompt).lower()\n if move in ['rock', 'paper', 'sci...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002507", "row_id": 2507, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8038']" }
0.652441
Filter_2507
I
[ "get_player_move", "get_computer_move", "determine_winner", "play_game" ]
4
[ [ "play_game", "determine_winner" ], [ "play_game", "get_computer_move" ], [ "play_game", "get_player_move" ] ]
3
[]
false
[]
false
pytest
true
[]
true
07e2510abfb31233c7004edf4cd0e0bfc945cced
75367015e382cf048441622d03c7bb17b5ba5b7d
v1.0
instruct
Filter
Filter_2531_I
# How do I create a binary search tree from a given array in python?
class TreeNode: def __init__(self, data): self.data = data self.left = None self.right = None def insert_into_bst(root, value): """ Inserts a value into the binary search tree rooted at 'root' and returns the new root. """ if root is None: return TreeNode(value) ...
from solution import create_bst_from_array, inorder_traversal def test_empty_array(): assert create_bst_from_array([]) is None def test_single_element_array(): root = create_bst_from_array([10]) assert root is not None assert root.data == 10 assert root.left is None assert root.right is None ...
[]
[ 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, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n # If the tree is empty, return a new n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002531", "row_id": 2531, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8122']" }
0.577815
Filter_2531
I
[ "insert_into_bst", "create_bst_from_array", "inorder_traversal" ]
3
[ [ "create_bst_from_array", "insert_into_bst" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
38431a3f9282147d37065abd766c863f50aa265d
9f8a8c22360c2121d4d1906d43672a3703988ab5
v1.0
instruct
Filter
Filter_2541_I
import heapq def mergesort(arr): heapq.heapify(arr) sorted_arr = [] while arr: sorted_arr.append(heapq.heappop(arr)) return sorted_arr # Testing the implementation arr = [64, 34, 25, 12, 22, 11, 90] print("Original array is", arr) print("Sorted array is", mergesort(arr)) In the implementation...
def merge(left, right): """ Merges two sorted lists into one sorted list. """ result = [] i = j = 0 # Traverse both lists and insert smaller value from either list into the result list while i < len(left) and j < len(right): if left[i] < right[j]: result.append(left[...
from solution import mergesort def test_mergesort_empty_array(): assert mergesort([]) == [] def test_mergesort_single_element(): assert mergesort([1]) == [1] def test_mergesort_double_elements(): assert mergesort([2, 1]) == [1, 2] def test_mergesort_multiple_elements(): assert mergesort([64, 34, 25,...
[ { "docstring": "Merges two sorted lists into one sorted list.", "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" }, { "docstring": "Implements the mergesort algorithm to sort an array.", "function_declaration": "def mergesort(...
[ 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 Implements the merge sort algorithm using a divide-and-conquer approach.\n \"\"\"\n if len(arr) > 1:\n mid = len(arr) // 2\n left_half...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002541", "row_id": 2541, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8150']" }
0.568477
Filter_2541
I
[ "merge", "mergesort" ]
2
[ [ "mergesort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2bd67ede300b6bb589b4ed7f1937661acc788e49
e04847bba9a1cfdefe0b8b852ed492f5b46b9b39
v1.0
instruct
Filter
Filter_2543_I
import math import random def generate_prime_numbers(n): primes = [] for num in range(2, n): is_prime = True for i in range(2, math.isqrt(num) + 1): if num % i == 0: is_prime = False break if is_prime: primes.append(num) return...
import math import random def generate_prime_numbers(n): """ Generates a list of prime numbers up to n (exclusive). """ primes = [] for num in range(2, n): is_prime = True for i in range(2, math.isqrt(num) + 1): if num % i == 0: is_prime = False ...
from solution import generate_prime_numbers, generate_random_prime def test_generate_prime_numbers(): assert generate_prime_numbers(10) == [2, 3, 5, 7] assert generate_prime_numbers(20) == [2, 3, 5, 7, 11, 13, 17, 19] assert generate_prime_numbers(2) == [] assert generate_prime_numbers(3) == [2] d...
[ { "docstring": "Generates a list of prime numbers up to n (exclusive).", "function_declaration": "def generate_prime_numbers(n):", "function_name": "generate_prime_numbers", "parameter_list": "(n)" }, { "docstring": "Generates a random prime number from the list of primes up to n (exclusive)...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nimport random\n\ndef generate_prime_numbers(n):\n \"\"\"\n Generates a list of prime numbers up to (but not including) n.\n \"\"\"\n primes = []\n for num in range(...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002543", "row_id": 2543, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8154']" }
0.592706
Filter_2543
I
[ "generate_prime_numbers", "generate_random_prime" ]
2
[ [ "generate_random_prime", "generate_prime_numbers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8356dceae6266afeebff023ac058785bfbade0f9
645c050a568f52f12d2c9c5c3f8c2c91b13d8ace
v1.0
instruct
Filter
Filter_2551_I
I need to design an algorithm that takes a given input of points in a 2D space and outputs the hull of the convex hull of the points. The algorithm I am looking to implement is the Graham's scan algorithm. I need the help of choosing the appropriate data structures used in this algorithm. For this problem, I will be...
import math from typing import List, Tuple def orientation(p: Tuple[int, int], q: Tuple[int, int], r: Tuple[int, int]) -> int: val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1]) if val == 0: return 0 # Collinear elif val > 0: return 1 # Clockwise else: return ...
from solution import graham_scan def test_graham_scan_basic(): points = [(0, 3), (1, 1), (2, 2), (4, 4), (0, 0), (1, 2), (3, 1), (3, 3)] expected_hull = [(0, 0), (3, 1), (4, 4), (0, 3)] assert graham_scan(points) == expected_hull def test_graham_scan_collinear_points(): points = [(0, 0), (1, 1), (2, 2...
[ { "docstring": null, "function_declaration": "def orientation(p, q, r):", "function_name": "orientation", "parameter_list": "(p, q, r)" }, { "docstring": null, "function_declaration": "def distance_squared(p1, p2):", "function_name": "distance_squared", "parameter_list": "(p1, p2...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom typing import List, Tuple\n\ndef orientation(p: Tuple[int, int], q: Tuple[int, int], r: Tuple[int, int]) -> int:\n val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002551", "row_id": 2551, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8192']" }
0.379244
Filter_2551
I
[ "orientation", "distance_squared", "graham_scan" ]
3
[ [ "graham_scan", "distance_squared" ], [ "graham_scan", "orientation" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e8e8c6ae4002cafbd021c41a3364b584e7123c0b
f78679ecc6fb0329c8b9b93fd3ccbed1558a1861
v1.0
instruct
Filter
Filter_2568_I
### Overview of the Project You have been asked to design and implement a turn-based game where two players take turns to guess a randomly generated number within a certain range. The game continues until one of the players correctly guesses the number. You will need to create a Python script to implement the game. #...
import random def generate_number(): """ Generate a random number between 1 and 100. """ return random.randint(1, 100) def get_player_guess(player_name): """ Get the player's guess and validate it. """ while True: try: guess = int(input(f"{player_name}, enter your g...
import pytest from solution import generate_number, check_guess def test_generate_number(): number = generate_number() assert 1 <= number <= 100 def test_check_guess_correct(): assert check_guess(50, 50) == "Correct" def test_check_guess_higher(): assert check_guess(50, 30) == "Higher" def test_chec...
[ { "docstring": "Generate a random number between 1 and 100.", "function_declaration": "def generate_number():", "function_name": "generate_number", "parameter_list": "()" }, { "docstring": "Get the player's guess and validate it.", "function_declaration": "def get_player_guess(player_nam...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_number():\n \"\"\"\n Generates a random number between 1 and 100.\n \"\"\"\n return random.randint(1, 100)\n\ndef get_player_guess(player_name, guess)...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002568", "row_id": 2568, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8262']" }
0.635979
Filter_2568
I
[ "generate_number", "get_player_guess", "check_guess", "game" ]
4
[ [ "game", "check_guess" ], [ "game", "generate_number" ], [ "game", "get_player_guess" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e0817e3758e720ad44b11f80d5330c1627c3f5dd
283fb6d046a9f98b63c9c6d152cc5b885b3d2103
v1.0
instruct
Filter
Filter_2576_I
# Step 1: Identify the purpose of the problem The problem is to create a Python program that generates a random quiz for the given topics. The expected output is a quiz with a set of questions and their corresponding answers. # Step 2: Outline the solution strategy To solve this problem, we will: 1. Define the topics ...
import random topics = { "History": [ {"question": "Who was the first president of the United States?", "answer": "George Washington"}, {"question": "In what year did World War II end?", "answer": "1945"}, {"question": "Who discovered America?", "answer": "Christopher Columbus"}, ], ...
from solution import choose_random_topic, generate_random_quiz, generate_quiz, topics def test_choose_random_topic(): topic = choose_random_topic(topics) assert topic in topics def test_generate_random_quiz(): topic = 'History' question = generate_random_quiz(topic, topics) assert question in topi...
[ { "docstring": "Randomly select a topic from the given topics.", "function_declaration": "def choose_random_topic(topics):", "function_name": "choose_random_topic", "parameter_list": "(topics)" }, { "docstring": "Generate a random quiz for the selected topic.", "function_declaration": "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ntopics = {\n \"History\": [\n {\"question\": \"Who was the first president of the United States?\", \"answer\": \"George Washington\"},\n {\"question\": \"In ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002576", "row_id": 2576, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8279']" }
0.552442
Filter_2576
I
[ "choose_random_topic", "generate_random_quiz", "generate_quiz" ]
3
[ [ "generate_quiz", "choose_random_topic" ], [ "generate_quiz", "generate_random_quiz" ] ]
2
[]
false
[]
false
pytest
true
[]
true
56f671d7b65b469c4ebb8d72303b6929e429551c
d767f49ce136babc1ac1a904b84ac9f08135f260
v1.0
instruct
Filter
Filter_2605_I
function lowbit(x): return x&(-x) def sum(n): res = 0 while n: res += tree[n] n -= lowbit(n) return res def modify(n, k): while n <= size: tree[n] += k n += lowbit(n) def build(): for i in range(1, size + 1): j = i + lowbit(i) if j <= size: ...
def lowbit(x): return x & (-x) def sum(n, tree): res = 0 while n: res += tree[n] n -= lowbit(n) return res def modify(n, k, tree, size): while n <= size: tree[n] += k n += lowbit(n) def build(tree, size): for i in range(1, size + 1): j = i + lowbit(i) ...
import pytest from solution import lowbit, sum, modify, build @pytest.fixture def setup(): size = 12 tree = [0] * (size + 1) nums = [3, 2, -1, -4, 5, 7, -1, -2, 3, 4, 5, 6] for i, num in enumerate(nums, 1): tree[i] = num build(tree, size) return tree, size def test_lowbit(): assert...
[ { "docstring": null, "function_declaration": "def lowbit(x):", "function_name": "lowbit", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def sum(n, tree):", "function_name": "sum", "parameter_list": "(n, tree)" }, { "docstring": null, "functi...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def lowbit(x):\n return x & (-x)\n\ndef sum(n, tree):\n res = 0\n while n:\n res += tree[n]\n n -= lowbit(n)\n return res\n\ndef modify(n, k, tree, size):\n while ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002605", "row_id": 2605, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8393']" }
0.64966
Filter_2605
I
[ "lowbit", "sum", "modify", "build" ]
4
[ [ "build", "lowbit" ], [ "modify", "lowbit" ], [ "sum", "lowbit" ] ]
3
[]
false
[]
false
pytest
true
[]
true
f5544ad0d909173bdd6fa5d3228a9f000da4cad0
3bf746e155830f208ae5d7ca42d7e773b21764f8
v1.0
instruct
Filter
Filter_2614_I
def find_maximum_subarray_crossing_mid(array, low, mid, high): left_sum = float('-inf') sum_ = 0 for i in range(mid, low-1, -1): sum_ = sum_ + array[i] if (sum_ > left_sum): left_sum = sum_ right_sum = float('-inf') sum_ = 0 for i in range(mid + 1, high + 1): ...
def find_maximum_subarray_crossing_mid(array, low, mid, high): left_sum = float('-inf') sum_ = 0 for i in range(mid, low-1, -1): sum_ += array[i] if sum_ > left_sum: left_sum = sum_ right_sum = float('-inf') sum_ = 0 for i in range(mid + 1, high + 1): sum_ +=...
from solution import find_maximum_subarray def test_single_element_array(): assert find_maximum_subarray([1], 0, 0) == 1 assert find_maximum_subarray([0], 0, 0) == 0 assert find_maximum_subarray([-1], 0, 0) == -1 def test_all_positive_numbers(): assert find_maximum_subarray([1, 2, 3, 4, 5], 0, 4) == 1...
[ { "docstring": null, "function_declaration": "def find_maximum_subarray_crossing_mid(array, low, mid, high):", "function_name": "find_maximum_subarray_crossing_mid", "parameter_list": "(array, low, mid, high)" }, { "docstring": null, "function_declaration": "def find_maximum_subarray(arr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_maximum_subarray_crossing_mid(array, low, mid, high):\n \"\"\"\n Helper function to find the maximum subarray sum that crosses the midpoint.\n \"\"\"\n left_sum = float('-...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002614", "row_id": 2614, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8422']" }
0.672165
Filter_2614
I
[ "find_maximum_subarray_crossing_mid", "find_maximum_subarray" ]
2
[ [ "find_maximum_subarray", "find_maximum_subarray_crossing_mid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8b70dc6effc454e4e10fb710861acde63e17409b
0cf1f0d92103f49469e008ab8453051d39c4b6c3
v1.0
instruct
Filter
Filter_2615_I
import os import uuid APP_DIR = os.path.dirname(__file__) # Create a unique identifier for this application. application_id = str(uuid.uuid4()) def generate_random_string(length): """Generate a random string of a given length.""" return ''.join(random.choices(string.ascii_letters + string.digits, k=length)) ...
import os import uuid import random import string APP_DIR = os.path.dirname(__file__) # Create a unique identifier for this application. application_id = str(uuid.uuid4()) def generate_random_string(length): """Generate a random string of a given length.""" return ''.join(random.choices(string.ascii_letters ...
import os import uuid import random import string from solution import generate_random_string, get_app_dir, get_app_id, generate_input def test_generate_random_string_length(): assert len(generate_random_string(10)) == 10 assert len(generate_random_string(100)) == 100 def test_generate_random_string_content()...
[ { "docstring": "Generate a random string of a given length.", "function_declaration": "def generate_random_string(length):", "function_name": "generate_random_string", "parameter_list": "(length)" }, { "docstring": "Return the absolute path of the application directory.", "function_decla...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport uuid\nimport random\nimport string\n\nAPP_DIR = os.path.dirname(__file__)\n\n# Create a unique identifier for this application.\napplication_id = str(uuid.uuid4())\n\ndef gen...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002615", "row_id": 2615, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8429']" }
0.604781
Filter_2615
I
[ "generate_random_string", "get_app_dir", "get_app_id", "generate_input", "main" ]
5
[ [ "generate_input", "generate_random_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
382aa90bf91484f40e8868adcdb43073adb86686
1a25548aeb79a262c910b2168843215fa3e719b4
v1.0
instruct
Filter
Filter_2623_I
# Python Code to generate all combination of a given size from a set of elements. def get_combinations(elements, size): if size == 0: return [[]] else: result = [] for i in range(len(elements)): current = elements[i] rest_of_elements = elements[i+1:] f...
def get_combinations(elements, size): if size == 0: return [[]] else: result = [] for i in range(len(elements)): current = elements[i] rest_of_elements = elements[i+1:] for c in get_combinations(rest_of_elements, size-1): result.append(...
from solution import get_all_combinations def test_all_combinations(): elements = [1, 2, 3, 4] expected_combinations = [ [1], [2], [3], [4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4], [1, 2, 3, 4] ] result = get_all_combin...
[ { "docstring": null, "function_declaration": "def get_combinations(elements, size):", "function_name": "get_combinations", "parameter_list": "(elements, size)" }, { "docstring": null, "function_declaration": "def get_all_combinations(elements):", "function_name": "get_all_combination...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_combinations_of_all_sizes(elements):\n \"\"\"\n Returns all combinations of all sizes from 1 to len(elements).\n \"\"\"\n def get_combinations(elements, size):\n if ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002623", "row_id": 2623, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8450']" }
0.708731
Filter_2623
I
[ "get_combinations", "get_all_combinations" ]
2
[ [ "get_all_combinations", "get_combinations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
052d323cb54cee73a8c96146d6519264b6090cf6
71c482aaf50753e5d00075461144c93128fa3ea0
v1.0
instruct
Filter
Filter_2657_I
def calculate_tax(income, tax_rate): return income * tax_rate tax_rates = { "single": 0.25, "married": 0.15 } income = 50000 filing_status = "single" tax_amount = calculate_tax(income, tax_rates[filing_status]) print(f"Tax amount: {tax_amount:.2f}")
def calculate_tax(income, tax_rate): """ Calculate tax based on income and tax rate. """ return income * tax_rate tax_rates = { "single": 0.25, "married": 0.15, "head_of_household": 0.20 } def get_tax_amount(income, filing_status): """ Calculate the tax amount based on filing statu...
from solution import calculate_tax, get_tax_amount, tax_rates def test_calculate_tax(): assert calculate_tax(50000, 0.25) == 12500 assert calculate_tax(40000, 0.15) == 6000 def test_get_tax_amount_single(): assert get_tax_amount(50000, "single") == 12500 assert get_tax_amount(30000, "single") == 7500 ...
[ { "docstring": "Calculate tax based on income and tax rate.", "function_declaration": "def calculate_tax(income, tax_rate):", "function_name": "calculate_tax", "parameter_list": "(income, tax_rate)" }, { "docstring": "Calculate the tax amount based on filing status and income.", "functio...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_tax(income, tax_rate):\n \"\"\"\n Calculate the tax based on income and tax rate.\n\n :param income: The taxable income\n :param tax_rate: The tax rate to be applied\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002657", "row_id": 2657, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8546']" }
0.422469
Filter_2657
I
[ "calculate_tax", "get_tax_amount" ]
2
[ [ "get_tax_amount", "calculate_tax" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c9e2c5c0af887e8f2da096df684160a47ae4d441
e614178aae0d5d71ef4c92996705e9a4a1942c56
v1.0
instruct
Filter
Filter_2682_I
def is_prime(n): """Return True if n is a prime number, False otherwise.""" if n <= 1: return False for i in range(2, n): if n % i == 0: return False return True def nth_prime(n): """Return the nth prime number.""" count = 0 num = 2 while True: if is_...
def is_prime(n): """Return True if n is a prime number, False otherwise.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def nth_prime(n): """Return the nth prime number.""" count = 0 num = 2 while True: ...
from solution import is_prime, nth_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(-1) == False assert is_prime(0) == False assert is_prime(1) == False ...
[ { "docstring": "Return True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return the nth prime number.", "function_declaration": "def nth_prime(n):", "function_name": "nth...
[ 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 Return True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002682", "row_id": 2682, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8615']" }
0.893837
Filter_2682
I
[ "is_prime", "nth_prime" ]
2
[ [ "nth_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9834376a2608683b3c6f7384ecf5d3d37155b805
ed5aedbf7c1d2d5f20004f4d472b4ca29ca0e45b
v1.0
instruct
Filter
Filter_2685_I
This program is designed to balance a given chemical equation. ## Step 1: Define the problem and identify the input The program will take a string representing a chemical equation as input, where the equation is in a format that can be parsed into reactants and products separated by an arrow (->). Each compound is rep...
import re from collections import defaultdict from sympy import Matrix, lcm def parse_equation(equation): reactants, products = equation.split(' -> ') reactants = reactants.split(' + ') products = products.split(' + ') return reactants, products def parse_compound(compound): elements = re.findall...
from solution import parse_equation, parse_compound, get_elements, create_matrix, balance_equation def test_parse_equation(): reactants, products = parse_equation("H2 + O2 -> H2O") assert reactants == ["H2", "O2"] assert products == ["H2O"] def test_parse_compound(): compound_dict = parse_compound("H2...
[ { "docstring": null, "function_declaration": "def parse_equation(equation):", "function_name": "parse_equation", "parameter_list": "(equation)" }, { "docstring": null, "function_declaration": "def parse_compound(compound):", "function_name": "parse_compound", "parameter_list": "(...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nfrom collections import defaultdict\n\ndef parse_equation(equation):\n \"\"\"\n Split the equation into reactants and products.\n \"\"\"\n reactants, products = equation...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002685", "row_id": 2685, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8632']" }
0.499575
Filter_2685
I
[ "parse_equation", "parse_compound", "get_elements", "create_matrix", "balance_equation", "print_balanced_equation" ]
6
[ [ "balance_equation", "create_matrix" ], [ "balance_equation", "parse_equation" ], [ "create_matrix", "get_elements" ], [ "create_matrix", "parse_compound" ], [ "print_balanced_equation", "balance_equation" ] ]
5
[]
false
[]
false
pytest
true
[ "sympy" ]
false
25111441090b9fcb14f3b644ccdc5d91cdf6ae14
c4c450e2e342236c2fa958c9ca0c908042e269de
v1.0
instruct
Filter
Filter_2686_I
# Problem Write a Python function `unique_factorizations(n, primes)` that takes an integer `n` and a list of prime numbers `primes` as input. The function should return a list of unique factorizations of `n` using the prime numbers in the list. Each factorization is represented as a list of tuples, where each tuple con...
from itertools import combinations_with_replacement def prime_factors(n, primes): """ Helper function to get the prime factors of n using the given primes list. """ factor_counts = {} for p in primes: count = 0 while n % p == 0: n //= p count += 1 if ...
from solution import unique_factorizations def test_unique_factorizations_basic(): primes = [2, 3, 5] n = 30 result = unique_factorizations(n, primes) expected = [(2, 1), (3, 1), (5, 1)] assert sorted(result) == sorted(expected) def test_unique_factorizations_no_factors(): primes = [2, 3, 5] ...
[ { "docstring": "Helper function to get the prime factors of n using the given primes list.", "function_declaration": "def prime_factors(n, primes):", "function_name": "prime_factors", "parameter_list": "(n, primes)" }, { "docstring": "Returns unique factorizations of n using the prime number...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations_with_replacement\n\ndef prime_factors(n, primes):\n \"\"\"\n Helper function to get the prime factors of n using the given primes list.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002686", "row_id": 2686, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8634']" }
0.695946
Filter_2686
I
[ "prime_factors", "unique_factorizations" ]
2
[ [ "unique_factorizations", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a425d5aa127b31cb8b0fcfe0e787539277089b95
055454798b7db6fde3430bd269fcadda050a6803
v1.0
instruct
Filter
Filter_2690_I
import os def create_dir_if_not_exists(directory_path): if not os.path.exists(directory_path): os.makedirs(directory_path) def create_subdir_if_not_exists(parent_directory, subdirectory_name): subdirectory_path = os.path.join(parent_directory, subdirectory_name) create_dir_if_not_exists(subdirecto...
import os def create_dir_if_not_exists(directory_path): if not os.path.exists(directory_path): os.makedirs(directory_path) def create_subdir_if_not_exists(parent_directory, subdirectory_name): subdirectory_path = os.path.join(parent_directory, subdirectory_name) create_dir_if_not_exists(subdirecto...
import os import shutil from solution import create_dir_if_not_exists, create_subdir_if_not_exists, main def test_create_dir_if_not_exists(): test_dir = "test_dir" if os.path.exists(test_dir): shutil.rmtree(test_dir) create_dir_if_not_exists(test_dir) assert os.path.exists(test_dir) shutil....
[ { "docstring": null, "function_declaration": "def create_dir_if_not_exists(directory_path):", "function_name": "create_dir_if_not_exists", "parameter_list": "(directory_path)" }, { "docstring": null, "function_declaration": "def create_subdir_if_not_exists(parent_directory, subdirectory_...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef create_dir_if_not_exists(directory_path):\n if not os.path.exists(directory_path):\n os.makedirs(directory_path)\n\ndef create_subdir_if_not_exists(parent_directory,...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002690", "row_id": 2690, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8648']" }
0.549752
Filter_2690
I
[ "create_dir_if_not_exists", "create_subdir_if_not_exists", "main" ]
3
[ [ "create_subdir_if_not_exists", "create_dir_if_not_exists" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fc381d0f37ed351569d71a5845ee25c106bec4f2
2757fcbf0507fe341ae9292f63cdb15f2b86e1c9
v1.0
instruct
Filter
Filter_2722_I
def is_prime(n): """Check if number is prime.""" if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def find_primes(n): """Find all primes in range [2, n].""" return [i for i in range(2, n+1) if is_prime(i)] def is_p...
def is_prime(n): """Check if number is prime.""" if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def find_primes(n): """Find all primes in range [2, n].""" return [i for i in range(2, n+1) if is_prime(i)] def is_pal...
from solution import is_prime, find_primes, is_palindrome, solve 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 def test_find_primes(): assert find_pr...
[ { "docstring": "Check if number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find all primes in range [2, n].", "function_declaration": "def find_primes(n):", "function_name": "find_primes", "param...
[ 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 \"\"\"Check if number is prime.\"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002722", "row_id": 2722, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8752']" }
0.698874
Filter_2722
I
[ "is_prime", "find_primes", "is_palindrome", "solve" ]
4
[ [ "find_primes", "is_prime" ], [ "solve", "find_primes" ], [ "solve", "is_palindrome" ] ]
3
[]
false
[]
false
pytest
true
[]
true
60dcdee0fe7cfc659cf910afe80cec2eed32fb5f
9fb9c9269bbea3682d80119bb7d1c0731160e34a
v1.0
instruct
Filter
Filter_2723_I
def heapify(arr, n, i): largest = i left = 2 * i + 1 right = 2 * i + 2 if left < n and arr[i] < arr[left]: largest = left if right < n and arr[largest] < arr[right]: largest = right if largest != i: arr[i], arr[largest] = arr[largest], arr[i] heapify(arr, n, la...
def heapify(arr, n, i): """ Helper function to maintain the heap property. :param arr: List[int] - The array to heapify. :param n: int - Size of the heap. :param i: int - Index of the element to heapify. """ largest = i left = 2 * i + 1 right = 2 * i + 2 if left < n and arr[i] ...
from solution import heap_sort def test_heap_sort_with_unsorted_array(): assert heap_sort([12, 11, 13, 5, 6, 7]) == [5, 6, 7, 11, 12, 13] def test_heap_sort_with_already_sorted_array(): assert heap_sort([1, 2, 3, 4, 5, 6]) == [1, 2, 3, 4, 5, 6] def test_heap_sort_with_reverse_sorted_array(): assert heap_...
[ { "docstring": "Helper function to maintain the heap property.\n\n:param arr: List[int] - The array to heapify.\n:param n: int - Size of the heap.\n:param i: int - Index of the element to heapify.", "function_declaration": "def heapify(arr, n, i):", "function_name": "heapify", "parameter_list": "(ar...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def heapify(arr, n, i):\n \"\"\"\n Converts a subtree rooted with node i into a max heap, assuming that the \n subtrees are already max heaps.\n \n :param arr: List of elements ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002723", "row_id": 2723, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8755']" }
0.628102
Filter_2723
I
[ "heapify", "heap_sort" ]
2
[ [ "heap_sort", "heapify" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9339038c60f149d5ea76bf5633f6743223d52beb
07ce7e5a69a76c0084c8b615a676b22971dd0256
v1.0
instruct
Filter
Filter_2730_I
def calculate_median(numbers): numbers.sort() n = len(numbers) if n % 2 == 1: return numbers[n//2] else: return (numbers[n//2 - 1] + numbers[n//2]) / 2 def is_even(number): return number % 2 == 0 def get_median(numbers): return calculate_median(numbers)
def calculate_median(numbers): """ Returns the median of a list of numbers. The median is the middle number if the list length is odd, and the average of the two middle numbers if the list length is even. """ numbers.sort() n = len(numbers) if n % 2 == 1: return numbers[n//2] ...
from solution import calculate_median, is_even, get_median def test_calculate_median_odd_length(): assert calculate_median([1, 2, 3]) == 2 assert calculate_median([1, 3, 2, 5, 4]) == 3 assert calculate_median([7, 1, 3, 5, 2, 8, 6]) == 5 def test_calculate_median_even_length(): assert calculate_median(...
[ { "docstring": "Returns the median of a list of numbers.\nThe median is the middle number if the list length is odd,\nand the average of the two middle numbers if the list length is even.", "function_declaration": "def calculate_median(numbers):", "function_name": "calculate_median", "parameter_list...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_median(numbers):\n \"\"\"\n Returns the median of a list of numbers.\n If the list has an even number of elements, it returns the average of the two middle elements.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002730", "row_id": 2730, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8779']" }
0.82555
Filter_2730
I
[ "calculate_median", "is_even", "get_median" ]
3
[ [ "get_median", "calculate_median" ] ]
1
[]
false
[]
false
pytest
true
[]
true
01d1d3ddae20dd6ad76d6f9d774e66a1541c05c4
ccc5dd0bf63c41a3412afd9bb8c86655da3fec39
v1.0
instruct
Filter
Filter_2756_I
import random # Function to generate a random hand of cards def generate_hand(): # List of suits suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] # List of card types types = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King'] # Generate a random suit and card type for e...
import random # Function to generate a random hand of cards def generate_hand(): suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] types = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King'] hand = [{'suit': random.choice(suits), 'type': random.choice(types)} for _ in range(5)] ...
from solution import generate_hand, calculate_hand_value, is_blackjack, is_bust, deal_card def test_generate_hand(): hand = generate_hand() assert len(hand) == 5 assert all(card['suit'] in ['Hearts', 'Diamonds', 'Clubs', 'Spades'] for card in hand) assert all(card['type'] in ['Ace', '2', '3', '4', '5',...
[ { "docstring": null, "function_declaration": "def generate_hand():", "function_name": "generate_hand", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def calculate_hand_value(hand):", "function_name": "calculate_hand_value", "parameter_list": "(hand)" }...
[ 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_hand():\n suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']\n types = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']\n ha...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002756", "row_id": 2756, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8872']" }
0.731713
Filter_2756
I
[ "generate_hand", "calculate_hand_value", "is_blackjack", "is_bust", "deal_card" ]
5
[ [ "is_blackjack", "calculate_hand_value" ], [ "is_bust", "calculate_hand_value" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f543bda25d4d0cf2fe410368a132c52ec946a1b7
1cd4e62c9597f67344c276e63c40b002e3cc7848
v1.0
instruct
Filter
Filter_2763_I
from __future__ import division from random import randint, choice from string import ascii_letters, digits def generate_key(): all_characters = ascii_letters + digits length = randint(3, 10) key = ''.join(choice(all_characters) for _ in range(length)) return key def add_key(key, dictionary): dict...
from __future__ import division from random import randint, choice from string import ascii_letters, digits def generate_key(): all_characters = ascii_letters + digits length = randint(3, 10) key = ''.join(choice(all_characters) for _ in range(length)) return key def add_key(key, dictionary): dict...
from solution import generate_key, add_key, is_key_in_dict, produce_random_data def test_generate_key(): key = generate_key() assert isinstance(key, str) assert 3 <= len(key) <= 10 def test_add_key(): dictionary = {} key = "test_key" add_key(key, dictionary) assert key in dictionary as...
[ { "docstring": null, "function_declaration": "def generate_key():", "function_name": "generate_key", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def add_key(key, dictionary):", "function_name": "add_key", "parameter_list": "(key, dictionary)" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from __future__ import division\nfrom random import randint, choice\nfrom string import ascii_letters, digits\n\ndef generate_key():\n all_characters = ascii_letters + digits\n length = ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002763", "row_id": 2763, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8886']" }
0.627847
Filter_2763
I
[ "generate_key", "add_key", "is_key_in_dict", "produce_random_data", "main" ]
5
[ [ "produce_random_data", "add_key" ], [ "produce_random_data", "generate_key" ], [ "produce_random_data", "is_key_in_dict" ] ]
3
[]
false
[]
false
pytest
true
[]
true
59ee3f0049f4404aed84925909803c3f197e16c2
18a3ba789a5d9690bbb84cc59f03636f86cad9d5
v1.0
instruct
Filter
Filter_2766_I
def is_prime(n): """Return True if n is a prime number, False otherwise.""" if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def count_prime_fractions(n): """Return the number of prime fractions in the range [1, n]."""...
def is_prime(n): """ Return True if n is a prime number, False otherwise. """ if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def count_prime_fractions(n): """ Return the number of prime numbers in the ran...
from solution import is_prime, count_prime_fractions 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)...
[ { "docstring": "Return True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return the number of prime numbers in the range [2, n].", "function_declaration": "def count_prime_fr...
[ 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 Return True if n is a prime number, False otherwise.\n \"\"\"\n if n < 2:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002766", "row_id": 2766, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8905']" }
0.754964
Filter_2766
I
[ "is_prime", "count_prime_fractions" ]
2
[ [ "count_prime_fractions", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e95fddc77c045ec68234dc0b236e25b40fbcf222
1cf3351fb22238cc9d0ace1f1fc54abdf4903b80
v1.0
instruct
Filter
Filter_2782_I
import random import time import datetime import string def generate_dates(): start_date = datetime.date(1900, 1, 1) end_date = datetime.date(2022, 12, 31) time_between_dates = end_date - start_date days_between_dates = time_between_dates.days random_number_of_days = random.randrange(days_between_d...
import random import time import datetime import string def generate_dates(): start_date = datetime.date(1900, 1, 1) end_date = datetime.date(2022, 12, 31) time_between_dates = end_date - start_date days_between_dates = time_between_dates.days random_number_of_days = random.randrange(days_between_d...
from solution import generate_name def test_generate_name_length(): for _ in range(100): name = generate_name() assert 2 <= len(name) <= 12 def test_generate_name_format(): for _ in range(100): name = generate_name() assert name[0].isupper() assert name[1:].islower() i...
[ { "docstring": null, "function_declaration": "def generate_dates():", "function_name": "generate_dates", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def generate_name():", "function_name": "generate_name", "parameter_list": "()" }, { "docstring...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_dates():\n start_date = datetime.date(1900, 1, 1)\n end_date = datetime.date(2022, 12, 31)\n time_between_dates = end_date - start_date\n days_between_dates = time_bet...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002782", "row_id": 2782, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8970']" }
0.632217
Filter_2782
I
[ "generate_dates", "generate_name", "generate_random_data", "execute_scenario" ]
4
[ [ "execute_scenario", "generate_random_data" ], [ "generate_random_data", "generate_dates" ], [ "generate_random_data", "generate_name" ] ]
3
[]
false
[]
false
pytest
true
[]
true
bcd9fe9ff0371da9d4458bef9ec3f0c56d04e3e3
b813a7114f90186edfb2e1293af952e6af83c94b
v1.0
instruct
Filter
Filter_2785_I
class Solution: def get_max(self, matrix): max_val = 0 max_pos = (-1, -1) for i in range(len(matrix)): for j in range(len(matrix[i])): if matrix[i][j] > max_val: max_val = matrix[i][j] max_pos = (i, j) return max_val...
def get_max(matrix): max_val = matrix[0][0] max_pos = (0, 0) for i in range(len(matrix)): for j in range(len(matrix[i])): if matrix[i][j] > max_val: max_val = matrix[i][j] max_pos = (i, j) return max_val, max_pos def spiral_traverse(matrix): resul...
from solution import get_max, spiral_traverse, spiral_order def test_get_max(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert get_max(matrix) == (9, (2, 2)) matrix = [ [1, 2, 3], [4, 5, 6], [7, 9, 8] ] assert get_max(matrix) == (9, (2, 1)) ...
[ { "docstring": null, "function_declaration": "def get_max(matrix):", "function_name": "get_max", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def spiral_traverse(matrix):", "function_name": "spiral_traverse", "parameter_list": "(matrix)" }, { ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Solution:\n def get_max(self, matrix):\n \"\"\"\n Finds the maximum value in a 2D matrix and the position of that value.\n\n :param List[List[int]] matrix: 2D lis...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002785", "row_id": 2785, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_8984']" }
0.604719
Filter_2785
I
[ "get_max", "spiral_traverse", "spiral_order" ]
3
[ [ "spiral_order", "get_max" ], [ "spiral_order", "spiral_traverse" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3f35c1a455cdadd035f7fd1f541158583aa598f5
799f6a71a2a5df6e2c515b85bd5935292a6810ed
v1.0
instruct
Filter
Filter_2798_I
def f(x): if x == 0: return 0 elif x < 0: return -1 else: return 1 def g(x, y): return f(x-y)
def f(x): """ Function f returns: - 0 if x is 0 - -1 if x is negative - 1 if x is positive """ if x == 0: return 0 elif x < 0: return -1 else: return 1 def g(x, y): """ Function g returns the output of f(x - y). This function subtracts y from x a...
from solution import f, g def test_f_zero(): assert f(0) == 0 def test_f_negative(): assert f(-1) == -1 assert f(-5) == -1 def test_f_positive(): assert f(1) == 1 assert f(5) == 1 def test_g_equal_arguments(): assert g(5, 5) == 0 assert g(0, 0) == 0 assert g(-5, -5) == 0 def test_g_...
[ { "docstring": "Function f returns:\n- 0 if x is 0\n- -1 if x is negative\n- 1 if x is positive", "function_declaration": "def f(x):", "function_name": "f", "parameter_list": "(x)" }, { "docstring": "Function g returns the output of f(x - y). \nThis function subtracts y from x and passes the...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def f(x):\n \"\"\"\n Returns:\n 0 if x is 0,\n -1 if x is negative,\n 1 if x is positive.\n \"\"\"\n if x == 0:\n return 0\n elif x < 0:\n return -1\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002798", "row_id": 2798, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9013']" }
0.559296
Filter_2798
I
[ "f", "g" ]
2
[ [ "g", "f" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e36111bd4925a536c75d72c95a4ffb4052c88eb
f881910dcf89f6a62f34629f60eb0cf2164b070f
v1.0
instruct
Filter
Filter_2811_I
def is_prime(n): 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_next_prime(n): n += 1 while not is_prime(n): n += 1 return n def rotate(n): n_str = str(n) return [int(n_str[i:] + n_str[:i]...
def is_prime(n): 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_next_prime(n): n += 1 while not is_prime(n): n += 1 return n def rotate(n): n_str = str(n) return [int(n_str[i:] + n_str[:i]...
from solution import is_prime, find_next_prime, rotate, is_circular_prime, count_circular_primes def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert is_prime(29) assert not is_prime(49) assert not is_prime(1) assert not is_prime(0)...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_next_prime(n):", "function_name": "find_next_prime", "parameter_list": "(n)" }, { "docstring": n...
[ 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(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\ndef find_next_prime(n):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002811", "row_id": 2811, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9054']" }
0.707232
Filter_2811
I
[ "is_prime", "find_next_prime", "rotate", "is_circular_prime", "count_circular_primes" ]
5
[ [ "count_circular_primes", "is_circular_prime" ], [ "find_next_prime", "is_prime" ], [ "is_circular_prime", "is_prime" ], [ "is_circular_prime", "rotate" ] ]
4
[]
false
[]
false
pytest
true
[]
true
67b75104753c33c6a289e620758c64f9dc9fcdcc
0074331a47bb2f85f3081c12dfba6492253ee2e7
v1.0
instruct
Filter
Filter_2819_I
import numpy as np import math def calculate_distance(x, y): return math.sqrt(x**2 + y**2) def calculate_shortest_distance(point1, point2, obstacles): points = [point1, point2] points.extend(obstacles) centroid_x = sum(point[0] for point in points) / len(points) centroid_y = sum(point[1] for point...
import math def calculate_distance(point1, point2): return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) def calculate_shortest_distance(point1, point2, obstacles): """ Calculate the shortest distance between point1 and point2 considering the obstacles. Returns: The Euclid...
from solution import calculate_distance, calculate_shortest_distance def test_calculate_distance(): assert calculate_distance((0, 0), (3, 4)) == 5 assert calculate_distance((1, 1), (4, 5)) == 5 assert calculate_distance((0, 0), (0, 0)) == 0 assert calculate_distance((-1, -1), (-4, -5)) == 5 def test_c...
[ { "docstring": null, "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Calculate the shortest distance between point1 and point2 considering the obstacles.\nReturns:\n The Eucli...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_distance(point1, point2):\n return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2)\n\ndef calculate_shortest_distance(point1, point2, obstacl...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002819", "row_id": 2819, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9083']" }
0.620943
Filter_2819
I
[ "calculate_distance", "calculate_shortest_distance" ]
2
[ [ "calculate_shortest_distance", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b493db877891a8a4b37b971d771969dbb3011ddd
c400873ba9809cbb2dd72240a5e87cc0ffc3eceb
v1.0
instruct
Filter
Filter_2822_I
import numpy as np import matplotlib.pyplot as plt def function1(): x = np.linspace(0,10,100) y = np.sin(x) plt.figure(figsize = (6,6)) plt.plot(x,y) plt.title('Sine wave') plt.xlabel('X') plt.ylabel('sin(x)') plt.grid(True) plt.show() function1() I have a function called functi...
import numpy as np import matplotlib.pyplot as plt def function1(amplitude=1): x = np.linspace(0, 10, 100) y = amplitude * np.sin(x) plt.figure(figsize=(6, 6)) plt.plot(x, y) plt.title('Sine wave') plt.xlabel('X') plt.ylabel(f'{amplitude} * sin(x)') plt.grid(True) plt.show() def fu...
def test_function1_default(): # This test will simply call the function and visually inspect the plot function1() def test_function2_amplitude_change(): # This test will call the function with a new amplitude and visually inspect the plot function2(2) def test_function2_amplitude_negative(): # Thi...
[ { "docstring": null, "function_declaration": "def function1(amplitude=1):", "function_name": "function1", "parameter_list": "(amplitude=1)" }, { "docstring": null, "function_declaration": "def function2(new_amplitude):", "function_name": "function2", "parameter_list": "(new_ampli...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\n\ndef function1(frequency=1):\n x = np.linspace(0, 10, 100)\n y = np.sin(frequency * x)\n plt.figure(figsize=(6, 6))\n plt.plot...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002822", "row_id": 2822, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9096']" }
0.5715
Filter_2822
I
[ "function1", "function2" ]
2
[ [ "function2", "function1" ] ]
1
[]
false
[]
false
pytest
false
[ "matplotlib", "numpy" ]
false
7ad497ee99a741eb167e15499e3f062b2ccaa5c0
e352d619c4470f05461d6a7130c358bf6389f84e
v1.0
instruct
Filter
Filter_2825_I
### PART 1: Write a function to determine if a given string is a palindrome. ### PART 2: Generate all possible palindromic substrings of a given string. ### PART 3: Expand the function from PART 2 to generate all possible substrings (not just palindromic ones). ## Step 1: Define the function to check if a string is a ...
def is_palindrome(s): """ Checks if the given string is a palindrome. Args: s (str): The input string. Returns: bool: True if the string is a palindrome, False otherwise. """ return s == s[::-1] def get_palindromic_substrings(s): """ Generates all possible palindromic substrin...
from solution import is_palindrome, get_palindromic_substrings, get_all_substrings def test_is_palindrome(): assert is_palindrome("racecar") == True assert is_palindrome("abba") == True assert is_palindrome("abc") == False assert is_palindrome("a") == True assert is_palindrome("") == True def test...
[ { "docstring": "Checks if the given string is a palindrome.\n\nArgs:\ns (str): The input string.\n\nReturns:\nbool: True if the string is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstrin...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Determine if a given string is a palindrome.\n\n Args:\n s (str): Input string.\n\n Returns:\n bool: True if the string is a palindrome, else...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002825", "row_id": 2825, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9121']" }
0.779782
Filter_2825
I
[ "is_palindrome", "get_palindromic_substrings", "get_all_substrings" ]
3
[ [ "get_palindromic_substrings", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8de47ce77e129b1b33f5539747b0b9c108c30840
b56290f1e33ba6643d5b42891a355a6b3a20711d
v1.0
instruct
Filter
Filter_2853_I
This project is an implementation of a keyword-based search in a streaming data. The search should be able to find all unique occurrences (i.e., index positions) of each keyword in the streaming data. stream = ["apple", "banana", "apple", "orange", "banana", "banana"] The desired output: keyword: apple [0, 2] ...
def keyword_search_streaming(stream, keywords): """ Returns the unique index positions of each keyword in the streaming data. """ keyword_index = {keyword: [] for keyword in keywords} for index, word in enumerate(stream): if word in keywords: keyword_index[word].append(index) ...
from solution import keyword_search_streaming def test_keyword_search_apples(): stream = ["apple", "banana", "apple", "orange", "banana", "banana"] keywords = ["apple"] result = keyword_search_streaming(stream, keywords) assert result == {"apple": [0, 2]} def test_keyword_search_bananas(): stream ...
[ { "docstring": "Returns the unique index positions of each keyword in the streaming data.", "function_declaration": "def keyword_search_streaming(stream, keywords):", "function_name": "keyword_search_streaming", "parameter_list": "(stream, keywords)" }, { "docstring": null, "function_dec...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def keyword_search(iterator, keywords):\n keyword_index = {}\n for index, word in enumerate(iterator):\n if word in keywords:\n if word not in keyword_index:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002853", "row_id": 2853, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9217']" }
0.47793
Filter_2853
I
[ "keyword_search_streaming", "example_usage_streaming" ]
2
[ [ "example_usage_streaming", "keyword_search_streaming" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4b533a5a3934a64b331b8032ea8080541567748a
9b3403344dca6a970d5f42314286a1f54150d6cf
v1.0
instruct
Filter
Filter_2857_I
import random def greet(name): if name == "Alice": return "Hello Alice!" else: return "Hello!" def roll_dice(): return random.randint(1,6) def main(): print(greet("Alice")) print(greet("Bob")) print(roll_dice()) if __name__ == "__main__": main() I want to use the greet f...
import random def greet(name): """ Greets the person by name. Special greeting if the person's name is Alice. """ if name == "Alice": return "Hello Alice!" else: return f"Hello {name}!" def roll_dice(): """ Rolls a dice and returns a number between 1 and 6. """ retu...
from solution import greet, roll_dice, perform_tasks import pytest import random def test_greet(): assert greet("Alice") == "Hello Alice!" assert greet("Bob") == "Hello Bob!" assert greet("Charlie") == "Hello Charlie!" def test_roll_dice(monkeypatch): # Setting a fixed return value for randint to ensu...
[ { "docstring": "Greets the person by name. Special greeting if the person's name is Alice.", "function_declaration": "def greet(name):", "function_name": "greet", "parameter_list": "(name)" }, { "docstring": "Rolls a dice and returns a number between 1 and 6.", "function_declaration": "d...
[ 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 greet(name):\n \"\"\"\n Returns a greeting for the given name.\n \"\"\"\n if name == \"Alice\":\n return \"Hello Alice!\"\n else:\n return f\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002857", "row_id": 2857, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9236']" }
0.492443
Filter_2857
I
[ "greet", "roll_dice", "perform_tasks" ]
3
[ [ "perform_tasks", "greet" ], [ "perform_tasks", "roll_dice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b67b17ee4e4b4aefd01db08150a13d84af977a7a
be32dc0c3ee1c772d9de84cb0c6efb4ca5aa0e2d
v1.0
instruct
Filter
Filter_2884_I
import random import math def random_number(): return random.randint(1, 100) def area_of_circle(radius): return math.pi * (radius ** 2) print("Choose an option!") print("1 - Generate a random number between 1 and 100.") print("2 - Calculate the area of a circle.") while True: choice = int(input("Enter y...
import random import math def random_number(): return random.randint(1, 100) def area_of_circle(radius): return math.pi * (radius ** 2) def menu(choice, radius=None): if choice == 1: return random_number() elif choice == 2: if radius is None: return "Radius not provided" ...
from solution import random_number, area_of_circle, menu import math def test_random_number(): num = random_number() assert 1 <= num <= 100 def test_area_of_circle_zero_radius(): assert area_of_circle(0) == 0 def test_area_of_circle_positive_radius(): assert math.isclose(area_of_circle(1), math.pi) ...
[ { "docstring": null, "function_declaration": "def random_number():", "function_name": "random_number", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def area_of_circle(radius):", "function_name": "area_of_circle", "parameter_list": "(radius)" }, { ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport math\n\ndef random_number():\n \"\"\"\n Returns a random integer between 1 and 100.\n \"\"\"\n return random.randint(1, 100)\n\ndef area_of_circle(radius):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002884", "row_id": 2884, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9326']" }
0.577619
Filter_2884
I
[ "random_number", "area_of_circle", "menu" ]
3
[ [ "menu", "area_of_circle" ], [ "menu", "random_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e0acbab6f748b922aea944e2642269f9d13be8eb
8178539326f98f8896f6eaabca0092c0a7b9639a
v1.0
instruct
Filter
Filter_2960_I
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def maxDepth(node): if node is None: return 0 else: left_depth = maxDepth(node.left) right_depth = maxDepth(node.right) return max(left_depth, right_depth) + ...
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def maxDepth(node): if node is None: return 0 else: left_depth = maxDepth(node.left) right_depth = maxDepth(node.right) return max(left_depth, right_depth) + ...
from solution import Node, isBalanced def test_balanced_tree(): root = Node(1) root.left = Node(2) root.right = Node(3) root.left.left = Node(4) root.left.right = Node(5) root.right.left = Node(6) root.right.right = Node(7) assert isBalanced(root) == True def test_unbalanced_tree(): ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef maxDepth(node):\n if node is None:\n return 0\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002960", "row_id": 2960, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9612']" }
0.585816
Filter_2960
I
[ "maxDepth", "isBalanced" ]
2
[ [ "isBalanced", "maxDepth" ] ]
1
[]
false
[ "Node" ]
true
pytest
true
[]
true
7eab9aa7bd349444608290e1167394276179b3af
90d9f16c401f1c6ce7b4f5dde7428c6e9d67e813
v1.0
instruct
Filter
Filter_2978_I
Here is a challenge to your programming skills: can you write a program that implements the classic recursive sequence of the Fibonacci sequence, which is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. Here is what I would expect the program to do: - It s...
import timeit def fibonacci(n): """ Recursive function to return the nth Fibonacci number. """ if n < 0: raise ValueError("n must be a non-negative integer.") # base cases if n == 0: return 0 elif n == 1: return 1 # recursive case else: return fi...
from solution import fibonacci, timed_fibonacci def test_fibonacci_base_cases(): assert fibonacci(0) == 0 assert fibonacci(1) == 1 def test_fibonacci_recursive(): assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(4) == 3 assert fibonacci(5) == 5 assert fibonacci(10) == 55 ...
[ { "docstring": "Recursive function to return the nth Fibonacci number.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Returns the nth Fibonacci number along with the time taken to compute it.", "function_declaration...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import timeit\n\ndef fibonacci(n):\n \"\"\"\n Returns the nth Fibonacci number using a recursive approach.\n \"\"\"\n # base cases\n if n == 0:\n return 0\n elif n == ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002978", "row_id": 2978, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_9676']" }
0.658119
Filter_2978
I
[ "fibonacci", "timed_fibonacci", "main" ]
3
[ [ "timed_fibonacci", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bce690d143f3786d5f8c611efb803821525a016e
6e50859ce767f162cbe500985986c19b1c159dcc