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
complete
Prefill
Prefill_26593_C
def number_to_words(num: int) -> str: """ Convert a number into words. >>> number_to_words(0) 'zero' >>> number_to_words(4) 'four' >>> number_to_words(123) 'one hundred twenty-three' >>> number_to_words(1001) 'one thousand one' >>> number_to_words(1000000) 'one million' "...
def number_to_words(num): # Helper function to handle numbers less than 1000 def helper(n): if n < 20: return below_20[n] elif n < 100: return tens[n // 10] + ('' if n % 10 == 0 else '-' + below_20[n % 10]) else: return below_20[n // 100] + ' hundred' ...
from solution import number_to_words def test_number_to_words_single_digits(): assert number_to_words(0) == "zero" assert number_to_words(1) == "one" assert number_to_words(9) == "nine" def test_number_to_words_two_digits(): assert number_to_words(10) == "ten" assert number_to_words(19) == "ninete...
[ { "docstring": null, "function_declaration": "def number_to_words(num):", "function_name": "number_to_words", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def chunk_number(num):", "function_name": "chunk_number", "parameter_list": "(num)" }, { ...
[ 1, 1, 0, 1, 1, 0, 1, 0, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def number_to_words(num):\n if num == 0:\n return \"zero\"\n \n ones = [\"\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"]\n te...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes an integer as an input and returns a string that displays the integer in words. For example, if the input is 4, the output should be \"forty\". If the input is 123, the output should be \"one hundred twenty-three\".", "prompt_id": "00026593", "row_id": 26593...
0.596923
Prefill_26593
C
[ "number_to_words", "chunk_number" ]
2
[ [ "number_to_words", "chunk_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
78a7595e275a0d7deaa3743b50b5e177a2f0e429
cc7f5fe97eb3c4f4fd25b7d9b60dda220b038c11
v1.0
complete
Prefill
Prefill_26325_C
def fibonacci_generator(n): """ A generator function that yields the first n Fibonacci numbers. """ def sum_fibonacci(n): """ Sums the first n Fibonacci numbers. """ # Test cases if __name__ == "__main__": # Testing fibonacci_generator assert list(fibonacci_generator(0)) == [] ...
def fibonacci_generator(n): """ A generator function that yields the first n Fibonacci numbers. """ a, b = 0, 1 count = 0 while count < n: yield a a, b = b, a + b count += 1 def sum_fibonacci(n): """ Sums the first n Fibonacci numbers. """ return sum(fibo...
from solution import fibonacci_generator, sum_fibonacci def test_fibonacci_generator(): assert list(fibonacci_generator(0)) == [] assert list(fibonacci_generator(1)) == [0] assert list(fibonacci_generator(2)) == [0, 1] assert list(fibonacci_generator(5)) == [0, 1, 1, 2, 3] def test_sum_fibonacci(): ...
[ { "docstring": "A generator function that yields the first n Fibonacci numbers.", "function_declaration": "def fibonacci_generator(n):", "function_name": "fibonacci_generator", "parameter_list": "(n)" }, { "docstring": "Sums the first n Fibonacci numbers.", "function_declaration": "def s...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci_generator(n):\n \"\"\"\n Generates the first n Fibonacci numbers.\n \n :param n: The number of Fibonacci numbers to generate.\n :yield: The next Fibonacci number ...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates the first `n` Fibonacci numbers using a generator function in Python. Then, write a loop to sum these numbers.", "prompt_id": "00026325", "row_id": 26325, "seed_ids": "['magpie_prefill_26325']" }
0.732977
Prefill_26325
C
[ "fibonacci_generator", "sum_fibonacci" ]
2
[ [ "sum_fibonacci", "fibonacci_generator" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6642cf03da9f61afaa273d480e9381b278062058
c1d45763f2190ce2a98bd3d829d5b0be855bef6e
v1.0
complete
Prefill
Prefill_26182_C
def reachSlow(n): """ Returns the sum of squares of the digits of n. """ pass def reachFast(n): """ Returns the next number by applying the sum of squares of the digits twice. """ pass def is_happy_number(n: int) -> bool: """ Determines whether the given number n is a Happy Number....
def reachSlow(n): """ Returns the sum of squares of the digits of n. """ return sum(int(digit) ** 2 for digit in str(n)) def reachFast(n): """ Returns the next number by applying the sum of squares of the digits twice. """ return reachSlow(reachSlow(n)) def is_happy_number(n): """ ...
from solution import is_happy_number # Test cases def test_happy_number_1(): assert is_happy_number(1) == True def test_happy_number_19(): assert is_happy_number(19) == True def test_happy_number_7(): assert is_happy_number(7) == True def test_unhappy_number_2(): assert is_happy_number(2) == False ...
[ { "docstring": "Returns the sum of squares of the digits of n.", "function_declaration": "def reachSlow(n):", "function_name": "reachSlow", "parameter_list": "(n)" }, { "docstring": "Returns the next number by applying the sum of squares of the digits twice.", "function_declaration": "de...
[ 0, 1, 0, 1, 1, 0, 0, 1, 1 ]
5
medium
0.556
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Prefill-43K_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_happy_number(n):\n \"\"\"\n Returns whether a number n is a Happy Number.\n A Happy Number is a number which eventually reaches 1 when replaced by the...
trial_gpt4o_9
{ "original_instruction": "Create a function that accepts an integer as an argument and returns whether it is a Happy Number. Here is the definition of a Happy Number: A happy number is a number which eventually reaches 1 when replaced by the sum of the square of each digit, and eventually reaches 2 if it does not. I...
0.602208
Prefill_26182
C
[ "reachSlow", "reachFast", "is_happy_number" ]
3
[ [ "is_happy_number", "reachFast" ], [ "is_happy_number", "reachSlow" ], [ "reachFast", "reachSlow" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8be4e2c3c181b8a06f03d2f66c6d1aee1f5be0b1
36f83d8f6cbc21e8df5b2c2605f182184f759ab4
v1.0
complete
Prefill
Prefill_26394_C
def contains_vowel(word: str) -> bool: """ Helper function to check if a word contains a vowel. """ vowels = 'aeiouAEIOU' return any(char in vowels for char in word) def filter_words_with_vowels(words_list: List[str]) -> List[str]: """ Function to filter out words containing vowels from a l...
def contains_vowel(word): """ Helper function to check if a word contains a vowel """ vowels = 'aeiouAEIOU' return any(char in vowels for char in word) def filter_words_with_vowels(words_list): """ Function to filter out words containing vowels from a list. """ return [word for word...
from solution import filter_words_with_vowels def test_filter_words_with_vowels_all_vowel_words(): assert filter_words_with_vowels(['apple', 'orange', 'grape']) == ['apple', 'orange', 'grape'] def test_filter_words_with_vowels_mixed_words(): assert filter_words_with_vowels(['sky', 'apple', 'try']) == ['apple'...
[ { "docstring": "Helper function to check if a word contains a vowel", "function_declaration": "def contains_vowel(word):", "function_name": "contains_vowel", "parameter_list": "(word)" }, { "docstring": "Function to filter out words containing vowels from a list.", "function_declaration"...
[ 1, 1, 1, 0, 1, 1, 1, 1, 0, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def filter_vowels(words):\n \"\"\"\n Returns a list of words that contain at least one vowel.\n \"\"\"\n vowels = set(\"aeiouAEIOU\")\n def has_vowel(word):\n return any...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes a list as an argument and returns a new list with all the list items containing vowels in them.", "prompt_id": "00026394", "row_id": 26394, "seed_ids": "['magpie_prefill_26394']" }
0.752243
Prefill_26394
C
[ "contains_vowel", "filter_words_with_vowels" ]
2
[ [ "filter_words_with_vowels", "contains_vowel" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1180b5d22af35e074fa8329fea199ab474842441
e3d471b5872c680064d84248891f7f7dd5895796
v1.0
complete
Prefill
Prefill_8132_C
def is_palindrome(n: int) -> bool: """ Checks if the given integer n is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(12321) True >>> is_palindrome(123) False >>> is_palindrome(10) False """ def steps_to_palindrome(n: int) -> (bool, int): """ Returns a tupl...
def is_palindrome(n): """ Checks if the given integer n is a palindrome. """ return str(n) == str(n)[::-1] def steps_to_palindrome(n): """ Returns a tuple (is_palindrome, steps) where: - is_palindrome is a boolean indicating if n is already a palindrome. - steps is the number of steps r...
from solution import is_palindrome, steps_to_palindrome, palindrome_transformation def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(12321) == True assert is_palindrome(123) == False assert is_palindrome(10) == False def test_steps_to_palindrome(): assert steps_to_pa...
[ { "docstring": "Checks if the given integer n is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Returns a tuple (is_palindrome, steps) where:\n- is_palindrome is a boolean indicating if n is alread...
[ 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Checks if the given integer n is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef steps_to_palindrome(n):\n \"\"\"\n Returns th...
trial_gpt4o_9
{ "original_instruction": "Write a function to determine if a given integer is a palindrome and if so, find the number of steps required to transform it into a palindrome by repeatedly reversing and adding the number to itself.", "prompt_id": "00008132", "row_id": 8132, "seed_ids": "['magpie_prefill_8132']" }
0.696232
Prefill_8132
C
[ "is_palindrome", "steps_to_palindrome", "palindrome_transformation" ]
3
[ [ "palindrome_transformation", "is_palindrome" ], [ "palindrome_transformation", "steps_to_palindrome" ], [ "steps_to_palindrome", "is_palindrome" ] ]
3
[]
false
[]
false
pytest
true
[]
true
ea64e2d7e9f37f6da295599dd8c30cb3cce2c8a2
015d068b1998f695393d9ab12c44c662a056e55a
v1.0
complete
Prefill
Prefill_8737_C
def is_prime(n: int) -> bool: """ Check if a number n is a prime number. >>> is_prime(1) == False >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(9) == False >>> is_prime(11) == True """ def generate_primes(start: int...
def is_prime(n): """ Check if a number n is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for current in range(3, int(n**0.5) + 1, 2): if n % current == 0: return False return True def generate_...
from solution import generate_primes, is_prime def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(11) def test_generate_primes_normal_range(): assert generate_primes(10, 20) ...
[ { "docstring": "Check if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate a list of prime numbers within the given range [start, end].", "function_declaration": "def generate_prime...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Check if a number is a prime number.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n re...
trial_gpt4o_8
{ "original_instruction": "Write a function to generate a list of prime numbers within a given range [start, end].", "prompt_id": "00008737", "row_id": 8737, "seed_ids": "['magpie_prefill_8737']" }
0.783132
Prefill_8737
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
10088f2c3a403e3725b015d1b6790135ae805f08
a9516f193801c279125404cdaa86a703b6600787
v1.0
complete
Prefill
Prefill_26557_C
from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(10) == False >>> is_prime(23) == True """ pass def next_prime(n: int) -> int: ...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def next_prime(n): """ Returns the next prime number greater than n. If n is prime, return n. ...
from solution import is_prime, next_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(23) == True def test_next_prime_with_prime_input(): assert next_prime...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the next prime number greater than n. If n is prime, return n.", "function_declaration": "def next_prime(n):", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sympy\n\ndef next_prime(n):\n \"\"\"\n Returns the next prime number greater than or equal to n.\n \"\"\"\n if n <= 1:\n return 2\n prime_candidate = n\n while...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates a prime number greater than a given input number `n`. If the number is prime, return it; otherwise, find the next prime number and return it.", "prompt_id": "00026557", "row_id": 26557, "seed_ids": "['magpie_prefill_26557']" }
0.823209
Prefill_26557
C
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
45647a04c271c11a78f4a084ba17c94e16f5bb9c
0030fff65faf31e5588ff4c2a2702f424dccbd32
v1.0
complete
Prefill
Prefill_26511_C
def is_prime_number(num: int) -> bool: """ Helper function to check if a number is prime. """ def find_primes_in_range(start: int, end: int) -> list: """ Create a function that finds all the prime numbers within a given range of integers. The function should take two parameters, `start...
def is_prime_number(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False p = 3 while p * p <= num: if num % p == 0: return False p += 2 return ...
from solution import find_primes_in_range def test_find_primes_in_range_inclusive(): assert find_primes_in_range(10, 20) == [11, 13, 17, 19] def test_find_primes_in_range_no_primes(): assert find_primes_in_range(24, 28) == [] def test_find_primes_in_range_single_prime(): assert find_primes_in_range(18, 1...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime_number(num):", "function_name": "is_prime_number", "parameter_list": "(num)" }, { "docstring": "Returns a list of all prime numbers between start and end (inclusive).", "function_declar...
[ 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_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 < 2:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that finds all the prime numbers within a given range of integers. The function should take two parameters, `start` and `end`, and return a list of all prime numbers between `start` and `end` (inclusive).", "prompt_id": "00026511", "row_id": 26511, "seed_ids": "['mag...
0.740831
Prefill_26511
C
[ "is_prime_number", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2e8c0b3ac04713e3824815f26374b4a62e063e47
e6c939e27237c187a9aa80aa74fd67ff47a3a0fb
v1.0
complete
Prefill
Prefill_25996_C
def can_partition(nums: List[int], k: int, max_sum: int) -> bool: """ Helper function that checks if the list can be partitioned into k or fewer sublists such that the maximum sum of any sublist does not exceed max_sum. """ current_sum = 0 partitions = 1 for num in nums: if current_...
def can_partition(nums, k, max_sum): current_sum = 0 partitions = 1 for num in nums: if current_sum + num > max_sum: partitions += 1 current_sum = num if partitions > k: return False else: current_sum += num return...
from solution import min_max_partition_sum def test_min_max_partition_sum_example(): nums = [7, 2, 5, 10, 8] k = 2 assert min_max_partition_sum(nums, k) == 18 def test_min_max_partition_sum_single_element(): nums = [10] k = 1 assert min_max_partition_sum(nums, k) == 10 def test_min_max_partit...
[ { "docstring": null, "function_declaration": "def can_partition(nums, k, max_sum):", "function_name": "can_partition", "parameter_list": "(nums, k, max_sum)" }, { "docstring": null, "function_declaration": "def min_max_partition_sum(nums, k):", "function_name": "min_max_partition_sum...
[ 1, 1, 1, 0, 0, 1, 1, 1, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_partition(nums, k, max_sum):\n \"\"\"\n Utility function to check whether it's possible to partition the list into k sublists\n where each sublist has a sum less than or equa...
trial_gpt4o_8
{ "original_instruction": "Create a function that partitions the given list into K non-empty sublists such that the maximum sum of elements in any sublist is minimized.", "prompt_id": "00025996", "row_id": 25996, "seed_ids": "['magpie_prefill_25996']" }
0.688386
Prefill_25996
C
[ "can_partition", "min_max_partition_sum" ]
2
[ [ "min_max_partition_sum", "can_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
91924c1eed68e7592849b505ad490dbdbf0da65a
e5ccb4a58d5036d3cfb7126ade442eaa3e6eaa66
v1.0
complete
Prefill
Prefill_27007_C
def validate_integer(value): """ Validates if the provided value is an integer. Raises: ValueError: If the provided value is not an integer. """ pass def custom_sum(a, b): """ Returns the sum of a and b with post-processing: - If the sum is even, returns the sum multiplied by 3....
def validate_integer(value): """ Validates if the provided value is an integer. """ if not isinstance(value, int): raise ValueError(f"Value {value} is not an integer.") def custom_sum(a, b): """ Returns the sum of a and b with post-processing: - If the sum is even, returns the sum m...
import pytest from solution import custom_sum, validate_integer def test_custom_sum_even_result(): assert custom_sum(2, 2) == 12 # 4 is even, 4 * 3 = 12 def test_custom_sum_odd_result(): assert custom_sum(1, 2) == 3 # 3 is odd, should return 3 def test_custom_sum_negative_numbers(): assert custom_sum(...
[ { "docstring": "Validates if the provided value is an integer.", "function_declaration": "def validate_integer(value):", "function_name": "validate_integer", "parameter_list": "(value)" }, { "docstring": "Returns the sum of a and b with post-processing:\n- If the sum is even, returns the sum...
[ 0, 1, 0, 1, 0, 0, 0, 0, 1, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def custom_add(a, b):\n \"\"\"\n Returns the sum of a and b after validating that both are integers.\n If the sum is an even number, returns the sum multiplied by 3.\n Otherwise, ...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes two integers `a` and `b` as input and returns the sum of `a` and `b`. Validate the input to ensure both are integers and raise a ValueError if they are not. If the sum is an even number, return the sum multiplied by 3; otherwise, return the sum as is.", "promp...
0.742874
Prefill_27007
C
[ "validate_integer", "custom_sum" ]
2
[ [ "custom_sum", "validate_integer" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7ac34005caf65dd0cd9308765f39330c2eb9bedc
4e0f5b06ec1d2af74d806ef6480a362f1767866b
v1.0
complete
Prefill
Prefill_26236_C
def generate_primes_in_range(start: int, end: int) -> list: """ Generate a list of all prime numbers within a given range, inclusive. >>> generate_primes_in_range(10, 20) [11, 13, 17, 19] >>> generate_primes_in_range(14, 16) [] >>> generate_primes_in_range(29, 29) [29] ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import generate_primes_in_range def test_primes_in_standard_range(): assert generate_primes_in_range(10, 20) == [11, 13, 17, 19] def test_primes_with_no_primes_in_range(): assert generate_primes_in_range(14, 16) == [] def test_primes_single_prime_in_range(): assert generate_primes_in_range(...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate a list of all prime numbers within a given range, inclusive.", "function_declaration": "def genera...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates and returns a list of all prime numbers within a given range, inclusive of the start and end of the range. The prime numbers should be in ascending order.", "prompt_id": "00026236", "row_id": 26236, "seed_ids": "['magpie_prefill_26236']" }
0.661789
Prefill_26236
C
[ "is_prime", "generate_primes_in_range" ]
2
[ [ "generate_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bc8e228495379887784673bde24f40d3d3994e39
42069241f05439e23e34a0ac6be6bffdcff501f9
v1.0
complete
Prefill
Prefill_26987_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. """ # Implement this function to check for prime number def find_prime_in_array(arr: List[int]) -> int: """ Returns the only prime number in the array. If no prime number is found, return 0. >>> find_prime_...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def find_prime_...
from solution import find_prime_in_array def test_find_prime_in_array_single_prime(): assert find_prime_in_array([4, 6, 8, 11, 12]) == 11 def test_find_prime_in_array_no_primes(): assert find_prime_in_array([4, 6, 8, 10, 12]) == 0 def test_find_prime_in_array_multiple_primes(): assert find_prime_in_array...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the only prime number in the array.\nIf no prime number is found, return 0.", "function_declaration...
[ 1, 1, 0, 1, 0, 1, 0, 1, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\" Helper function to determine 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 ...
trial_gpt4o_5
{ "original_instruction": "Create a function that takes an array of integers and returns the only prime number found in the array. If no prime number is found, return 0.", "prompt_id": "00026987", "row_id": 26987, "seed_ids": "['magpie_prefill_26987']" }
0.812814
Prefill_26987
C
[ "is_prime", "find_prime_in_array" ]
2
[ [ "find_prime_in_array", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
08ca139018cbb50407157b639eca9d9fe1d7a66f
3210b0f14307fb2c61a91b9ff694109505346fc2
v1.0
complete
Prefill
Prefill_27659_C
def sieve_of_eratosthenes(n: int) -> List[int]: """ Returns a list of all prime numbers less than n using the Sieve of Eratosthenes algorithm. """ pass def largest_prime_less_than(n: int) -> int: """ Returns the largest prime number less than the given number n. >>> largest_prime_less_...
def sieve_of_eratosthenes(n): """ Returns a list of all prime numbers less than n using the Sieve of Eratosthenes algorithm. """ if n <= 2: return [] is_prime = [True] * n is_prime[0] = is_prime[1] = False for i in range(2, int(n**0.5) + 1): if is_prime[i]: for j ...
from solution import largest_prime_less_than def test_prime_less_than_10(): assert largest_prime_less_than(10) == 7 def test_prime_less_than_20(): assert largest_prime_less_than(20) == 19 def test_prime_less_than_2(): assert largest_prime_less_than(2) is None def test_prime_less_than_50(): assert la...
[ { "docstring": "Returns a list of all prime numbers less than n using the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns the largest prime number less tha...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_prime_less_than(n):\n \"\"\"\n Returns the largest prime number less than n using the Sieve of Eratosthenes algorithm.\n \"\"\"\n if n <= 2:\n return None # Th...
trial_gpt4o_4
{ "original_instruction": "Write a python function to find the largest prime number less than a given number n using the Sieve of Eratosthenes algorithm.", "prompt_id": "00027659", "row_id": 27659, "seed_ids": "['magpie_prefill_27659']" }
0.666399
Prefill_27659
C
[ "sieve_of_eratosthenes", "largest_prime_less_than" ]
2
[ [ "largest_prime_less_than", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e1577ebb4febc0b0a19dfaa841b6ca01f69ac49d
0e1a99b80d6f68d3275b4c912d2571b715348e54
v1.0
complete
Prefill
Prefill_26955_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(29) == True >>> is_prime(30) == False """ def sum_primes_up_to(n: int) -> int: """ Returns the...
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import is_prime, sum_primes_up_to def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(30) == False def test_sum_primes_up_to(): assert sum_primes_up_to(10...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers up to and including n.", "function_declaration": "def sum_primes_up_to(n):", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_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_0
{ "original_instruction": "Create a function that takes an integer as input and returns the sum of all prime numbers up to and including that integer.", "prompt_id": "00026955", "row_id": 26955, "seed_ids": "['magpie_prefill_26955']" }
0.780028
Prefill_26955
C
[ "is_prime", "sum_primes_up_to" ]
2
[ [ "sum_primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2945184674452a93efe50cb7d68b90e85154e5ec
083ba266c97a54f47560b77e6c88c3774621e3a2
v1.0
complete
Prefill
Prefill_26730_C
def is_prime(n: int) -> bool: """ Helper function to determine if a number n is prime. """ # TODO: Implement this function to return True if n is a prime number, otherwise False. def primes_in_range(start: int, end: int) -> List[int]: """ Returns a list of all prime numbers in the range [start,...
def is_prime(n): """ Helper function to determine if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import primes_in_range def test_primes_in_small_range(): assert primes_in_range(1, 10) == [2, 3, 5, 7] def test_primes_in_medium_range(): assert primes_in_range(10, 30) == [11, 13, 17, 19, 23, 29] def test_primes_with_no_primes(): assert primes_in_range(14, 16) == [] def test_primes_single...
[ { "docstring": "Helper function to determine if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers in the range [start, end].", "function_declaration": "def primes_...
[ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates a list of all prime numbers between the given range [start, end]. The function should efficiently check for primality.", "prompt_id": "00026730", "row_id": 26730, "seed_ids": "['magpie_prefill_26730']" }
0.768735
Prefill_26730
C
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a07bbc52077ec359c7c9458441f0f48bb29fa530
6c429eccb3faa59657a74297bee10033a27cc148
v1.0
complete
Prefill
Prefill_27075_C
def find_second_largest(nums): """ Recursive function to find the second largest number in a list. The function should not use any loops and must be a pure recursive approach. Args: nums (List[int]): List of integers Returns: int: The second largest number in the list Rais...
def find_max(nums): """ Recursive helper function to find the maximum number in a list. """ if len(nums) == 1: return nums[0] else: return max(nums[0], find_max(nums[1:])) def find_second_largest(nums): """ Recursive function to find the second largest number in a list. ...
from solution import find_second_largest def test_find_second_largest_typical_case(): assert find_second_largest([1, 3, 4, 5, 0, 2]) == 4 def test_find_second_largest_with_negative_numbers(): assert find_second_largest([10, -1, -10, 20, -5, 2, -8, 20]) == 10 def test_find_second_largest_with_duplicates(): ...
[ { "docstring": "Recursive helper function to find the maximum number in a list.", "function_declaration": "def find_max(nums):", "function_name": "find_max", "parameter_list": "(nums)" }, { "docstring": "Recursive function to find the second largest number in a list.", "function_declarat...
[ 0, 0, 1, 1, 0, 1, 0, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_second_largest(numbers):\n \"\"\"\n Find the second largest number in a list using recursion.\n \"\"\"\n if len(numbers) < 2:\n return None # Not enough elements ...
trial_gpt4o_5
{ "original_instruction": "Write a python function to find the second largest number in a list using recursion. The function should not use any loops and must be a pure recursive approach.", "prompt_id": "00027075", "row_id": 27075, "seed_ids": "['magpie_prefill_27075']" }
0.719794
Prefill_27075
C
[ "find_max", "find_second_largest" ]
2
[ [ "find_second_largest", "find_max" ] ]
1
[]
false
[]
false
pytest
true
[]
true
85ecf1304d17fcb719b615d7670c91187eb509c1
72a7388e6ed2aeb7549e2b9b193db9bdfd6da4eb
v1.0
complete
Prefill
Prefill_27629_C
from collections import deque from typing import List def removeInvalidParentheses(s: str) -> List[str]: """ Removes all invalid parentheses from a string so that the result string is valid. Returns all possible results. """
from collections import deque def removeInvalidParentheses(s): """ Removes all invalid parentheses from a string so that the result string is valid. Returns all possible results. """ if not s: return [""] results = set() queue = deque([s]) visited = set([s]) found = False ...
from solution import removeInvalidParentheses def test_removeInvalidParentheses(): assert set(removeInvalidParentheses("()())()")) == set(["()()()", "(())()"]) assert set(removeInvalidParentheses("(a)())()")) == set(["(a)()()", "(a())()"]) assert set(removeInvalidParentheses(")(")) == set([""]) assert ...
[ { "docstring": "Removes all invalid parentheses from a string so that the result string is valid.\nReturns all possible results.", "function_declaration": "def removeInvalidParentheses(s):", "function_name": "removeInvalidParentheses", "parameter_list": "(s)" }, { "docstring": "Checks if a g...
[ 1, 0, 1, 0, 0, 0, 0, 1, 1, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef remove_invalid_parentheses(s):\n \"\"\"\n Removes all invalid parentheses from the string s \n and returns all possible results.\n \"\"\"\n ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to remove all invalid parentheses from a string so that the result string is valid. Return all possible results. Your solution should be able to handle multiple test cases efficiently.", "prompt_id": "00027629", "row_id": 27629, "seed_ids": "['magpie_prefill_27...
0.690231
Prefill_27629
C
[ "removeInvalidParentheses", "isValid" ]
2
[ [ "removeInvalidParentheses", "isValid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9613d89cb97b305feb917cf3056d2346cdc59aaf
3dacc21b4e286a3dcdb38722d0cf5e262604a555
v1.0
complete
Prefill
Prefill_26157_C
def merge_sort(arr): """ Sorts an array using the merge sort algorithm. Merge sort is implemented using recursion. :param arr: List of elements to be sorted :return: Sorted list """ pass def merge(left, right): """ Merges two sorted arrays into one sorted array. :param lef...
def merge_sort(arr): """ Sorts an array using the merge sort algorithm. Merge sort is implemented using recursion. :param arr: List of elements to be sorted :return: Sorted list """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = merge_sort(arr[:mid]) r...
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 using the merge sort algorithm. Merge sort is implemented using recursion.\n\n:param arr: List of elements to be sorted\n:return: Sorted list", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstr...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts an array using the merge sort algorithm.\n \n Parameters:\n arr (list): List of elements to be sorted.\n \n Returns:\n list: New ...
trial_gpt4o_9
{ "original_instruction": "Create a function that sorts an array using the merge sort algorithm. Merge sort should be implemented using recursion.", "prompt_id": "00026157", "row_id": 26157, "seed_ids": "['magpie_prefill_26157']" }
0.643576
Prefill_26157
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f8256210cfc5c0e81282a9afb8033889eaf18887
9aaca3312491e179849bf7597b3125b5f904de2a
v1.0
complete
Prefill
Prefill_27554_C
import math from typing import List def is_perfect_square(n: int) -> bool: """ Returns True if n is a perfect square, else False. """ pass def filter_non_perfect_squares(numbers: List[int]) -> List[int]: """ Returns a list of numbers from the input list that are not perfect squares. >>> fi...
import math def is_perfect_square(n): """ Returns True if n is a perfect square, else False. """ if n < 0: return False sqrt_n = int(math.sqrt(n)) return sqrt_n * sqrt_n == n def filter_non_perfect_squares(numbers): """ Returns a list of numbers from the input list that are not...
from solution import filter_non_perfect_squares def test_non_perfect_squares_mixed_list(): assert filter_non_perfect_squares([1, 2, 3, 4, 5, 16, 18]) == [2, 3, 5, 18] def test_non_perfect_squares_only_perfect_squares(): assert filter_non_perfect_squares([1, 4, 9, 16, 25]) == [] def test_non_perfect_squares_o...
[ { "docstring": "Returns True if n is a perfect square, else False.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Returns a list of numbers from the input list that are not perfect squares.", "functi...
[ 1, 1, 0, 1, 1, 0, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(n):\n \"\"\"\n Checks if the given number n is a perfect square.\n \"\"\"\n root = math.isqrt(n) # integer square root of n\n return n == ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to print all the numbers in a given list that are not perfect squares.", "prompt_id": "00027554", "row_id": 27554, "seed_ids": "['magpie_prefill_27554']" }
0.690631
Prefill_27554
C
[ "is_perfect_square", "filter_non_perfect_squares" ]
2
[ [ "filter_non_perfect_squares", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9359a25c33cc7811a4e9732a870f5b41e4309bc3
ec0d9787e5fda50b5cee1da900b9a0d2a045b1fe
v1.0
complete
Prefill
Prefill_27545_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def insert_into_bst(root, val): """ Insert a value into a binary search tree. >>> tree = insert_into_bst(None, 10) >>> insert_into_bst(tree, 5) >>> tree.val ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def insert_into_bst(root, val): if not root: return TreeNode(val) if val < root.val: root.left = insert_into_bst(root.left, val) else: ...
from solution import TreeNode, insert_into_bst, is_bst def test_insert_and_is_bst(): values = [10, 5, 15, 3, 7, 12, 17] tree = None for value in values: tree = insert_into_bst(tree, value) assert is_bst(tree) == True def test_is_bst_empty_tree(): assert is_bst(None) == True def test_is_bs...
[]
[ 1, 1, 1, 1, 0, 1, 1, 0, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef insert_into_bst(root, value):...
trial_gpt4o_9
{ "original_instruction": "Write a python function to create a binary search tree and check if it is a binary search tree.", "prompt_id": "00027545", "row_id": 27545, "seed_ids": "['magpie_prefill_27545']" }
0.579306
Prefill_27545
C
[ "insert_into_bst", "is_bst_helper", "is_bst" ]
3
[ [ "is_bst", "is_bst_helper" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
2b5c3f57814ea0facccdbe895084da1af45b9cbb
48934f6b137c77b4845a869ca42d5a3eb4c3c8fd
v1.0
complete
Prefill
Prefill_28034_C
def longest_palindromic_subsequence(s: str) -> str: """ Write a python function to detect the longest palindromic subsequence in a string. The function should return the longest palindromic subsequence. >>> longest_palindromic_subsequence("a") "a" >>> longest_palindromic_subsequence("") "" ...
def longest_palindromic_subsequence(s): """ Returns the longest palindromic subsequence in a string. """ n = len(s) if n == 0: return "" dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = 1 for cl in range(2, n + 1): for i in range(n - c...
from solution import longest_palindromic_subsequence def test_longest_palindromic_subsequence_single_char(): assert longest_palindromic_subsequence("a") == "a" def test_longest_palindromic_subsequence_empty_string(): assert longest_palindromic_subsequence("") == "" def test_longest_palindromic_subsequence_re...
[ { "docstring": "Returns the longest palindromic subsequence in a string.", "function_declaration": "def longest_palindromic_subsequence(s):", "function_name": "longest_palindromic_subsequence", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def reconstruct_palin...
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindromic_subsequence(s):\n \"\"\"\n Returns the longest palindromic subsequence in a given string s.\n \"\"\"\n n = len(s)\n \n # Create a table to store resu...
trial_gpt4o_2
{ "original_instruction": "Write a python function to detect the \"Longest Palindromic Subsequence\" in a string. The function should return the longest palindromic subsequence.", "prompt_id": "00028034", "row_id": 28034, "seed_ids": "['magpie_prefill_28034']" }
0.815186
Prefill_28034
C
[ "longest_palindromic_subsequence", "reconstruct_palindrome" ]
2
[ [ "longest_palindromic_subsequence", "reconstruct_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
49fa07a7a5472ae969aacd60bc7aef83502e6d71
b247e2a76e072b5c94b25db9a160069bdaeae6fa
v1.0
complete
Prefill
Prefill_28427_C
def reverse_number(n): """ Returns the reverse of a given integer n. """ reversed_n = int(str(n)[::-1]) return reversed_n def generate_sequence(n): """ Generates the first n numbers in the sequence where each number is the sum of the previous number and its reverse. >>> generate_sequence(...
def reverse_number(n): """ Returns the reverse of a given integer n. """ reversed_n = int(str(n)[::-1]) return reversed_n def generate_sequence(n): """ Generates the first n numbers in the sequence where each number is the sum of the previous number and its reverse. """ if n <=...
from solution import generate_sequence def test_generate_sequence_single_element(): assert generate_sequence(1) == [1] def test_generate_sequence_two_elements(): assert generate_sequence(2) == [1, 2] # 1 + reversed(1) = 2 def test_generate_sequence_three_elements(): assert generate_sequence(3) == [1, 2,...
[ { "docstring": "Returns the reverse of a given integer n.", "function_declaration": "def reverse_number(n):", "function_name": "reverse_number", "parameter_list": "(n)" }, { "docstring": "Generates the first n numbers in the sequence where each number is the \nsum of the previous number and ...
[ 1, 0, 0, 1, 0, 1, 1, 0, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_sequence(n):\n \"\"\"\n Generates the first n numbers in the sequence where each number is the sum\n of the previous number and its reverse.\n \n Parameters:\n ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to generate the first n (n>0) numbers in the sequence where each number is the sum of the previous number and its reverse.", "prompt_id": "00028427", "row_id": 28427, "seed_ids": "['magpie_prefill_28427']" }
0.663978
Prefill_28427
C
[ "reverse_number", "generate_sequence" ]
2
[ [ "generate_sequence", "reverse_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
56eb471005a7c8f942cec12d92087e2e986b27b3
a58d9b764c8d962fe173534131d9ba388214fe94
v1.0
complete
Prefill
Prefill_28130_C
def is_palindrome(n: int) -> bool: """ Helper function to check if a number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False >>> is_palindrome(1) True >>> is_palindrome(22) True >>> is_palindrome(123321) True """ def next_palindrome(num: int, length: int, digits: in...
def is_palindrome(n): # Helper function to check if a number is a palindrome s = str(n) return s == s[::-1] def next_palindrome(num, length, digits): """ Returns the smallest palindrome greater than the given number. :param num: The given number :param length: The length of the given number...
from solution import next_palindrome, is_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True assert is_palindrome(123321) == True def test_next_palindrome(): assert next_palin...
[ { "docstring": null, "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Returns the smallest palindrome greater than the given number.\n:param num: The given number\n:param length: The length of the given number\n:par...
[ 1, 1, 1, 1, 1, 0, 0, 0, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\ndef next_palindrome(n, length, num_digits):\n while True:\n n += 1\n if is_palindrome(n):\n return n", ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to return the smallest palindrome greater than the given number. The function should have at least 3 inputs: the given number, the length of the given number, and the number of possible digits.", "prompt_id": "00028130", "row_id": 28130, "seed_ids": "['magpie_p...
0.741352
Prefill_28130
C
[ "is_palindrome", "next_palindrome" ]
2
[ [ "next_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fae6c403afb97ecac1c8ec5d26710e8aa8a46a03
485d6bfed176b2647131d4e8ef4b64b0ba5650e8
v1.0
complete
Prefill
Prefill_27703_C
def matrix_mult(A, B): """ Multiplies two 2x2 matrices A and B. """ return [ [A[0][0]*B[0][0] + A[0][1]*B[1][0], A[0][0]*B[0][1] + A[0][1]*B[1][1]], [A[1][0]*B[0][0] + A[1][1]*B[1][0], A[1][0]*B[0][1] + A[1][1]*B[1][1]] ] def matrix_power(matrix, n): """ Raises the matrix to...
def matrix_mult(A, B): """ Multiplies two 2x2 matrices A and B. """ return [ [A[0][0]*B[0][0] + A[0][1]*B[1][0], A[0][0]*B[0][1] + A[0][1]*B[1][1]], [A[1][0]*B[0][0] + A[1][1]*B[1][0], A[1][0]*B[0][1] + A[1][1]*B[1][1]] ] def matrix_power(matrix, n): """ Raises the matrix to...
from solution import fibonacci def test_fibonacci_zero(): assert fibonacci(0) == 0 def test_fibonacci_one(): assert fibonacci(1) == 1 def test_fibonacci_small_numbers(): assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(4) == 3 assert fibonacci(5) == 5 def test_fibonacci_lar...
[ { "docstring": "Multiplies two 2x2 matrices A and B.", "function_declaration": "def matrix_mult(A, B):", "function_name": "matrix_mult", "parameter_list": "(A, B)" }, { "docstring": "Raises the matrix to the power of n using binary exponentiation.", "function_declaration": "def matrix_po...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def matrix_mult(A, B):\n \"\"\"\n Multiplies two 2x2 matrices A and B.\n \"\"\"\n return [\n [A[0][0] * B[0][0] + A[0][1] * B[1][0], A[0][0] * B[0][1] + A[0][1] * B[1][1]],...
trial_gpt4o_9
{ "original_instruction": "Write a python function to compute n-th Fibonacci number using matrix exponentiation.", "prompt_id": "00027703", "row_id": 27703, "seed_ids": "['magpie_prefill_27703']" }
0.655226
Prefill_27703
C
[ "matrix_mult", "matrix_power", "fibonacci" ]
3
[ [ "fibonacci", "matrix_power" ], [ "matrix_power", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
deb2a88b34fd94d6b8b735027d59f211d0bc71b0
e20361244da3708dca8f8d76e53b96d9f9808087
v1.0
complete
Prefill
Prefill_27648_C
def binary_search(arr, x, search_first): low = 0 high = len(arr) - 1 result = -1 while low <= high: mid = (low + high) // 2 if arr[mid] == x: result = mid if search_first: high = mid - 1 else: low = mid + 1...
def binary_search(arr, x, search_first): low = 0 high = len(arr) - 1 result = -1 while low <= high: mid = (low + high) // 2 if arr[mid] == x: result = mid if search_first: high = mid - 1 else: low = mid + 1...
from solution import find_count def test_element_present_multiple_times(): assert find_count([1, 2, 2, 2, 3, 4, 5], 2) == 3 def test_element_present_once(): assert find_count([1, 2, 3, 4, 5], 3) == 1 def test_element_not_present(): assert find_count([1, 2, 3, 4, 5], 6) == -1 def test_empty_array(): ...
[ { "docstring": null, "function_declaration": "def binary_search(arr, x, search_first):", "function_name": "binary_search", "parameter_list": "(arr, x, search_first)" }, { "docstring": "Returns the count of 'x' in the sorted array 'arr'.\nIf 'x' is not present, returns -1.", "function_dec...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_count(arr, x):\n def binary_search(arr, x, search_first):\n low, high = 0, len(arr) - 1\n result = -1\n while low <= high:\n mid = (low + high) // ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the count of an element in a sorted array using binary search. The function signature is `def find_count(arr, x)`, where 'arr' is the sorted array and 'x' is the element whose count needs to be found. If the element is not found, the function should return -1...
0.694409
Prefill_27648
C
[ "binary_search", "find_count" ]
2
[ [ "find_count", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e41c2de4960cb243c1edbcaafbafbc06aaafa4ab
0ab5f3122874d277fb83ce227196bd94c6ba2215
v1.0
complete
Prefill
Prefill_28196_C
from typing import List def is_prime(n: int) -> bool: """Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False """ pass def primes_in_range(start: int, end: int) -> List[int]: """Generate all prime numbers in the given range [start, end]. >>> primes_in_range(10, 5...
def is_prime(n): """Check if a number is a prime number.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True ...
from solution import primes_in_range def test_primes_in_range_10_to_50(): expected_primes = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47] assert primes_in_range(10, 50) == expected_primes def test_primes_in_range_1_to_10(): expected_primes = [2, 3, 5, 7] assert primes_in_range(1, 10) == expected_primes...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate all prime numbers in the given range [start, end].", "function_declaration": "def primes_in_range(start, end...
[ 1, 1, 0, 1, 1, 1, 1, 1, 0, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_primes_10_to_50():\n \"\"\"\n Generates all prime numbers in the range from 10 to 50 inclusive.\n \"\"\"\n def is_prime(n):\n if n <= 1:\n return Fa...
trial_gpt4o_9
{ "original_instruction": "Write a python function to generate all the prime numbers from 10 to 50.", "prompt_id": "00028196", "row_id": 28196, "seed_ids": "['magpie_prefill_28196']" }
0.720233
Prefill_28196
C
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ea0ccd852ec7f86c5a8df807555f9f19967a36f3
0c0cd5906d8b8cabd57ff734801efbf95ee7f1ca
v1.0
complete
Prefill
Prefill_27188_C
class TreeNode: def __init__(self, key=0, left=None, right=None): self.key = key self.left = left self.right = right def delete_node(root, key): """ Deletes a node with the given key from the binary search tree rooted at the given root. Returns the root of the modified tree. ...
class TreeNode: def __init__(self, key=0, left=None, right=None): self.key = key self.left = left self.right = right def delete_node(root, key): """ Deletes a node with the given key from the binary search tree rooted at the given root. Returns the root of the modified tree. ...
from solution import TreeNode, delete_node def bst_to_list(root): """ Converts a binary search tree to a sorted list. """ if root is None: return [] return bst_to_list(root.left) + [root.key] + bst_to_list(root.right) def test_delete_node_leaf(): root = TreeNode(5, TreeNode(3), TreeNod...
[]
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key=0, left=None, right=None):\n self.key = key\n self.left = left\n self.right = right\n\ndef delete_node(root, key):\n \"\"\"...
trial_gpt4o_0
{ "original_instruction": "Write a python function to delete a node from a binary search tree. The function should take the root of the tree, the key (the value of the node to be deleted), and return the root of the modified tree.", "prompt_id": "00027188", "row_id": 27188, "seed_ids": "['magpie_prefill_27188']...
0.629855
Prefill_27188
C
[ "delete_node", "get_min" ]
2
[ [ "delete_node", "get_min" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
8f351dc1e3ad6ac7927c5c28fbca9c2534c5909d
6b27d788c24c0a95ce316d27115fb3b0f19a0502
v1.0
complete
Prefill
Prefill_28928_C
def is_palindrome(n: int) -> bool: """ Check if a number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False >>> is_palindrome(12321) True >>> is_palindrome(1234321) True >>> is_palindrome(1234567) False """ def largest_palindrome_product() -> int: """ Returns the ...
def is_palindrome(n): """ Check if a number is a palindrome. """ return str(n) == str(n)[::-1] def largest_palindrome_product(): """ Returns the largest palindrome made from the product of two 3-digit numbers. """ max_palindrome = 0 for i in range(100, 1000): for j in range(...
from solution import is_palindrome, largest_palindrome_product def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(12321) == True assert is_palindrome(1234321) == True assert is_palindrome(1234567) == False def test_largest_palindrome...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Returns the largest palindrome made from the product of two 3-digit numbers.", "function_declaration": "def l...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Check if a number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef largest_palindrome_product():\n \"\"\"\n Returns the larg...
trial_gpt4o_8
{ "original_instruction": "Write a python function to find the largest palindrome made from the product of two 3-digit numbers given that the largest palindrome made from the product of two 2-digit numbers is 9009 (91 x 99).", "prompt_id": "00028928", "row_id": 28928, "seed_ids": "['magpie_prefill_28928']" }
0.688516
Prefill_28928
C
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
562f6b1a8494d82477bc39c0ab81e0feed55a892
8fd5530defcec2274eed70552c2d558efdefd11b
v1.0
complete
Prefill
Prefill_27511_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(17) == True >>> is_prime(19) == True >>> is_prime(20) == False >>> is_prime(1) == False ...
def is_prime(n): """ Returns True if n is a prime number, otherwise 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 sum_of_first_100_primes(): """ Returns the sum of the first 100 prime numb...
from solution import is_prime, sum_of_first_100_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(19) == True assert is_prime(20) == False assert is_prime(1) == False assert is_prime(...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of the first 100 prime numbers.", "function_declaration": "def sum_of_first_100_prim...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n...
trial_gpt4o_7
{ "original_instruction": "Write a python function to find the sum of the first 100 prime numbers and return that sum.", "prompt_id": "00027511", "row_id": 27511, "seed_ids": "['magpie_prefill_27511']" }
0.823924
Prefill_27511
C
[ "is_prime", "sum_of_first_100_primes" ]
2
[ [ "sum_of_first_100_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bc0c2ccb98e2aae02c2f07f934cafeee7414beac
e14f57d7b065bc8c0e812d8975a4463058696a13
v1.0
complete
Prefill
Prefill_27660_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_subtree(s, t): """ Check if a binary tree is a sub-tree of another binary tree. >>> tree1 = TreeNode(3, TreeNode(4, TreeNode(1), TreeNode(2)), TreeNode(5)) ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_subtree(s, t): if not s: return False if is_same_tree(s, t): return True return is_subtree(s.left, t) or is_subtree(s.right, t) def is_sam...
from solution import TreeNode, is_subtree, is_same_tree def test_is_same_tree(): tree1 = TreeNode(1, TreeNode(2), TreeNode(3)) tree2 = TreeNode(1, TreeNode(2), TreeNode(3)) assert is_same_tree(tree1, tree2) tree3 = TreeNode(1, TreeNode(2), TreeNode(4)) assert not is_same_tree(tree1, tree3) ...
[]
[ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef is_identical(tree1: TreeNode, tree2...
trial_gpt4o_8
{ "original_instruction": "Write a python function to check if a binary tree is a sub-tree of another binary tree. A binary tree is a sub-tree of another binary tree if there exists a node in the larger binary tree such that the smaller binary tree rooted at this node is identical to the smaller binary tree.", "pro...
0.609138
Prefill_27660
C
[ "is_subtree", "is_same_tree" ]
2
[ [ "is_subtree", "is_same_tree" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
5102a53b59ddba385ebe6143a6075cb1ead8254b
1c63536f2908241640470f86e089438fa241fa16
v1.0
complete
Prefill
Prefill_29006_C
def is_prime(n): """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(16) False >>> is_prime(17) True """ pass def primes_in_range(start, end): """ Returns a list of prime num...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import is_prime, 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(16) == False assert is_prime(17) == True def test_primes_in_range(): assert primes_in_range(10, 2...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers in the given range [start, end].", "function_declaration": "def primes_in_r...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if n...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find all the prime numbers in a range of given numbers. For example, for a range from 10 to 20, the function should return [11, 13, 17, 19]. You can use a helper function to check if a number is prime or not.", "prompt_id": "00029006", "row_id": 29006, "seed...
0.799739
Prefill_29006
C
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
869509713a15261141ea6fee6cc580efe0b265aa
c92c66e74a3f744eb828fa85638bb6e4a1dc8ef1
v1.0
complete
Prefill
Prefill_28356_C
from typing import List def is_prime(n: int) -> bool: """ Helper function to determine if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(29) == True >>> is_prime(25) == False >>> is_prime(1) == False >>> is_prime(0) == False ...
def is_prime(n): """ Helper function to determine 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 ...
from solution import is_prime, list_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(25) == False assert is_prime(1) == False assert is_prime(0) == False def test_list_primes(): ass...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers up to the given limit.", "function_declaration": "def list_primes(l...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(n):\n \"\"\"\n Returns a list of all prime numbers up to the given limit `n` using the Sieve of Eratosthenes algorithm.\n \n :param n: int - The upper li...
trial_gpt4o_9
{ "original_instruction": "Write a python function to create a list of all prime numbers up to a given limit `n`. The function should be efficient and avoid unnecessary computations.", "prompt_id": "00028356", "row_id": 28356, "seed_ids": "['magpie_prefill_28356']" }
0.811153
Prefill_28356
C
[ "is_prime", "list_primes" ]
2
[ [ "list_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d06504aea3c785cce4753a26dbc7a9466606ad5f
f79e202cc4490f22399deab2c0cfa8b0e423cbab
v1.0
complete
Prefill
Prefill_26034_C
def is_valid(board, row, col, num): """ Checks if placing the number 'num' in the position (row, col) is valid according to Sudoku rules. """ pass def solve_sudoku(board): """ Solves the Sudoku puzzle by filling the board. """ pass def find_empty(board): """ Finds an empty ...
def is_valid(board, row, col, num): """ Checks if placing the number 'num' in the position (row, col) is valid according to Sudoku rules. """ # Check if 'num' is not in the given row for x in range(9): if board[row][x] == num: return False # Check if 'num' is not in the ...
from solution import solve_sudoku_puzzle def test_solve_sudoku_puzzle(): grid = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0,...
[ { "docstring": "Checks if placing the number 'num' in the position (row, col) is valid\naccording to Sudoku rules.", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Solves the Sudoku puz...
[ 1, 1, 1, 1, 1, 1, 0, 0, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solve_sudoku(sudoku_grid):\n \"\"\"\n Solves a given Sudoku puzzle.\n \n Args:\n sudoku_grid (list of list of int): A 2D list representing the Sudoku grid, where 0 denotes ...
trial_gpt4o_9
{ "original_instruction": "Create a function that solves a given Sudoku puzzle. The function should take a 2D list called `sudoku_grid` as input, where each cell contains a number or is `0` if the cell is empty. The function should return the solved Sudoku puzzle as a 2D list.", "prompt_id": "00026034", "row_id":...
0.525836
Prefill_26034
C
[ "is_valid", "solve_sudoku", "find_empty", "solve_sudoku_puzzle" ]
4
[ [ "solve_sudoku", "find_empty" ], [ "solve_sudoku", "is_valid" ], [ "solve_sudoku_puzzle", "solve_sudoku" ] ]
3
[]
false
[]
false
pytest
true
[]
true
31ae3f031b6aad663b61c660ceed6b0ea9f8cf2c
ae6cf32c97ba9cd18f5ec038b65be37eefe8c254
v1.0
complete
Prefill
Prefill_29263_C
def max_area_of_X(matrix): """ Returns the largest area formed by consecutive 'X's in a given binary matrix. >>> max_area_of_X([]) == 0 >>> max_area_of_X([['X']]) == 1 >>> max_area_of_X([['X', 'X', '0', 'X']]) == 2 >>> max_area_of_X([['X'], ['X'], ['0'], ['X']]) == 2 >>> max_area_of_X([['0',...
def max_area_of_X(matrix): """ Returns the largest area formed by consecutive 'X's in a given binary matrix. """ if not matrix: return 0 rows = len(matrix) cols = len(matrix[0]) height = [0] * cols max_area = 0 for i in range(rows): for j in range(cols): ...
from solution import max_area_of_X def test_max_area_of_X_empty_matrix(): assert max_area_of_X([]) == 0 def test_max_area_of_X_single_X(): assert max_area_of_X([['X']]) == 1 def test_max_area_of_X_single_row(): assert max_area_of_X([['X', 'X', '0', 'X']]) == 2 def test_max_area_of_X_single_column(): ...
[ { "docstring": "Returns the largest area formed by consecutive 'X's in a given binary matrix.", "function_declaration": "def max_area_of_X(matrix):", "function_name": "max_area_of_X", "parameter_list": "(matrix)" }, { "docstring": "Helper function to calculate the largest rectangle in a hist...
[ 0, 0, 0, 0, 1, 0, 0, 1, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_area_of_X(matrix):\n \"\"\"\n Returns the largest area formed by consecutive 'X's in the given binary matrix.\n \n Parameters:\n matrix (list of list of str): A 2D ...
trial_gpt4o_7
{ "original_instruction": "Write a python function to extract the largest area formed by consecutive 'X's in a given binary matrix.", "prompt_id": "00029263", "row_id": 29263, "seed_ids": "['magpie_prefill_29263']" }
0.669476
Prefill_29263
C
[ "max_area_of_X", "largest_rectangle_area" ]
2
[ [ "max_area_of_X", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
61e11e9bae40a7c60c108880aa305e6174fda5ac
54a5b6ca16ff1e52afa5bd8634eac7c4685a8bb0
v1.0
complete
Prefill
Prefill_29269_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) == True >>> is_prime(4) == False >>> is_prime(29) == True """ pass def first_n_primes(n: int) -> List[int]: """ Returns the first n prime numbers. >>> first_n_primes(1) == [2] >>> firs...
def is_prime(num): """ Helper function to check if a number is prime. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def first_n_primes(n): """ Returns the first n prime numbers. """ prim...
from solution import first_n_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(-5) == False def test_first_n_primes_1(): assert first_n_primes(1...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the first n prime numbers.", "function_declaration": "def first_n_primes(n):", "function_na...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num %...
trial_gpt4o_7
{ "original_instruction": "Write a python function to find the first n prime numbers and return them in a list. For example, for n=4, the first 4 prime numbers are [2, 3, 5, 7].", "prompt_id": "00029269", "row_id": 29269, "seed_ids": "['magpie_prefill_29269']" }
0.828539
Prefill_29269
C
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
01d8787ac654d93f282bf5dd68fe531937545617
d46d88f1401408353bfb746e8cc38779d50f1ff7
v1.0
complete
Prefill
Prefill_29112_C
def sum_of_first_n_natural_numbers(n): """ Returns the sum of the first n natural numbers. >>> sum_of_first_n_natural_numbers(1) 1 >>> sum_of_first_n_natural_numbers(5) 15 >>> sum_of_first_n_natural_numbers(10) 55 """ def common_sum(N, M): """ Returns the common sum when you add up ...
def sum_of_first_n_natural_numbers(n): """ Returns the sum of the first n natural numbers. """ return n * (n + 1) // 2 def common_sum(N, M): """ Returns the common sum when you add up the sums of the first N natural numbers for the first M terms. """ total_sum = 0 for i in range...
from solution import sum_of_first_n_natural_numbers, common_sum def test_sum_of_first_n_natural_numbers(): assert sum_of_first_n_natural_numbers(1) == 1 assert sum_of_first_n_natural_numbers(5) == 15 assert sum_of_first_n_natural_numbers(10) == 55 def test_common_sum(): assert common_sum(1, 1) == 1 ...
[ { "docstring": "Returns the sum of the first n natural numbers.", "function_declaration": "def sum_of_first_n_natural_numbers(n):", "function_name": "sum_of_first_n_natural_numbers", "parameter_list": "(n)" }, { "docstring": "Returns the common sum when you add up the sums of the first N nat...
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_natural_numbers(N):\n \"\"\"\n Returns the sum of the first N natural numbers.\n \"\"\"\n return N * (N + 1) // 2\n\ndef cumulative_sum_of_sums(N, M):\n \"\"\"\n Ret...
trial_gpt4o_2
{ "original_instruction": "Write a python function to calculate the sum of the first N natural numbers and then find the common sum when you add up the sums of the first N natural numbers for the first M terms. That is, calculate \\((1+2+3+...+N) + (1+2+3+...+(N+1)) + (1+2+3+...+(N+2)) + ... + (1+2+3+...+(N+M-1)) + (...
0.723129
Prefill_29112
C
[ "sum_of_first_n_natural_numbers", "common_sum" ]
2
[ [ "common_sum", "sum_of_first_n_natural_numbers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
be40619ae5c0c4b9ddabf3c5240addbbc75d874d
6cd8268400e7b8f8c08912ef3307311e15c9127b
v1.0
complete
Prefill
Prefill_29666_C
from functools import reduce import math def lcm(a, b): """ Returns the least common multiple of a and b. """ pass def smallest_multiple(n): """ Returns the smallest number that is evenly divisible by all numbers from 1 to n. >>> smallest_multiple(1) == 1 >>> smallest_multiple(2) == 2...
from functools import reduce import math def lcm(a, b): """ Returns the least common multiple of a and b. """ return a * b // math.gcd(a, b) def smallest_multiple(n): """ Returns the smallest number that is evenly divisible by all numbers from 1 to n. """ return reduce(lcm, range(1, n ...
from solution import smallest_multiple def test_smallest_multiple_1(): assert smallest_multiple(1) == 1 def test_smallest_multiple_2(): assert smallest_multiple(2) == 2 def test_smallest_multiple_3(): assert smallest_multiple(3) == 6 def test_smallest_multiple_4(): assert smallest_multiple(4) == 12 ...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest number that is evenly divisible by all numbers from 1 to n.", "function_declaration": "def ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef lcm_of_range(n):\n \"\"\"\n Function to find the smallest number that is evenly divisible by all numbers from 1 to n.\n \"\"\"\n def lcm(a, b):\n return ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the smallest number that is evenly divisible by all numbers from 1 to n. This number is known as the least common multiple (LCM).", "prompt_id": "00029666", "row_id": 29666, "seed_ids": "['magpie_prefill_29666']" }
0.658291
Prefill_29666
C
[ "lcm", "smallest_multiple" ]
2
[ [ "smallest_multiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
77ee58b02980f15389210db9b8398796698ae52a
bfae204544c88e9856aa3152cf5ebe7934e90358
v1.0
complete
Prefill
Prefill_25930_C
def sudoku_solver(puzzle: List[List[int]]) -> Tuple[bool, List[List[int]]]: """ Solve a Sudoku puzzle. The function takes a 2D list representing a Sudoku grid, where '0' represents an empty cell. It returns True if the puzzle is solvable and False otherwise. If solvable, also provides the solved p...
def is_valid(board, row, col, num): for x in range(9): if board[row][x] == num or board[x][col] == num: return False if board[row // 3 * 3 + x // 3][col // 3 * 3 + x % 3] == num: return False return True def solve_sudoku(board): for row in range(9): for col i...
from solution import sudoku_solver def test_sudoku_solver_solvable(): puzzle = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, ...
[ { "docstring": null, "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": null, "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_list...
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solve_sudoku(board):\n \"\"\"\n Solves the given Sudoku puzzle.\n - board: A 2D list representing the Sudoku grid where empty cells are marked as 0.\n Returns True if the puzz...
trial_gpt4o_9
{ "original_instruction": "Create a function that solves a Sudoku puzzle. The function should take a 2D list representing a Sudoku grid, where '0' represents an empty cell. The function should return True if the puzzle is solvable and False otherwise. The solution should also provide a completed grid if the puzzle is...
0.597561
Prefill_25930
C
[ "is_valid", "solve_sudoku", "sudoku_solver" ]
3
[ [ "solve_sudoku", "is_valid" ], [ "sudoku_solver", "solve_sudoku" ] ]
2
[]
false
[]
false
pytest
true
[]
true
833106eac97ec32323b76e3ff86617747a049e3e
c3e411197cac65db61f54ac0ad39748ebcfe0f84
v1.0
complete
Prefill
Prefill_27419_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def find_nearest_greater_node_in_bst(root): """ Given the root of a Binary Search Tree (BST), this function finds the nearest greater node in the BST for each nod...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def find_nearest_greater_node_in_bst(root): """ Given the root of a Binary Search Tree (BST), this function finds the nearest greater node in the BST for each nod...
from solution import TreeNode, find_nearest_greater_node_in_bst, nearest_greater_node_list def test_single_node(): root = TreeNode(10) assert nearest_greater_node_list([10], root) == [-1] def test_multiple_nodes_with_successor(): root = TreeNode(10, TreeNode(5), TreeNode(15)) assert nearest_greate...
[]
[ 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef find_nearest_greater_node_in_bst(ro...
trial_gpt4o_8
{ "original_instruction": "Write a python function to find the nearest greater node in a Binary Search Tree (BST) for each node's value. You need to return the results in a list where the index represents the index of the original node's value and the value at that index represents the nearest greater node value. If ...
0.536726
Prefill_27419
C
[ "find_nearest_greater_node_in_bst", "nearest_greater_node_list" ]
2
[ [ "nearest_greater_node_list", "find_nearest_greater_node_in_bst" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3f186aa662c4e9cbac3515afc2612348b34c81d9
152eee5392a759bb7f63358142ae23ee4accaa4a
v1.0
complete
Prefill
Prefill_29357_C
def reverse_stack(stack): """ Reverses the order of the elements in a stack using only stack operations. """ ... def insert_at_bottom(stack, item): ... from solution import reverse_stack def test_reverse_stack_with_multiple_elements(): stack = [1, 2, 3, 4, 5] reverse_stack(stack) asse...
def reverse_stack(stack): """ Reverses the order of the elements in a stack using only stack operations. """ if len(stack) > 0: temp = stack.pop() reverse_stack(stack) insert_at_bottom(stack, temp) def insert_at_bottom(stack, item): if len(stack) == 0: stack.append(i...
from solution import reverse_stack def test_reverse_stack_with_multiple_elements(): stack = [1, 2, 3, 4, 5] reverse_stack(stack) assert stack == [5, 4, 3, 2, 1] def test_reverse_stack_with_one_element(): stack = [1] reverse_stack(stack) assert stack == [1] def test_reverse_stack_with_no_eleme...
[ { "docstring": "Reverses the order of the elements in a stack using only stack operations.", "function_declaration": "def reverse_stack(stack):", "function_name": "reverse_stack", "parameter_list": "(stack)" }, { "docstring": null, "function_declaration": "def insert_at_bottom(stack, ite...
[ 0, 0, 1, 0, 0, 1, 1, 1 ]
4
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Stack:\n def __init__(self):\n self.items = []\n\n def is_empty(self):\n return len(self.items) == 0\n\n def push(self, item):\n self.items.append(item)\n\...
trial_gpt4o_9
{ "original_instruction": "Write a python function to reverse the order of the elements in a stack. You are not allowed to use any additional data structures (like list, array, etc.) and you should only use the built-in stack operations provided in the question.", "prompt_id": "00029357", "row_id": 29357, "seed...
0.569327
Prefill_29357
C
[ "reverse_stack", "insert_at_bottom" ]
2
[ [ "reverse_stack", "insert_at_bottom" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3d440940a7d0f3bea458c7435bffbc5f92394411
e6801126e51c16daa30ce1b9d16ad35c1163fff1
v1.0
complete
Prefill
Prefill_27255_C
from math import sqrt from typing import List, Tuple def euclidean_distance(point1: Tuple[float, float], point2: Tuple[float, float]) -> float: """ Computes the Euclidean distance between two points. Each point is represented as a tuple of coordinates (x, y). >>> round(euclidean_distance((0, 0), (...
from math import sqrt def euclidean_distance(point1, point2): """ Computes the Euclidean distance between two points. Each point is represented as a tuple of coordinates (x, y). """ return sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) def shortest_distance(from_point, points_list):...
from solution import euclidean_distance, shortest_distance def test_euclidean_distance(): assert round(euclidean_distance((0, 0), (3, 4)), 5) == 5.0 assert round(euclidean_distance((1, 2), (4, 6)), 5) == 5.0 assert round(euclidean_distance((0, 0), (0, 0)), 5) == 0.0 assert round(euclidean_distance((-1,...
[ { "docstring": "Computes the Euclidean distance between two points.\nEach point is represented as a tuple of coordinates (x, y).", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": ...
[ 1, 1, 1, 0, 1, 0, 1, 0, 1 ]
6
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef euclidean_distance(point1, point2):\n \"\"\"\n Calculate the Euclidean distance between two points.\n \"\"\"\n return math.sqrt(sum((x - y) ** 2 for x, y in zip...
trial_gpt4o_9
{ "original_instruction": "Write a python function to compute the shortest distance from a given point to a list of points using the Euclidean distance formula.", "prompt_id": "00027255", "row_id": 27255, "seed_ids": "['magpie_prefill_27255']" }
0.680485
Prefill_27255
C
[ "euclidean_distance", "shortest_distance" ]
2
[ [ "shortest_distance", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9a18fbdeb7634982696fd260b3c79d1121d834a8
efb3ebaad67ea267362bd81bc9b320c9134fc3ab
v1.0
complete
Prefill
Prefill_29373_C
def sieve_of_eratosthenes(n): """ Helper function that returns a list of prime numbers up to n using the sieve of Eratosthenes. """ def prime_factors(n): """ Returns a list of all prime factors of the input number n in ascending order. >>> prime_factors(1) [] >>> prime_factors(7) ...
def sieve_of_eratosthenes(n): """ Helper function that returns a list of prime numbers up to n using the sieve of Eratosthenes. """ is_prime = [True] * (n + 1) p = 2 while (p * p <= n): if is_prime[p]: for i in range(p * p, n + 1, p): is_prime[i] = False ...
from solution import prime_factors def test_prime_factors_of_1(): assert prime_factors(1) == [] def test_prime_factors_of_prime(): assert prime_factors(7) == [7] def test_prime_factors_of_composite(): assert prime_factors(28) == [2, 2, 7] def test_prime_factors_of_large_number(): assert prime_factor...
[ { "docstring": "Helper function that returns a list of prime numbers up to n using the sieve of Eratosthenes.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime factors of...
[ 1, 1, 1, 1, 1, 1, 0, 1, 0, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(n):\n \"\"\"Generate a list of prime numbers up to n.\"\"\"\n is_prime = [True] * (n + 1)\n p = 2\n while p * p <= n:\n if is_prime[p]:\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find all the prime factors of a given number using the sieve of Eratosthenes. The function should return a list of all prime factors of the input number in ascending order.", "prompt_id": "00029373", "row_id": 29373, "seed_ids": "['magpie_prefill_29373']" }
0.781426
Prefill_29373
C
[ "sieve_of_eratosthenes", "prime_factors" ]
2
[ [ "prime_factors", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e41156fbc47c000333067a478b04eaf461d4a4d1
575f98797eb1e75545771f2de2abd7eb3702f0dd
v1.0
complete
Prefill
Prefill_30195_C
def sum_of_digits(n: int) -> Tuple[int, bool]: """ Calculate the sum of the digits of a given positive integer n. Returns a tuple containing the sum and a boolean indicating whether the sum is a prime number. >>> sum_of_digits(23) (5, True) >>> sum_of_digits(124) (7, True) """
def is_prime(n): """ Determines if the provided integer n is a prime number. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def sum_of_digits(n): """ Calculate the sum of the digits of a given positive ...
from solution import sum_of_digits def test_single_digit_prime(): assert sum_of_digits(2) == (2, True) assert sum_of_digits(3) == (3, True) def test_single_digit_not_prime(): assert sum_of_digits(4) == (4, False) assert sum_of_digits(6) == (6, False) def test_multiple_digits_prime(): assert sum_o...
[ { "docstring": "Determines if the provided integer n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculate the sum of the digits of a given positive integer n.\nReturns a tuple containing the sum and...
[ 0, 0, 1, 1, 1, 1, 1, 1, 0, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the sum of the digits of a given positive integer. The function should also check if the sum is a prime number. If the sum is a prime number, return both the sum and a boolean value `True`. If the sum is not a prime number, return both the sum and a bool...
0.686687
Prefill_30195
C
[ "is_prime", "sum_of_digits" ]
2
[ [ "sum_of_digits", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
598c9bf30eb0d43012a74f9de824aaf0efcc70ed
67b395befaf009db049013d9c278a2ab59a502c3
v1.0
complete
Prefill
Prefill_29230_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
def is_prime(n): """Helper function to check if a number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import primes_in_range def test_primes_in_small_range(): assert primes_in_range(10, 20) == [11, 13, 17, 19] def test_no_primes_in_range(): assert primes_in_range(24, 28) == [] def test_single_prime_in_range(): assert primes_in_range(22, 23) == [23] def test_large_range(): expected_prim...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers in the range [lower, upper].", "function_declaration": "def primes_in_r...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to determine if a 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...
trial_gpt4o_9
{ "original_instruction": "Write a python function to create a list of all prime numbers in a given range. The function should accept two arguments: the lower and upper limits of the range. The function should return a list of all prime numbers in the range.", "prompt_id": "00029230", "row_id": 29230, "seed_ids...
0.815256
Prefill_29230
C
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6a7263937696b819bdf2b784637b85747c87cc23
12d6aa33e54472a5d38a15b29a05666d887d0d99
v1.0
complete
Prefill
Prefill_29401_C
def is_prime(num: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(11) True >>> is_prime(15) False """ def sum_of_primes_between(n: int, m: int) -> int: """ Returns the sum of all prime numbers b...
def is_prime(num): """ Check if a number is a prime number. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def sum_of_primes_between(n, m): """ Returns the sum of all prime numbers between integ...
from solution import is_prime, sum_of_primes_between def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(15) == False def test_sum_of_primes_between(): assert sum_of_primes_between(10, 20) == 60 # p...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers between integers n and m (inclusive).", "function_declaration": "def sum_of_...
[ 0, 0, 1, 1, 1, 1, 1, 0, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the sum of all prime numbers between two integers `n` and `m`.", "prompt_id": "00029401", "row_id": 29401, "seed_ids": "['magpie_prefill_29401']" }
0.723746
Prefill_29401
C
[ "is_prime", "sum_of_primes_between" ]
2
[ [ "sum_of_primes_between", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4f47e885233799d9132d006df4447893c32c7e9b
9a1dc826adc9111b0fab4736741363f5da6eccff
v1.0
complete
Prefill
Prefill_28573_C
def min_steps_and_path_DFS(matrix): """ Find the minimum number of steps to move from the top-left corner to the bottom-right corner of an MxN matrix using DFS that outputs both the least steps and the path taken to reach it. >>> matrix = [ >>> [0, 0, 0], >>> [0, 0, 0], >>> [0, 0, 0]] ...
def get_neighbors(position, matrix): """ Get the valid neighbors of a given position in the matrix. """ x, y = position M, N = len(matrix), len(matrix[0]) neighbors = [] for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]: nx, ny = x + dx, y + dy if 0 <= nx < M and 0 <= ny < N ...
from solution import min_steps_and_path_DFS def test_no_obstacles(): matrix = [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] steps, path = min_steps_and_path_DFS(matrix) assert steps == 4 assert path == [(0, 0), (0, 1), (0, 2), (1, 2), (2, 2)] def test_with_obstacles(): matrix = [...
[ { "docstring": "Get the valid neighbors of a given position in the matrix.", "function_declaration": "def get_neighbors(position, matrix):", "function_name": "get_neighbors", "parameter_list": "(position, matrix)" }, { "docstring": "Find the minimum number of steps to move from the top-left ...
[ 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_steps_with_path(matrix):\n \"\"\"\n Returns the minimum number of steps to move from the top-left to the bottom-right corner\n of an MxN matrix using DFS and the path taken t...
trial_gpt4o_6
{ "original_instruction": "Write a python function to find the minimum number of steps to move from the top-left corner to the bottom-right corner of an MxN matrix using DFS that outputs both least steps to reach the bottom-right corner and the path taken to reach it. The function should also handle cases where the m...
0.589596
Prefill_28573
C
[ "get_neighbors", "min_steps_and_path_DFS" ]
2
[ [ "min_steps_and_path_DFS", "get_neighbors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
51b3adf0da7436ca38f4dd9fbf90b4fa939537dd
cd24af862ce3bd8264c0881aeb006419e63f1752
v1.0
complete
Prefill
Prefill_30419_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, else False. >>> is_prime(11) True >>> is_prime(4) False """ def primes_in_range(start: int, end: int) -> List[int]: """ Returns a list of all prime numbers within the given range [start, end]. >>> pr...
def is_prime(n): """ Returns True if n is a prime number, else 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 primes_in_range(start, end): """ Returns a list of all prime numbers within the g...
from solution import primes_in_range def test_primes_in_small_range(): assert primes_in_range(1, 10) == [2, 3, 5, 7] def test_primes_in_large_range(): assert primes_in_range(10, 50) == [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47] def test_primes_with_no_primes(): assert primes_in_range(14, 16) == [] ...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers within the given range [start, end].", "function_declaration": "def p...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 =...
trial_gpt4o_8
{ "original_instruction": "Write a python function to return all prime numbers within a given range", "prompt_id": "00030419", "row_id": 30419, "seed_ids": "['magpie_prefill_30419']" }
0.749997
Prefill_30419
C
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
785f4cb0035c732a502b50edb759ce05fd9cf578
5ff92c1b338f3e5a2f1446d0154f4de24a217c95
v1.0
complete
Prefill
Prefill_31276_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, False otherwise. """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Filters out all the prime numbers in the given list of integers. >>> filter_primes([2, 3, 4, 5, 6, 7]) == [2, 3, 5, 7] ...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def filt...
from solution import filter_primes, is_prime def test_single_prime(): assert filter_primes([7]) == [7] def test_multiple_primes(): assert filter_primes([2, 3, 4, 5, 6, 7]) == [2, 3, 5, 7] def test_no_primes(): assert filter_primes([4, 6, 8, 9, 10]) == [] def test_primes_with_negative_numbers(): ...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters out all the prime numbers in the given list of integers.", "function_declaration": "def filt...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even prime num...
trial_gpt4o_9
{ "original_instruction": "Write a python function to filter out all the prime numbers in a given list of integers. A prime number is a natural number greater than 1 and has no positive divisors other than 1 and itself.", "prompt_id": "00031276", "row_id": 31276, "seed_ids": "['magpie_prefill_31276']" }
0.780462
Prefill_31276
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5d977e94d2060a22ee3dadd1f3f02bb927c5e0c1
784c893d6cd9e9cc109e93237c0dc206341fb160
v1.0
complete
Prefill
Prefill_30885_C
from typing import List def is_feasible(boards: List[int], n: int, m: int, max_time: int) -> bool: """ Helper function to check if it is feasible to paint all boards within max_time given m painters. """ pass def minimum_time(boards: List[int], m: int) -> int: """Returns the minimum time requi...
def is_feasible(boards, n, m, max_time): """ Helper function to check if it is feasible to paint all boards within max_time given m painters. """ painters_count = 1 current_time = 0 for time in boards: if current_time + time <= max_time: current_time += time else...
from solution import minimum_time def test_minimum_time_single_painter(): assert minimum_time([10, 20, 30, 40], 1) == 100 def test_minimum_time_multiple_painters(): assert minimum_time([10, 20, 30, 40], 2) == 60 def test_minimum_time_more_painters_than_boards(): assert minimum_time([10, 20, 30], 5) == 30...
[ { "docstring": "Helper function to check if it is feasible to paint all boards within max_time\ngiven m painters.", "function_declaration": "def is_feasible(boards, n, m, max_time):", "function_name": "is_feasible", "parameter_list": "(boards, n, m, max_time)" }, { "docstring": "Returns the ...
[ 1, 0, 1, 0, 1, 1, 0, 0, 0, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_time_to_paint_boards(arr, m):\n \"\"\"\n Determines the minimum time required to paint all boards using binary search.\n \n Args:\n arr: List[int] - An array of non-neg...
trial_gpt4o_9
{ "original_instruction": "Write a python function to solve thePainter's Partition problem using a binary search approach. The function should take an array of non-negative integers representing the time taken to paint each board and an integer m representing the number of painters available. The function should retu...
0.672655
Prefill_30885
C
[ "is_feasible", "minimum_time" ]
2
[ [ "minimum_time", "is_feasible" ] ]
1
[]
false
[]
false
pytest
true
[]
true
11ddd98e3692658a3e6c17f1e83b5960745e49dc
b804b8160db24ce0ab6ee4a6eada5378c4550fcf
v1.0
complete
Prefill
Prefill_31013_C
def reverse_stack(stack): """ Reverse a stack using recursion. You can use only one additional stack or no additional stack and you are allowed to use extra space on the recursion call stack. >>> s = [1, 2, 3, 4, 5] >>> reverse_stack(s) >>> s [5, 4, 3, 2, 1] >>> t = [1] >>> reverse...
def reverse_stack(stack): """ This function reverses the stack using recursion. """ if not stack: return # Pop the top element of the stack top = stack.pop() # Reverse the remaining stack reverse_stack(stack) # Insert the popped element at the bottom of the rev...
from solution import reverse_stack def test_reverse_stack(): stack = [1, 2, 3, 4, 5] reverse_stack(stack) assert stack == [5, 4, 3, 2, 1] def test_reverse_single_element_stack(): stack = [1] reverse_stack(stack) assert stack == [1] def test_reverse_empty_stack(): stack = [] reverse_st...
[ { "docstring": "This function reverses the stack using recursion.", "function_declaration": "def reverse_stack(stack):", "function_name": "reverse_stack", "parameter_list": "(stack)" }, { "docstring": "A helper function to insert an item at the bottom of a stack.", "function_declaration"...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def insert_at_bottom(stack, item):\n if not stack:\n stack.append(item)\n else:\n top = stack.pop()\n insert_at_bottom(stack, item)\n stack.append(top)\n\nde...
trial_gpt4o_9
{ "original_instruction": "Write a python function to reverse a stack using recursion. You can use only one additional stack or no additional stack and you are allowed to use extra space on the recursion call stack.", "prompt_id": "00031013", "row_id": 31013, "seed_ids": "['magpie_prefill_31013']" }
0.552419
Prefill_31013
C
[ "reverse_stack", "insert_at_bottom" ]
2
[ [ "reverse_stack", "insert_at_bottom" ] ]
1
[]
false
[]
false
pytest
true
[]
true
720724d9ffe5c7465f458b10dd169a77764ec2e2
2e2dca494ba6129ef848eb1644bb3ab13468d9ed
v1.0
complete
Prefill
Prefill_30724_C
def factorial_iterative(n): """ Returns the factorial of a given number using iteration. >>> factorial_iterative(0) 1 >>> factorial_iterative(1) 1 >>> factorial_iterative(5) 120 >>> factorial_iterative(10) 3628800 """ pass def factorial_recursive(n): """ Returns the factorial of...
def factorial_iterative(n): """ Returns the factorial of a given number using iteration. """ result = 1 for i in range(2, n + 1): result *= i return result def factorial_recursive(n): """ Returns the factorial of a given number using recursion. """ if n == 0 or n == 1: ...
import pytest from solution import factorial_iterative, factorial_recursive, discuss_tradeoffs def test_factorial_iterative(): assert factorial_iterative(0) == 1 assert factorial_iterative(1) == 1 assert factorial_iterative(5) == 120 assert factorial_iterative(10) == 3628800 def test_factorial_recursi...
[ { "docstring": "Returns the factorial of a given number using iteration.", "function_declaration": "def factorial_iterative(n):", "function_name": "factorial_iterative", "parameter_list": "(n)" }, { "docstring": "Returns the factorial of a given number using recursion.", "function_declar...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\ndef factorial_iterative(n):\n \"\"\"\n Returns the factorial of a given number n using an iterative approach.\n \"\"\"\n if n < 0:\n raise ValueError(\"Facto...
trial_gpt4o_8
{ "original_instruction": "Write a python function to calculate the factorial of a given number using iteration and another function to calculate the factorial using recursion. Compare their performance and discuss the trade-offs.", "prompt_id": "00030724", "row_id": 30724, "seed_ids": "['magpie_prefill_30724']...
0.656903
Prefill_30724
C
[ "factorial_iterative", "factorial_recursive", "compare_performance", "discuss_tradeoffs" ]
4
[ [ "compare_performance", "factorial_iterative" ], [ "compare_performance", "factorial_recursive" ], [ "discuss_tradeoffs", "compare_performance" ] ]
3
[]
false
[]
false
pytest
true
[]
true
091cee6f743256b765276024d331c860f72676f5
f486d0743ab852f01d328c2e0a154cf27db1adcb
v1.0
complete
Prefill
Prefill_31236_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(29) True >>> is_prime(97) True >>> is_prime(1) False """ def sum_of_primes() -> int: """ Returns the sum o...
def is_prime(n): """ Returns True if n is a prime number, otherwise 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 sum_of_primes(): """ Returns the sum of all prime numbers between 1 and 100....
from solution import sum_of_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(97) == True assert is_prime(1) == False def test_sum_of_primes(): assert sum_of_primes() == 1060
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers between 1 and 100.", "function_declaration": "def sum_of_primes...
[ 1, 0, 1, 1, 1, 1, 0, 0, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_primes_between_1_and_100():\n \"\"\"\n Returns the sum of all prime numbers between 1 and 100 inclusive.\n \"\"\"\n def is_prime(n):\n \"\"\"Helper function to chec...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the sum of all prime numbers between 1 and 100.", "prompt_id": "00031236", "row_id": 31236, "seed_ids": "['magpie_prefill_31236']" }
0.803279
Prefill_31236
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2bd3e1f5ba8cb43579f13aa0040c210d2bcd7ec3
a85814ce5b9063fc594ebb868d2e7b5b5cad5447
v1.0
complete
Prefill
Prefill_29397_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(1) == False >>> is_prime(0) == False >>> is_prime(-1) == False """ pass def s...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def sum_of_primes_less_than_n(n): """ Returns the sum of all prime numbers less...
from solution import is_prime, sum_of_primes_less_than_n 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 test_sum_of_pr...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers less than n.", "function_declaration": "def sum_of_primes_less_tha...
[ 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_primes(n):\n \"\"\"\n Returns the sum of all prime numbers less than n.\n \"\"\"\n def is_prime(num):\n if num <= 1:\n return False\n if num <=...
trial_gpt4o_6
{ "original_instruction": "Write a python function to calculate the sum of all prime numbers less than `n`. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.", "prompt_id": "00029397", "row_id": 29397, "seed_ids": "['magpie_prefill_29397']" }
0.805093
Prefill_29397
C
[ "is_prime", "sum_of_primes_less_than_n" ]
2
[ [ "sum_of_primes_less_than_n", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fba6301532d1413469131f4a2c5394268e15bdfe
87b949be58394c5c46940482d02badbaf4e8fb9c
v1.0
complete
Prefill
Prefill_31551_C
def factorial(n: int) -> int: """ Returns the factorial of n using recursion. >>> factorial(0) 1 >>> factorial(1) 1 >>> factorial(2) 2 >>> factorial(3) 6 >>> factorial(4) 24 >>> factorial(5) 120 >>> factorial(6) 720 >>> factorial(7) 5040 "...
def factorial(n): """ Returns the factorial of n using recursion. """ if n == 0: return 1 else: return n * factorial(n - 1) def check_factorial(): """ Checks the correctness of the factorial function by comparing its output with known values. """ test_cases = {0:...
from solution import factorial, check_factorial def test_factorial_base_cases(): assert factorial(0) == 1 assert factorial(1) == 1 def test_factorial_small_numbers(): assert factorial(2) == 2 assert factorial(3) == 6 def test_factorial_medium_numbers(): assert factorial(4) == 24 assert factor...
[ { "docstring": "Returns the factorial of n using recursion.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Checks the correctness of the factorial function by comparing its output\nwith known values.", "function_dec...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorial(n):\n \"\"\"\n Returns the factorial of a non-negative integer n using recursion.\n \"\"\"\n if n < 0:\n raise ValueError(\"Factorial is not defined for negat...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the factorial of a number using recursion. Then, implement a check function to ensure your factorial function is working correctly.", "prompt_id": "00031551", "row_id": 31551, "seed_ids": "['magpie_prefill_31551']" }
0.735763
Prefill_31551
C
[ "factorial", "check_factorial" ]
2
[ [ "check_factorial", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
10126a797205ce21cb9b382001fe0636ea8ec303
a1ee24e6308e1757a3cb6856271caf105346c2fb
v1.0
complete
Prefill
Prefill_30260_C
def is_prime(n: int) -> bool: """ Helper function to determine if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(1) == False >>> is_prime(0) == False >>> is_prime(-1) == False """ def find_pri...
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def find_primes(numbers): """ Returns a list of prime numbers from the given list o...
from solution import is_prime, find_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False def test_find_primes_with_mixed_...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of numbers.", "function_declaration": "def find_pri...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i =...
trial_gpt4o_8
{ "original_instruction": "Write a python function to find all the prime numbers in a given list of numbers and return a list of those prime numbers.", "prompt_id": "00030260", "row_id": 30260, "seed_ids": "['magpie_prefill_30260']" }
0.849726
Prefill_30260
C
[ "is_prime", "find_primes" ]
2
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1d112bb1a90960b0ae78441d7c321134384064e6
1db06a13e8f13e30250400752fd51b9b2b3ed13a
v1.0
complete
Prefill
Prefill_30922_C
def is_prime(n: int) -> bool: """ Determines if a number is prime. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prim...
def is_prime(n): """ Determines if a number is prime. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: r...
from solution import prime_numbers_in_range, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(-...
[ { "docstring": "Determines if a number is prime.\n\nArgs:\nn (int): The number to check for primality.\n\nReturns:\nbool: True if the number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_primes_in_range(start, end):\n \"\"\"\n Finds all prime numbers in the range from start to end (inclusive).\n :param start: The lower bound of the range (inclusive).\n :p...
trial_gpt4o_9
{ "original_instruction": "Write a python function to identify prime numbers within a given range. The function should find all prime numbers between two integers, inclusive. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Make sure to test your function with s...
0.784142
Prefill_30922
C
[ "is_prime", "prime_numbers_in_range" ]
2
[ [ "prime_numbers_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f8adf16dcbb031fe657bfedeb130537174c96357
90c81f42fad08d402557069a4119b85af236c721
v1.0
complete
Prefill
Prefill_30898_C
def merge_sort(arr): """ Performs a merge sort on the input array. Parameters: arr (list): The array to sort. Returns: list: The sorted array. Example: >>> merge_sort([3, 1, 4, 1, 5, 9, 2, 6, 5]) [1, 1, 2, 3, 4, 5, 5, 6, 9] >>> merge_sort([5, 4, 3, 2, 1]) [1, 2...
def merge_sort(arr): """ Performs a merge sort on the input array. Parameters: arr (list): The array to sort. Returns: list: The sorted array. """ if len(arr) <= 1: return arr # Find the middle point and divide it mid = len(arr) // 2 left_half = merge_sort(...
from solution import merge_sort 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(): assert merge_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] def test_merge_sort_unsorted_array(): assert merge_sort([3, 1, 4, 1, 5, 9, 2, 6, 5]) ...
[ { "docstring": "Performs a merge sort on the input array.\n\nParameters:\narr (list): The array to sort.\n\nReturns:\nlist: The sorted array.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted lists ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Perform a merge sort on an array.\n \n :param arr: List of elements to be sorted.\n :return: Sorted list of elements.\n \"\"\"\n if len(ar...
trial_gpt4o_9
{ "original_instruction": "Write a python function to perform a merge sort on an array.", "prompt_id": "00030898", "row_id": 30898, "seed_ids": "['magpie_prefill_30898']" }
0.667217
Prefill_30898
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
000a47a2b435cd1ee229b79ee872df90dcfa3bb3
05a4f82321c58ccc981a98e9bf99c3dd32cd0ce0
v1.0
complete
Prefill
Prefill_31407_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Returns a list containing only the prime numbers from the given list of integers. >>> filter_primes([]) [] >...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter...
from solution import filter_primes def test_empty_list(): assert filter_primes([]) == [] def test_no_primes(): assert filter_primes([4, 6, 8, 9, 10]) == [] def test_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_mixed_numbers(): assert filter_primes([1, 2, 4, 5, 8,...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the given list of integers.", "function_declar...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n r...
trial_gpt4o_7
{ "original_instruction": "Write a python function to return a list containing only the prime numbers from the given list of integers.", "prompt_id": "00031407", "row_id": 31407, "seed_ids": "['magpie_prefill_31407']" }
0.757405
Prefill_31407
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a1d8273520ca76835000d98c1745417fb3e5ed22
1744f84d441d0c8e5cbe603812467b7f332c2a4e
v1.0
complete
Prefill
Prefill_29635_C
def is_armstrong(number): """ Check if a number is an Armstrong number. An Armstrong number of a given number of digits is a number such that the sum of its digits each raised to the power of the number of digits is equal to the number itself. >>> is_armstrong(153) == True >>> is_armstrong(370...
def is_armstrong(number): """ Check if a number is an Armstrong number. An Armstrong number of a given number of digits is a number such that the sum of its digits each raised to the power of the number of digits is equal to the number itself. """ digits = list(map(int, str(number))) num_d...
from solution import is_armstrong, find_armstrong_numbers def test_is_armstrong(): assert is_armstrong(153) == True assert is_armstrong(370) == True assert is_armstrong(371) == True assert is_armstrong(9474) == True assert is_armstrong(123) == False assert is_armstrong(10) == False def test_fi...
[ { "docstring": "Check if a number is an Armstrong number.\n\nAn Armstrong number of a given number of digits is a number such that the sum of its digits each raised \nto the power of the number of digits is equal to the number itself.", "function_declaration": "def is_armstrong(number):", "function_name...
[ 1, 1, 0, 1, 1, 1, 0, 1, 0, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_armstrong_number(num):\n \"\"\"\n Check if a number is an Armstrong number.\n \"\"\"\n num_str = str(num)\n num_len = len(num_str)\n sum_of_powers = sum(int(digit)**n...
trial_gpt4o_7
{ "original_instruction": "Write a python function to find all the Armstrong numbers within a given range.", "prompt_id": "00029635", "row_id": 29635, "seed_ids": "['magpie_prefill_29635']" }
0.573912
Prefill_29635
C
[ "is_armstrong", "find_armstrong_numbers" ]
2
[ [ "find_armstrong_numbers", "is_armstrong" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6109fa9cd7cf8edb99b19b5b687bd9039acda11e
9d111caac3f1344c0e47a0a24ec94027236ffbca
v1.0
complete
Prefill
Prefill_32302_C
def fibonacci(n, mode='loop'): """ Generates the Fibonacci sequence of length n. Parameters: n (int): Length of the sequence to generate. mode (str): Method to generate the sequence ('loop' for iterative, 'recursive' for recursive). Returns: list: Fibonacci sequence of length n. ...
def fibonacci(n, mode='loop'): """ Generates the Fibonacci sequence of length n. Parameters: n (int): Length of the sequence to generate. mode (str): Method to generate the sequence ('loop' for iterative, 'recursive' for recursive). Returns: list: Fibonacci sequence of length n. ...
from solution import fibonacci def test_fibonacci_loop(): assert fibonacci(0, 'loop') == [] assert fibonacci(1, 'loop') == [0] assert fibonacci(2, 'loop') == [0, 1] assert fibonacci(5, 'loop') == [0, 1, 1, 2, 3] assert fibonacci(10, 'loop') == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] def test_fibonacci_r...
[ { "docstring": "Generates the Fibonacci sequence of length n.\n\nParameters:\nn (int): Length of the sequence to generate.\nmode (str): Method to generate the sequence ('loop' for iterative, 'recursive' for recursive).\n\nReturns:\nlist: Fibonacci sequence of length n.", "function_declaration": "def fibonac...
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fib(n, mode='loop'):\n \"\"\"\n Generates the Fibonacci sequence of length n using the specified mode.\n \n Parameters:\n n (int): Length of the Fibonacci sequence to gener...
trial_gpt4o_9
{ "original_instruction": "Write a python function to generate the Fibonacci sequence with a given length. The function should take two parameters: `n` (the length of the sequence to generate) and `mode` (either 'loop' for iterative method or 'recursive' for recursive method). The function should return the Fibonacci...
0.834378
Prefill_32302
C
[ "fibonacci", "fibonacci_loop", "fibonacci_recursive_helper", "fibonacci_recursive" ]
4
[ [ "fibonacci", "fibonacci_loop" ], [ "fibonacci", "fibonacci_recursive_helper" ], [ "fibonacci_recursive_helper", "fibonacci_recursive" ] ]
3
[]
false
[]
false
pytest
true
[]
true
73411bf28265b214aeb1d12aae39750a180e9a73
dbe2db75574066355734f977dddafc612ee14a3d
v1.0
complete
Prefill
Prefill_31503_C
def merge_and_count(arr, temp_arr, left, mid, right): pass def merge_sort_and_count(arr, temp_arr, left, right): pass def count_inversions(arr): """ Function to count inversions in an array efficiently. Inversion count for an array is the count of pairs (i, j) such that i < j and arr[i] > arr[j]. ...
def merge_and_count(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 # Conditions are checked to ensure that i doesn't exceed mid and j doesn't exceed right wh...
from solution import count_inversions def test_count_inversions_none(): assert count_inversions([]) == 0 def test_count_inversions_sorted(): assert count_inversions([1, 2, 3, 4, 5, 6, 7, 8]) == 0 def test_count_inversions_reverse_sorted(): assert count_inversions([8, 7, 6, 5, 4, 3, 2, 1]) == 28 def test...
[ { "docstring": null, "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, right):", "function_name": "merge_and_count", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_arr, left, r...
[ 1, 1, 0, 0, 0, 0, 1, 1, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_and_count(arr, temp_arr, left, mid, right):\n i = left # Starting index for left subarray\n j = mid + 1 # Starting index for right subarray\n k = left # Starting inde...
trial_gpt4o_7
{ "original_instruction": "Write a python function to find the number of inversions in an array efficiently. Inversion count for an array is the count of pairs (i, j) such that i < j and arr[i] > arr[j].", "prompt_id": "00031503", "row_id": 31503, "seed_ids": "['magpie_prefill_31503']" }
0.742846
Prefill_31503
C
[ "merge_and_count", "merge_sort_and_count", "count_inversions" ]
3
[ [ "count_inversions", "merge_sort_and_count" ], [ "merge_sort_and_count", "merge_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ca3ae30713cf63031423d0d52eca44b6f87ea14f
7755d2fd982e4b5fe0527d41d910419dd823dbec
v1.0
complete
Prefill
Prefill_30959_C
def is_prime(n: int) -> bool: """ Helper function to determine if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(10) False >>> is_prime(17) True >>> is_prime(19) True >>> is_prime(21) False >>> is_prime(1) Fals...
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def print_pri...
from solution import is_prime, print_primes_between def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(17) == True assert is_prime(19) == True assert is_prime(21) ...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Prints all prime numbers between a and b (inclusive).", "function_declaration": "def print_primes_betwe...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n i...
trial_gpt4o_9
{ "original_instruction": "Write a python function to print all the prime numbers between two given numbers (inclusive). The function should accept two integer parameters and print all the prime numbers from the smaller to the greater number. You should also consider edge cases.", "prompt_id": "00030959", "row_id...
0.797496
Prefill_30959
C
[ "is_prime", "print_primes_between" ]
2
[ [ "print_primes_between", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8aef5c64abcd2d8870c70ea56dff504bcd19822b
eb2e373ece702e25b0b3fbefd72376bc8e2f1196
v1.0
complete
Prefill
Prefill_30129_C
def rolling_window(arr, window_size): """ Create a list of rolling windows from the input array. Parameters: arr (list): Input array. window_size (int): Size of the rolling window. Returns: list: A list of rolling windows. """ # Your code here def moving_average(arr, windo...
def rolling_window(arr, window_size): """ Create a list of rolling windows from the input array. Parameters: arr (list): Input array. window_size (int): Size of the rolling window. Returns: list: A list of rolling windows. """ if window_size > len(arr) or window_size <= 0: ...
from solution import rolling_window, moving_average def test_rolling_window(): assert rolling_window([1, 2, 3, 4, 5], 3) == [[1, 2, 3], [2, 3, 4], [3, 4, 5]] assert rolling_window([1, 2, 3, 4, 5], 1) == [[1], [2], [3], [4], [5]] assert rolling_window([1, 2, 3, 4, 5], 5) == [[1, 2, 3, 4, 5]] assert roll...
[ { "docstring": "Create a list of rolling windows from the input array.\n\nParameters:\narr (list): Input array.\nwindow_size (int): Size of the rolling window.\n\nReturns:\nlist: A list of rolling windows.", "function_declaration": "def rolling_window(arr, window_size):", "function_name": "rolling_windo...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rolling_window_view(arr, window_size):\n \"\"\"\n Generate a list of rolling windows of a specified size from an array.\n \n :param arr: List of numbers.\n :param window_si...
trial_gpt4o_8
{ "original_instruction": "Write a python function to create a list of rolling window_view of an array without using numpy. You should write the rolling window_view function and a main function that uses this window_view function to compute the moving average of an array.", "prompt_id": "00030129", "row_id": 3012...
0.577035
Prefill_30129
C
[ "rolling_window", "moving_average" ]
2
[ [ "moving_average", "rolling_window" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a790349ef81962b245f96f724603ace29ecb4599
e37c8434f114da0cfd2d456ab3f150cdfa612441
v1.0
complete
Prefill
Prefill_31936_C
import time def fib_recursive(n): """ Returns the nth Fibonacci number using recursion. >>> fib_recursive(0) 0 >>> fib_recursive(1) 1 >>> fib_recursive(10) 55 >>> fib_recursive(5) 5 """ pass def fib_iterative(n): """ Returns the nth Fibonacci number using iteration. >>> fib...
import time def fib_recursive(n): """ Returns the nth Fibonacci number using recursion. """ if n <= 1: return n return fib_recursive(n - 1) + fib_recursive(n - 2) def fib_iterative(n): """ Returns the nth Fibonacci number using iteration. """ if n <= 1: return n ...
from solution import fib_recursive, fib_iterative, compare_fibonacci_performance def test_fib_recursive_base_cases(): assert fib_recursive(0) == 0 assert fib_recursive(1) == 1 def test_fib_recursive_general_case(): assert fib_recursive(10) == 55 assert fib_recursive(5) == 5 assert fib_recursive(7)...
[ { "docstring": "Returns the nth Fibonacci number using recursion.", "function_declaration": "def fib_recursive(n):", "function_name": "fib_recursive", "parameter_list": "(n)" }, { "docstring": "Returns the nth Fibonacci number using iteration.", "function_declaration": "def fib_iterative...
[ 1, 1, 1, 1, 0, 0, 0, 1, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\ndef fibonacci_iterative(n):\n \"\"\"\n Returns the nth Fibonacci number using an iterative method.\n \"\"\"\n if n <= 0:\n return 0\n elif n == 1:\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the nth Fibonacci number using both iterative and recursive methods. Compare their performance for large values of n.", "prompt_id": "00031936", "row_id": 31936, "seed_ids": "['magpie_prefill_31936']" }
0.756676
Prefill_31936
C
[ "fib_recursive", "fib_iterative", "compare_fibonacci_performance" ]
3
[ [ "compare_fibonacci_performance", "fib_iterative" ], [ "compare_fibonacci_performance", "fib_recursive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ec31baa5d18e2440329ffa334e7a62bd9f6e08eb
1396d43d7ae780d2cdd0cedb924eda0561259168
v1.0
complete
Prefill
Prefill_30896_C
from typing import List def matrix_multiply(A: List[List[int]], B: List[List[int]]) -> List[List[int]]: """ Multiplies two 2x2 matrices A and B. >>> matrix_multiply([[1, 2], [3, 4]], [[2, 0], [1, 2]]) [[4, 4], [10, 8]] """ pass def matrix_power(matrix: List[List[int]], n: int) -> List[List[int...
def matrix_multiply(A, B): """ Multiplies two 2x2 matrices A and B. """ return [ [A[0][0] * B[0][0] + A[0][1] * B[1][0], A[0][0] * B[0][1] + A[0][1] * B[1][1]], [A[1][0] * B[0][0] + A[1][1] * B[1][0], A[1][0] * B[0][1] + A[1][1] * B[1][1]] ] def matrix_power(matrix, n): """ ...
from solution import matrix_multiply, matrix_power, fibonacci_matrix_exponentiation def test_matrix_multiply(): A = [[1, 2], [3, 4]] B = [[2, 0], [1, 2]] result = matrix_multiply(A, B) assert result == [[4, 4], [10, 8]] def test_matrix_power(): matrix = [[1, 1], [1, 0]] result = matrix_power(m...
[ { "docstring": "Multiplies two 2x2 matrices A and B.", "function_declaration": "def matrix_multiply(A, B):", "function_name": "matrix_multiply", "parameter_list": "(A, B)" }, { "docstring": "Raises the matrix to the power of n using exponentiation by squaring.", "function_declaration": "...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def matrix_mult(A, B):\n \"\"\"\n Multiplies two 2x2 matrices A and B.\n \"\"\"\n return [\n [A[0][0] * B[0][0] + A[0][1] * B[1][0], A[0][0] * B[0][1] + A[0][1] * B[1][1]],...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the nth Fibonacci number using the Matrix Exponentiation method. This method involves using matrix exponentiation to efficiently compute Fibonacci numbers, which is particularly useful for large n. Please provide a detailed explanation of the code and the met...
0.688105
Prefill_30896
C
[ "matrix_multiply", "matrix_power", "fibonacci_matrix_exponentiation" ]
3
[ [ "fibonacci_matrix_exponentiation", "matrix_power" ], [ "matrix_power", "matrix_multiply" ] ]
2
[]
false
[]
false
pytest
true
[]
true
121c3ebb526eeb344f0ea4a44fea6d976b8386b5
64923b62e35ae0f789ab95b5812713e2525fb6e7
v1.0
complete
Prefill
Prefill_31877_C
def is_prime(num: int) -> bool: """ Helper function to check whether a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def product_of_primes(numbers: List[int]) -> int: """ Calcula...
def is_prime(num): """ Helper function to check whether a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def product_of_primes(numbers): """ Returns the product of all prime numbe...
from solution import product_of_primes def test_product_of_primes_with_all_primes(): assert product_of_primes([2, 3, 5, 7]) == 210 def test_product_of_primes_with_some_primes(): assert product_of_primes([4, 6, 7, 9, 11]) == 77 def test_product_of_primes_with_no_primes(): assert product_of_primes([4, 6, 8...
[ { "docstring": "Helper function to check whether a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the product of all prime numbers in the given list.\nIf there are no prime numbers, returns 0....
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_6
{ "original_instruction": "Write a python function to calculate the product of all prime numbers in a given list. If there are no prime numbers, return `0`.", "prompt_id": "00031877", "row_id": 31877, "seed_ids": "['magpie_prefill_31877']" }
0.750648
Prefill_31877
C
[ "is_prime", "product_of_primes" ]
2
[ [ "product_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8dc4a360c1aa02de1091b335f2d86ee3bc02ef86
9dd2c3f9ead892529b6cf768b17810d9bd5e62b5
v1.0
complete
Prefill
Prefill_31797_C
import math def solve_quadratic(a: float, b: float, c: float) -> tuple: """ Solves the quadratic equation of the form ax^2 + bx + c = 0. Args: a, b, c: Coefficients of the quadratic equation. Returns: A tuple of two solutions or (None, None) if there is no real solution. >>> solve_quadra...
import math def solve_quadratic(a, b, c): """ Solves the quadratic equation of the form ax^2 + bx + c = 0. Args: a, b, c: Coefficients of the quadratic equation. Returns: A tuple of two solutions. """ discriminant = b ** 2 - 4 * a * c if discriminant < 0: return No...
from solution import solve_given_quadratic def test_solve_given_quadratic(): x1, x2 = solve_given_quadratic() assert round(x1, 6) == 1.0 assert round(x2, 6) == -3.0 def test_no_real_solution(): assert solve_quadratic(1, 0, 1) == (None, None) # x^2 + 1 = 0 has no real solution def test_double_root():...
[ { "docstring": "Solves the quadratic equation of the form ax^2 + bx + c = 0.\n\nArgs:\na, b, c: Coefficients of the quadratic equation.\n\nReturns:\nA tuple of two solutions.", "function_declaration": "def solve_quadratic(a, b, c):", "function_name": "solve_quadratic", "parameter_list": "(a, b, c)" ...
[ 1, 1, 1, 1, 0, 0, 1, 1, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef solve_quadratic_equation(a, b, c):\n \"\"\"\n Solves the quadratic equation of the form ax^2 + bx + c = 0 using\n the quadratic formula.\n \n :param a: coeff...
trial_gpt4o_8
{ "original_instruction": "Write a python function to solve the equation of the form 2x^2 + 4x - 6 = 0, using the quadratic formula.", "prompt_id": "00031797", "row_id": 31797, "seed_ids": "['magpie_prefill_31797']" }
0.637238
Prefill_31797
C
[ "solve_quadratic", "solve_given_quadratic" ]
2
[ [ "solve_given_quadratic", "solve_quadratic" ] ]
1
[]
false
[]
false
pytest
true
[]
true
21cb2f244da42d197bcbde74b26f084697c32854
be7aa86c236df97ec537ef64f621f7641b149400
v1.0
complete
Prefill
Prefill_32437_C
def max_digital_sum(limit: int) -> int: """ Finds the maximum digital sum of a number a^b where a, b < limit. >>> max_digital_sum(100) 972 """ def digital_sum(n: int) -> int: return sum(int(digit) for digit in str(n)) def max_digital_sum_100() -> int: return max_digital_sum(100)
def max_digital_sum(limit): """ Finds the maximum digital sum of a number a^b where a, b < limit. """ def digital_sum(n): return sum(int(digit) for digit in str(n)) max_sum = 0 for a in range(1, limit): for b in range(1, limit): num = a ** b current_sum =...
from solution import max_digital_sum_100 def test_digital_sum_1_to_99(): result = max_digital_sum_100() assert result > 0 # There should be at least one maximum digital sum greater than zero. assert result == 972 # Verification of the known result for the specific limit of 100.
[ { "docstring": "Finds the maximum digital sum of a number a^b where a, b < limit.", "function_declaration": "def max_digital_sum(limit):", "function_name": "max_digital_sum", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def max_digital_sum_100():", "fu...
[ 1, 0, 0, 0, 1, 1, 0, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_digit_sum():\n \"\"\"\n Returns the maximum digital sum of a number a^b where a, b < 100.\n \"\"\"\n def digital_sum(n):\n return sum(int(digit) for digit in str(n)...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the maximum digital sum of a number a^b where a, b < 100", "prompt_id": "00032437", "row_id": 32437, "seed_ids": "['magpie_prefill_32437']" }
0.616781
Prefill_32437
C
[ "max_digital_sum", "max_digital_sum_100" ]
2
[ [ "max_digital_sum_100", "max_digital_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8b1aac057399f8c5fb74e43766a4670852a71b89
85eb71ee0c785ea0a3089a759d3b278c8d291496
v1.0
complete
Prefill
Prefill_30879_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(9) == False >>> is_prime(11) == True """ def sum_of_squares_of_primes(n: int) -> int: """ ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import is_prime, sum_of_squares_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False assert is_prime(11) == True def test_sum_of_squares_of_primes(): assert sum_...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of squares of all prime numbers up to n.", "function_declaration": "def sum_of_squares_...
[ 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import isqrt\n\ndef is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ret...
trial_gpt4o_3
{ "original_instruction": "Write a python function to find the sum of squares of all prime numbers upto n", "prompt_id": "00030879", "row_id": 30879, "seed_ids": "['magpie_prefill_30879']" }
0.731714
Prefill_30879
C
[ "is_prime", "sum_of_squares_of_primes" ]
2
[ [ "sum_of_squares_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
76807925c0becb85189d33373b7c854206ed5933
4bc631e7ce4a1a53c293a5b0efb0cd6139a30ac5
v1.0
complete
Prefill
Prefill_31156_C
def find_fibonacci_in_list(nums: List[int]) -> List[int]: """ Finds all Fibonacci numbers in the given list. Parameters: nums (list): List of integers to check for Fibonacci numbers. Returns: list: A list containing all Fibonacci numbers from the input list (if any). Returns...
def is_fibonacci(n): if n < 0: return False if n == 0 or n == 1: return True a, b = 0, 1 while b < n: a, b = b, a + b return b == n def find_fibonacci_in_list(nums): """ Finds all Fibonacci numbers in the given list. Parameters: nums (list...
from solution import find_fibonacci_in_list def test_find_fibonacci_in_list_all_fib_numbers(): assert find_fibonacci_in_list([0, 1, 1, 2, 3, 5, 8, 13, 21, 34]) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] def test_find_fibonacci_in_list_mixed_numbers(): assert find_fibonacci_in_list([4, 6, 8, 13, 20, 21]) == [8, 13, ...
[ { "docstring": null, "function_declaration": "def is_fibonacci(n):", "function_name": "is_fibonacci", "parameter_list": "(n)" }, { "docstring": "Finds all Fibonacci numbers in the given list.\n\nParameters:\nnums (list): List of integers to check for Fibonacci numbers.\n\nReturns:\nlist: A l...
[ 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_fibonacci(n):\n \"\"\"\n Check if the number n is part of the Fibonacci sequence.\n \"\"\"\n if n < 0:\n return False\n # A number is Fibonacci if and only if one...
trial_gpt4o_8
{ "original_instruction": "Write a python function to find the all the fibonacci numbers in a list. Please make sure to handle edge cases properly, like if the list is empty or contains no fibonacci numbers.", "prompt_id": "00031156", "row_id": 31156, "seed_ids": "['magpie_prefill_31156']" }
0.73016
Prefill_31156
C
[ "is_fibonacci", "find_fibonacci_in_list" ]
2
[ [ "find_fibonacci_in_list", "is_fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8bcaf873b37a0b5e5593f2d2dadd31eb2db361cb
4f8dc5b37a75454e1b4e101c43dc24d3f929d63a
v1.0
complete
Prefill
Prefill_30758_C
def factorial_iterative(n: int) -> int: """Returns the factorial of n using an iterative approach. >>> factorial_iterative(0) 1 >>> factorial_iterative(1) 1 >>> factorial_iterative(5) 120 >>> factorial_iterative(10) 3628800 """ def factorial_recursive(n: int) -> int: """Returns the factoria...
def factorial_iterative(n): """ Returns the factorial of n using an iterative approach. """ result = 1 for i in range(2, n + 1): result *= i return result def factorial_recursive(n): """ Returns the factorial of n using a recursive approach. """ if n == 0 or n == 1: ...
from solution import factorial_iterative, factorial_recursive, compare_factorial_methods def test_factorial_iterative(): assert factorial_iterative(0) == 1 assert factorial_iterative(1) == 1 assert factorial_iterative(5) == 120 assert factorial_iterative(10) == 3628800 def test_factorial_recursive(): ...
[ { "docstring": "Returns the factorial of n using an iterative approach.", "function_declaration": "def factorial_iterative(n):", "function_name": "factorial_iterative", "parameter_list": "(n)" }, { "docstring": "Returns the factorial of n using a recursive approach.", "function_declarati...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorial_iterative(n):\n \"\"\"\n Returns the factorial of n using an iterative approach.\n \"\"\"\n result = 1\n for i in range(1, n + 1):\n result *= i\n retur...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the factorial of a number iteratively, and another function that compares the results iterating and recursively.", "prompt_id": "00030758", "row_id": 30758, "seed_ids": "['magpie_prefill_30758']" }
0.64729
Prefill_30758
C
[ "factorial_iterative", "factorial_recursive", "compare_factorial_methods" ]
3
[ [ "compare_factorial_methods", "factorial_iterative" ], [ "compare_factorial_methods", "factorial_recursive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
97a40f986eb0af30069d55ae397839b1b2c978f1
f14c2f7386ef84f0653e0ccfafd9898d908ae4e4
v1.0
complete
Prefill
Prefill_30448_C
def decimal_to_base(decimal_number, base): """ Converts a decimal number to the specified base (between 2 and 36). The base is rounded to the nearest integer if it is not an integer. Args: decimal_number (float): The decimal number to be converted. base (float): The base to which the decimal n...
from math import modf, floor def decimal_to_base(decimal_number, base): """ Converts a decimal number to the specified base (between 2 and 36). The base is rounded to the nearest integer if it is not an integer. Args: decimal_number (float): The decimal number to be converted. base (float): T...
from solution import decimal_to_base def test_decimal_to_base_positive_integer(): assert decimal_to_base(10, 2) == "1010" assert decimal_to_base(10, 16) == "A" assert decimal_to_base(255, 16) == "FF" def test_decimal_to_base_negative_integer(): assert decimal_to_base(-10, 2) == "-1010" assert deci...
[ { "docstring": "Converts a decimal number to the specified base (between 2 and 36). \nThe base is rounded to the nearest integer if it is not an integer.\n\nArgs:\ndecimal_number (float): The decimal number to be converted.\nbase (float): The base to which the decimal number is to be converted.\n\nReturns:\nstr...
[ 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def decimal_to_base(n, base):\n \"\"\"\n Convert a decimal number to a specified base (between 2 and 36).\n Handles both integer and non-integer bases (rounded to nearest whole numbe...
trial_gpt4o_9
{ "original_instruction": "Write a python function to convert a decimal number to a specified base (between 2 and 36). The function should handle decimal numbers, both positive and negative, as well as numbers with fractional parts. The function should also be able to handle non-integer bases, such as 2.5, by roundin...
0.743576
Prefill_30448
C
[ "decimal_to_base", "convert_integral_part", "convert_fractional_part" ]
3
[ [ "decimal_to_base", "convert_fractional_part" ], [ "decimal_to_base", "convert_integral_part" ] ]
2
[]
false
[]
false
pytest
true
[]
true
09c51caa7efd4a9036469ec78e7763eb72ca46b9
fb83ca5dcfc2c26f3e1c14d143c03bfa7288160c
v1.0
complete
Prefill
Prefill_30860_C
def sum_of_primes(start: int, end: int) -> int: """ Calculate the sum of all prime numbers within a given range. >>> sum_of_primes(1, 10) == 17 # 2, 3, 5, 7 are primes >>> sum_of_primes(10, 20) == 60 # 11, 13, 17, 19 are primes >>> sum_of_primes(1, 5) == 10 # 2, 3, 5 are primes >>> sum_of_primes(...
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def sum_of_pr...
from solution import sum_of_primes def test_sum_of_primes_within_range(): assert sum_of_primes(1, 10) == 17 # 2, 3, 5, 7 are primes assert sum_of_primes(10, 20) == 60 # 11, 13, 17, 19 are primes assert sum_of_primes(1, 5) == 10 # 2, 3, 5 are primes def test_sum_of_primes_no_primes(): assert sum_of_...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the range [start, end].", "function_declaration": "def sum_of_p...
[ 1, 1, 0, 1, 1, 0, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is prime, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n %...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the sum of all prime numbers within a given range. The function takes two integers `start` and `end` as input and returns the sum of prime numbers between `start` and `end` (inclusive).", "prompt_id": "00030860", "row_id": 30860, "seed_ids": "['mag...
0.719941
Prefill_30860
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bac3e88a2aa819c8a79de88eb3900d1d8e77c35a
2a52103f0b27a42e604ecda715a1b3032006223e
v1.0
complete
Prefill
Prefill_31039_C
def bucket_sort(arr): """ Sorts an array using bucket sort algorithm. >>> bucket_sort([]) == [] >>> bucket_sort([42]) == [42] >>> bucket_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] >>> bucket_sort([4, 1, 3, 5, 2]) == [1, 2, 3, 4, 5] >>> bucket_sort([4, 1, 3, 5, 1]) == [1, 1, 3, 4, 5] """ ...
def bucket_sort(arr): """ Sorts an array using bucket sort algorithm. """ if len(arr) == 0: return arr # Determine minimum and maximum values min_value = min(arr) max_value = max(arr) # Number of buckets bucket_count = len(arr) buckets = [[] for _ in range(bucket_count)...
from solution import bucket_sort, radix_sort def test_bucket_sort_empty(): assert bucket_sort([]) == [] def test_bucket_sort_single_element(): assert bucket_sort([42]) == [42] def test_bucket_sort_sorted(): assert bucket_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_bucket_sort_unsorted(): asser...
[ { "docstring": "Sorts an array using bucket sort algorithm.", "function_declaration": "def bucket_sort(arr):", "function_name": "bucket_sort", "parameter_list": "(arr)" }, { "docstring": "Sorts an array using radix sort algorithm with bucket sort as subroutine.", "function_declaration": ...
[ 0, 0, 0, 1, 1, 1, 0, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def counting_sort(arr, exp):\n n = len(arr)\n output = [0] * n \n count = [0] * 10\n\n for i in range(n):\n index = (arr[i] // exp) % 10\n count[index] += 1\n\n f...
trial_gpt4o_5
{ "original_instruction": "Write a python function to sort an array and then solve a radix sort algorithm using bucket sort as a subroutine.", "prompt_id": "00031039", "row_id": 31039, "seed_ids": "['magpie_prefill_31039']" }
0.609454
Prefill_31039
C
[ "bucket_sort", "radix_sort", "counting_sort_by_digit" ]
3
[ [ "radix_sort", "counting_sort_by_digit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aa998489e12b37a16a420ab4ab1bccca437803b8
5a9e82b7cfda00ff508d5048327188fb67da669e
v1.0
complete
Prefill
Prefill_32072_C
def is_anti_prime(num: int) -> bool: """ Check if a number is anti-prime (highly composite). An anti-prime is a positive integer with more divisors than any smaller positive integer. >>> is_anti_prime(1) == True >>> is_anti_prime(2) == True >>> is_anti_prime(3) == False >>> is_anti_prime(4)...
def count_divisors(n): """ Helper function to count the number of divisors of n. """ count = 0 for i in range(1, n+1): if n % i == 0: count += 1 return count def is_anti_prime(num): """ Returns True if num is an anti-prime, False otherwise. An anti-prime (or high...
from solution import is_anti_prime def test_is_anti_prime_1(): assert is_anti_prime(1) == True def test_is_anti_prime_2(): assert is_anti_prime(2) == True def test_is_anti_prime_3(): assert is_anti_prime(3) == False def test_is_anti_prime_4(): assert is_anti_prime(4) == True def test_is_anti_prime_...
[ { "docstring": "Helper function to count the number of divisors of n.", "function_declaration": "def count_divisors(n):", "function_name": "count_divisors", "parameter_list": "(n)" }, { "docstring": "Returns True if num is an anti-prime, False otherwise.\nAn anti-prime (or highly composite n...
[ 1, 1, 1, 1, 1, 0, 1, 1, 0, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_anti_prime(n):\n \"\"\"\n Returns True if the given number is anti-prime, otherwise False.\n \"\"\"\n if n <= 0:\n return False\n\n def count_divisors(x):\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to check if a number is anti-prime. An anti-prime (or highly composite number) is a positive integer with more divisors than any smaller positive integer. The function should take an integer as input and return True if it is anti-prime, False otherwise.", "prompt_i...
0.789782
Prefill_32072
C
[ "count_divisors", "is_anti_prime" ]
2
[ [ "is_anti_prime", "count_divisors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8680b058fe3a405e4ac6d1f9ad1a8072fe6f07e1
5e38a5d1edd38112d6dc53597bc329d06b6fbbfd
v1.0
complete
Prefill
Prefill_32174_C
def is_prime(n: int) -> bool: """Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False """ pass def sum_of_first_100_primes() -> int: """ Calculate and return the sum of the first 100 prime numbers. >>> sum_of_first_100_primes() 24133 ...
def is_prime(n): """Check if a number is a prime number.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def sum_of_first_100_primes(): ""...
from solution import is_prime, sum_of_first_100_primes def test_is_prime(): # Test known prime numbers assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(11) == True assert is_prime(13) == True # Test known non-prime numbers assert is_prime...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculate and return the sum of the first 100 prime numbers.", "function_declaration": "def sum_of_first_100_primes()...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even prime number\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the first 100 prime numbers and sum them up. The user should be able to run this function directly and print out the result. Please add comments for code understanding.", "prompt_id": "00032174", "row_id": 32174, "seed_ids": "['magpie_prefill_32174...
0.762361
Prefill_32174
C
[ "is_prime", "sum_of_first_100_primes" ]
2
[ [ "sum_of_first_100_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
05452fde55ee9c0122424ee07a7ce04bd0bfb8d9
d6c51db90daf9b890e8a8b753950a46d67c5cfd8
v1.0
complete
Prefill
Prefill_31785_C
def is_prime(n): """ Helper function to determine if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(29) == True >>> is_prime(30) == False >>> is_prime(1) == False """ pass def find_primes_in_interval(l, r): """ Re...
def is_prime(n): """ Helper function to determine 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 ...
from solution import find_primes_in_interval, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(30) == False assert is_prime(1) == False def test_find_primes_in_interval_short_range(): ...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers in the interval [l, r].", "function_declaration": "def find_primes_...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_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_8
{ "original_instruction": "Write a python function to find all the prime numbers within an interval [l, r].", "prompt_id": "00031785", "row_id": 31785, "seed_ids": "['magpie_prefill_31785']" }
0.801224
Prefill_31785
C
[ "is_prime", "find_primes_in_interval" ]
2
[ [ "find_primes_in_interval", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a10bdba3f8abc18bf576d6a18b9f6caa37831d62
cd347407deaba2bd76081677748d49d9f0232dd7
v1.0
complete
Prefill
Prefill_32585_C
def min_knight_moves(n: int, start: (int, int), target: (int, int)) -> int: """ Returns the minimum number of knight moves required to reach the target square from the starting square on an n x n chessboard. >>> min_knight_moves(8, (0, 0), (0, 0)) == 0 >>> min_knight_moves(8, (0, 0), (1, 2)) == 1 ...
from collections import deque def is_valid_move(x, y, n): """ Check if the given position (x, y) is within the bounds of the board. """ return 0 <= x < n and 0 <= y < n def min_knight_moves(n, start, target): """ Returns the minimum number of knight moves required to reach the target squa...
from solution import min_knight_moves def test_min_knight_moves_same_square(): assert min_knight_moves(8, (0, 0), (0, 0)) == 0 def test_min_knight_moves_standard_case(): assert min_knight_moves(8, (0, 0), (1, 2)) == 1 def test_min_knight_moves_two_moves(): assert min_knight_moves(8, (0, 0), (2, 4)) == 2 ...
[ { "docstring": "Check if the given position (x, y) is within the bounds of the board.", "function_declaration": "def is_valid_move(x, y, n):", "function_name": "is_valid_move", "parameter_list": "(x, y, n)" }, { "docstring": "Returns the minimum number of knight moves required to reach \nthe...
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_within_bounds(x, y):\n \"\"\"\n Check if (x, y) is within the bounds of an 8x8 chessboard.\n \"\"\"\n return 0 <= x < 8 and 0 <= y < 8\n\nd...
trial_gpt4o_2
{ "original_instruction": "Write a python function to solve a puzzle involving chess knights that can move in an \"L\" shape on a chessboard. The function should determine if a knight, starting from a given square, can reach a target square by making a series of legal knight moves. The function should also return the...
0.727912
Prefill_32585
C
[ "is_valid_move", "min_knight_moves" ]
2
[ [ "min_knight_moves", "is_valid_move" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a0c0a67dae1cd78904dc48fb64122d016e5a8806
d67c32eeb5192a7e71612d3ac5d84a33f17a1da3
v1.0
complete
Prefill
Prefill_32661_C
def generate_primes(start: int, end: int) -> List[int]: """ Generate a list of prime numbers between a given range [start, end]. >>> generate_primes(10, 20) [11, 13, 17, 19] >>> generate_primes(1, 10) [2, 3, 5, 7] >>> generate_primes(21, 30) [23, 29] >>> generate_primes(29, 29) [29] ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def generate_primes(start, end): """ Returns a list of prime numbers between the...
from solution import generate_primes def test_primes_in_range_10_20(): assert generate_primes(10, 20) == [11, 13, 17, 19] def test_primes_in_range_1_10(): assert generate_primes(1, 10) == [2, 3, 5, 7] def test_primes_in_range_21_30(): assert generate_primes(21, 30) == [23, 29] def test_primes_in_range_s...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers between the given range [start, end].", "function_declaration": "def ge...
[ 1, 1, 1, 1, 1, 1, 0, 0, 0, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is a prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to generate a list of prime numbers between a given range. For example, if the range is between 10 and 20, the list should return [11, 13, 17, 19].", "prompt_id": "00032661", "row_id": 32661, "seed_ids": "['magpie_prefill_32661']" }
0.679366
Prefill_32661
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d81a53ab37e2a8dac907e1051de9e90c01fbca85
5aaab6c089a1d11095f34dd09615ef123501a1da
v1.0
complete
Prefill
Prefill_32550_C
def is_prime(n: int) -> bool: """ Checks if a number n is prime. """ def filter_primes(numbers: List[int]) -> List[int]: """ Filters out and returns a list of prime numbers from the given list of integers using list comprehension. >>> filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) [2, 3, 5, 7] >>>...
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def filter_primes(numbers): """ Filters and returns a list of prime numbers from the given list of inte...
from solution import filter_primes def test_filter_primes_with_mixed_numbers(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_with_no_primes(): assert filter_primes([4, 6, 8, 10, 12, 14]) == [] def test_filter_primes_with_only_primes(): assert filter_primes([2,...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters and returns a list of prime numbers from the given list of integers.", "function_declaration": "def filter_primes(n...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if an integer n is a prime number.\n Returns True if n is prime, else False.\n \"\"\"\n if n <= 1:\n return False\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to filter out and return all prime numbers from a given list of integers, using list comprehension.", "prompt_id": "00032550", "row_id": 32550, "seed_ids": "['magpie_prefill_32550']" }
0.772145
Prefill_32550
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
26b3750b4ed9f16ccc258d5f760be97a877ee743
72d9246e5bd6b920bd53b1a3ef9a6491cf714cf6
v1.0
complete
Prefill
Prefill_31490_C
import math from typing import List def is_perfect_square(n: int) -> bool: """ Returns True if n is a perfect square, otherwise False. """ pass def filter_perfect_squares(numbers: List[int]) -> List[int]: """ Filters out numbers that are not perfect squares from the given list of integers. ...
import math def is_perfect_square(n): """ Returns True if n is a perfect square, otherwise False. """ if n < 0: return False return math.isqrt(n) ** 2 == n def filter_perfect_squares(numbers): """ Filters out numbers that are not perfect squares from the given list of integers. ...
from solution import filter_perfect_squares def test_filter_all_perfect_squares(): assert filter_perfect_squares([1, 4, 9, 16, 25]) == [1, 4, 9, 16, 25] def test_filter_no_perfect_squares(): assert filter_perfect_squares([2, 3, 5, 7, 8]) == [] def test_filter_mixed_numbers(): assert filter_perfect_square...
[ { "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": "Filters out numbers that are not perfect squares from the given list of integers.\n\...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef filter_perfect_squares(numbers):\n \"\"\"\n Filters out numbers that are not perfect squares from the given list of integers.\n \n :param numbers: List of integ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to filter out numbers that are not perfect squares from a given list of integers.", "prompt_id": "00031490", "row_id": 31490, "seed_ids": "['magpie_prefill_31490']" }
0.655539
Prefill_31490
C
[ "is_perfect_square", "filter_perfect_squares" ]
2
[ [ "filter_perfect_squares", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
932dca49dc3857646d08836d198ca83921e5441d
310560eb4d3cd090a9d478cc788268687aeb96a8
v1.0
complete
Prefill
Prefill_32654_C
from math import sqrt def is_valid_triangle(a: float, b: float, c: float) -> bool: """ Check if three sides can form a valid triangle. >>> is_valid_triangle(3, 4, 5) True >>> is_valid_triangle(1, 1, 2) False """ def triangle_area(a: float, b: float, c: float) -> float: """ ...
from math import sqrt def is_valid_triangle(a, b, c): """ Check if three sides can form a valid triangle. """ return a + b > c and a + c > b and b + c > a def triangle_area(a, b, c): """ Calculate the area of a triangle given the lengths of its three sides using Heron's formula. Ensure the...
import pytest from solution import is_valid_triangle, triangle_area def test_is_valid_triangle(): assert is_valid_triangle(3, 4, 5) == True assert is_valid_triangle(1, 1, 2) == False assert is_valid_triangle(5, 5, 5) == True assert is_valid_triangle(10, 1, 1) == False def test_triangle_area(): ass...
[ { "docstring": "Check if three sides can form a valid triangle.", "function_declaration": "def is_valid_triangle(a, b, c):", "function_name": "is_valid_triangle", "parameter_list": "(a, b, c)" }, { "docstring": "Calculate the area of a triangle given the lengths of its three sides using Hero...
[ 0, 1, 0, 0, 0, 1, 1, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef validate_triangle_sides(a, b, c):\n \"\"\"\n Validate if the given sides can form a triangle using the triangle inequality theorem.\n \"\"\"\n return a + b > c ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the area of a triangle given the lengths of its three sides. Use Heron's formula. The function should also check if the input sides can form a valid triangle before calculating the area.", "prompt_id": "00032654", "row_id": 32654, "seed_ids": "['ma...
0.898132
Prefill_32654
C
[ "is_valid_triangle", "triangle_area" ]
2
[ [ "triangle_area", "is_valid_triangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2e29afebf0293a50d2879180848e68aa3a015e2d
7c3cbd5f58d2fec122bfb3e21346fba8e7897e31
v1.0
complete
Prefill
Prefill_33477_C
def factorial(n): """ Returns the factorial of a given number n. >>> factorial(0) == 1 >>> factorial(1) == 1 >>> factorial(2) == 2 >>> factorial(3) == 6 >>> factorial(4) == 24 >>> factorial(5) == 120 """ def calculate_factorials_up_to_5(): """ Calculates the factorial of num...
def factorial(n): """ Returns the factorial of a given number n. """ if n == 0: return 1 result = 1 for i in range(1, n + 1): result *= i return result def calculate_factorials_up_to_5(): """ Calculates the factorial of numbers from 1 to 5 and returns a list of the r...
from solution import factorial, calculate_factorials_up_to_5 def test_factorial(): assert factorial(0) == 1 assert factorial(1) == 1 assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 assert factorial(5) == 120 def test_calculate_factorials_up_to_5(): assert calcul...
[ { "docstring": "Returns the factorial of a given number n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Calculates the factorial of numbers from 1 to 5 and returns a list of the results.", "function_declaration": ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorial(n):\n \"\"\"\n Returns the factorial of n.\n \"\"\"\n if n == 0 or n == 1:\n return 1\n else:\n return n * factorial(n - 1)\n\ndef factorials_in_ran...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the factorial of a number and then use this function in a loop to calculate the factorial of numbers from 1 to 5.", "prompt_id": "00033477", "row_id": 33477, "seed_ids": "['magpie_prefill_33477']" }
0.73345
Prefill_33477
C
[ "factorial", "calculate_factorials_up_to_5" ]
2
[ [ "calculate_factorials_up_to_5", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fd7852eaab98ef657348a4694f44215bc082c8bc
658eb7771ca3c6e2516af04c862cdde6be9a114f
v1.0
complete
Prefill
Prefill_32608_C
def number_of_days_in_month(year: int, month: int) -> int: """ Returns the number of days in a given month and year. >>> number_of_days_in_month(2000, 2) 29 >>> number_of_days_in_month(1900, 2) 28 >>> number_of_days_in_month(2020, 4) 30 >>> number_of_days_in_month(2020, 1) 3...
def number_of_days_in_month(year, month): """ Returns the number of days in a given month and year. """ if month < 1 or month > 12: raise ValueError("Invalid month. Month should be between 1 and 12.") # Days in each month (index 1-based for months 1 to 12) month_days = [0, 31, 28, 31, 3...
from solution import number_of_days_in_month, is_leap_year def test_is_leap_year(): assert is_leap_year(2000) == True assert is_leap_year(1900) == False assert is_leap_year(2004) == True assert is_leap_year(2001) == False def test_number_of_days_in_month(): # February in leap year assert numbe...
[ { "docstring": "Returns the number of days in a given month and year.", "function_declaration": "def number_of_days_in_month(year, month):", "function_name": "number_of_days_in_month", "parameter_list": "(year, month)" }, { "docstring": "Returns True if the given year is a leap year, False o...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def days_in_month(year, month):\n \"\"\"\n Returns the number of days in the given month and year.\n \n Args:\n year (int): The year.\n month (int): The month (1 to 12).\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the number of days in a given month and year. The function should handle both leap years and non-leap years. A typical non-leap year has 365 days, and a leap year has 366 days. The leap year condition is that the year is divisible by 4, except for years which...
0.607292
Prefill_32608
C
[ "number_of_days_in_month", "is_leap_year" ]
2
[ [ "number_of_days_in_month", "is_leap_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00b2f3f97f9b7af2ec9a592f35059139852de0b5
31e69a797d05bac3dc999383d02242960488105b
v1.0
complete
Prefill
Prefill_33282_C
def insert_at_bottom(stack, item): """ Helper function that inserts an item at the bottom of a stack using recursion. """ pass def reverse_stack(stack): """ Reverses a stack using recursion. >>> reverse_stack([]) == [] >>> reverse_stack([1]) == [1] >>> reverse_stack([1, 2]) == [2, 1...
def insert_at_bottom(stack, item): """ Helper function that inserts an item at the bottom of a stack using recursion. """ if not stack: stack.append(item) else: temp = stack.pop() insert_at_bottom(stack, item) stack.append(temp) def reverse_stack(stack): """ ...
from solution import reverse_stack def test_reverse_stack_empty(): assert reverse_stack([]) == [] def test_reverse_stack_single_element(): assert reverse_stack([1]) == [1] def test_reverse_stack_two_elements(): assert reverse_stack([1, 2]) == [2, 1] def test_reverse_stack_multiple_elements(): assert...
[ { "docstring": "Helper function that inserts an item at the bottom of a stack using recursion.", "function_declaration": "def insert_at_bottom(stack, item):", "function_name": "insert_at_bottom", "parameter_list": "(stack, item)" }, { "docstring": "Reverses a stack using recursion.", "fu...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def insert_at_bottom(stack, item):\n \"\"\"\n Helper function to insert an item at the bottom of a stack.\n \"\"\"\n if not stack:\n stack.append(item)\n else:\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to reverse a stack using recursion without the use of auxiliary stack.", "prompt_id": "00033282", "row_id": 33282, "seed_ids": "['magpie_prefill_33282']" }
0.533348
Prefill_33282
C
[ "insert_at_bottom", "reverse_stack" ]
2
[ [ "reverse_stack", "insert_at_bottom" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9e950604bf94e58ef7b0a78ae05d237637ff162b
82a2b95c3885b2de83f49b0f57c4d8b38968d527
v1.0
complete
Prefill
Prefill_32618_C
class TreeNode: def __init__(self, key): self.left = None self.right = None self.value = key def get_depth(node): """ Helper function to get the depth of the leftmost path in the tree. """ depth = 0 while node is not None: depth += 1 node = node.left return d...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.value = key def get_depth(node): depth = 0 while node is not None: depth += 1 node = node.left return depth def is_perfect_binary_tree(root, depth, level=0): if root is None: ...
from solution import TreeNode, check_perfect_binary_tree def test_perfect_binary_tree(): # Constructing a perfect binary tree root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(3) root.left.left = TreeNode(4) root.left.right = TreeNode(5) root.right.left = TreeNode(6) root...
[]
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\n\ndef is_perfect_binary_tree(root: TreeNode) -> bool:\n if not roo...
trial_gpt4o_8
{ "original_instruction": "Write a python function to check if a number in a binary tree is a perfect binary tree or not. In a perfect binary tree, all internal nodes have two children and all leaves are at the same level.", "prompt_id": "00032618", "row_id": 32618, "seed_ids": "['magpie_prefill_32618']" }
0.649205
Prefill_32618
C
[ "get_depth", "is_perfect_binary_tree", "check_perfect_binary_tree" ]
3
[ [ "check_perfect_binary_tree", "get_depth" ], [ "check_perfect_binary_tree", "is_perfect_binary_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
bb8857742014e90713de21b5625e4249f873ae9b
22f041ebbb3dcbd75dd5b7c7f25c7a6fcab1cacf
v1.0
complete
Prefill
Prefill_32755_C
def levenshtein_distance(word1: str, word2: str) -> int: """ Calculates the Levenshtein distance between two words. >>> levenshtein_distance("kitten", "kitten") 0 >>> levenshtein_distance("kitten", "kittens") 1 >>> levenshtein_distance("kitten", "sitten") 1 >>> levenshtein_distance("...
def levenshtein_distance(word1, word2): """ Calculates the Levenshtein distance between two words. """ len1, len2 = len(word1), len(word2) dp = [[0] * (len2 + 1) for _ in range(len1 + 1)] for i in range(len1 + 1): dp[i][0] = i for j in range(len2 + 1): dp[0][j] = j ...
from solution import levenshtein_distance, closest_word def test_levenshtein_distance_same_words(): assert levenshtein_distance("kitten", "kitten") == 0 def test_levenshtein_distance_one_insertion(): assert levenshtein_distance("kitten", "kittens") == 1 def test_levenshtein_distance_one_substitution(): a...
[ { "docstring": "Calculates the Levenshtein distance between two words.", "function_declaration": "def levenshtein_distance(word1, word2):", "function_name": "levenshtein_distance", "parameter_list": "(word1, word2)" }, { "docstring": "Finds the word in the sentence that is closest to the tar...
[ 0, 0, 1, 0, 0, 0, 1, 0, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef levenshtein_distance(word1, word2):\n \"\"\"\n Calculate the Levenshtein distance between two words.\n \"\"\"\n if len(word1) < len(word2):\n return...
trial_gpt4o_9
{ "original_instruction": "Write a python function to identify a word in a sentence that is closest to the given word in terms of Levenshtein distance. Levenshtein distance is the minimum number of single-character edits (insertions, deletions or substitutions) required to change a word into the other.", "prompt_id...
0.669726
Prefill_32755
C
[ "levenshtein_distance", "closest_word" ]
2
[ [ "closest_word", "levenshtein_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a0a934d140599c8925b2656b173dd5ed3991ecfe
2862f2f49c0d1ecf9d3336b4ea6e5ecd0a8833e4
v1.0
complete
Prefill
Prefill_33245_C
def prefix_to_infix(prefix_expression: str) -> str: """ Convert a prefix expression to an equivalent infix expression. >>> prefix_to_infix("+AB") "(A+B)" >>> prefix_to_infix("*+AB-CD") "((A+B)*(C-D))" >>> prefix_to_infix("-+A*BCD") "((A+(B*C))-D)" >>> prefix_to_infix("A") "A" >>>...
def is_operator(c): return c in "+-*/" def prefix_to_infix(prefix_expression): stack = [] # Read the prefix expression in reverse order for ch in prefix_expression[::-1]: if is_operator(ch): # Pop two operands from stack op1 = stack.pop() op2 = stack.pop...
from solution import prefix_to_infix def test_simple_expression(): assert prefix_to_infix("+AB") == "(A+B)" def test_expression_with_multiple_operators(): assert prefix_to_infix("*+AB-CD") == "((A+B)*(C-D))" def test_expression_with_same_operators(): assert prefix_to_infix("-+A*BCD") == "((A+(B*C))-D)" ...
[ { "docstring": null, "function_declaration": "def is_operator(c):", "function_name": "is_operator", "parameter_list": "(c)" }, { "docstring": null, "function_declaration": "def prefix_to_infix(prefix_expression):", "function_name": "prefix_to_infix", "parameter_list": "(prefix_ex...
[ 1, 0, 1, 0, 0, 1, 0, 0, 1, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_operator(c):\n \"\"\"\n Check if the character is an operator.\n \"\"\"\n return c in {'+', '-', '*', '/', '^'}\n\ndef prefix_to_infix(expression):\n \"\"\"\n Convert...
trial_gpt4o_9
{ "original_instruction": "Write a python function to convert prefix to infix. Given a Prefix expression, write a function to convert it to an equivalent Infix expression. The prefix expression is in the form of a string.", "prompt_id": "00033245", "row_id": 33245, "seed_ids": "['magpie_prefill_33245']" }
0.581555
Prefill_33245
C
[ "is_operator", "prefix_to_infix" ]
2
[ [ "prefix_to_infix", "is_operator" ] ]
1
[]
false
[]
false
pytest
true
[]
true
280d6da488396d69ae2688be28dedb7f4cc870f1
5053faef78bd2d0104f4b48d6ff370a0c36ef0b9
v1.0
complete
Prefill
Prefill_33663_C
from math import isqrt from typing import List def is_prime(n: int) -> bool: """ Helper function to check if a number n is prime. """ pass def is_magical_triplet_number(n: int) -> bool: """ Returns True if the input number n is a Magical Triplet number. A Magical Triplet number is defined as a per...
from math import isqrt def is_prime(n): """ Helper function to check if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, isqrt(n) + 1, 2): if n % i == 0: return False return ...
from solution import is_magical_triplet_number def test_prime_square(): assert is_magical_triplet_number(4) == True # 2^2 assert is_magical_triplet_number(9) == True # 3^2 assert is_magical_triplet_number(25) == True # 5^2 def test_non_prime_square(): assert is_magical_triplet_number(8) == Fal...
[ { "docstring": "Helper function to check if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns True if the input number n is a Magical Triplet number.\nA Magical Triplet number is defined as a per...
[ 0, 1, 0, 0, 1, 1, 0, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % ...
trial_gpt4o_4
{ "original_instruction": "Write a python function to check if the input number is a Magical Triplet number or not. A Magical Triplet number is defined as a perfect square of a prime number. Your function should return `True` if the number is a Magical Triplet number, and `False` otherwise.", "prompt_id": "00033663...
0.70282
Prefill_33663
C
[ "is_prime", "is_magical_triplet_number" ]
2
[ [ "is_magical_triplet_number", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed6b7fe62722b1db01752d18c847e2b4aab0966a
b0ef9280bf29d8c11f8d93d9964eadceecb0837c
v1.0
complete
Prefill
Prefill_33236_C
from typing import List def merge_sort_desc(lst: List[int]) -> List[int]: """ Sorts the given list in descending order using the merge sort algorithm. >>> merge_sort_desc([]) == [] True >>> merge_sort_desc([1]) == [1] True >>> merge_sort_desc([5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1] True ...
def merge_sort_desc(lst): """ Sorts the given list in descending order using the merge sort algorithm. """ if len(lst) <= 1: return lst mid = len(lst) // 2 left_half = merge_sort_desc(lst[:mid]) right_half = merge_sort_desc(lst[mid:]) return merge_desc(left_half, right_...
from solution import merge_sort_desc def test_merge_sort_desc_empty(): assert merge_sort_desc([]) == [] def test_merge_sort_desc_single_element(): assert merge_sort_desc([1]) == [1] def test_merge_sort_desc_sorted(): assert merge_sort_desc([5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1] def test_merge_sort_desc_rev...
[ { "docstring": "Sorts the given list in descending order using the merge sort algorithm.", "function_declaration": "def merge_sort_desc(lst):", "function_name": "merge_sort_desc", "parameter_list": "(lst)" }, { "docstring": "Merges two lists into one in descending order.", "function_decl...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort_descending(arr):\n \"\"\"\n Sorts the given list in descending order using the merge sort algorithm.\n \n Args:\n arr (list): List of elements to sort.\n \n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to sort a given list in descending order using merge sort algorithm.", "prompt_id": "00033236", "row_id": 33236, "seed_ids": "['magpie_prefill_33236']" }
0.636152
Prefill_33236
C
[ "merge_sort_desc", "merge_desc" ]
2
[ [ "merge_sort_desc", "merge_desc" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d8ca7aabba9f33fdc4d5b92d0952c637607bb7c0
e08b7615e4f636984a40ee5d3a56feff699f610e
v1.0
complete
Prefill
Prefill_33467_C
def determine_string_type(s: str) -> str: """ Write a python function to determine if a given string is a palindrome, a permutation of a palindrome, or neither. >>> determine_string_type("A man a plan a canal Panama") "palindrome" >>> determine_string_type("racecar") "palindrome" >>> determine_strin...
from collections import Counter def is_palindrome(s): """ Check if the given string is a palindrome. """ s = s.replace(" ", "").lower() return s == s[::-1] def can_form_palindrome(s): """ Check if any permutation of the given string can form a palindrome. """ s = s.replace(" ", "")...
from solution import determine_string_type def test_palindrome(): assert determine_string_type("A man a plan a canal Panama") == "palindrome" assert determine_string_type("racecar") == "palindrome" assert determine_string_type("madam") == "palindrome" assert determine_string_type("Never Odd Or Even") =...
[ { "docstring": "Check if the given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Check if any permutation of the given string can form a palindrome.", "function_declaration": "def ca...
[ 0, 0, 1, 1, 1, 0, 0, 1, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef is_palindrome(s):\n \"\"\"\n Checks if the given string is a palindrome.\n \"\"\"\n s = ''.join(filter(str.isalnum, s)).lower()\n return ...
trial_gpt4o_7
{ "original_instruction": "Write a python function to determine if a given string is a palindrome, a permutation of a palindrome, or neither.", "prompt_id": "00033467", "row_id": 33467, "seed_ids": "['magpie_prefill_33467']" }
0.813594
Prefill_33467
C
[ "is_palindrome", "can_form_palindrome", "determine_string_type" ]
3
[ [ "determine_string_type", "can_form_palindrome" ], [ "determine_string_type", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
db4a12c34aefeea5160ccb30fea0c2f6e9098a15
2e7df38921cac95cfc99078b5cace7c025ac2b69
v1.0
complete
Prefill
Prefill_33430_C
from typing import List def find_primes_between(a: int, b: int) -> List[int]: """ Finds all prime numbers between two given non-negative numbers a and b (inclusive). Returns a list of prime numbers in the range [a, b]. >>> find_primes_between(10, 20) == [11, 13, 17, 19] >>> find_primes_between...
def is_prime(n): """ Check if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def find_primes_between(a, b): ...
from solution import find_primes_between def test_find_primes_between_10_and_20(): assert find_primes_between(10, 20) == [11, 13, 17, 19] def test_find_primes_between_1_and_10(): assert find_primes_between(1, 10) == [2, 3, 5, 7] def test_find_primes_between_20_and_30(): assert find_primes_between(20, 30)...
[ { "docstring": "Check if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds all prime numbers between two given non-negative numbers a and b (inclusive).\nReturns a list of prime numbers in the rang...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_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_9
{ "original_instruction": "Write a python function to find all prime numbers between two given numbers. In this function, the function input will always be two positive non-negative numbers. The function output will be a list of all prime numbers between the given range.", "prompt_id": "00033430", "row_id": 33430...
0.658216
Prefill_33430
C
[ "is_prime", "find_primes_between" ]
2
[ [ "find_primes_between", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
002174fc8223b104e498a4a9b4e95c414bde3147
63319a27e26073ae26eb4b2f4cd2375fb8eb5cdc
v1.0
complete
Prefill
Prefill_32200_C
from typing import List def merge_sort(arr: List[int]) -> List[int]: """ Implements the merge sort algorithm. Takes a list of integers and returns the sorted list. """ def merge(left: List[int], right: List[int]) -> List[int]: """ Merges two sorted lists into a single sorted list. """ def...
def merge_sort(arr): """ Implements the merge sort algorithm. Takes a list of integers and returns the sorted list. """ 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)...
from solution import merge_sort def test_merge_sort_empty_list(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_ordered_elements(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_ordered_elements(): ...
[ { "docstring": "Implements the merge sort algorithm. \nTakes a list of integers and returns the sorted list.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted lists into a single sorted list.", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Implement merge sort algorithm to sort a list of integers.\n \n Parameters:\n arr (list): List of integers to be sorted.\n \n Returns:\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to implement merge sort algorithm. Merge Sort uses a divide-and-conquer approach to sort an array. It splits the array into two halves, recursively sorts them, and then merges them back together. The function should take a list of integers as input and return the sor...
0.613978
Prefill_32200
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
144aa6df79b0a1c019ebe05e099c2dc5fbe67b6a
defe5b45405987d7b9f2d3efc074d90b269265fd
v1.0
complete
Prefill
Prefill_33585_C
from typing import List from math import gcd from functools import reduce def lcm(a, b): """ Returns the least common multiple of a and b. """ return a * b // gcd(a, b) def find_smallest_divisible(n: int) -> int: """Returns the smallest positive number that is evenly divisible by all the numbers f...
from math import gcd from functools import reduce def lcm(a, b): """ Returns the least common multiple of a and b. """ return a * b // gcd(a, b) def find_smallest_divisible(n): """ Returns the smallest positive number that is evenly divisible by all the numbers from 1 to n. """ return ...
from solution import find_smallest_divisible def test_find_smallest_divisible_1(): assert find_smallest_divisible(1) == 1 def test_find_smallest_divisible_2(): assert find_smallest_divisible(2) == 2 def test_find_smallest_divisible_3(): assert find_smallest_divisible(3) == 6 def test_find_smallest_divis...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest positive number that is evenly divisible by all the numbers from 1 to n.", "function_declar...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef find_smallest_divisible(n):\n \"\"\"\n Returns the smallest positive number that is evenly divisible by all the numbers from 1 to n.\n \"\"\"\n def lcm(a, b):\n...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the smallest positive number that is evenly divisible by all the numbers from 1 to n, where n is a positive integer provided by the user. The function should be named `find_smallest_divisible` and take one parameter `n`.", "prompt_id": "00033585", "row_id...
0.710274
Prefill_33585
C
[ "lcm", "find_smallest_divisible" ]
2
[ [ "find_smallest_divisible", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
af4d8ddfaf1397c8886f8d9211ae5b6b0e327732
6a7340de4f7f292df523543748ab401482564681
v1.0
complete
Prefill
Prefill_32532_C
def is_prime(n): """Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False >>> is_prime(19) True """ def sum_of_digits(n): """Calculate the sum of digits of a number. >...
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 sum_...
from solution import is_prime, sum_of_digits, prime_numbers_with_digit_sums def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True def test_sum_of_digits(): ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculate the sum of digits of a number.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digit...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:...
trial_gpt4o_9
{ "original_instruction": "Write a python function to identify prime numbers within a given range. Additionally, for each prime number identified, calculate and return the sum of its digits.", "prompt_id": "00032532", "row_id": 32532, "seed_ids": "['magpie_prefill_32532']" }
0.750622
Prefill_32532
C
[ "is_prime", "sum_of_digits", "prime_numbers_with_digit_sums" ]
3
[ [ "prime_numbers_with_digit_sums", "is_prime" ], [ "prime_numbers_with_digit_sums", "sum_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a048a7178cc9f9b17f867c8620cefb5d8d742dd8
44705394610731ae70155566cec614ca22c275b8
v1.0
complete
Prefill
Prefill_33127_C
def next_number_with_prime_digits(n: int) -> int: """ Find the smallest number greater than a given number that is composed only of prime digits (2, 3, 5, 7). >>> next_number_with_prime_digits(1) == 2 >>> next_number_with_prime_digits(2) == 3 >>> next_number_with_prime_digits(35) == 37 >>> next_numb...
def is_prime_digit(num): """ Check if the given number is composed only of prime digits (2, 3, 5, 7). """ prime_digits = {'2', '3', '5', '7'} return all(char in prime_digits for char in str(num)) def next_number_with_prime_digits(n): """ Find the smallest number greater than n that is compo...
from solution import next_number_with_prime_digits def test_next_number_small_input(): assert next_number_with_prime_digits(1) == 2 assert next_number_with_prime_digits(2) == 3 def test_next_number_larger_input(): assert next_number_with_prime_digits(35) == 37 assert next_number_with_prime_digits(57) ...
[ { "docstring": "Check if the given number is composed only of prime digits (2, 3, 5, 7).", "function_declaration": "def is_prime_digit(num):", "function_name": "is_prime_digit", "parameter_list": "(num)" }, { "docstring": "Find the smallest number greater than n that is composed only of prim...
[ 1, 0, 0, 0, 1, 1, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def next_prime_digit_number(n):\n \"\"\"\n Returns the smallest number greater than n that is composed only of prime digits (2, 3, 5, 7).\n \"\"\"\n prime_digits = {'2', '3', '5',...
trial_gpt4o_8
{ "original_instruction": "Write a python function to find the smallest number greater than a given number that is composed only of prime digits (2, 3, 5, 7).", "prompt_id": "00033127", "row_id": 33127, "seed_ids": "['magpie_prefill_33127']" }
0.720141
Prefill_33127
C
[ "is_prime_digit", "next_number_with_prime_digits" ]
2
[ [ "next_number_with_prime_digits", "is_prime_digit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
60895d1ebc3aec179ac57d1e0fe1939ecf6536e8
d3d3026a8a434b21541dab2ad5cdda1524f6e1a4
v1.0
complete
Prefill
Prefill_34162_C
def is_narcissistic(number: int) -> bool: """Check if a number is a narcissistic number. A number is narcissistic if it is equal to the sum of its own digits each raised to the power of the number of digits. Args: number (int): The number to check. Returns: bool: True if the numbe...
def is_narcissistic(number): """ Check if a number is a narcissistic number. A number is narcissistic if it is equal to the sum of its own digits each raised to the power of the number of digits. Args: number (int): The number to check. Returns: bool: True if the number is narcissi...
from solution import is_narcissistic, smallest_positive_narcissistic def test_is_narcissistic(): assert is_narcissistic(1) == True # 1^1 == 1 assert is_narcissistic(2) == True # 2^1 == 2 assert is_narcissistic(5) == True # 5^1 == 5 assert is_narcissistic(153) == True # 1^3 + 5^3 + 3^3 == 153 as...
[ { "docstring": "Check if a number is a narcissistic number.\nA number is narcissistic if it is equal to the sum of its own digits each raised to the power of the number of digits.\n\nArgs:\nnumber (int): The number to check.\n\nReturns:\nbool: True if the number is narcissistic, False otherwise.", "function...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_narcissistic(number):\n \"\"\"\n Check if a given number is a narcissistic number.\n \"\"\"\n digits = [int(d) for d in str(number)]\n power = len(digits)\n return nu...
trial_gpt4o_4
{ "original_instruction": "Write a python function to return the smallest positive integer `n` such that the sum of the nth-powered numbers of its digits is equal to `n`. This number is known as an \"Narcissistic number\" in base 10.", "prompt_id": "00034162", "row_id": 34162, "seed_ids": "['magpie_prefill_3416...
0.530418
Prefill_34162
C
[ "is_narcissistic", "smallest_positive_narcissistic" ]
2
[ [ "smallest_positive_narcissistic", "is_narcissistic" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a252154410fb9f62df117c4738cfd335b8aad3e5
069c75c25f6ed65d6c5caa14d2cd699594a55d72
v1.0
complete
Prefill
Prefill_31539_C
import heapq from typing import List, Tuple def heuristic(state, goal): """ Computes the Manhattan distance heuristic between the current state and the goal state. """ pass def get_neighbors(state): """ Returns the neighbors of the given state. """ pass def astar_8_puzzle(start, goal)...
import heapq def heuristic(state, goal): """ Computes the Manhattan distance heuristic between the current state and the goal state. """ distance = 0 for i in range(1, 9): xi, yi = divmod(state.index(i), 3) xg, yg = divmod(goal.index(i), 3) distance += abs(xi - xg) + abs(yi ...
from solution import solve_8_puzzle def test_easy_puzzle(): start = [1, 2, 3, 4, 5, 6, 7, 8, 0] goal = [1, 2, 3, 4, 5, 6, 7, 8, 0] assert solve_8_puzzle(start, goal) == [[1, 2, 3, 4, 5, 6, 7, 8, 0]] def test_one_move_puzzle(): start = [1, 2, 3, 4, 5, 6, 7, 0, 8] goal = [1, 2, 3, 4, 5, 6, 7, 8, 0] ...
[ { "docstring": "Computes the Manhattan distance heuristic between the current state and the goal state.", "function_declaration": "def heuristic(state, goal):", "function_name": "heuristic", "parameter_list": "(state, goal)" }, { "docstring": "Returns the neighbors of the given state.", ...
[ 1, 0, 1, 0, 0, 0, 0, 0, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\nclass PuzzleState:\n def __init__(self, state, parent=None, move=0, cost=0):\n self.state = state\n self.parent = parent\n self.move = move\n se...
trial_gpt4o_9
{ "original_instruction": "Write a python function to solve the 8 puzzle problem using the A* algorithm.", "prompt_id": "00031539", "row_id": 31539, "seed_ids": "['magpie_prefill_31539']" }
0.543543
Prefill_31539
C
[ "heuristic", "get_neighbors", "astar_8_puzzle", "solve_8_puzzle" ]
4
[ [ "astar_8_puzzle", "get_neighbors" ], [ "astar_8_puzzle", "heuristic" ], [ "solve_8_puzzle", "astar_8_puzzle" ] ]
3
[]
false
[]
false
pytest
true
[]
true
06969d8cdece9e7358f9a033f0b20083f48ff5b4
23dd013f3a7ab71fd95a9881ea586cb388c355bd
v1.0
complete
Prefill
Prefill_33592_C
def roman_to_int(s: str) -> int: """ Converts a Roman numeral to an integer. >>> roman_to_int("I") 1 >>> roman_to_int("IV") 4 >>> roman_to_int("IX") 9 >>> roman_to_int("XL") 40 >>> roman_to_int("XC") 90 >>> roman_to_int("M") 1000 >>> roman_to_int("MCMXCIV") 1994 >>> roman_to_int...
def roman_to_int(s): """ Converts a Roman numeral to an integer. """ roman_to_int_map = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } total = 0 prev_value = 0 for char in reversed(s): value = roman_to_int_map[char] if value < prev_va...
from solution import roman_to_int, sum_roman_numerals def test_roman_to_int(): assert roman_to_int("I") == 1 assert roman_to_int("IV") == 4 assert roman_to_int("IX") == 9 assert roman_to_int("XL") == 40 assert roman_to_int("XC") == 90 assert roman_to_int("M") == 1000 assert roman_to_int("MC...
[ { "docstring": "Converts a Roman numeral to an integer.", "function_declaration": "def roman_to_int(s):", "function_name": "roman_to_int", "parameter_list": "(s)" }, { "docstring": "Evaluates the value of two Roman numerals and returns their sum.", "function_declaration": "def sum_roman_...
[ 0, 0, 1, 0, 0, 1, 0, 1, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def roman_to_int(roman):\n roman_dict = {\n 'I': 1, 'V': 5, 'X': 10, 'L': 50,\n 'C': 100, 'D': 500, 'M': 1000\n }\n total = 0\n prev_value = 0\n\n for char in rev...
trial_gpt4o_7
{ "original_instruction": "Write a python function to evaluate the value of two Roman numerals and return their sum. For example, if the input is `num1 = \"MCDLXXI\"` and `num2 = \"MCMXCIV\"`, the function should return the sum of these two Roman numerals, which should be `2445`.", "prompt_id": "00033592", "row_i...
0.680358
Prefill_33592
C
[ "roman_to_int", "sum_roman_numerals" ]
2
[ [ "sum_roman_numerals", "roman_to_int" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd30d831d3c62ba372f2b084be76f8124b391f22
4a220975ad118af6a7871111a9e809f34f4e30cb
v1.0
complete
Prefill
Prefill_33977_C
def solve_puzzle(grid: List[List[int]]) -> List[List[int]]: """ Solve a 2D grid puzzle where each row and column contains each number from 1 to N exactly once. >>> solve_puzzle([[0, 2, 3], [3, 0, 2], [2, 3, 0]]) [[1, 2, 3], [3, 1, 2], [2, 3, 1]] >>> solve_puzzle([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]...
def is_valid(grid, row, col, num): N = len(grid) for x in range(N): if grid[row][x] == num: return False if grid[x][col] == num: return False return True def solve_grid(grid, N): for row in range(N): for col in range(N): if grid[row][col] == 0...
from solution import solve_puzzle def test_solve_puzzle_1(): grid = [ [0, 2, 3], [3, 0, 2], [2, 3, 0] ] solved_grid = solve_puzzle(grid) assert solved_grid == [ [1, 2, 3], [3, 1, 2], [2, 3, 1] ] def test_solve_puzzle_2(): grid = [ [0, 0, ...
[ { "docstring": null, "function_declaration": "def is_valid(grid, row, col, num):", "function_name": "is_valid", "parameter_list": "(grid, row, col, num)" }, { "docstring": null, "function_declaration": "def solve_grid(grid, N):", "function_name": "solve_grid", "parameter_list": "...
[ 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_safe(grid, row, col, num):\n \"\"\"\n Check if it's safe to place a number in the given cell according\n to the puzzle's rules.\n \"\"\"\n N = len(grid)\n # Check if ...
trial_gpt4o_7
{ "original_instruction": "Write a python function to solve a 2D grid puzzle where the task is to fill in a grid with numbers such that each row and each column contains each number from 1 to N exactly once, where N is the size of the grid. The function should take the grid as a list of lists and return the solved gr...
0.620136
Prefill_33977
C
[ "is_valid", "solve_grid", "solve_puzzle" ]
3
[ [ "solve_grid", "is_valid" ], [ "solve_puzzle", "solve_grid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2b0d2734f26e4aeff13de9947fa6013a2349daa4
f32b0f649afecda2b804b721e02d46b95c3abaa3