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_17450_C
def remainder_finder(n: int, d: int, r: int) -> List[int]: """ Returns a list of numbers from 1 to n that produce a remainder r when divided by d. >>> remainder_finder(10, 3, 1) == [1, 4, 7, 10] >>> remainder_finder(20, 5, 2) == [2, 7, 12, 17] >>> remainder_finder(15, 4, 3) == [3, 7, 11, 15] >>>...
def remainder_finder(n, d, r): """ Returns a list of numbers from 1 to n that produce a remainder r when divided by d. """ result = [] for i in range(1, n+1): if i % d == r: result.append(i) return result def sum_of_remainders(n, d, r): """ Returns the sum of all int...
from solution import sum_of_remainders, remainder_finder def test_remainder_finder(): assert remainder_finder(10, 3, 1) == [1, 4, 7, 10] assert remainder_finder(20, 5, 2) == [2, 7, 12, 17] assert remainder_finder(15, 4, 3) == [3, 7, 11, 15] assert remainder_finder(5, 1, 0) == [1, 2, 3, 4, 5] def test_...
[ { "docstring": "Returns a list of numbers from 1 to n that produce a remainder r when divided by d.", "function_declaration": "def remainder_finder(n, d, r):", "function_name": "remainder_finder", "parameter_list": "(n, d, r)" }, { "docstring": "Returns the sum of all integers from 1 to n th...
[ 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 remainder_finder(n, d, r):\n \"\"\"\n Given an integer n, finds all numbers from 1 to n that produce the remainder r when divided by d.\n Returns a list of such numbers.\n \"\...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes an integer `n` as an argument and returns the sum of all the integers from 1 to `n` that have a remainder of `r` when divided by `d`. The function should call another auxiliary function `remainder_finder(n, d)` that finds all numbers from 1 to `n` that produce t...
0.664081
Prefill_17450
C
[ "remainder_finder", "sum_of_remainders" ]
2
[ [ "sum_of_remainders", "remainder_finder" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d20d773788bff562d47f24e2acced9b0e19e741a
8fd898ca640914e384e21426a4d0f95f26a97e91
v1.0
complete
Prefill
Prefill_18259_C
def factorial(n: int) -> int: """ Returns the factorial of a given number n. >>> factorial(0) == 1 >>> factorial(1) == 1 >>> factorial(5) == 120 """ def number_of_permutations(n: int) -> int: """ Returns the number of permutations for a set of n distinct values. >>> number_of_permutations(0...
def factorial(n): """ Returns the factorial of a given number n. """ if n == 0 or n == 1: return 1 result = 1 for i in range(2, n+1): result *= i return result def number_of_permutations(n): """ Returns the number of permutations for a set of n distinct values. "...
from solution import factorial, number_of_permutations def test_factorial_base_cases(): assert factorial(0) == 1 assert factorial(1) == 1 def test_factorial(): assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 assert factorial(5) == 120 assert factorial(6) == 720 ...
[ { "docstring": "Returns the factorial of a given number n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Returns the number of permutations for a set of n distinct values.", "function_declaration": "def number_of_p...
[ 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 number_of_permutations(n):\n \"\"\"\n Returns the number of permutations for a set of n elements.\n \"\"\"\n if n < 0:\n raise ValueError(\"The number of...
trial_gpt4o_9
{ "original_instruction": "Create a function that can generate the number of permutations for a given set of values. I want to understand the concept and implement it in Python. Could you walk me through the process step by-step?", "prompt_id": "00018259", "row_id": 18259, "seed_ids": "['magpie_prefill_18259']"...
0.679769
Prefill_18259
C
[ "factorial", "number_of_permutations" ]
2
[ [ "number_of_permutations", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fef7b4e000c28cc549cc72fa9c2599ba4b9350fd
4d9ffe91b0d4527e7bad034007015970ab498dbd
v1.0
complete
Prefill
Prefill_18301_C
from typing import List def is_prime(n: int) -> bool: """Returns True if n is a prime number, else False.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False ...
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def count_pri...
from solution import count_primes def test_count_primes_with_empty_list(): assert count_primes([]) == 0 def test_count_primes_all_primes(): assert count_primes([2, 3, 5, 7, 11]) == 5 def test_count_primes_no_primes(): assert count_primes([1, 4, 6, 8, 9, 10]) == 0 def test_count_primes_mixed_numbers(): ...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the count of prime numbers in the list nums.", "function_declaration": "def count_primes(nums):",...
[ 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 Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 ==...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes a list of integers and returns the number of integers that are prime. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 2, 3, 5, and 7 are prime numbers.", "prompt_id": "00018301", "row_id":...
0.806294
Prefill_18301
C
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
467d1d21ad723b98a54dc02cabe97b5881a49ca7
96a456a0dafd4bcd11605b89ee9e38785e873362
v1.0
complete
Prefill
Prefill_17273_C
def generate_matrix_with_path(rows, cols, path): """Generates a matrix with a specific path from top to bottom, left to right. The 'path' parameter is a list of tuples representing the coordinates of the filled path. Example: >>> generate_matrix_with_path(3, 3, [(0, 0), (0, 1), (0, 2), (1, 2), (2, 2)]) ...
def generate_matrix_with_path(rows, cols, path): """ Generates a matrix with a specific path from top to bottom, left to right. 'path' parameter is a list of tuples representing the coordinates of the filled path. """ # Initialize the matrix with 'empty' matrix = [['empty' for _ in range(cols)] ...
from solution import generate_matrix_with_path, print_matrix, move_and_print_path def test_generate_matrix_with_path(): rows = 3 cols = 3 path = [(0, 0), (0, 1), (0, 2), (1, 2), (2, 2)] expected_matrix = [ ['filled', 'filled', 'filled'], ['empty', 'empty', 'filled'], ['empty', '...
[ { "docstring": "Generates a matrix with a specific path from top to bottom, left to right.\n'path' parameter is a list of tuples representing the coordinates of the filled path.", "function_declaration": "def generate_matrix_with_path(rows, cols, path):", "function_name": "generate_matrix_with_path", ...
[ 0, 0, 0, 0, 0, 1, 1, 0 ]
2
hard
0.25
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_matrix(rows, cols):\n \"\"\"\n Generate a matrix with a single path from top to bottom, left to right.\n 'filled' denotes the path, and 'empty' denotes the empty squares...
trial_gpt4o_8
{ "original_instruction": "Create a function that generates a matrix with a single path taken from top to bottom, left to right. The path will consist of filled squares (denoted as 'filled') and empty squares (denoted as 'empty'). The function should also provide a method to move and print the path step-by-step on th...
0.598604
Prefill_17273
C
[ "generate_matrix_with_path", "print_matrix", "move_and_print_path" ]
3
[ [ "move_and_print_path", "print_matrix" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec9398883b1dd33759e09b72a0331ce2dd872416
f5198b9c9da23a0dddbeb401ab9796e9583a226a
v1.0
complete
Prefill
Prefill_18375_C
def quicksort_and_search(arr: List[int], target: int) -> int: """ Sorts the array using quicksort and searches for the target value. If found, return the index of target value, otherwise return -1. >>> quicksort_and_search([4, 2, 6, 3, 1, 5], 3) == 2 >>> quicksort_and_search([4, 2, 6, 3, 1, 5],...
def quicksort(arr): """ Quicksort algorithm to sort the array. """ if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quicksort(left) + middle + quic...
from solution import quicksort_and_search def test_quicksort_and_search_found(): assert quicksort_and_search([4, 2, 6, 3, 1, 5], 3) == 2 # Sorted array is [1, 2, 3, 4, 5, 6] def test_quicksort_and_search_not_found(): assert quicksort_and_search([4, 2, 6, 3, 1, 5], 7) == -1 def test_quicksort_and_search_empt...
[ { "docstring": "Quicksort algorithm to sort the array.", "function_declaration": "def quicksort(arr):", "function_name": "quicksort", "parameter_list": "(arr)" }, { "docstring": "Binary search algorithm to find the target value in the sorted array.", "function_declaration": "def binary_s...
[ 0, 0, 1, 1, 1, 0, 0, 0, 1, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quicksort(arr):\n \"\"\"\n Implements the quicksort algorithm to sort an array in ascending order.\n \"\"\"\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) /...
trial_gpt4o_4
{ "original_instruction": "Create a function that takes an array of integers and a target value as parameters. The function should use the quicksort algorithm to sort the array. After sorting, the function should search for the target value in the sorted array. If the target value is found, return the index of the ta...
0.639342
Prefill_18375
C
[ "quicksort", "binary_search", "quicksort_and_search" ]
3
[ [ "quicksort_and_search", "binary_search" ], [ "quicksort_and_search", "quicksort" ] ]
2
[]
false
[]
false
pytest
true
[]
true
40f9ad280b34a0868fad4755ef8858b2f922a994
235864cbe679742b4b9ab178c803de8c160050f4
v1.0
complete
Prefill
Prefill_18354_C
import math from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def count_primes(arr: List[int]) -> int: """ Returns the count of prime numbers in an array of integers. >>> count_primes([2, 3, 5...
import math def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def count_primes(...
from solution import count_primes def test_count_primes_all_primes(): assert count_primes([2, 3, 5, 7, 11]) == 5 def test_count_primes_mix(): assert count_primes([1, 2, 4, 5, 6, 7, 8, 9, 10, 11]) == 4 def test_count_primes_no_primes(): assert count_primes([4, 6, 8, 9, 10, 12]) == 0 def test_count_primes...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the count of prime numbers in an array of integers.", "function_declaration": "def count_primes(arr):", "function_name": "count_primes"...
[ 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 is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes an array of integers as an argument and returns the count of prime numbers in the array. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. For simplicity, assume the array will not contain any non-integer values or ...
0.808898
Prefill_18354
C
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b68760566a8ffdeca64680b9ab31b7f6046b4fe3
e99350126e16f5cc7290dcf2f7781388f66b6775
v1.0
complete
Prefill
Prefill_18749_C
from typing import List def is_prime(num: int) -> bool: """ Returns True if num is a prime number, else False. >>> is_prime(2) True >>> is_prime(4) False """ pass def identify_primes(numbers: List[int]) -> List[int]: """ Identifies all the prime numbers within a given list of integers....
def is_prime(num): """ Returns True if num is a prime number, else False. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True d...
from solution import is_prime, identify_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(20) == False assert is_prime(1) == False assert is_prime(-5) == False assert is_prime(0) == F...
[ { "docstring": "Returns True if num is a prime number, else False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Identifies all the prime numbers within a given list of integers.\n\n:param numbers: 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": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise returns False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if ...
trial_gpt4o_9
{ "original_instruction": "Create a function that identifies all the prime numbers within a given list of integers. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself.", "prompt_id": "00018749", "row_id": 18749, "seed_ids": "['magpie_prefill_18749']" }
0.80511
Prefill_18749
C
[ "is_prime", "identify_primes" ]
2
[ [ "identify_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8cc4cc488f22bb7248fcdf39290872be700137cf
d11296e72d8005cef8883fcc781d6d0fa9617960
v1.0
complete
Prefill
Prefill_18123_C
import matplotlib.pyplot as plt import numpy as np def create_polygon(length, width): """ Creates a polygon (for simplicity, a rectangle) with the given length and width. Parameters: - length: The length of the polygon. - width: The width of the polygon. Returns: - A list of vertices ...
import matplotlib.pyplot as plt import numpy as np def create_polygon(length, width): """ Creates a polygon (for simplicity, a rectangle) with the given length and width. Parameters: - length: The length of the polygon. - width: The width of the polygon. Returns: - A list of vertices repr...
from solution import create_polygon, plot_polygon def test_create_polygon_square(): vertices = create_polygon(5, 5) expected_vertices = [(0, 0), (5, 0), (5, 5), (0, 5), (0, 0)] assert vertices == expected_vertices def test_create_polygon_rectangle(): vertices = create_polygon(3, 6) expected_vertic...
[ { "docstring": "Creates a polygon (for simplicity, a rectangle) with the given length and width.\n\nParameters:\n- length: The length of the polygon.\n- width: The width of the polygon.\n\nReturns:\n- A list of vertices representing the polygon.", "function_declaration": "def create_polygon(length, width):"...
[ 1, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_square(length, width):\n \"\"\"\n Generates a string representation of a polygon (square/rectangle).\n \"\"\"\n if length < 1 or width < 1:\n raise ValueError(...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a length and a width and outputs a polygon with those dimensions. Assuming a square for simplicity. For additional programming practice, create a user interface where the user can input the length and width, and display the resulting polygon. You can use any lib...
0.578047
Prefill_18123
C
[ "create_polygon", "plot_polygon", "user_interface" ]
3
[ [ "user_interface", "create_polygon" ], [ "user_interface", "plot_polygon" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
edc9fc85cfeb2428c9ff0f6856829af97abb6a9d
5f1596fcd3d66659b25ee9762f5fd2cb171cbe90
v1.0
complete
Prefill
Prefill_18773_C
def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def all_primes(numbers: List[int]) -> bool: """ Checks if all numbers in the list are prime. >>> all_primes([2, 3, 5, 7, 11]) True >>> all_primes([2, 3, 4, 5, 7]) False ...
def is_prime(num): if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def all_primes(numbers): """ Checks if all numbers in the list are prime. Parameters: numbers (list of int): List of numbers to be ch...
from solution import all_primes def test_all_primes_with_only_prime_numbers(): assert all_primes([2, 3, 5, 7, 11]) == True def test_all_primes_with_one_non_prime_number(): assert all_primes([2, 3, 4, 5, 7]) == False def test_all_primes_with_empty_list(): assert all_primes([]) == True def test_all_pr...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Checks if all numbers in the list are prime.\n\nParameters:\nnumbers (list of int): List of numbers to be checked.\n\nReturns:\nbool: True if all numbe...
[ 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 n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % ...
trial_gpt4o_8
{ "original_instruction": "Create a function that checks if a list of numbers contains only prime numbers. Return True if all numbers are prime, otherwise return False.", "prompt_id": "00018773", "row_id": 18773, "seed_ids": "['magpie_prefill_18773']" }
0.828413
Prefill_18773
C
[ "is_prime", "all_primes" ]
2
[ [ "all_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
efcb46734dc08eec73eddd4eb812c12b19ac0daf
b7c05e67c78c56135281bcc2bdfd866546ad1af7
v1.0
complete
Prefill
Prefill_18540_C
def generate_sequence(length: int, sequence_type: str) -> list: """ Generates a sequence of numbers up to a specified length. Parameters: length (int): Length of the list (number of terms in the sequence). sequence_type (str): Type of sequence, either 'fibonacci' or 'luhn'. Returns: ...
def generate_sequence(length, sequence_type): """ Generates a sequence of numbers up to a specified length. Parameters: length (int): Length of the list (number of terms in the sequence). sequence_type (str): Type of sequence, either 'fibonacci' or 'luhn'. Returns: list: A list of ...
from solution import generate_sequence def test_generate_fibonacci_sequence(): assert generate_sequence(0, 'fibonacci') == [] assert generate_sequence(1, 'fibonacci') == [0] assert generate_sequence(2, 'fibonacci') == [0, 1] assert generate_sequence(5, 'fibonacci') == [0, 1, 1, 2, 3] assert generat...
[ { "docstring": "Generates a sequence of numbers up to a specified length.\n\nParameters:\nlength (int): Length of the list (number of terms in the sequence).\nsequence_type (str): Type of sequence, either 'fibonacci' or 'luhn'.\n\nReturns:\nlist: A list of numbers in the specified sequence.", "function_decl...
[ 1, 0, 0, 0, 0, 1, 0, 1, 1, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_sequence(length, sequence_type):\n \"\"\"\n Generates a list of numbers up to a specified length of the selected type of sequence.\n \n Parameters:\n - length (int...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates a list of Fibonacci numbers up to a specified length. The function should take two parameters: the length of the list and the type of sequence (either 'fibonacci' or 'luhn'). The 'fibonacci' type should generate the traditional Fibonacci sequence, while the ...
0.651841
Prefill_18540
C
[ "generate_sequence", "generate_fibonacci", "generate_luhn" ]
3
[ [ "generate_sequence", "generate_fibonacci" ], [ "generate_sequence", "generate_luhn" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cd7694e53a939e1287a6df3be620429f53c7bab6
c08449a7e5d8fe41104dd44318731125cbe15c87
v1.0
complete
Prefill
Prefill_18814_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(0) == False >>> is_prime(29) == True >>> is_prime(87) == False """ pass def primes_in_range(start: int, end: ...
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 primes_in_range(start, end): """ Returns a list of prime numbers between s...
from solution import is_prime, primes_in_range def test_is_prime_basic(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False def test_is_prime_edge_cases(): assert is_prime(0) == False assert is_prime(1) == False assert is_prime(29) == True assert is_prime(87...
[ { "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 of prime numbers between start and end, inclusive.", "function_declaration": "def pri...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1 ]
8
easy
0.889
{ "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 single number is 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": "Create a function that checks if a number is prime. The function should take two parameters: a start and an end number.", "prompt_id": "00018814", "row_id": 18814, "seed_ids": "['magpie_prefill_18814']" }
0.790718
Prefill_18814
C
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ee023b51ac6d7a0ac382b8cb52eb23668d760db8
a39634b089580ddc2d01386d91923c8e20035185
v1.0
complete
Prefill
Prefill_18882_C
def sum_of_primes(lst: List[int]) -> int: """ Returns the sum of prime numbers in the list. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. If there are no prime numbers in the list, the function should return 0. >>> sum_of_primes([2, 3, 5, 7]) 17 ...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False # other even numbers are not prime for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: ...
from solution import sum_of_primes def test_sum_of_primes_with_primes(): assert sum_of_primes([2, 3, 5, 7]) == 17 def test_sum_of_primes_with_non_primes(): assert sum_of_primes([4, 6, 8, 9]) == 0 def test_sum_of_primes_with_mixed_numbers(): assert sum_of_primes([2, 4, 5, 6, 7]) == 14 def test_sum_of_pri...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of prime numbers in the list.", "function_declaration": "def sum_of_primes(lst):", "function_name": "sum_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 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": "Create a function that takes in a list of integers and returns the sum of the prime numbers in the list. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. If there are no prime numbers in the list, the function should return 0.", "prompt_id":...
0.708092
Prefill_18882
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83f6b62f85f25064ea6c321bca64b1350f530d56
e5cf9c3397fa7ace5766ecd204a1e14be36c4f7e
v1.0
complete
Prefill
Prefill_17929_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. Parameters: n (int): The number to check. Returns: bool: True if n is a prime number, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: ...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def generate_primes(start, end): """ G...
from solution import generate_primes def test_generate_primes_range_with_primes(): assert generate_primes(10, 20) == [11, 13, 17, 19] def test_generate_primes_no_primes_in_range(): assert generate_primes(14, 16) == [] def test_generate_primes_single_prime_in_range(): assert generate_primes(25, 29) == [29...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of all prime numbers within the given range [start, end].\n\nParameters:\nstart (int): The starting number of the range.\nend (int): The e...
[ 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 is_prime(n):\n \"\"\"\n Check if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates a list of all the prime numbers within a given range, including both the start and end numbers. The function should be efficient and handle large ranges effectively.", "prompt_id": "00017929", "row_id": 17929, "seed_ids": "['magpie_prefill_17929']" }
0.74704
Prefill_17929
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ee8c86428b784b90b253b96b7006d17c54c270de
24609855a06c250ebfaaa7c08809519a3b198efe
v1.0
complete
Prefill
Prefill_18443_C
import random previously_generated_words = set() def generate_random_word() -> str: """Generates a random five-letter word using the characters 'a', 'b', and 'c'. Ensures that the word generated is not a subsequence of another previously generated word. >>> is_subsequence("abc", "aabbcc") True >...
import random previously_generated_words = set() def generate_random_word(): chars = 'abc' while True: word = ''.join(random.choices(chars, k=5)) if not any(is_subsequence(word, prev_word) for prev_word in previously_generated_words): previously_generated_words.add(word) ...
from solution import generate_random_word, is_subsequence def test_is_subsequence(): assert is_subsequence("abc", "aabbcc") assert is_subsequence("abc", "abc") assert not is_subsequence("abc", "ab") assert not is_subsequence("abc", "bac") assert not is_subsequence("abc", "cab") def test_generate_r...
[ { "docstring": null, "function_declaration": "def generate_random_word():", "function_name": "generate_random_word", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def is_subsequence(sub, string):", "function_name": "is_subsequence", "parameter_list": "(s...
[ 1, 0, 0, 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": "import random\n\npreviously_generated_words = set()\n\ndef generate_random_word():\n chars = 'abc'\n while True:\n word = ''.join(random.choices(chars, k=5))\n if not any(...
trial_gpt4o_0
{ "original_instruction": "Create a function that generates a random five-letter word using the characters 'a', 'b', and 'c'. The function should return the word as a string. Additionally, you must ensure that the word generated by the function is not a subsequence of another previously generated word.", "prompt_id...
0.733675
Prefill_18443
C
[ "generate_random_word", "is_subsequence" ]
2
[ [ "generate_random_word", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5835b3a6c297b6527ae08cea87328db331631c20
937a888aad1de62279df08a8134fed07d588b1a3
v1.0
complete
Prefill
Prefill_18966_C
def gcd(a: int, b: int) -> int: """ Returns the GCD of two numbers using the Euclidean algorithm. >>> gcd(48, 64) 16 >>> gcd(64, 80) 16 >>> gcd(100, 25) 25 >>> gcd(25, 0) 25 >>> gcd(0, 25) 25 """ def gcd_of_three(a: int, b: int, c: int) -> int: """ Returns the GCD of three numbe...
def gcd(a, b): while b: a, b = b, a % b return a def gcd_of_three(a, b, c): """ Returns the GCD of three numbers a, b, and c. """ first_gcd = gcd(a, b) return gcd(first_gcd, c) # Example usage gcd_of_three(48, 64, 80)
from solution import gcd_of_three, gcd def test_gcd(): assert gcd(48, 64) == 16 assert gcd(64, 80) == 16 assert gcd(100, 25) == 25 assert gcd(25, 0) == 25 assert gcd(0, 25) == 25 def test_gcd_of_three(): assert gcd_of_three(48, 64, 80) == 16 assert gcd_of_three(14, 21, 28) == 7 assert ...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the GCD of three numbers a, b, and c.", "function_declaration": "def gcd_of_three(a, b, c):", "function_name": "gcd_of_three", "parameter_l...
[ 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Returns the GCD of two numbers using the Euclidean algorithm.\n \"\"\"\n while b != 0:\n a, b = b, a % b\n return a\n\ndef gcd_of_three(a, b, c...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes three integers as input and prints the greatest common divisor (GCD) of the three numbers using the Euclidean algorithm. The Euclidean algorithm to find the GCD of two numbers is based on the principle that the GCD of two numbers also divides their difference. E...
0.796345
Prefill_18966
C
[ "gcd", "gcd_of_three" ]
2
[ [ "gcd_of_three", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6ca8e5031e088a0a777e09f869302f748c7c5232
b85353e4ec49a544c2b438690299e2d966994234
v1.0
complete
Prefill
Prefill_19121_C
def filter_strings_with_more_consonants(strings: List[str]) -> List[str]: """ Create a function that takes a list of strings and returns a new list containing the substrings from the given string list, but only if the substrings' consonants are more than vowels. >>> filter_strings_with_more_c...
def is_consonant(ch): """ Check if a character is a consonant. """ return ch.lower() in 'bcdfghjklmnpqrstvwxyz' def count_consonants_and_vowels(s): """ Return a tuple with counts of consonants and vowels in a given string. """ consonants_count = sum(1 for ch in s if is_consonant(ch)) ...
from solution import filter_strings_with_more_consonants def test_single_string_with_more_consonants(): assert filter_strings_with_more_consonants(['hello']) == ['hello'] def test_single_string_with_more_vowels(): assert filter_strings_with_more_consonants(['aerie']) == [] def test_multiple_strings_mixed(): ...
[ { "docstring": "Check if a character is a consonant.", "function_declaration": "def is_consonant(ch):", "function_name": "is_consonant", "parameter_list": "(ch)" }, { "docstring": "Return a tuple with counts of consonants and vowels in a given string.", "function_declaration": "def count...
[ 0, 0, 1, 1, 0, 0, 1, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def substrings_with_more_consonants_than_vowels(string_list):\n \"\"\"\n Returns a new list containing the substrings from the given string list,\n but only if the substrings have mo...
trial_gpt4o_6
{ "original_instruction": "Create a function that takes a list of strings and returns a new list containing the substrings from the given string list, but only if the substrings consonants are more than vowels.", "prompt_id": "00019121", "row_id": 19121, "seed_ids": "['magpie_prefill_19121']" }
0.733067
Prefill_19121
C
[ "is_consonant", "count_consonants_and_vowels", "filter_strings_with_more_consonants" ]
3
[ [ "count_consonants_and_vowels", "is_consonant" ], [ "filter_strings_with_more_consonants", "count_consonants_and_vowels" ] ]
2
[]
false
[]
false
pytest
true
[]
true
030be30a26c3bd3ae4c49e6cec9ab5cbd3ec079d
cdd0ba7c4ad56f1f28df3b8ac7099f9eedbaee13
v1.0
complete
Prefill
Prefill_19088_C
def is_prime(n: int) -> bool: """ Checks if a number n is prime. """ pass def list_prime_indicators(numbers: List[int]) -> List[bool]: """ Takes a list of integers and returns a new list with boolean values indicating the primality of each number. >>> list_prime_indicators([2, 3, 4, 5, 10, 11, 13,...
def is_prime(n): """ Checks 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, int(n**0.5) + 1, 2): if n % i == 0: return False return True def list_prime_indicators(numbers...
from solution import list_prime_indicators def test_list_prime_indicators_with_mixed_numbers(): assert list_prime_indicators([2, 3, 4, 5, 10, 11, 13, 14, 17, 18]) == [True, True, False, True, False, True, True, False, True, False] def test_list_prime_indicators_with_primes_only(): assert list_prime_indicators...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a new list with boolean values indicating the primality of each number.", "function_de...
[ 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 if n == 2:\n return True\n if n % 2 ==...
trial_gpt4o_6
{ "original_instruction": "Create a function that takes a list of integers and returns a new list with boolean values indicating the primality of each number in the input list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.", "prompt_id": "00019088", "row_...
0.833861
Prefill_19088
C
[ "is_prime", "list_prime_indicators" ]
2
[ [ "list_prime_indicators", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a7f26ee321d2dab3aa5a0ee46b258aec9ba5797
3573c7005c616396e5a1587611a75a29f22cdda6
v1.0
complete
Prefill
Prefill_19154_C
def is_prime(n: int) -> bool: """ 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 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 filter_...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_some_non_primes(): assert filter_primes([1, 2, 3, 4, 5, 6]) == [2, 3, 5] def test_filter_primes_no_primes(): assert filter_primes([1, 4, 6, 8, 9, 10]) ...
[ { "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 new list containing only the prime numbers from the original list.", "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 is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\ndef filter_primes(numbers...
trial_gpt4o_4
{ "original_instruction": "Create a function that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. For example, given a list [1, 2, 3, 4, 5, 6], the function should return [2, 3, 5].", "prompt_id": "00019154", "row_id": 19154, "seed_ids": "['magp...
0.778823
Prefill_19154
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f63f24185e23b7662fcfaff5e10760391f33423e
8acfa219943cda011af65dec30e82f164f93f847
v1.0
complete
Prefill
Prefill_18638_C
def is_prime(n: int) -> bool: """ Check if the number n is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(13) True >>> is_prime(1) False """ def is_sum_prime(num1: int, num2: int) -> bool: """ Check if the sum of num1 and num2 is a prime...
def is_prime(n): """ Check if the number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, is_sum_prime def test_is_sum_prime_with_prime_sum(): assert is_sum_prime(2, 3) == True assert is_sum_prime(3, 4) == True def test_is_sum_prime_with_non_prime_sum(): assert is_sum_prime(2, 2) == False assert is_sum_prime(3, 3) == False def test_is_sum_prime_with_zero(): ...
[ { "docstring": "Check if the number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Check if the sum of num1 and num2 is a prime number.", "function_declaration": "def is_sum_prime(num1, num2):", ...
[ 0, 0, 0, 1, 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 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_3
{ "original_instruction": "Create a function that takes two integers num1 and num2 as input and returns true if the sum of num1 and num2 is a prime number, false otherwise. A function called \"is_prime\" is provided as a utility for checking primality.", "prompt_id": "00018638", "row_id": 18638, "seed_ids": "['...
0.802808
Prefill_18638
C
[ "is_prime", "is_sum_prime" ]
2
[ [ "is_sum_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00b56dfc2231607f99463738bc8f0c41a28a4d25
987dc47b55401d32e0fe01d47898b7232a2381a9
v1.0
complete
Prefill
Prefill_19388_C
from typing import List def is_prime(n: int) -> bool: """ Checks if a number is prime. >>> is_prime(2) == True >>> is_prime(4) == False """ def filter_primes(numbers: List[int]) -> List[int]: """ Filters the input list of numbers, returning only the prime numbers. >>> filter_primes...
def is_prime(n): """ Checks 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 filter_primes(numbers): """ Filters the input list of numbers, returning only the prime numbers. ...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False def test_filter_primes(): ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the input list of numbers, returning only the prime numbers.", "function_declaration": "def filter_primes(numbers):",...
[ 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 if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_6
{ "original_instruction": "Create a function that filters a list of numbers and returns only the prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 5 is a prime number because the only numbers that divide it exactly are 1 and 5.", "pr...
0.775092
Prefill_19388
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef45733b68cf5107e866a5eb005f8715566bd8e6
6a842b704015f3e3f43430aa1a1141b5f05c532e
v1.0
complete
Prefill
Prefill_18774_C
def is_prime(n): """ Checks if the provided number 'n' is a prime number. """ pass def next_prime(n): """ Finds the next prime number greater than the provided number 'n'. """ pass def sum_and_check_prime(*args): """ Sums the provided arguments and returns the sum if it is a pr...
def is_prime(n): """ Checks if the provided number 'n' is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import sum_and_check_prime def test_sum_and_check_prime_all_prime(): assert sum_and_check_prime(2, 3) == 5 def test_sum_and_check_prime_non_prime(): assert sum_and_check_prime(4, 6) == [10, 11] def test_sum_and_check_prime_empty(): assert sum_and_check_prime() == [0, 2] def test_sum_and_ch...
[ { "docstring": "Checks if the provided number 'n' is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds the next prime number greater than the provided number 'n'.", "function_declaration": "def next...
[ 1, 1, 0, 0, 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": "def is_prime(n):\n \"\"\"\n Return True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == ...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes a variable amount of arguments and calculates their sum. If the sum is a prime number, return the sum, otherwise, return an array containing the sum and the next prime number after the sum.", "prompt_id": "00018774", "row_id": 18774, "seed_ids": "['magpie_...
0.792591
Prefill_18774
C
[ "is_prime", "next_prime", "sum_and_check_prime" ]
3
[ [ "next_prime", "is_prime" ], [ "sum_and_check_prime", "is_prime" ], [ "sum_and_check_prime", "next_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c5fbe3f3e05118e1b4cfb055e1f7ee66ccd1803e
089c83e6371690d2318baa2fa0ebcb245cf68754
v1.0
complete
Prefill
Prefill_18564_C
def sum_primes(numbers: List[int]) -> int: """ Returns the sum of all prime numbers in the provided list of integers. >>> sum_primes([1, 2, 3, 4, 5]) == 10 >>> sum_primes([10, 11, 12, 13]) == 24 >>> sum_primes([2, 3, 5, 7, 11]) == 28 >>> sum_primes([]) == 0 >>> sum_primes([4, 6, 8, 9, 10]) == 0 ...
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 p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def sum_prime...
from solution import sum_primes def test_sum_primes_basic(): assert sum_primes([1, 2, 3, 4, 5]) == 10 assert sum_primes([10, 11, 12, 13]) == 24 assert sum_primes([2, 3, 5, 7, 11]) == 28 def test_sum_primes_empty_list(): assert sum_primes([]) == 0 def test_sum_primes_no_primes(): assert sum_primes...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the provided list 'numbers'.", "function_declaration": "def sum_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 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_9
{ "original_instruction": "Create a function that takes a list of integers as an input, and returns the sum of all prime numbers in the list. A prime number is defined as a number that is greater than 1 and has no divisors other than 1 and itself.", "prompt_id": "00018564", "row_id": 18564, "seed_ids": "['magpi...
0.737809
Prefill_18564
C
[ "is_prime", "sum_primes" ]
2
[ [ "sum_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a8e29cf262705fedea63034f8156b0a1c44ed178
7c7ae2f6d599e71ca6d78ba160cfe0245a18f37c
v1.0
complete
Prefill
Prefill_18724_C
def int_to_roman(num: int) -> str: """ Converts an integer to a Roman numeral string. :param num: int :return: str """ pass def list_to_roman(lst: List[int]) -> List[str]: """ Converts a list of integers to a list of Roman numeral strings. >>> list_to_roman([1]) == ['I'] >>> li...
def int_to_roman(num): """ Converts an integer to a roman numeral string. :param num: int :return: str """ val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syb = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX",...
from solution import list_to_roman def test_list_to_roman_single_number(): assert list_to_roman([1]) == ['I'] assert list_to_roman([3999]) == ['MMMCMXCIX'] def test_list_to_roman_multiple_numbers(): assert list_to_roman([1, 2, 3, 4, 5]) == ['I', 'II', 'III', 'IV', 'V'] assert list_to_roman([10, 20, 30...
[ { "docstring": "Converts an integer to a roman numeral string.\n:param num: int\n:return: str", "function_declaration": "def int_to_roman(num):", "function_name": "int_to_roman", "parameter_list": "(num)" }, { "docstring": "Converts a list of integers to a list of roman numeral strings.\n:pa...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def int_to_roman(num):\n \"\"\"\n Convert an integer to a Roman numeral.\n \"\"\"\n val = [\n 1000, 900, 500, 400,\n 100, 90, 50, 40,\n 10, 9, 5, 4,\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of integers and returns a list of strings representing the integer values as Roman numerals. The function should also handle numbers in the range of 1 to 3999.", "prompt_id": "00018724", "row_id": 18724, "seed_ids": "['magpie_prefill_18724']" }
0.775281
Prefill_18724
C
[ "int_to_roman", "list_to_roman" ]
2
[ [ "list_to_roman", "int_to_roman" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e358644348f12c5685e85e691099431b28fb4486
db35757616e17235e85f925d69c650648d0ebdc7
v1.0
complete
Prefill
Prefill_19673_C
import timeit from typing import Generator, Tuple def fibonacci_gen() -> Generator[int, None, None]: """ A generator function to generate Fibonacci numbers. """ a, b = 0, 1 while True: yield a a, b = b, a + b def nth_fibonacci_with_n_digits(n: int) -> Tuple[int, float]: """ ...
import timeit def fibonacci_gen(): """ A generator function to generate Fibonacci numbers. """ a, b = 0, 1 while True: yield a a, b = b, a + b def nth_fibonacci_with_n_digits(n): """ Returns the nth Fibonacci number with less than or equal to n digits and the time taken to ...
from solution import nth_fibonacci_with_n_digits def test_nth_fibonacci_with_n_digits_for_n_1(): # 0 is the 1st fibonacci number with 1 or fewer digits fib_number, time_taken = nth_fibonacci_with_n_digits(1) assert fib_number == 0 assert time_taken >= 0 def test_nth_fibonacci_with_n_digits_for_n_2(): ...
[ { "docstring": "A generator function to generate Fibonacci numbers.", "function_declaration": "def fibonacci_gen():", "function_name": "fibonacci_gen", "parameter_list": "()" }, { "docstring": "Returns the nth Fibonacci number with less than or equal to n digits and the time taken to \ngener...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import timeit\n\ndef fibonacci_generator():\n a, b = 0, 1\n while True:\n yield a\n a, b = b, a + b\n\ndef nth_fibonacci_with_digits(n):\n \"\"\"\n Returns the nth F...
trial_gpt4o_7
{ "original_instruction": "Create a function that returns the nth Fibonacci number with less than or equal to n digits. The function should use a generator to generate Fibonacci numbers and stop when the nth Fibonacci number with less than or equal to n digits is found. The function should also measure and return the...
0.788883
Prefill_19673
C
[ "fibonacci_gen", "nth_fibonacci_with_n_digits" ]
2
[ [ "nth_fibonacci_with_n_digits", "fibonacci_gen" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e9835677e3b6a3756a2f5d38c7e8c46520563dd
f4878e4705378e7e20ff5e663939e4aff9fd5044
v1.0
complete
Prefill
Prefill_18656_C
def generate_fibonacci_sequence(n: int) -> List[int]: """ Generate a list of the first n Fibonacci numbers. >>> generate_fibonacci_sequence(1) == [0] >>> generate_fibonacci_sequence(2) == [0, 1] >>> generate_fibonacci_sequence(5) == [0, 1, 1, 2, 3] >>> generate_fibonacci_sequence(20) == [0, 1, 1, 2,...
def fibonacci(n, computed={0: 0, 1: 1}): """ Returns the Fibonacci sequence up to the nth term. This implementation uses caching to improve performance for larger values of n. """ if n not in computed: computed[n] = fibonacci(n - 1, computed) + fibonacci(n - 2, computed) return computed[...
from solution import generate_fibonacci_sequence def test_generate_fibonacci_sequence(): assert generate_fibonacci_sequence(1) == [0] assert generate_fibonacci_sequence(2) == [0, 1] assert generate_fibonacci_sequence(5) == [0, 1, 1, 2, 3] assert generate_fibonacci_sequence(10) == [0, 1, 1, 2, 3, 5, 8, ...
[ { "docstring": "Returns the Fibonacci sequence up to the nth term.\nThis implementation uses caching to improve performance for larger values of n.", "function_declaration": "def fibonacci(n, computed={0: 0, 1: 1}):", "function_name": "fibonacci", "parameter_list": "(n, computed={0: 0, 1: 1})" }, ...
[ 1, 1, 1, 1, 0, 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 fibonacci(n, cache = {0: 0, 1: 1}):\n \"\"\"\n Generates the Fibonacci sequence up to the nth term using a caching mechanism.\n \"\"\"\n if n in cache:\n return cache[n...
trial_gpt4o_8
{ "original_instruction": "Create a function that generates the Fibonacci sequence up to the nth term. The function should be able to reach at least up to 100 terms without taking too long to compute. To achieve this, you can implement a caching mechanism to store previously computed terms of the Fibonacci sequence. ...
0.834167
Prefill_18656
C
[ "fibonacci", "generate_fibonacci_sequence" ]
2
[ [ "generate_fibonacci_sequence", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2dc921d70b8a92cd01b91a914a8798cdd176913b
150c9e05fe835451b2ccdb7e19fdc83a802d524b
v1.0
complete
Prefill
Prefill_19299_C
def is_prime(n: int) -> bool: """ Checks if a given number n is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(29) == True >>> is_prime(1) == False >>> is_prime(0) == False >>> is_prime(-7) == False """ def smallest_prime_greater_or_equal...
def is_prime(n): """ Checks if a given 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, int(n**0.5)+1, 2): if n % i == 0: return False return True def smallest_prime_greater_or...
from solution import is_prime, smallest_prime_greater_or_equal 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(0) == False assert is_prime(-7) == False def test_sm...
[ { "docstring": "Checks if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number that is greater or equal to the given number n.\nIf no such prime number exists, return...
[ 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 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_7
{ "original_instruction": "Create a function that receives a number and returns the smallest prime number that is greater or equal to the given number. If no such prime number exists (for example, if the input is less than 2), the function should return `None`.", "prompt_id": "00019299", "row_id": 19299, "seed_...
0.812947
Prefill_19299
C
[ "is_prime", "smallest_prime_greater_or_equal" ]
2
[ [ "smallest_prime_greater_or_equal", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9a3a84cd16074dab770d9badeca8543729374658
e97c58460a9d7f0470e80084d8df4a64a27d1793
v1.0
complete
Prefill
Prefill_19590_C
from typing import Tuple def gcd(a: int, b: int) -> int: """ Returns the greatest common divisor of a and b using Euclid's algorithm. """ def lcm(a: int, b: int) -> int: """ Returns the least common multiple of a and b using the GCD method. lcm(a, b) = abs(a*b) / gcd(a, b) >>> lcm(4, ...
def gcd(a, b): """ Returns the greatest common divisor of a and b using Euclid's algorithm. """ while b: a, b = b, a % b return a def lcm(a, b): """ Returns the least common multiple of a and b using the GCD method. lcm(a, b) = abs(a*b) / gcd(a, b) """ return abs(a * b) ...
from solution import gcd, lcm def test_gcd(): assert gcd(54, 24) == 6 assert gcd(48, 18) == 6 assert gcd(101, 103) == 1 def test_lcm(): assert lcm(4, 5) == 20 assert lcm(12, 15) == 60 assert lcm(7, 3) == 21 assert lcm(9, 6) == 18 assert lcm(25, 10) == 50
[ { "docstring": "Returns the greatest common divisor of a and b using Euclid's algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the least common multiple of a and b using the GCD method.\nlcm(a, b) = abs(a*b) ...
[ 0, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Returns the greatest common divisor of a and b.\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n \"\"\"\n Returns the...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes two positive integers as arguments and returns their least common multiple. The function should use the greatest common divisor (GCD) method to calculate the LCM.", "prompt_id": "00019590", "row_id": 19590, "seed_ids": "['magpie_prefill_19590']" }
0.808831
Prefill_19590
C
[ "gcd", "lcm" ]
2
[ [ "lcm", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
da38467d0aae644ca1720498a5077f9f0d2e3801
073b803e93270f1481bf112b78255373b79230f1
v1.0
complete
Prefill
Prefill_18984_C
def is_prime(num: 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(0) == False >>> is_prime(1) == False """ pass def sum_primes_below(n: int) -> int...
def is_prime(num): """ Helper function to determine 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_primes_below(n): """ Returns the sum of all prime numbers below a g...
from solution import sum_primes_below, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(0) == False assert is_prime(1) == False def test_sum_primes_below(): assert sum_primes_below(10)...
[ { "docstring": "Helper function to determine 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 below a given integer n.", "function_declaration": "def sum_pr...
[ 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 Returns True if num is prime, False otherwise.\n \"\"\"\n if num <= 1:\n return False\n ...
trial_gpt4o_6
{ "original_instruction": "Create a function that calculates the sum of all prime numbers up to but not including a given integer `n`.", "prompt_id": "00018984", "row_id": 18984, "seed_ids": "['magpie_prefill_18984']" }
0.795248
Prefill_18984
C
[ "is_prime", "sum_primes_below" ]
2
[ [ "sum_primes_below", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20dc853ed4404c34c774fd053d1fbb4e26b43cb1
ebd7124fde4c59ac461853d40ebdbcd5f3d3b6da
v1.0
complete
Prefill
Prefill_20152_C
def prime_or_next_prime(n: int) -> str: """ Determines whether the input number is a prime number or not. If the input number is not a prime number, return the smallest prime number that is greater than the input number. If the input number is a prime number, return "PrimeNumber". >>> prime_or_next_prim...
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 next_prime(n): """ Returns the smallest prime number greater than n. """ candidate = n + 1 ...
from solution import prime_or_next_prime def test_prime_number(): assert prime_or_next_prime(2) == "PrimeNumber" assert prime_or_next_prime(3) == "PrimeNumber" assert prime_or_next_prime(5) == "PrimeNumber" assert prime_or_next_prime(7) == "PrimeNumber" assert prime_or_next_prime(11) == "PrimeNumbe...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number greater than n.", "function_declaration": "def next_prime(n):", "function_name": "nex...
[ 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 n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes an integer as an input and determines whether it is a prime number or not. If the input number is not a prime number, return the smallest prime number that is greater than the input number. If the input number is a prime number, return \"PrimeNumber\".", "prom...
0.758105
Prefill_20152
C
[ "is_prime", "next_prime", "prime_or_next_prime" ]
3
[ [ "next_prime", "is_prime" ], [ "prime_or_next_prime", "is_prime" ], [ "prime_or_next_prime", "next_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
858b1a712d95d4d1736763fa3700461e3ff15313
43aa5c71bf4a3f3061f9bf413134c1baffa5bece
v1.0
complete
Prefill
Prefill_17854_C
def count_3x3_magic_squares(grid: List[List[int]]) -> int: """ Counts the number of 3x3 magic squares within a 9x9 grid. >>> grid = [[i for i in range(9)] for _ in range(9)] >>> count_3x3_magic_squares(grid) == 0 >>> grid = [[8, 1, 6, 0, 0, 0, 0, 0, 0], [3, 5, 7, 0, 0, 0, 0, 0, 0], [4, 9, 2, 0, 0,...
def is_magic_square(square): """ Check if a given 3x3 square is a magic square. """ s = 15 # The magic constant for a 3x3 magic square with numbers 1 to 9 # Check rows and columns for i in range(3): if sum(square[i]) != s or sum([row[i] for row in square]) != s: return False...
from solution import count_3x3_magic_squares def test_no_magic_squares(): grid = [[i for i in range(9)] for _ in range(9)] assert count_3x3_magic_squares(grid) == 0 def test_single_magic_square(): grid = [[8, 1, 6, 0, 0, 0, 0, 0, 0], [3, 5, 7, 0, 0, 0, 0, 0, 0], [4, 9, 2, 0, 0, 0, ...
[ { "docstring": "Check if a given 3x3 square is a magic square.", "function_declaration": "def is_magic_square(square):", "function_name": "is_magic_square", "parameter_list": "(square)" }, { "docstring": "Counts the number of 3x3 magic squares within a 9x9 grid.", "function_declaration":...
[ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magic_square(grid):\n \"\"\"\n Determines if a given 3x3 grid is a magic square.\n \"\"\"\n # Sum of all rows, columns and diagonals must be equal and be exactly 15.\n m...
trial_gpt4o_1
{ "original_instruction": "Create a function that determines the total number of 3x3 magic squares within a 9x9 grid. A magic square is a square grid with a specific arrangement of its elements such that the sum of each column, each row, and both main diagonals are all the same. The elements of the magic square must ...
0.671908
Prefill_17854
C
[ "is_magic_square", "count_3x3_magic_squares" ]
2
[ [ "count_3x3_magic_squares", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
683e0cecc6c4b5891eea375a527d0d0704d14256
7e407fc17f88d44d2cbdea90b70c843fc6c5d193
v1.0
complete
Prefill
Prefill_20065_C
def factorial(n: int) -> int: """ Returns the factorial of a given integer 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) 504...
def factorial(n): """ Returns the factorial of a given integer n using recursion. """ # Base case: if n is 0 or 1, return 1 if n == 0 or n == 1: return 1 # Recursive case: n * factorial of (n-1) return n * factorial(n - 1) def check_factorial(): """ Check the accuracy of the...
from solution import 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 assert factorial(4) == 24 def test_factorial_medium_numbers(): assert factorial(5) == 120 ...
[ { "docstring": "Returns the factorial of a given integer n using recursion.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Check the accuracy of the factorial function with data points.", "function_declaration": "de...
[ 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 factorial(n):\n \"\"\"\n Returns the factorial of a non-negative integer n using recursion.\n \"\"\"\n # Base case: factorial of 0 or 1 is 1\n if n == 0 or n == 1:\n ...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes an integer and returns the factorial of that integer using recursion. To ensure the accuracy of your function, include a check function with provided data points to verify that the function works as intended. Additionally, add comments explaining each part of th...
0.747431
Prefill_20065
C
[ "factorial", "check_factorial" ]
2
[ [ "check_factorial", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8d3f8a0b1dc67055b118e34699e678f87b711ab
4dc31cd4bf1ea7815ef86b668779f09a25cb4aef
v1.0
complete
Prefill
Prefill_19658_C
def is_prime(n: int) -> bool: """Helper function to check if a number is prime.""" pass def get_prime_factors(n: int) -> Set[int]: """Helper function to get the prime factors of a number.""" pass def has_lonely_number(arr: List[int]) -> bool: """ Returns True if the array contains at least one...
def is_prime(n): """Helper function to check if a number is prime.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def get_prime_factors(n): """Helper function to get the prime factors of a number.""" factors = s...
from solution import has_lonely_number from solution import get_prime_factors, 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 def test_get_prime_factors(): assert get_prime...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to get the prime factors of a number.", "function_declaration": "def get_prime_factors(n):"...
[ 0, 1, 0, 0, 0, 0, 0, 1, 1, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_lonely_number(num):\n \"\"\"\n Determines whether a number is \"lonely\".\n A lonely number is greater than 10 and has exactly two distinct prime factors.\n \"\"\"\n if ...
trial_gpt4o_1
{ "original_instruction": "Create a function that takes in an integer array and returns a boolean value indicating whether the array contains a \"lonely\" number. A \"lonely\" number is defined as a number that is both greater than 10 and has exactly two distinct prime factors.", "prompt_id": "00019658", "row_id"...
0.708431
Prefill_19658
C
[ "is_prime", "get_prime_factors", "has_lonely_number" ]
3
[ [ "get_prime_factors", "is_prime" ], [ "has_lonely_number", "get_prime_factors" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9b3eca0f1dc784521625458e14887d9f26a25008
f15dda28736fe122ba5ebf012cea03fde8045f31
v1.0
complete
Prefill
Prefill_20318_C
def is_prime(num): """ Returns True if num is a prime number, else False. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(17) == True >>> is_prime(18) == False >>> is_prime(1) == False >>> is_prime(0) == False >>> is_prime(-7) == False ""...
def is_prime(num): """ Returns True if num is a prime number, else False. """ 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: retu...
from solution import is_prime, sum_of_primes_less_than def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(...
[ { "docstring": "Returns True if num is a prime number, else False.", "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...
[ 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 check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 =...
trial_gpt4o_5
{ "original_instruction": "Create a function that takes an integer `n` as input and returns the sum of all prime numbers less than `n`.", "prompt_id": "00020318", "row_id": 20318, "seed_ids": "['magpie_prefill_20318']" }
0.825849
Prefill_20318
C
[ "is_prime", "sum_of_primes_less_than" ]
2
[ [ "sum_of_primes_less_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e21037e270519347284f236a574930bc1ef1680
971f39eb2e49adb4f1d1cd634ef6b95cee258b9c
v1.0
complete
Prefill
Prefill_19955_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ pass def primes_up_to(n: int) -> List[int]: """ Returns a list of all prime numbers between 1 and n (inclusive). >>> primes_up_to(1) == [] >>> primes_up_to(10) == [2, 3, 5, 7] >>> primes_up_to(20) =...
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 primes_up_to(n): """ Returns a list of all prime numbers between 1 and n (i...
from solution import primes_up_to def test_no_primes(): assert primes_up_to(1) == [] def test_primes_up_to_10(): assert primes_up_to(10) == [2, 3, 5, 7] def test_primes_up_to_20(): assert primes_up_to(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_primes_up_to_50(): assert primes_up_to(50) == [2, 3, 5...
[ { "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 all prime numbers between 1 and n (inclusive).", "function_declaration": "def 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(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_4
{ "original_instruction": "Create a function that takes in an integer n and returns the list of all prime numbers between 1 and n (inclusive).", "prompt_id": "00019955", "row_id": 19955, "seed_ids": "['magpie_prefill_19955']" }
0.835467
Prefill_19955
C
[ "is_prime", "primes_up_to" ]
2
[ [ "primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83e47556129a75b1ca1237e753329715a64f4029
bc9893ea7972f58c06a5551ed3f63e9ab8271eab
v1.0
complete
Prefill
Prefill_19951_C
def caesar_cipher_encrypt(text: str, shift: int = 3) -> str: """ Encrypts the input text using Caesar Cipher with a shift of 3. Args: - text (str): The input text to encrypt. - shift (int): The number of positions to shift the alphabet. Default is 3. Returns: - str: The encrypted t...
def caesar_cipher_encrypt(text, shift=3): """ Encrypts the input text using Caesar Cipher with a shift of 3. Args: - text (str): The input text to encrypt. - shift (int): The number of positions to shift the alphabet. Default is 3. Returns: - str: The encrypted text. """ re...
from solution import caesar_cipher_encrypt, caesar_cipher_decrypt def test_caesar_cipher_encrypt_basic(): assert caesar_cipher_encrypt("HELLO") == "KHOOR" def test_caesar_cipher_encrypt_with_non_alpha(): assert caesar_cipher_encrypt("HELLO WORLD!") == "KHOOR ZRUOG!" def test_caesar_cipher_encrypt_lowercase()...
[ { "docstring": "Encrypts the input text using Caesar Cipher with a shift of 3.\n\nArgs:\n- text (str): The input text to encrypt.\n- shift (int): The number of positions to shift the alphabet. Default is 3.\n\nReturns:\n- str: The encrypted text.", "function_declaration": "def caesar_cipher_encrypt(text, sh...
[ 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 caesar_cipher_encrypt(text, shift=3):\n \"\"\"\n Encrypts the given text using Caesar Cipher with a shift of 3.\n \"\"\"\n encrypted_text = \"\"\n for char in text:\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that implements the Caesar Cipher with a shift of 3. The function should take a string as input and return the encrypted string. Additionally, provide a Python code to decode the string using the Caesar Cipher with the same shift value.", "prompt_id": "00019951", "row_...
0.655401
Prefill_19951
C
[ "caesar_cipher_encrypt", "caesar_cipher_decrypt" ]
2
[ [ "caesar_cipher_decrypt", "caesar_cipher_encrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
68a0401a0fb0ba0153d8852b2da9528ff91cc3b6
1323b03459ca04e44dcab71d0d7acb0775b76e8e
v1.0
complete
Prefill
Prefill_21027_C
import re DATABASE = { "projects": [] } def validate_project_name(name): """ Validates if the project name starts with a letter and contains only letters and digits. """ return bool(re.match(r'^[a-zA-Z][a-zA-Z0-9]*$', name)) def validate_version_number(version): """ Validates if the versi...
import re DATABASE = { "projects": [] } def validate_project_name(name): """ Validates if the project name starts with a letter and contains only letters and digits. """ return bool(re.match(r'^[a-zA-Z][a-zA-Z0-9]*$', name)) def validate_version_number(version): """ Validates if the vers...
from solution import get_project_id, DATABASE import pytest def setup_module(module): """ Setup the module by clearing the database. """ DATABASE["projects"].clear() def test_valid_new_project(): setup_module(None) assert get_project_id("ProjectA", "1.0.0") == 1 def test_existing_project(): ...
[ { "docstring": "Validates if the project name starts with a letter and contains only letters and digits.", "function_declaration": "def validate_project_name(name):", "function_name": "validate_project_name", "parameter_list": "(name)" }, { "docstring": "Validates if the version number is in...
[ 1, 1, 0, 1, 0, 1, 1, 0, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndatabase = {}\nproject_id_counter = 1\n\ndef validate_project_name(name):\n if re.match(r\"^[A-Za-z][A-Za-z0-9]*$\", name):\n return True\n return False\n\ndef valid...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes two parameters, a project name and a version number, and generates a project name if it doesn't exist in the database, and returns the project ID. If the project exists, it should return the project ID of the existing project. The project name and version number...
0.462372
Prefill_21027
C
[ "validate_project_name", "validate_version_number", "get_project_id" ]
3
[ [ "get_project_id", "validate_project_name" ], [ "get_project_id", "validate_version_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
79da3d28bce0403c2086fa62724f0bf01ec125bb
d2063559d9e29ca94bd56a3e0a9c791daf585182
v1.0
complete
Prefill
Prefill_20688_C
def sum_of_primes(arr: List[int]) -> int: """ Create a function that takes in an array of integers and returns the sum of all the prime numbers in the array. Prime numbers are numbers greater than 1 that have no divisors other than 1 and themselves. >>> sum_of_primes([]) 0 >>> sum_of_primes([1, 4, 6, 8,...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False ...
from solution import sum_of_primes def test_empty_array(): assert sum_of_primes([]) == 0 def test_array_with_no_primes(): assert sum_of_primes([1, 4, 6, 8, 9, 10]) == 0 def test_array_with_all_primes(): assert sum_of_primes([2, 3, 5, 7, 11]) == 28 def test_array_with_mixed_numbers(): assert sum_of_p...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the input array.", "function_declaration": "def sum_of_primes(arr):...
[ 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 if n == 2:\n return True\n if n % 2 == 0:\n return False...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes in an array of integers and returns the sum of all the prime numbers in the array. Prime numbers are numbers greater than 1 that have no divisors other than 1 and themselves.", "prompt_id": "00020688", "row_id": 20688, "seed_ids": "['magpie_prefill_20688']...
0.750713
Prefill_20688
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
52c44d5e56b835dfef2a18557a3965e0768fa51c
64cd8214ee8cffab8fbe0832878a1bd1886b4050
v1.0
complete
Prefill
Prefill_20779_C
def longest_palindrome(s: str) -> str: """ Finds the longest palindrome in the given string s. A palindrome is a string that reads the same backward as forward, e.g., "radar" or "level". If there are multiple longest palindromes, returns the first one found. If no palindrome is found, returns an empty...
def longest_palindrome(s): """ Returns the longest palindrome found in the string s. If there are multiple longest palindromes, it returns the first one found. If no palindrome is found, it returns an empty string. """ n = len(s) if n == 0: return "" longest = "" ...
from solution import longest_palindrome def test_single_character(): assert longest_palindrome("a") == "a" def test_multiple_characters(): assert longest_palindrome("babad") in ["bab", "aba"] assert longest_palindrome("cbbd") == "bb" def test_palindrome_at_end(): assert longest_palindrome("forgeekssk...
[ { "docstring": "Returns the longest palindrome found in the string s.\nIf there are multiple longest palindromes, it returns the first one found.\nIf no palindrome is found, it returns an empty string.", "function_declaration": "def longest_palindrome(s):", "function_name": "longest_palindrome", "pa...
[ 0, 0, 1, 0, 1, 0, 1, 0, 1, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindrome(s):\n \"\"\"\n Finds the longest palindrome in a given string.\n \n :param s: Input string\n :return: Longest palindromic substring\n \"\"\"\n if n...
trial_gpt4o_8
{ "original_instruction": "Create a function that finds the longest palindrome in a given string. A palindrome is a string that reads the same backward as forward, e.g., \"radar\" or \"level\". The function should return the longest palindrome found in the string. If there are multiple longest palindromes, return the...
0.780358
Prefill_20779
C
[ "longest_palindrome", "expand_around_center" ]
2
[ [ "longest_palindrome", "expand_around_center" ] ]
1
[]
false
[]
false
pytest
true
[]
true
abad6e77af95c13ff2d8985c536319d4c4cc5864
06dbe50a5008e88fdbcc3910b429d49a4f24dbed
v1.0
complete
Prefill
Prefill_20515_C
def is_prime(num): """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(29) True >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-5) False """ def first_n_primes(n): ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def...
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(0) == False assert is_prime(-5) == False def test_first_n_primes(): ...
[ { "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 the first 'n' prime numbers.", "function_declaration": "def first_n_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(num):\n \"\"\"\n Check if the number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i =...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a number as an argument and prints out the first \"n\" prime numbers. How can this be achieved in Python?", "prompt_id": "00020515", "row_id": 20515, "seed_ids": "['magpie_prefill_20515']" }
0.860516
Prefill_20515
C
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
49807c881d3c2e80f888d2b890f72d1277197f36
d928b627c6d238162e29343e41d8857309328b87
v1.0
complete
Prefill
Prefill_20723_C
def is_palindrome(num: int) -> bool: """ Check if a number is a palindrome. """ pass def palindromic_numbers(nums: List[int]) -> Tuple[List[int], int]: """ Return a list of palindromic numbers and the count of such numbers from the provided list of integers. Args: nums (list of int...
def is_palindrome(num): """ Check if a number is a palindrome. """ return str(num) == str(num)[::-1] def palindromic_numbers(nums): """ Return a list of palindromic numbers and the count of such numbers from the provided list of integers. Args: nums (list of int): The list of integ...
from solution import palindromic_numbers def test_palindromic_numbers_single_digit(): assert palindromic_numbers([1, 2, 3, 4, 5]) == ([1, 2, 3, 4, 5], 5) def test_palindromic_numbers_mixed(): assert palindromic_numbers([121, 123, 131, 1221, 12321, 12345]) == ([121, 131, 1221, 12321], 4) def test_palindromic_...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Return a list of palindromic numbers and the count of such numbers from the provided list of integers.\n\nArg...
[ 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 is_palindrome(n):\n \"\"\"\n Helper function to check if an integer is a palindrome.\n \"\"\"\n s = str(n)\n return s == s[::-1]\n\ndef filter_palindromic_numbers(numbers):...
trial_gpt4o_9
{ "original_instruction": "Create a function that accepts a list of integers and returns a new list containing only the integers that are palindromic numbers. A palindromic number reads the same forward and backward. Additionally, the function should return the count of such palindromic numbers.", "prompt_id": "000...
0.789485
Prefill_20723
C
[ "is_palindrome", "palindromic_numbers" ]
2
[ [ "palindromic_numbers", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bb5915d0d590c3347d108faf3559a129f31e6313
1ef2e7e1f53c491f54734d1e374af1c0e757cb7c
v1.0
complete
Prefill
Prefill_20068_C
def bubble_sort(arr): """ Sorts an array in ascending order using the bubble sort algorithm. """ n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr def find_largest_integer(arr): ...
def bubble_sort(arr): """ Sorts an array in ascending order using the bubble sort algorithm. """ n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr def find_largest_integer(arr): ...
from solution import find_largest_integer def test_empty_array(): assert find_largest_integer([]) == None def test_single_element_array(): assert find_largest_integer([5]) == 5 def test_all_positive_numbers(): assert find_largest_integer([1, 2, 3, 4, 5]) == 5 def test_all_negative_numbers(): assert ...
[ { "docstring": "Sorts an array in ascending order using the bubble sort algorithm.", "function_declaration": "def bubble_sort(arr):", "function_name": "bubble_sort", "parameter_list": "(arr)" }, { "docstring": "Returns the largest integer in the array by first sorting it using bubble sort.",...
[ 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 bubble_sort(arr):\n \"\"\"\n Bubble sort function that sorts an array in ascending order.\n \"\"\"\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that accepts an array of integers as a parameter and returns the largest integer in the array. Sort the array in ascending order using the bubble sort algorithm, then find the largest number in the array.", "prompt_id": "00020068", "row_id": 20068, "seed_ids": "['mag...
0.690108
Prefill_20068
C
[ "bubble_sort", "find_largest_integer" ]
2
[ [ "find_largest_integer", "bubble_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4cbfd71b1cd912f3bdc726e2a53c60a339528e3b
7489223104c76ada6c9d1f09e06d39730979db52
v1.0
complete
Prefill
Prefill_21407_C
def generate_primes(start: int, end: int) -> List[int]: """ Generate a list of all prime numbers between two integers, start and end, inclusive. >>> generate_primes(10, 20) [11, 13, 17, 19] >>> generate_primes(5, 10) [5, 7] >>> generate_primes(30, 40) [31, 37] >>> generate_primes(1, 10) [2, 3, 5, 7]...
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False # Other even numbers are not prime max_divisor = int(n ** 0.5) + 1 for d in r...
from solution import generate_primes def test_primes_in_range(): assert generate_primes(10, 20) == [11, 13, 17, 19] assert generate_primes(5, 10) == [5, 7] assert generate_primes(30, 40) == [31, 37] assert generate_primes(1, 10) == [2, 3, 5, 7] def test_primes_at_bounds(): assert generate_primes(1...
[ { "docstring": "Helper function to determine 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 between the integers start and end, inclusive.", "function_declara...
[ 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 the number `n` is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if ...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates a list of all prime numbers between two integers, `start` and `end`. The function should include the start and end integers if they are prime. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.", "promp...
0.684851
Prefill_21407
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
700b21876959a25a55a601d29104be4d3711d05d
34489b2469024b18c330178951ec211ea523b8ec
v1.0
complete
Prefill
Prefill_20587_C
import sqlite3 def create_connection(): """ Create a connection to the SQLite database. """ pass def setup_database(conn): """ Set up the initial database schema and populate tables with data. """ pass def place_order(customer_id, product_id, quantity): """ Create a function that processes an...
import sqlite3 def create_connection(): conn = sqlite3.connect(':memory:') # Create an in-memory database for demonstration purposes return conn def setup_database(conn): cursor = conn.cursor() cursor.execute('''CREATE TABLE customer_details_table ( customer_id INTEGER PRIMARY...
import pytest from solution import place_order, create_connection, setup_database @pytest.fixture(scope='module') def setup_test_db(): conn = create_connection() setup_database(conn) yield conn conn.close() def test_place_order_success(setup_test_db): customer_details, new_order_details = place_or...
[ { "docstring": null, "function_declaration": "def create_connection():", "function_name": "create_connection", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def setup_database(conn):", "function_name": "setup_database", "parameter_list": "(conn)" }, ...
[ 1, 1, 1, 1, 0, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def place_order(customer_id, product_id, quantity):\n \"\"\"\n Processes an order for a customer including stock validation, \n stock deduction, and updating order history.\n \n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes the following arguments, customer_id, product_id, and quantity. This function should retrieve customer_details from the customer_details_table where customer_id matches. After that, it should validate the product_id against the products_available_table to ensure...
0.533052
Prefill_20587
C
[ "create_connection", "setup_database", "place_order" ]
3
[ [ "place_order", "create_connection" ], [ "place_order", "setup_database" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c9be085701fad3fca72f819973f43f749cd3c83b
fa6a24db4c43c021a7e73bf557c85ff409d80c2c
v1.0
complete
Prefill
Prefill_20331_C
def is_prime(n): """ Helper function to check if a number is prime. """ # Your code goes here def sum_or_prime_check(a, b): """ Returns the sum of a and b, or a message if one or both numbers are prime. >>> sum_or_prime_check(3, 5) == "Both numbers are prime numbers." >>> sum_or_prime_...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def sum_or_prime_check(a, b): """ Returns the sum of a and b, or a message if one or bo...
from solution import sum_or_prime_check def test_sum_or_prime_check_with_prime_numbers(): assert sum_or_prime_check(3, 5) == "Both numbers are prime numbers." assert sum_or_prime_check(2, 9) == "One of the numbers is a prime number." assert sum_or_prime_check(10, 7) == "One of the numbers is a prime number...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of a and b, or a message if one or both numbers are prime.", "function_declaration": "def s...
[ 0, 1, 1, 0, 1, 1, 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(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": "Create a function that takes two numbers as input and returns the sum of the two numbers. However, the function should also check if either of the numbers is a prime number and return the string \"One of the numbers is a prime number.\" if either number is prime. If both numbers are prime, ...
0.815276
Prefill_20331
C
[ "is_prime", "sum_or_prime_check" ]
2
[ [ "sum_or_prime_check", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4a943e2ee69799d97d6ac923e88da14ff53a5aab
77c94cdeaff68f09b88b6fe108e195f41ec11117
v1.0
complete
Prefill
Prefill_20626_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, else False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(11) True >>> is_prime(15) False """ def count_greater_than_ten_and_prime(...
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i...
from solution import count_greater_than_ten_and_prime, is_prime def test_is_prime(): assert is_prime(2) is True assert is_prime(3) is True assert is_prime(4) is False assert is_prime(5) is True assert is_prime(11) is True assert is_prime(15) is False def test_count_greater_than_ten_and_prime()...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the number of elements in the array that are greater than 10 and are prime numbers.", "function_d...
[ 1, 1, 1, 0, 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": "from math import isqrt\n\ndef 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 re...
trial_gpt4o_4
{ "original_instruction": "Create a function that receives an array of integers and returns the number of elements that are greater than 10 and are prime numbers.", "prompt_id": "00020626", "row_id": 20626, "seed_ids": "['magpie_prefill_20626']" }
0.766856
Prefill_20626
C
[ "is_prime", "count_greater_than_ten_and_prime" ]
2
[ [ "count_greater_than_ten_and_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
23dceeb89e0c3c76f2a906aac633eb1691f35b8a
1961bc9f35d43e30439e0f5cf9a40f4fafafc276
v1.0
complete
Prefill
Prefill_20836_C
def sum_numbers(numbers: List[int]) -> int: """Returns the sum of the numbers in the list. >>> sum_numbers([1, 2, 3, 4, 5]) == 15 >>> sum_numbers([-1, -2, -3, -4, -5]) == -15 >>> sum_numbers([-1, 2, -3, 4, -5]) == -3 >>> sum_numbers([]) == 0 """ def max_number(numbers: List[int]) -> int: ""...
def sum_numbers(numbers): """ Returns the sum of the numbers in the list. """ return sum(numbers) def max_number(numbers): """ Returns the maximum number in the list. """ return max(numbers) def sum_and_max(numbers): """ Returns a tuple containing the sum and the maximum number...
from solution import sum_numbers, max_number, sum_and_max def test_sum_numbers_with_positive_numbers(): assert sum_numbers([1, 2, 3, 4, 5]) == 15 def test_sum_numbers_with_negative_numbers(): assert sum_numbers([-1, -2, -3, -4, -5]) == -15 def test_sum_numbers_with_mixed_numbers(): assert sum_numbers([-1...
[ { "docstring": "Returns the sum of the numbers in the list.", "function_declaration": "def sum_numbers(numbers):", "function_name": "sum_numbers", "parameter_list": "(numbers)" }, { "docstring": "Returns the maximum number in the list.", "function_declaration": "def max_number(numbers):"...
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\n\ndef sum_numbers(numbers: List[int]) -> int:\n \"\"\"\n Returns the sum of the numbers in the list.\n \"\"\"\n return sum(numbers)\n\ndef max_numb...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a list of numbers and returns their sum. You should then create another function that takes a list of numbers and returns their maximum value. Finally, create a function that takes a list of numbers and returns both the sum and the maximum value.", "prompt_id"...
0.684404
Prefill_20836
C
[ "sum_numbers", "max_number", "sum_and_max" ]
3
[ [ "sum_and_max", "max_number" ], [ "sum_and_max", "sum_numbers" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2ed4be54976a40b91a80f59b119e27f4716863dc
6d0d2ca51f27f4aae3550c84fe494bbf3f2f9079
v1.0
complete
Prefill
Prefill_21696_C
def largest_palindrome_product(n: int) -> int: """ Create a function that takes an integer N and returns the largest palindrome made from the product of two N-digit numbers. >>> largest_palindrome_product(2) == 9009 >>> largest_palindrome_product(3) == 906609 >>> largest_palindrome_product(1) == 9 ...
def is_palindrome(number): """ Checks if a number is a palindrome. """ return str(number) == str(number)[::-1] def largest_palindrome_product(n): """ Find the largest palindrome made from the product of two n-digit numbers. """ max_num = 10**n - 1 min_num = 10**(n-1) max_palindr...
from solution import largest_palindrome_product def test_largest_palindrome_product_2_digits(): assert largest_palindrome_product(2) == 9009 # 91 * 99 = 9009 def test_largest_palindrome_product_3_digits(): assert largest_palindrome_product(3) == 906609 # 913 * 993 = 906609 def test_largest_palindrome_produ...
[ { "docstring": "Checks if a number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Find the largest palindrome made from the product of two n-digit numbers.", "function_declaration"...
[ 1, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Checks if the provided number n is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef largest_palindrome_product(n):\n \"\"\"\n R...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes an integer N and returns the largest palindrome made from the product of two N-digit numbers.", "prompt_id": "00021696", "row_id": 21696, "seed_ids": "['magpie_prefill_21696']" }
0.705614
Prefill_21696
C
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ce44a0be7bf43463b4502be56f867c2a138afc8c
7b13631f6338a456de2d7e8263e0889dd89339c8
v1.0
complete
Prefill
Prefill_21169_C
def is_prime(n: int) -> bool: """ 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(1) False >>> is_prime(0) False >>> is_prime(-5) False """ def sum_of_primes(a: int, b: int) -> ...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def sum_of_primes(a, b): """...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == Fal...
[ { "docstring": "Check 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 between a and b (inclusive).", "function_declaration": "def sum_of_primes(a, b):", "f...
[ 1, 0, 1, 1, 1, 0, 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 \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes two numbers and returns the sum of all prime numbers between these two numbers (inclusive). Prime numbers are numbers greater than 1 that have no divisors other than 1 and themselves.", "prompt_id": "00021169", "row_id": 21169, "seed_ids": "['magpie_prefil...
0.78145
Prefill_21169
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
70f98c6c984978c19219808bb9bdd9c8397bc531
a55d5c17e51e576c9711a317f1e683951e70b4dd
v1.0
complete
Prefill
Prefill_21370_C
def sum_with_conversion(a, b): """ Return the sum of a and b after converting them to numbers. If both a and b cannot be converted to numbers, return 0. >>> sum_with_conversion(3, 4) 7 >>> sum_with_conversion('3', '4') 7 >>> sum_with_conversion(3, '4') 7 >>> sum_with_conversion('a', 'b') 0 ...
def convert_to_number(value): """ Attempt to convert the value to a number. If it fails, return None. """ try: return float(value) except (ValueError, TypeError): return None def sum_with_conversion(a, b): """ Return the sum of a and b after converting them to numbers. ...
from solution import sum_with_conversion def test_sum_with_conversion_both_numbers(): assert sum_with_conversion(3, 4) == 7 assert sum_with_conversion(0, 5) == 5 def test_sum_with_conversion_string_numbers(): assert sum_with_conversion('3', '4') == 7 assert sum_with_conversion('0', '5') == 5 asser...
[ { "docstring": "Attempt to convert the value to a number.\nIf it fails, return None.", "function_declaration": "def convert_to_number(value):", "function_name": "convert_to_number", "parameter_list": "(value)" }, { "docstring": "Return the sum of a and b after converting them to numbers.\nIf...
[ 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 add(a, b):\n \"\"\"\n Returns the sum of a and b converting them to numbers if necessary.\n If both a and b can't be converted to numbers, returns 0.\n \"\"\"\n try:\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes two numbers, a and b, and returns their sum. If a is not a number, convert it to a number before the operation. If b is also not a number, convert it to a number before the operation. If both a and b are not numbers, return 0.", "prompt_id": "00021370", "row...
0.688161
Prefill_21370
C
[ "convert_to_number", "sum_with_conversion" ]
2
[ [ "sum_with_conversion", "convert_to_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
763017420d1f21f16d285465bb83e77afb2be877
dcc7f24d892717e6bb7ec2ca3da3ab091b0d46b2
v1.0
complete
Prefill
Prefill_20377_C
def merge_sort_descending(arr): """ Takes a list of numbers and returns a new list with the numbers sorted in descending order using the merge sort algorithm. >>> merge_sort_descending([4, 1, 5, 3, 2]) [5, 4, 3, 2, 1] >>> merge_sort_descending([-1, -3, -2, -5, -4]) [-1, -2, -3, -4, -5] >>> m...
def merge_sort_descending(arr): """ Takes a list of numbers and returns a new list with the numbers sorted in descending order using the merge sort algorithm. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = merge_sort_descending(arr[:mid]) right_half = merge_sort_de...
from solution import merge_sort_descending def test_merge_sort_descending_with_positive_numbers(): assert merge_sort_descending([4, 1, 5, 3, 2]) == [5, 4, 3, 2, 1] def test_merge_sort_descending_with_negative_numbers(): assert merge_sort_descending([-1, -3, -2, -5, -4]) == [-1, -2, -3, -4, -5] def test_merge...
[ { "docstring": "Takes a list of numbers and returns a new list with the numbers sorted in descending order using the merge sort algorithm.", "function_declaration": "def merge_sort_descending(arr):", "function_name": "merge_sort_descending", "parameter_list": "(arr)" }, { "docstring": null, ...
[ 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 a list in descending order using merge sort algorithm.\n \n Parameters:\n arr (list): List of numbers\n \n Returns:\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of numbers and returns a new list with the numbers sorted in descending order using merge sort algorithm.", "prompt_id": "00020377", "row_id": 20377, "seed_ids": "['magpie_prefill_20377']" }
0.629568
Prefill_20377
C
[ "merge_sort_descending", "merge" ]
2
[ [ "merge_sort_descending", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d3541c506e92eca351ca79a950f91ee40a0591f0
afe6c3a18d2d29c6e62fa717608effea6ea73447
v1.0
complete
Prefill
Prefill_22069_C
def get_test_message() -> str: """ Returns the test message string. >>> get_test_message() "This is a test message." """ def print_test_passed(): """ Prints 'Test passed.' if `get_test_message` returns the correct message. """
def get_test_message(): """ Returns the test message string. """ return "This is a test message." def print_test_passed(): """ Prints 'Test passed.' if `get_test_message` returns the correct message. """ if get_test_message() == "This is a test message.": print("Test passed.")
from solution import get_test_message, print_test_passed def test_get_test_message(): assert get_test_message() == "This is a test message." def test_print_test_passed(capsys): print_test_passed() captured = capsys.readouterr() assert captured.out.strip() == "Test passed."
[ { "docstring": "Returns the test message string.", "function_declaration": "def get_test_message():", "function_name": "get_test_message", "parameter_list": "()" }, { "docstring": "Prints 'Test passed.' if `get_test_message` returns the correct message.", "function_declaration": "def 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 test_message():\n \"\"\"\n Returns a test message.\n \"\"\"\n return \"This is a test message.\"\n\ndef call_and_verify():\n \"\"\"\n Calls test_message and prints \"Tes...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes no parameters and returns a string that contains the message \"This is a test message.\" Is the function then called, it should print \"Test passed.\".", "prompt_id": "00022069", "row_id": 22069, "seed_ids": "['magpie_prefill_22069']" }
0.509625
Prefill_22069
C
[ "get_test_message", "print_test_passed" ]
2
[ [ "print_test_passed", "get_test_message" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e2d8f4a6cf79c6fd3eae465ca18edb9459d5858
aba82a91808c5a26b2e2bc94f481aae7f1cf847c
v1.0
complete
Prefill
Prefill_21138_C
def is_prime(num): """ Helper function to check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False """ pass def generate_primes(n): """ Generates a list of prime numbers up to a given number n, where n is a positive integer. ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True # 2 is the only even prime number if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: r...
from solution import is_prime, generate_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == F...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a list of prime numbers up to a given number n.", "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(number):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if number <= 1:\n return False\n if number == 2:\n return True\n if ...
trial_gpt4o_6
{ "original_instruction": "Create a function that generates a list of prime numbers up to a given number n, where n is a positive integer. You want to use a helper function to check if a number is prime. The primes should be generated in ascending order. For example, for n=10, the function should return `[2, 3, 5, 7]...
0.804624
Prefill_21138
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b7585e854f10d6a21841627ee7e969b14d183090
144c184160a17720d3987817911f6686e29688e6
v1.0
complete
Prefill
Prefill_22014_C
def generate_primes(start: int, end: int) -> List[int]: """ Generate a list of prime numbers between a given range of numbers. >>> generate_primes(10, 50) [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47] >>> generate_primes(5, 10) [5, 7] >>> generate_primes(8, 10) [] ...
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...
from solution import generate_primes def test_generate_primes_standard_range(): assert generate_primes(10, 50) == [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47] def test_generate_primes_single_prime_range(): assert generate_primes(5, 10) == [5, 7] def test_generate_primes_no_primes_range(): assert generate...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate a list of prime numbers in the given range [start, end].", "function_declaration": "def generate_primes(start, end):"...
[ 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 Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n...
trial_gpt4o_8
{ "original_instruction": "Create a function that generates a list of prime numbers between a given range of numbers. Provide an example usage of the function.", "prompt_id": "00022014", "row_id": 22014, "seed_ids": "['magpie_prefill_22014']" }
0.688366
Prefill_22014
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ac8aa81cd1cf39aa9fbff2d9172bd78e602605e8
d65d60b1980255a7ca53cab9f3f826fe55123d9b
v1.0
complete
Prefill
Prefill_21903_C
def add(a: int, b: int) -> int: """ Returns the sum of a and b. >>> add(2, 3) 5 >>> add(0, 5) 5 >>> add(-1, -1) -2 """ def add_and_print(a: int, b: int) -> int: """ Adds a and b using add function, and prints the result. >>> add_and_print(2, 3) 5 >>> add_and_...
def add(a, b): """ Returns the sum of a and b. """ return a + b def add_and_print(a, b): """ Adds a and b using add function, and prints the result. """ result = add(a, b) print(result) return result
import sys from io import StringIO import pytest from solution import add, add_and_print def test_add_positive_numbers(): assert add(2, 3) == 5 def test_add_with_zero(): assert add(0, 5) == 5 assert add(5, 0) == 5 def test_add_negative_numbers(): assert add(-1, -1) == -2 def test_add_mixed_sign_numb...
[ { "docstring": "Returns the sum of a and b.", "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": "Adds a and b using add function, and prints the result.", "function_declaration": "def add_and_print(a, b):", "function_name":...
[ 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 add_two_numbers(a, b):\n \"\"\"\n Returns the sum of a and b.\n \"\"\"\n return a + b\n\ndef print_sum_of_two_numbers(a, b):\n \"\"\"\n Calls add_two_numbers to add a an...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes two integers as input parameters and add them together. Then, create a new function that calls this addition function and prints the result.", "prompt_id": "00021903", "row_id": 21903, "seed_ids": "['magpie_prefill_21903']" }
0.809928
Prefill_21903
C
[ "add", "add_and_print" ]
2
[ [ "add_and_print", "add" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20623fedbfc65e8ed321904166ec704daf9b1f1d
16968d81a230325e9e47077011886aaf7859bec5
v1.0
complete
Prefill
Prefill_21220_C
import time def factorial_recursive(n): """ Returns the factorial of n using recursive method. >>> factorial_recursive(0) == 1 >>> factorial_recursive(1) == 1 >>> factorial_recursive(5) == 120 >>> factorial_recursive(10) == 3628800 """ def factorial_iterative(n): """ Returns th...
import time def factorial_recursive(n): """ Returns the factorial of n using recursive method. """ if n == 0: return 1 else: return n * factorial_recursive(n-1) def factorial_iterative(n): """ Returns the factorial of n using iterative method. """ result = 1 fo...
from solution import factorial_recursive, factorial_iterative, compare_efficiency def test_factorial_recursive(): assert factorial_recursive(0) == 1 assert factorial_recursive(1) == 1 assert factorial_recursive(5) == 120 assert factorial_recursive(10) == 3628800 def test_factorial_iterative(): ass...
[ { "docstring": "Returns the factorial of n using recursive method.", "function_declaration": "def factorial_recursive(n):", "function_name": "factorial_recursive", "parameter_list": "(n)" }, { "docstring": "Returns the factorial of n using iterative method.", "function_declaration": "def...
[ 1, 0, 1, 0, 1, 1, 1, 0, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\ndef factorial_recursive(n):\n \"\"\"\n Returns the factorial of a given number n using recursion.\n \"\"\"\n if n <= 1:\n return 1\n else:\n return...
trial_gpt4o_6
{ "original_instruction": "Create a function that calculates the factorial of a number using both recursive and iterative methods. Then, compare the efficiency of both approaches.", "prompt_id": "00021220", "row_id": 21220, "seed_ids": "['magpie_prefill_21220']" }
0.576328
Prefill_21220
C
[ "factorial_recursive", "factorial_iterative", "compare_efficiency" ]
3
[ [ "compare_efficiency", "factorial_iterative" ], [ "compare_efficiency", "factorial_recursive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4b72489e283dcfbf255717c2bdcbe3f12cdcfcf4
36d4d9bdd4d26ddbaa8b04612c531a9056ce46a3
v1.0
complete
Prefill
Prefill_21744_C
def is_prime(n: int) -> bool: """Checks if a number is prime.""" # Implementation omitted def generate_primes(start: int, end: int) -> List[int]: """Generates a list of prime numbers in the given range [start, end]. >>> generate_primes(14, 16) [] >>> generate_primes(10, 11) [11] >>...
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def g...
from solution import generate_primes def test_generate_primes_empty_range(): assert generate_primes(14, 16) == [] def test_generate_primes_single_prime(): assert generate_primes(10, 11) == [11] def test_generate_primes_multiple_primes(): assert generate_primes(10, 20) == [11, 13, 17, 19] def test_ge...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of prime numbers in the given range [start, end].", "function_declaration": "def generate_primes(start, end)...
[ 1, 1, 1, 1, 0, 1, 0, 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 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_9
{ "original_instruction": "Create a function that generates a list of prime numbers within a given range. The range is defined by two integers, `start` and `end`.", "prompt_id": "00021744", "row_id": 21744, "seed_ids": "['magpie_prefill_21744']" }
0.752228
Prefill_21744
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c4d8030fd3f8f3e9c77a920640781e7abb1164be
9790cbe91670fc792deb4f79c46769642e66c312
v1.0
complete
Prefill
Prefill_21000_C
from typing import List, Tuple def mean_median_mode(lst: List[float]) -> Tuple[float, float, List[float]]: """ Create a function that takes in a list of numbers and returns the mean, median, and mode of the list. >>> mean_median_mode([3]) == (3.0, 3.0, [3]) >>> mean_median_mode([1, 2, 3, 4]) == (2.5, 2.5, ...
from typing import List, Tuple from collections import Counter def calculate_mean(lst: List[float]) -> float: return sum(lst) / len(lst) def calculate_median(lst: List[float]) -> float: sorted_lst = sorted(lst) n = len(lst) mid = n // 2 if n % 2 == 0: return (sorted_lst[mid-1] + sorted_lst...
from solution import mean_median_mode def test_mean_median_mode_single_element(): assert mean_median_mode([3]) == (3.0, 3.0, [3]) def test_mean_median_mode_even_count(): assert mean_median_mode([1, 2, 3, 4]) == (2.5, 2.5, [1, 2, 3, 4]) def test_mean_median_mode_odd_count(): assert mean_median_mode([1, 2,...
[ { "docstring": null, "function_declaration": "def calculate_mean(lst):", "function_name": "calculate_mean", "parameter_list": "(lst)" }, { "docstring": null, "function_declaration": "def calculate_median(lst):", "function_name": "calculate_median", "parameter_list": "(lst)" }, ...
[ 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\nimport statistics\n\ndef calculate_mean_median_mode(numbers):\n \"\"\"\n Returns the mean, median, and mode of the list of numbers.\n \"\"\"\n if ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes in a list of numbers and returns the mean, median, and mode of the list.", "prompt_id": "00021000", "row_id": 21000, "seed_ids": "['magpie_prefill_21000']" }
0.779868
Prefill_21000
C
[ "calculate_mean", "calculate_median", "calculate_mode", "mean_median_mode" ]
4
[ [ "mean_median_mode", "calculate_mean" ], [ "mean_median_mode", "calculate_median" ], [ "mean_median_mode", "calculate_mode" ] ]
3
[]
false
[]
false
pytest
true
[]
true
6a5824a569293b5cafd1f5b2df458c6a0aefd04f
84f4de18ab0c2642f63231812535bcc78d7361eb
v1.0
complete
Prefill
Prefill_21828_C
def longest_palindrome_substring(word: str) -> str: """ Return the longest palindromic substring in the given word. >>> longest_palindrome_substring("babad") "bab" >>> longest_palindrome_substring("cbbd") "bb" >>> longest_palindrome_substring("a") "a" >>> longest_palindrome_substring("ac") "a" ...
def longest_palindrome_substring(word): """ Return the longest palindromic substring in the given word. """ def expand_around_center(s, left, right): while left >= 0 and right < len(s) and s[left] == s[right]: left -= 1 right += 1 return s[left + 1:right] if ...
from solution import longest_palindrome_substring, replace_words_with_longest_palindromes def test_longest_palindrome_substring(): assert longest_palindrome_substring("babad") == "bab" or longest_palindrome_substring("babad") == "aba" assert longest_palindrome_substring("cbbd") == "bb" assert longest_palin...
[ { "docstring": "Return the longest palindromic substring in the given word.", "function_declaration": "def longest_palindrome_substring(word):", "function_name": "longest_palindrome_substring", "parameter_list": "(word)" }, { "docstring": "Replace each word in the input string with its longe...
[ 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_palindrome_substring(s):\n \"\"\"\n Given a string s, this function returns the longest palindromic substring in s.\n \"\"\"\n n = len(s)\n if n == 0:\n retu...
trial_gpt4o_2
{ "original_instruction": "Create a function that takes a string and returns a new string with each word replaced by its longest palindrome substring.", "prompt_id": "00021828", "row_id": 21828, "seed_ids": "['magpie_prefill_21828']" }
0.766075
Prefill_21828
C
[ "longest_palindrome_substring", "replace_words_with_longest_palindromes" ]
2
[ [ "replace_words_with_longest_palindromes", "longest_palindrome_substring" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a2b33338f28a9dc6941f3473153ebd8e95d3d69a
7e43244942d8488ceaacbf2b8dfc8d954781cddd
v1.0
complete
Prefill
Prefill_21851_C
from typing import List def is_prime(n: 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(29) True >>> is_prime(49) False """ def sum_of_primes(arr: List[int]) -> int: """ Returns th...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) assert is_prime(3) assert is_prime(5) assert not is_prime(4) assert not is_prime(1) assert is_prime(29) assert not is_prime(49) def test_sum_of_primes_empty_array(): assert sum_of_primes([]) == 0 def ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the input array.", "function_declaration": "def sum_of_primes(arr):...
[ 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 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...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes an array of positive integers and returns an array containing the sum of all prime numbers found in the input array.", "prompt_id": "00021851", "row_id": 21851, "seed_ids": "['magpie_prefill_21851']" }
0.778436
Prefill_21851
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
46916af4dbcae61ebae506bc3d37c2d8967d254d
f807ec79fd75e83f8270afcdb74deb8cd663d7bb
v1.0
complete
Prefill
Prefill_21567_C
from typing import List def binary_search_recursive(arr: List[int], target: int, left: int, right: int) -> int: """ Perform binary search on a sorted list using recursion. """ pass def combined_binary_search(list1: List[int], list2: List[int], target: int) -> int: """ Takes in two lists and uses binar...
def binary_search_recursive(arr, target, left, right): if left > right: return -1 mid = (left + right) // 2 if arr[mid] == target: return mid elif arr[mid] < target: return binary_search_recursive(arr, target, mid + 1, right) else: return binary_search_recursive(arr, ...
from solution import combined_binary_search def test_combined_binary_search_target_present(): list1 = [1, 3, 5, 7] list2 = [2, 4, 6, 8] target = 5 assert combined_binary_search(list1, list2, target) == 4 def test_combined_binary_search_target_not_present(): list1 = [1, 3, 5, 7] list2 = [2, 4, ...
[ { "docstring": null, "function_declaration": "def binary_search_recursive(arr, target, left, right):", "function_name": "binary_search_recursive", "parameter_list": "(arr, target, left, right)" }, { "docstring": null, "function_declaration": "def combined_binary_search(list1, list2, targ...
[ 1, 1, 1, 0, 0, 0, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def binary_search_combined(list1, list2, target):\n \"\"\"\n Performs binary search to find a target value in the combined sorted list of list1 and list2.\n\n Args:\n list1 (list ...
trial_gpt4o_8
{ "original_instruction": "Create a function that supports a binary search based algorithm using recursion. I want a function that takes in two lists (list1 and list2) and uses binary search to find a target value in the combined list of list1 and list2. The combined list should not exceed 1000 elements.", "prompt_...
0.55991
Prefill_21567
C
[ "binary_search_recursive", "combined_binary_search" ]
2
[ [ "combined_binary_search", "binary_search_recursive" ] ]
1
[]
false
[]
false
pytest
true
[]
true
75698550a8e754c8d409af4bb29028942d91341b
d0e44bd514f1debed0b9869d34dea42f9416f893
v1.0
complete
Prefill
Prefill_22216_C
from typing import List def list_factorials(nums: List[int]) -> List[int]: """ Takes in a list of integers and returns a new list where each element is its factorial. This function uses an iterative approach to calculate the factorials and handles large numbers efficiently. >>> list_factorials([5]...
def factorial(n): """ Returns the factorial of a number n. """ if n == 0: return 1 result = 1 for i in range(1, n + 1): result *= i return result def list_factorials(nums): """ Takes in a list of integers and returns a new list where each element is its factorial. ...
from solution import list_factorials def test_list_factorials_single_element(): assert list_factorials([5]) == [120] def test_list_factorials_multiple_elements(): assert list_factorials([0, 1, 2, 3, 4, 5]) == [1, 1, 2, 6, 24, 120] def test_list_factorials_with_large_number(): assert list_factorials([10])...
[ { "docstring": "Returns the factorial of a number n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Takes in a list of integers and returns a new list where each element is its factorial.", "function_declaration": "...
[ 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": "from math import factorial\n\ndef list_factorial(numbers):\n \"\"\"\n Takes a list of integers and returns a list where each element is its factorial.\n \n :param numbers: List of...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes in a list of integers and returns a new list where each element is its factorial. The function should be able to handle large numbers efficiently and use an iterative approach for calculating the factorial.", "prompt_id": "00022216", "row_id": 22216, "seed...
0.731988
Prefill_22216
C
[ "factorial", "list_factorials" ]
2
[ [ "list_factorials", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a05334b2bb20c2977c2def079151ee2004330a5
3f6a293f987789ee13c4621da37efd7bf681bf0b
v1.0
complete
Prefill
Prefill_21523_C
def is_prime(n: int) -> bool: """ Helper function to check if a number n is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(10) == False >>> is_prime(11) == True """ pass def generate_primes_between(a: int, b: ...
def is_prime(n): """ Helper function to check if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i...
from solution import generate_primes_between, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(11) == True def test_generate_primes_between_single_value_range(...
[ { "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 a list of all prime numbers between a and b (inclusive).", "function_declaration": "def generate_...
[ 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_9
{ "original_instruction": "Create a function that generates a list of prime numbers between two given numbers, a and b (inclusive). The function should take two integers a and b as input and return a list of all prime numbers in the range [a, b].", "prompt_id": "00021523", "row_id": 21523, "seed_ids": "['magpie...
0.74541
Prefill_21523
C
[ "is_prime", "generate_primes_between" ]
2
[ [ "generate_primes_between", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
22dc8c2ec2cece27c403d11dc49cbdcf5384f603
b435ca2d17919944b735ed4fed2f4d851f4dc7c0
v1.0
complete
Prefill
Prefill_22042_C
class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def is_palindrome(head, length): """ Check if the provided linked list is a palindrome. Args: head (ListNode): The first node of the linked list. length (int): The length of the linked l...
class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def is_palindrome_util(head, length): if head is None or length <= 0: # Even length base case return True, head elif length == 1: # Odd length base case return True, head.next ...
from solution import ListNode, is_palindrome def create_linked_list(values): if not values: return None head = ListNode(values[0]) current = head for val in values[1:]: current.next = ListNode(val) current = current.next return head def test_empty_list(): assert is_pali...
[]
[ 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": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef is_palindrome(head: ListNode, length: int) -> bool:\n \"\"\"\n Check ...
trial_gpt4o_9
{ "original_instruction": "Create a function that checks if the provided linked list is a palindrome or not. The function will take three parameters: the first node of the linked list, the length of the linked list, and a boolean flag to indicate whether the linked list is a palindrome or not.", "prompt_id": "00022...
0.677942
Prefill_22042
C
[ "is_palindrome_util", "is_palindrome" ]
2
[ [ "is_palindrome", "is_palindrome_util" ] ]
1
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
f0d6505c0feec5f0dd04dced33e680494e5acd6f
c5b9bb76c19426cd9afd32b019df34379dace9b6
v1.0
complete
Prefill
Prefill_22124_C
def count_inversions(arr: List[int]) -> int: """ Create a function that takes a sequence of integers and returns the number of inversions in the sequence. An inversion is defined as a pair of indices i < j such that the value at index i is greater than the value at index j. >>> count_inversions([]) ...
def count_inversions(arr): """ Count inversions in the array using a modified merge sort. :param arr: List[int] Sequence of integers. :return: int Number of inversions in the sequence. """ return merge_sort_and_count(arr, 0, len(arr) - 1) def merge_sort_and_count(a...
from solution import count_inversions def test_empty_array(): assert count_inversions([]) == 0 def test_single_element(): assert count_inversions([1]) == 0 def test_sorted_array(): assert count_inversions([1, 2, 3, 4, 5]) == 0 def test_reverse_sorted_array(): assert count_inversions([5, 4, 3, 2, 1])...
[ { "docstring": "Count inversions in the array using a modified merge sort.\n\n:param arr: List[int]\n Sequence of integers.\n \n:return: int\n Number of inversions in the sequence.", "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list":...
[ 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 count_inversions(sequence):\n \"\"\"\n Counts the number of inversions in the sequence.\n \n An inversion is a pair of indices (i, j) such that i < j and sequence[i] > sequenc...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes a sequence of integers and returns the number of inversions in the sequence. An inversion is defined as a pair of indices i < j such that the value at index i is greater than the value at index j.", "prompt_id": "00022124", "row_id": 22124, "seed_ids": "['...
0.855751
Prefill_22124
C
[ "count_inversions", "merge_sort_and_count", "merge_and_count" ]
3
[ [ "count_inversions", "merge_sort_and_count" ], [ "merge_sort_and_count", "merge_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
960ca901bb1ad337d321f71a2683f582df8f36da
8ee519dd9a2f4fca6d95161e9e071b9ddf5ed254
v1.0
complete
Prefill
Prefill_21879_C
def is_palindrome(s: str) -> bool: """ Returns True if the given string s is a palindrome, False otherwise. >>> is_palindrome("racecar") True >>> is_palindrome("madam") True >>> is_palindrome("hello") False >>> is_palindrome("") True """ def is_number_palindrome(n: int) -> bool: """ Returns...
def is_palindrome(s): """ Returns True if the given string s is a palindrome, False otherwise. """ s = str(s) return s == s[::-1] # Test if a number when converted to a string is a palindrome def is_number_palindrome(n): """ Returns True if the given number n is a palindrome, False otherwis...
from solution import is_palindrome, is_number_palindrome def test_is_palindrome_with_palindromic_string(): assert is_palindrome("racecar") == True assert is_palindrome("madam") == True assert is_palindrome("a") == True assert is_palindrome("abba") == True def test_is_palindrome_with_non_palindromic_st...
[ { "docstring": "Returns True if the given string s is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns True if the given number n is a palindrome, False otherwise.", "fun...
[ 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_palindrome(string):\n \"\"\"\n Checks if the provided string or number (after converting to string) is a palindrome.\n \n Parameters:\n string (str or int): The input st...
trial_gpt4o_9
{ "original_instruction": "Create a function that validates if a given string is a palindrome (reads the same backward as forward). Also, check if this function can be used to determine if a number when converted to a string is a palindrome.", "prompt_id": "00021879", "row_id": 21879, "seed_ids": "['magpie_pref...
0.858756
Prefill_21879
C
[ "is_palindrome", "is_number_palindrome" ]
2
[ [ "is_number_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81723f26b2133a22d4e9e0d609c4fb5640ab2f75
6247fd84dcdd0763657918433c39f0b4f571256c
v1.0
complete
Prefill
Prefill_22396_C
def number_to_words(n: int) -> str: """ Converts a given number into its corresponding word representation. >>> number_to_words(3) 'three' >>> number_to_words(13) 'thirteen' >>> number_to_words(21) 'twenty-one' >>> number_to_words(105) 'one hundred five' >>> number_to_words...
def number_to_words(n): if n == 0: return "zero" num_to_19 = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] tens = ['', '', 'twenty', 'thi...
from solution import number_to_words def test_single_digit(): assert number_to_words(3) == "three" def test_teens(): assert number_to_words(13) == "thirteen" def test_tens(): assert number_to_words(21) == "twenty-one" def test_hundreds(): assert number_to_words(105) == "one hundred five" assert ...
[ { "docstring": null, "function_declaration": "def number_to_words(n):", "function_name": "number_to_words", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def split_by_thousands(n):", "function_name": "split_by_thousands", "parameter_list": "(n)" }, ...
[ 1, 0, 0, 1, 1, 1, 1, 0, 1 ]
6
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def number_to_words(num):\n \"\"\"\n Converts a given number (0 <= num < 1000) into its word representation.\n \"\"\"\n if num == 0:\n return \"zero\"\n\n units = [\"\",...
trial_gpt4o_9
{ "original_instruction": "Create a function that converts a given number into its corresponding word representation. For example, the number 123 should be converted to \"one hundred twenty-three\".", "prompt_id": "00022396", "row_id": 22396, "seed_ids": "['magpie_prefill_22396']" }
0.614808
Prefill_22396
C
[ "number_to_words", "split_by_thousands" ]
2
[ [ "number_to_words", "split_by_thousands" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3e4279c49942bdb1cac5ce8c7175dd06812f9f5f
a7418dccbd44463e0a1bd648bf14e55839c0c4ea
v1.0
complete
Prefill
Prefill_21254_C
def sieve_of_eratosthenes(max_num): """Create a list of prime numbers up to a given number using the Sieve of Eratosthenes.""" primes = [True] * (max_num + 1) p = 2 while (p * p <= max_num): if primes[p] == True: for i in range(p * p, max_num + 1, p): primes[i] = Fals...
def sieve_of_eratosthenes(max_num): primes = [True] * (max_num + 1) p = 2 while (p * p <= max_num): if primes[p] == True: for i in range(p * p, max_num + 1, p): primes[i] = False p += 1 prime_numbers = [] for p in range(2, max_num + 1): if primes[p...
from solution import find_primes_between_min_max def test_no_elements(): assert find_primes_between_min_max(0, []) == [] def test_single_element_array(): assert find_primes_between_min_max(1, [10]) == [] def test_all_same_elements(): assert find_primes_between_min_max(5, [7, 7, 7, 7, 7]) == [7] asser...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": null, "function_declaration": "def find_primes_between_min_max(n, arr):", "function_name": "find_primes_betwee...
[ 1, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if num is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3...
trial_gpt4o_2
{ "original_instruction": "Create a function that takes in the number of items (n) and an array (arr) as arguments. The function should return an array of all prime numbers between the smallest and largest numbers in the given array.", "prompt_id": "00021254", "row_id": 21254, "seed_ids": "['magpie_prefill_2125...
0.681573
Prefill_21254
C
[ "sieve_of_eratosthenes", "find_primes_between_min_max" ]
2
[ [ "find_primes_between_min_max", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
78f3ffa03cca5d6e278d02abbc47c5e5923aec43
1953849bb0bbea2f3da14c5fb2dc6e204b63979a
v1.0
complete
Prefill
Prefill_21987_C
def merge_sort(arr): """ Perform merge sort on the given list and return the sorted list. >>> merge_sort([]) == [] >>> merge_sort([1]) == [1] >>> merge_sort([2, 1]) == [1, 2] >>> merge_sort([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9] >>> merge_sort([-3, -1, -4, -1...
def merge_sort(arr): """ Perform merge sort on the given list and return the sorted list. """ if len(arr) <= 1: return arr # Finding the middle of the array mid = len(arr) // 2 # Dividing the array elements into 2 halves left_half = merge_sort(arr[:mid]) right_half ...
from solution import merge_sort def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_two_elements(): assert merge_sort([2, 1]) == [1, 2] def test_merge_sort_multiple_elements(): assert merge_sort([3, 1, 4, 1,...
[ { "docstring": "Perform merge sort on the given list and return the sorted list.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merge two sorted lists into one sorted list.", "function_declaration": "def merge...
[ 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 if len(arr) <= 1:\n return arr\n \n # Find the middle point and split the ar...
trial_gpt4o_9
{ "original_instruction": "Create a function that implements the merge sort algorithm in Python.", "prompt_id": "00021987", "row_id": 21987, "seed_ids": "['magpie_prefill_21987']" }
0.660947
Prefill_21987
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e2fcba416ba5331e8cd2db9273df0e90263b783d
1ec635f6685fca6b3143a4616b9b288233e670df
v1.0
complete
Prefill
Prefill_22307_C
def generate_primes(start: int, end: int) -> List[int]: """ Generates a list of all the prime numbers between start and end inclusive. >>> generate_primes(1, 10) [2, 3, 5, 7] >>> generate_primes(10, 11) [11] >>> generate_primes(14, 16) [] >>> generate_primes(10, 29) [11, 13, 17, 19, ...
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 def test_generate_primes_small_range(): assert generate_primes(1, 10) == [2, 3, 5, 7] def test_generate_primes_single_prime(): assert generate_primes(10, 11) == [11] def test_generate_primes_no_primes(): assert generate_primes(14, 16) == [] def test_generate_primes_l...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of all the prime numbers between start and end inclusive.", "function_declaration": "def g...
[ 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 is_prime(n):\n \"\"\"\n Helper function to check if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the onl...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates a list of all the prime numbers between two given numbers (inclusive). A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.", "prompt_id": "00022307", "row_id": 22307, "seed_ids": "['magpie_prefill_22...
0.702491
Prefill_22307
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a1bef1e8168d7ae8ee9e7a7db8931e7aba586c09
6fc66bd8e57e07a1ffbef8e29b3e0822cea6949f
v1.0
complete
Prefill
Prefill_22522_C
def filter_primes(numbers: List[int]) -> List[int]: """ Returns a list of prime numbers from the given list of integers. >>> filter_primes([2, 3, 4, 5, 10, 11, 13]) [2, 3, 5, 11, 13] >>> filter_primes([1, 4, 6, 8, 9, 10]) [] >>> filter_primes([2, 3, 5, 7, 11]) [2, 3, 5, 7, 11] >>>...
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 filter_primes(numbers): """ Returns a list of prime numbers from the given ...
from solution import filter_primes def test_filter_primes_with_mixed_numbers(): assert filter_primes([2, 3, 4, 5, 10, 11, 13]) == [2, 3, 5, 11, 13] def test_filter_primes_with_no_primes(): assert filter_primes([1, 4, 6, 8, 9, 10]) == [] def test_filter_primes_with_all_primes(): assert filter_primes([2, 3...
[ { "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 from the given list of integers.", "function_declaration": "def filter_...
[ 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 if n <= 3:\n return True\n if n % 2 == 0 or n...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes a list of integers and returns a new list with only the prime numbers from the original list.", "prompt_id": "00022522", "row_id": 22522, "seed_ids": "['magpie_prefill_22522']" }
0.703017
Prefill_22522
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dc8095c3c787cd5e9e65cfb566355de85da47827
17c8fe062c7e6e092e38182bf2412b5bf3c9c369
v1.0
complete
Prefill
Prefill_22860_C
from typing import List, Tuple def filter_tuples_with_prime_second_element(tuples_list: List[Tuple[int, int]]) -> List[Tuple[int, int]]: """ Takes a list of tuples and returns a new list containing only the tuples where the second element is a prime number. >>> filter_tuples_with_prime_second_element([(1, ...
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 filter_tuples_with_prime_second_element(tuples_list): """ Takes a list of...
from solution import filter_tuples_with_prime_second_element def test_empty_list(): assert filter_tuples_with_prime_second_element([]) == [] def test_all_prime_second_elements(): input_tuples = [(1, 2), (3, 3), (4, 5), (6, 7)] expected_output = [(1, 2), (3, 3), (4, 5), (6, 7)] assert filter_tuples_wit...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Takes a list of tuples and returns a new list containing only the tuples where\nthe second element is a pri...
[ 0, 1, 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 Helper function to check 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 % ...
trial_gpt4o_6
{ "original_instruction": "Create a function that takes a list of tuples as an argument and returns a new list containing only the tuples where the second element is a prime number.", "prompt_id": "00022860", "row_id": 22860, "seed_ids": "['magpie_prefill_22860']" }
0.619654
Prefill_22860
C
[ "is_prime", "filter_tuples_with_prime_second_element" ]
2
[ [ "filter_tuples_with_prime_second_element", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8506d821b639a53141f2eee44f209b30093e77a
d3521a7466660d41674703e1226bb61918e70b7b
v1.0
complete
Prefill
Prefill_22945_C
def is_palindrome(number): """ Check if a number is a palindrome. """ return str(number) == str(number)[::-1] def process_numbers(firstNumber, secondNumber): """ Returns the product of firstNumber and secondNumber if the product is a palindrome. Otherwise, returns the sum of the two numbers...
def is_palindrome(number): """ Check if a number is a palindrome. """ return str(number) == str(number)[::-1] def process_numbers(firstNumber, secondNumber): """ Returns the product of firstNumber and secondNumber if the product is a palindrome. Otherwise, returns the sum of the two numbers...
from solution import process_numbers def test_product_is_palindrome(): assert process_numbers(11, 11) == 121 # 11 * 11 = 121, which is a palindrome def test_product_is_not_palindrome(): assert process_numbers(10, 13) == 23 # 10 * 13 = 130, which is not a palindrome (10 + 13 = 23) def test_sum_instead_of_p...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Returns the product of firstNumber and secondNumber if the product is a palindrome.\nOtherwise, returns...
[ 1, 1, 0, 0, 0, 0, 1, 0, 1, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(number):\n \"\"\"\n Helper function to check if a number is a palindrome.\n \"\"\"\n return str(number) == str(number)[::-1]\n\ndef process_numbers(firstNumber, ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes two parameters, `firstNumber` and `secondNumber`, and returns the product of these two numbers. If the product of these numbers is a palindrome, return the product. Otherwise, return the sum of the two input numbers. A palindrome number reads the same forward an...
0.749098
Prefill_22945
C
[ "is_palindrome", "process_numbers" ]
2
[ [ "process_numbers", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
85f3bf2b18c4328b4749d65a1f594c46148dd0bf
74974edaa2e71223ac94feca38196906ae9e881f
v1.0
complete
Prefill
Prefill_22389_C
def is_prime(n: int) -> bool: """ Determines if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ def generate_primes(start: int, end: int) -> List[int]: """ Generates a list of all prime numbers within the range [start, end]. >>> generate_primes(10, 20) [11, 13, 17,...
def is_prime(n): """ Determines if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return...
from solution import generate_primes def test_generate_primes_within_range(): assert generate_primes(10, 20) == [11, 13, 17, 19] def test_generate_primes_single_prime(): assert generate_primes(17, 17) == [17] def test_generate_primes_no_primes_in_range(): assert generate_primes(8, 10) == [] asser...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of all prime numbers within the range [start, end].", "function_declaration": "def generate_primes(start...
[ 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 generate_primes(start, end):\n \"\"\"\n Generates a list of all prime numbers within a specified range [start, end].\n \n Parameters:\n start (int): The lower bound of the ...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates a list of all prime numbers up to a specified limit. The function should take two parameters: `start` and `end`, where `start` is the lower bound of the range (inclusive) and `end` is the upper bound of the range (inclusive). The function should return a lis...
0.73556
Prefill_22389
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e732f98cffd01bc785a697b5379b9514f38bb674
1556342c209dadc1813cec00db50947183220057
v1.0
complete
Prefill
Prefill_22676_C
import re import json def to_snake_case(s: str) -> str: """ Convert a string to snake_case. >>> to_snake_case("CamelCase") == "camel_case" >>> to_snake_case("camelCaseString") == "camel_case_string" >>> to_snake_case("anotherExampleTest") == "another_example_test" >>> to_snake_case("yetAno...
import re import json def to_snake_case(s): """ Convert a string to snake_case. """ s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s) s = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s) return s.lower() def convert_to_snake_case(obj): """ Recursively convert all keys and string values of a JSON-lik...
from solution import to_snake_case, convert_to_snake_case def test_to_snake_case(): assert to_snake_case("CamelCase") == "camel_case" assert to_snake_case("camelCaseString") == "camel_case_string" assert to_snake_case("anotherExampleTest") == "another_example_test" assert to_snake_case("yetAnotherExamp...
[ { "docstring": "Convert a string to snake_case.", "function_declaration": "def to_snake_case(s):", "function_name": "to_snake_case", "parameter_list": "(s)" }, { "docstring": "Recursively convert all keys and string values of a JSON-like object to snake_case.", "function_declaration": "d...
[ 1, 1, 0, 1, 0, 1, 1, 0, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef to_snake_case(name):\n \"\"\"\n Convert a string to snake_case.\n \"\"\"\n s1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', name)\n return re.sub('([a-z0-9])([A-Z])...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes in a JSON object and recursively converts all the keys and values to snake_case.", "prompt_id": "00022676", "row_id": 22676, "seed_ids": "['magpie_prefill_22676']" }
0.609527
Prefill_22676
C
[ "to_snake_case", "convert_to_snake_case" ]
2
[ [ "convert_to_snake_case", "to_snake_case" ] ]
1
[]
false
[]
false
pytest
true
[]
true
58a4d71cd0e1a617aa6e53bbf0b7f63d4cdecda9
9c83f3c269a2a6818f518d73f6d3743a9e9acae4
v1.0
complete
Prefill
Prefill_23468_C
def string_with_max_repeated_substring(s1: str, s2: str) -> str: """ Create a function that takes two strings, and returns the string with the maximum repeated substring among the two strings. If there's a tie, return the one that appears first alphabetically. If neither string has a repeated substring, return ...
def longest_repeated_substring(s): """ Helper function to find the longest repeated substring in a given string. """ n = len(s) for length in range(n, 0, -1): seen = set() for start in range(n - length + 1): substring = s[start:start + length] if substring in ...
from solution import string_with_max_repeated_substring def test_no_repeated_substring(): assert string_with_max_repeated_substring("abc", "def") == "" def test_one_repeated_substring(): assert string_with_max_repeated_substring("abcabc", "def") == "abcabc" def test_both_repeated_substring_different_lengths(...
[ { "docstring": "Helper function to find the longest repeated substring in a given string.", "function_declaration": "def longest_repeated_substring(s):", "function_name": "longest_repeated_substring", "parameter_list": "(s)" }, { "docstring": "Returns the string with maximum repeated substri...
[ 1, 0, 0, 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_repeated_substring(s):\n \"\"\"\n Helper function to find the longest repeated substring in a given string.\n \"\"\"\n n = len(s)\n for length in range(n, 0, -1):\n...
trial_gpt4o_0
{ "original_instruction": "Create a function that takes two strings, and returns the string with the maximum repeated substring among the two strings. If there's a tie, return the one that appears first alphabetically. If neither string has a repeated substring, return an empty string.", "prompt_id": "00023468", ...
0.717297
Prefill_23468
C
[ "longest_repeated_substring", "string_with_max_repeated_substring" ]
2
[ [ "string_with_max_repeated_substring", "longest_repeated_substring" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1fa238e5829f2caddda3b3f131526cdcb5d87e0f
6862b3f52084bf741cf6079c788127a2838530d0
v1.0
complete
Prefill
Prefill_23123_C
def string_to_special_binary(s: str) -> str: """ Converts a string into a binary representation for specific set of characters: digits, letters, or punctuation marks. Non-special characters are not included in the binary representation. Prepend each binary number with indicators: 'd' for digit, 'l'...
def char_to_binary(c): if c.isdigit(): return 'd' + bin(ord(c))[2:].zfill(8) elif c.isalpha(): return 'l' + bin(ord(c))[2:].zfill(8) elif c in '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~': return 'p' + bin(ord(c))[2:].zfill(8) else: return None def string_to_special_binary(s): ...
from solution import string_to_special_binary def test_only_special_characters(): assert string_to_special_binary("abc123!@#") == 'l01100001 l01100010 l01100011 d00110001 d00110010 d00110011 p00100001 p01000000 p00100011' def test_mixed_characters(): assert string_to_special_binary("a1! b2@ c3# $%^") == 'l011...
[ { "docstring": null, "function_declaration": "def char_to_binary(c):", "function_name": "char_to_binary", "parameter_list": "(c)" }, { "docstring": null, "function_declaration": "def string_to_special_binary(s):", "function_name": "string_to_special_binary", "parameter_list": "(s...
[ 0, 0, 1, 0, 0, 0, 0, 0, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def char_type(char):\n \"\"\" Identify the type of character: digit, letter, or punctuation. \"\"\"\n if char.isdigit():\n return 'digit'\n elif char.isalpha():\n retur...
trial_gpt4o_9
{ "original_instruction": "Create a function that converts a string into a binary representation, but only for a specific set of characters. In this case, we define a character to be \"special\" if it is a digit, a letter, or a punctuation mark. Non-special characters should not be included in the binary representati...
0.656678
Prefill_23123
C
[ "char_to_binary", "string_to_special_binary" ]
2
[ [ "string_to_special_binary", "char_to_binary" ] ]
1
[]
false
[]
false
pytest
true
[]
true
77300fee5d8102348165c69eb5ef5601a90d5cd5
092e0711b58e4a2cba5bb62de22d5b9f79a94888
v1.0
complete
Prefill
Prefill_23232_C
def is_prime(num): """ Helper function to check if a number is prime. """ pass def sum_of_primes_less_than(n: int) -> int: """ Returns the sum of all prime numbers less than n. >>> sum_of_primes_less_than(10) 17 >>> sum_of_primes_less_than(20) 77 >>> sum_of_primes_less_than(2) 0 >>>...
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 sum_of_primes_less_than def test_sum_of_primes_less_than_10(): assert sum_of_primes_less_than(10) == 17 # 2 + 3 + 5 + 7 def test_sum_of_primes_less_than_20(): assert sum_of_primes_less_than(20) == 77 # 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 def test_sum_of_primes_less_than_2(): assert 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 the sum of all prime numbers less than n.", "function_declaration": "def sum_of_primes_less_tha...
[ 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 Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num %...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes an integer `n` and returns the sum of all prime numbers less than `n` using Python.", "prompt_id": "00023232", "row_id": 23232, "seed_ids": "['magpie_prefill_23232']" }
0.838205
Prefill_23232
C
[ "is_prime", "sum_of_primes_less_than" ]
2
[ [ "sum_of_primes_less_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0973bf3466916ed3aaa71689ae488a18b683a72d
daf171dd5fb9bba5ef3979954b503775949f487b
v1.0
complete
Prefill
Prefill_22027_C
from typing import List def convert_number_to_base(number: int, base: int) -> str: """ Converts a given number to the specified base. :param number: The number to be converted, in base 10. :param base: The base to convert the number to, between 2 and 36. :return: A string representing the number i...
def convert_number_to_base(number, base): """ Converts a given number to the specified base. :param number: The number to be converted, in base 10. :param base: The base to convert the number to, between 2 and 36. :return: A string representing the number in the specified base. """ if numbe...
from solution import convert_number_to_base, convert_array_to_base def test_convert_number_to_base(): assert convert_number_to_base(10, 2) == '1010' assert convert_number_to_base(10, 10) == '10' assert convert_number_to_base(255, 16) == 'FF' assert convert_number_to_base(31, 16) == '1F' assert conv...
[ { "docstring": "Converts a given number to the specified base.\n\n:param number: The number to be converted, in base 10.\n:param base: The base to convert the number to, between 2 and 36.\n:return: A string representing the number in the specified base.", "function_declaration": "def convert_number_to_base(...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def convert_bases(numbers, base):\n \"\"\"\n Convert a list of numbers to the specified base system.\n\n Parameters:\n numbers (list of int): List of integers representing numbers...
trial_gpt4o_5
{ "original_instruction": "Create a function that can handle two inputs, an array of integers (each integer representing a number in a base system between 2 and 36) and a base system (between 2 and 36). The function should return an array of integers, each converted to the specified base.", "prompt_id": "00022027",...
0.741777
Prefill_22027
C
[ "convert_number_to_base", "convert_array_to_base" ]
2
[ [ "convert_array_to_base", "convert_number_to_base" ] ]
1
[]
false
[]
false
pytest
true
[]
true
764b952f5a87fb515f3eeb07060bee93d13849bd
8cd4ab87f48b9829c0ca5471a86470ac59869e4b
v1.0
complete
Prefill
Prefill_23692_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def sum_of_primes(lst: List[int]) -> int: """ Returns the sum of all prime numbers in the list. Returns -1 if there are no prime numbers in the list. >>> sum_of_primes([2, 3...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def sum_of_primes(lst): """ Returns the sum of all prime numbers in the list. Retur...
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(5) == True assert is_prime(11) == True assert is_prime(1) == False assert is_prime(-3) == False def test_sum_of_primes_with_pr...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the list.\nReturns -1 if there are no prime numbers in the 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 sum_of_primes(numbers):\n \"\"\"\n Returns the sum of all the prime numbers in the list.\n Returns -1 if the list does not contain any prime numbers.\n \"\"\"\n def is_prim...
trial_gpt4o_6
{ "original_instruction": "Create a function that takes in a list of integers and returns the sum of all the prime numbers in the list. Return -1 if the list does not contain any prime numbers.", "prompt_id": "00023692", "row_id": 23692, "seed_ids": "['magpie_prefill_23692']" }
0.771013
Prefill_23692
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e6d2b93306a0be0ae1fe9e47c267c1dfecf0e32a
04dac376a607b22143bfec81827584b6d8f8ac8f
v1.0
complete
Prefill
Prefill_23417_C
import math def area_of_circle(radius): """ Returns the area of a circle given its radius. >>> area_of_circle(1) 3.141592653589793 >>> area_of_circle(2) 12.566370614359172 >>> area_of_circle(3) 28.274333882308138 """ pass def areas_of_circles_from_1_to_10(): """ Calcula...
import math def area_of_circle(radius): """ Returns the area of a circle given its radius. """ if radius < 0: raise ValueError("Radius cannot be negative") return math.pi * (radius ** 2) def areas_of_circles_from_1_to_10(): """ Calculates the areas of circles with radii ranging fro...
import pytest from solution import area_of_circle, areas_of_circles_from_1_to_10 def test_area_of_circle(): assert math.isclose(area_of_circle(1), math.pi, rel_tol=1e-9) assert math.isclose(area_of_circle(2), 4 * math.pi, rel_tol=1e-9) assert math.isclose(area_of_circle(3), 9 * math.pi, rel_tol=1e-9) def ...
[ { "docstring": "Returns the area of a circle given its radius.", "function_declaration": "def area_of_circle(radius):", "function_name": "area_of_circle", "parameter_list": "(radius)" }, { "docstring": "Calculates the areas of circles with radii ranging from 1 to 10.\nReturns a list of these...
[ 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 circle_area(radius):\n \"\"\"\n Calculate and return the area of a circle given its radius.\n \"\"\"\n if radius < 0:\n raise ValueError(\"Radius cannot ...
trial_gpt4o_9
{ "original_instruction": "Create a function that calculates the area of a circle given its radius. Then, use a for loop to calculate the areas of circles with radii ranging from 1 to 10.", "prompt_id": "00023417", "row_id": 23417, "seed_ids": "['magpie_prefill_23417']" }
0.565804
Prefill_23417
C
[ "area_of_circle", "areas_of_circles_from_1_to_10" ]
2
[ [ "areas_of_circles_from_1_to_10", "area_of_circle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6ab7a7e51daf4e15ac430bb931588dca107aa6d3
f23b9f72959c264b413de5ecfab541763c6f5889
v1.0
complete
Prefill
Prefill_23811_C
def fibonacci(n, memo={}): """ Returns the nth Fibonacci number and prints the number of function calls made. Uses a top-down approach with memoization. """ pass def get_fibonacci(n): """ Wrapper function to get the nth Fibonacci number and print the number of function calls. """ pa...
def fibonacci(n, memo={}): """ Returns the nth Fibonacci number and prints the number of function calls made. Uses a top-down approach with memoization. """ if n in memo: return memo[n] if n <= 0: return 0 elif n == 1: return 1 memo[n] = fibonacci(n - 1,...
from solution import get_fibonacci def test_fibonacci_0(): assert get_fibonacci(0) == 0 def test_fibonacci_1(): assert get_fibonacci(1) == 1 def test_fibonacci_5(): assert get_fibonacci(5) == 5 def test_fibonacci_10(): assert get_fibonacci(10) == 55 def test_fibonacci_large(): assert get_fibona...
[ { "docstring": "Returns the nth Fibonacci number and prints the number of function calls made.\nUses a top-down approach with memoization.", "function_declaration": "def fibonacci(n, memo={}):", "function_name": "fibonacci", "parameter_list": "(n, memo={})" }, { "docstring": "Wrapper functio...
[ 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 fibonacci(n):\n memo = {}\n calls = {'count': 0}\n \n def fib_memo(n):\n calls['count'] += 1\n if n in memo:\n return memo[n]\n if n <= 1:\n ...
trial_gpt4o_8
{ "original_instruction": "Create a function that returns the nth Fibonacci number. The code should not just return the number but also print the number of function calls made to calculate the result. Use a top-down approach with memoization to solve the problem.", "prompt_id": "00023811", "row_id": 23811, "see...
0.80894
Prefill_23811
C
[ "fibonacci", "get_fibonacci" ]
2
[ [ "get_fibonacci", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
27164a3e7d62e0bb85465155e3280c1c5f7744b9
1ea1b47d559ec439add5a775d69449155c8c9dce
v1.0
complete
Prefill
Prefill_23392_C
def validate_integers(input_list): """ Helper function to verify that all elements in the list are integers. Raises a ValueError if a non-integer value is found. """ for item in input_list: if not isinstance(item, int): raise ValueError(f"Non-integer value found: {item}") def su...
def validate_integers(input_list): """ Helper function to verify that all elements in the list are integers. Raises a ValueError if a non-integer value is found. """ for item in input_list: if not isinstance(item, int): raise ValueError(f"Non-integer value found: {item}") def su...
from solution import validate_integers, sum_of_integers def test_validate_integers_all_integers(): validate_integers([1, 2, 3, 4]) # Should not raise any error def test_validate_integers_with_non_integer(): try: validate_integers([1, 'a', 3]) # Should raise ValueError except ValueError as e: ...
[ { "docstring": "Helper function to verify that all elements in the list are integers.\nRaises a ValueError if a non-integer value is found.", "function_declaration": "def validate_integers(input_list):", "function_name": "validate_integers", "parameter_list": "(input_list)" }, { "docstring":...
[ 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 sum_integers(lst):\n \"\"\"\n Takes a list of integers and returns the sum of those integers.\n Raises a ValueError if a non-integer value is present in the list.\n \"\"\"\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of integers and returns the sum of those integers. Additionally, the function should handle the potential ValueError that could occur if a non-integer value is passed in the list. To improve code readability and simplicity, use a helper function to verify...
0.758752
Prefill_23392
C
[ "validate_integers", "sum_of_integers" ]
2
[ [ "sum_of_integers", "validate_integers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3219e5a0ece2b78a7b1c97a07d6ceaf4ecb01425
6ee4025362288bc4dcf4f83f250f920d1b7440d8
v1.0
complete
Prefill
Prefill_23989_C
def is_prime(n: int) -> bool: """ Check if a number is prime. :param n: The integer to check. :return: True if the number is prime, False otherwise. >>> is_prime(2) True >>> is_prime(4) False """ def print_primes_in_interval(start: int, end: int) -> List[int]: """ Print all ...
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 print_primes_in_interval(start, end): """ Prints all prime numbers in the interva...
from solution import is_prime, print_primes_in_interval def test_is_prime(): assert is_prime(2) assert is_prime(3) assert is_prime(5) assert is_prime(11) assert not is_prime(1) assert not is_prime(4) assert not is_prime(9) assert not is_prime(15) def test_print_primes_in_interval(capfd...
[ { "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": "Prints all prime numbers in the interval [start, end].", "function_declaration": "def print_primes_in_int...
[ 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 print_primes(start, end):\n \"\"\"\n Prints all prime numbers within the interval [start, end].\n \"\"\"\n primes = []\n for num in range(start, end + 1):\n if num >...
trial_gpt4o_9
{ "original_instruction": "Create a function that prints all the prime numbers within an interval.", "prompt_id": "00023989", "row_id": 23989, "seed_ids": "['magpie_prefill_23989']" }
0.714867
Prefill_23989
C
[ "is_prime", "print_primes_in_interval" ]
2
[ [ "print_primes_in_interval", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
362080203ed479569f4e35d5cffbe3d2adef4bfb
36d3c2e23f4815759c3bf2f31132a5a7efaafd51
v1.0
complete
Prefill
Prefill_23513_C
def is_prime(n: int) -> bool: """ Determines if a number is prime. >>> is_prime(11) True >>> is_prime(4) False """ def generate_primes(lower: int, upper: int) -> List[int]: """ Generates a list of prime numbers within the given range [lower, upper]. >>> generate_primes(2, 5) [2, 3, 5] >>> g...
def is_prime(n): """ Determines if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return...
from solution import generate_primes def test_generate_primes_no_primes(): assert generate_primes(8, 10) == [] def test_generate_primes_inclusive(): assert generate_primes(2, 5) == [2, 3, 5] def test_generate_primes_single_prime(): assert generate_primes(13, 13) == [13] def test_generate_primes_large_ra...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of prime numbers within the given range [lower, upper].", "function_declaration": "def generate_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 is_prime(n):\n \"\"\"Helper function to check 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:\n...
trial_gpt4o_9
{ "original_instruction": "Create a function that can generate a list of prime numbers within a given range. The function should take two arguments, the lower and upper bounds of the range, and return a list of all prime numbers within that range.", "prompt_id": "00023513", "row_id": 23513, "seed_ids": "['magpi...
0.740156
Prefill_23513
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
431499b73b739320fe9752d4b718b4d8d360454e
e96b7876f9467ba622e9bd3dcf128ab05b6c83fd
v1.0
complete
Prefill
Prefill_23830_C
def is_prime(n: int) -> bool: """ Returns whether the given number n is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True """ def extract_primes(numbers: List[int]) -> List[int]: """ Returns a list of prime numbers from the give...
def is_prime(n): """ Returns whether the given number n 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 extrac...
from solution import extract_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(5) == True assert is_prime(10) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == Fal...
[ { "docstring": "Returns whether the given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of numbers.", "function_declaration": "def extra...
[ 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 for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_7
{ "original_instruction": "Create a function that checks each number in a given list to see if it is a prime number. If it is a prime number, add it to a new list. Return that list at the end.", "prompt_id": "00023830", "row_id": 23830, "seed_ids": "['magpie_prefill_23830']" }
0.764786
Prefill_23830
C
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a7668b39738a8d129a1a0c570bfd31dd75fa3677
113002cd3df74617c22220894acc095cf3928a64
v1.0
complete
Prefill
Prefill_24290_C
import requests import time def get_weather(api_key, city, country): """ Fetches the weather for a given city and country. Parameters: - api_key: str : API key for the weather service - city: str : Name of the city - country: str : Name of the country Prints the current weather condit...
import requests import time def get_weather(api_key, city, country): url = f'http://api.openweathermap.org/data/2.5/weather?q={city},{country}&appid={api_key}' response = requests.get(url) data = response.json() if response.status_code == 200: weather = data['weather'][0]['description'] ...
import pytest from unittest.mock import patch, MagicMock from solution import get_weather @patch('solution.requests.get') def test_get_weather_success(mock_get): mock_response = MagicMock() mock_response.status_code = 200 mock_response.json.return_value = { 'weather': [{'description': 'clear sky'}...
[ { "docstring": null, "function_declaration": "def get_weather(api_key, city, country):", "function_name": "get_weather", "parameter_list": "(api_key, city, country)" }, { "docstring": null, "function_declaration": "def start_weather_updates(api_key, city, country, frequency):", "func...
[ 0, 0, 1, 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 time\nimport requests\n\ndef get_weather(api_key, city, country):\n \"\"\"\n Fetches the weather data from OpenWeatherMap API for a given city and country.\n \"\"\"\n url =...
trial_gpt4o_9
{ "original_instruction": "Create a function that periodically checks the weather at a given location using an API and updates the UI accordingly. The user should be able to specify the location (city, country) and the frequency of updates. For simplicity, let's just print out the weather information to the console."...
0.598168
Prefill_24290
C
[ "get_weather", "start_weather_updates" ]
2
[ [ "start_weather_updates", "get_weather" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
f3b1c2b22d02d811fab0050bdbd7d05623fedba2
cdb92dc8459130f15e003a94f7d18ca432b35122
v1.0
complete
Prefill
Prefill_24105_C
def maximum_sum_subarray_2d(matrix: List[List[int]]) -> int: """ Finds the maximum sum of a subarray within the given 2D array. Args: matrix (list of list of int): 2D array to find the subarray with the maximum sum. Returns: int: The maximum sum of a subarray. >>> maximum_sum_subarray_2d(...
def maximum_sum_subarray_2d(matrix): """ Finds the maximum sum of a subarray within the given 2D array. Args: matrix (list of list of int): 2D array to find the subarray with the maximum sum. Returns: int: The maximum sum of a subarray. """ if not matrix: return 0 max_sum =...
from solution import maximum_sum_subarray_2d def test_empty_matrix(): assert maximum_sum_subarray_2d([]) == 0 def test_single_element_matrix(): assert maximum_sum_subarray_2d([[5]]) == 5 assert maximum_sum_subarray_2d([[-3]]) == -3 def test_positive_elements_matrix(): assert maximum_sum_subarray_2d([...
[ { "docstring": "Finds the maximum sum of a subarray within the given 2D array.\nArgs:\nmatrix (list of list of int): 2D array to find the subarray with the maximum sum.\n\nReturns:\nint: The maximum sum of a subarray.", "function_declaration": "def maximum_sum_subarray_2d(matrix):", "function_name": "ma...
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_2d_subarray_sum(matrix):\n def kadane_1d(array):\n max_ending_here = max_so_far = array[0]\n for x in array[1:]:\n max_ending_here = max(x, max_ending_here...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a 2D array of integers and returns the maximum sum of a subarray within the 2D array. The subarray can consist of elements from any contiguous rows and columns.", "prompt_id": "00024105", "row_id": 24105, "seed_ids": "['magpie_prefill_24105']" }
0.716189
Prefill_24105
C
[ "maximum_sum_subarray_2d", "kadane_algorithm" ]
2
[ [ "maximum_sum_subarray_2d", "kadane_algorithm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
93a979b99064ad032c6f607a60dda57d982c4921
f366a8e9a5f934b365b233c0d6b31ea23376c5a4
v1.0
complete
Prefill
Prefill_24845_C
def prime_numbers(lower_limit: int, upper_limit: int) -> List[int]: """ Returns a list of prime numbers between lower_limit and upper_limit, inclusive. >>> prime_numbers(10, 20) [11, 13, 17, 19] >>> prime_numbers(0, 10) [2, 3, 5, 7] >>> prime_numbers(14, 16) [] >>> prime_number...
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 prime_numbers def test_prime_numbers_typical_case(): assert prime_numbers(10, 20) == [11, 13, 17, 19] def test_prime_numbers_with_lower_limit_zero(): assert prime_numbers(0, 10) == [2, 3, 5, 7] def test_prime_numbers_no_primes(): assert prime_numbers(14, 16) == [] def test_prime_num...
[ { "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 between lower_limit and upper_limit, inclusive.", "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 is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n**0.5) + 1, 2):\n if n...
trial_gpt4o_9
{ "original_instruction": "Create a function that generates a list of prime numbers between two given numbers. The function should take two parameters, `lower_limit` and `upper_limit`, and return a list of all prime numbers within this range, inclusive.", "prompt_id": "00024845", "row_id": 24845, "seed_ids": "[...
0.738296
Prefill_24845
C
[ "is_prime", "prime_numbers" ]
2
[ [ "prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c69be7dfc71718117f1406ef9da6372acd4e25d
2d7f59ee79262ec664e7e73409e96b50c96c6522
v1.0
complete
Prefill
Prefill_24367_C
def factorial(n: int) -> int: """ Returns the factorial of n using recursion. >>> factorial(0) 1 >>> factorial(1) 1 >>> factorial(3) 6 >>> factorial(5) 120 >>> factorial(6) 720 """ def is_perfect_number(num: int) -> bool: """ Checks if the provided numbe...
def factorial(n): """ Returns the factorial of n using recursion. """ if n == 0 or n == 1: return 1 else: return n * factorial(n - 1) def is_perfect_number(num): """ Checks if the provided number is a perfect number. """ if num <= 1: return False ...
from solution import factorial, is_perfect_number, factorial_is_perfect def test_factorial(): # Testing factorial function assert factorial(0) == 1 assert factorial(1) == 1 assert factorial(3) == 6 assert factorial(5) == 120 assert factorial(6) == 720 def test_is_perfect_number(): # Te...
[ { "docstring": "Returns the factorial of n using recursion.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Checks if the provided number is a perfect number.", "function_declaration": "def is_perfect_number(num):", ...
[ 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorial(N):\n \"\"\"\n Returns the factorial of the integer N using recursion.\n \"\"\"\n if N == 0 or N == 1:\n return 1\n else:\n return N * factorial(N -...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes an integer N and computes the factorial of that number using recursion. Then, create a function that checks if the computed factorial is a perfect number. A perfect number is a positive integer that is equal to the sum of its positive divisors excluding the numb...
0.642138
Prefill_24367
C
[ "factorial", "is_perfect_number", "factorial_is_perfect" ]
3
[ [ "factorial_is_perfect", "factorial" ], [ "factorial_is_perfect", "is_perfect_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
00564375dfa09005ede6c1d185334eaa9044e156
46d117e802f104ede9dc57a4ef886e4ef3e4dc2f
v1.0
complete
Prefill
Prefill_25354_C
def is_prime(n: 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(17) True >>> is_prime(18) False """ def prime_product(lst: List[int]) -> int: """ Returns the product of all prime n...
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 prime_product(l...
from solution import prime_product, 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 def test_prime_product_with_primes(): assert prime_product([2, 3, 5, 7]) == 210 # 2*3*5*...
[ { "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 product of all prime numbers in the list.", "function_declaration": "def prime_product(lst):", ...
[ 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 <= 3:\n return True\n if n % 2 == 0 or...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes a list of integers and returns the product of all the prime numbers in the list.", "prompt_id": "00025354", "row_id": 25354, "seed_ids": "['magpie_prefill_25354']" }
0.774334
Prefill_25354
C
[ "is_prime", "prime_product" ]
2
[ [ "prime_product", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef73e9ca3ea70b2110f60bd80f885d9366fea124
eda747dd8c66af3f1a3c65777e93c3271da6d05c
v1.0
complete
Prefill
Prefill_24551_C
def is_consonant(char): """ Check if a given character is a consonant. Consonants are all alphabetic characters that are not vowels (a, e, i, o, u). """ return char.lower() in "bcdfghjklmnpqrstvwxyz" def starts_or_ends_with_consonant(word): """ Check if a word starts or ends with a consonan...
def is_consonant(char): """ Check if a given character is a consonant. Consonants are all alphabetic characters that are not vowels (a, e, i, o, u). """ return char.lower() in "bcdfghjklmnpqrstvwxyz" def starts_or_ends_with_consonant(word): """ Check if a word starts or ends with a consonan...
from solution import starts_or_ends_with_consonant def test_word_starts_with_consonant(): assert starts_or_ends_with_consonant("cat") == True assert starts_or_ends_with_consonant("dog") == True def test_word_ends_with_consonant(): assert starts_or_ends_with_consonant("pineapple") == True assert starts...
[ { "docstring": "Check if a given character is a consonant.\nConsonants are all alphabetic characters that are not vowels (a, e, i, o, u).", "function_declaration": "def is_consonant(char):", "function_name": "is_consonant", "parameter_list": "(char)" }, { "docstring": "Check if a word starts...
[ 1, 0, 1, 1, 0, 0, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def starts_or_ends_with_consonant(word):\n \"\"\"\n Checks if a word starts or ends with a consonant.\n \"\"\"\n if not word:\n return False\n \n consonants = \"b...
trial_gpt4o_8
{ "original_instruction": "Create a function that checks if a word starts or ends with a consonant.", "prompt_id": "00024551", "row_id": 24551, "seed_ids": "['magpie_prefill_24551']" }
0.703549
Prefill_24551
C
[ "is_consonant", "starts_or_ends_with_consonant" ]
2
[ [ "starts_or_ends_with_consonant", "is_consonant" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d18353b801404a94cb6c2eb29807b196365d6bb8
8b0e8c94add7643fa13ebe0924f80395318f349f
v1.0
complete
Prefill
Prefill_25073_C
from typing import List 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(10) False """ def next_nearest_divisible_by_five(n: int) -> int: """ He...
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...
from solution import prime_numbers_greater_than_n, next_nearest_divisible_by_five, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False def test_next_nearest_divisible_by_five(): ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Helper function to find the next nearest single digit integer greater than n that is divisible by 5.", ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def next_nearest_greater_divisible_by_5(n):\n \"\"\"\n Finds the next nearest single digit integer greater than n that is divisible by 5.\n \"\"\"\n for i in range(n+1, 10):\n ...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes an integer `n` as input and returns all the prime numbers greater than `n` up to and including `m`. Here `m` is the next nearest single digit integer greater than `n` that is divisible by 5.", "prompt_id": "00025073", "row_id": 25073, "seed_ids": "['magpie...
0.734889
Prefill_25073
C
[ "is_prime", "next_nearest_divisible_by_five", "prime_numbers_greater_than_n" ]
3
[ [ "prime_numbers_greater_than_n", "is_prime" ], [ "prime_numbers_greater_than_n", "next_nearest_divisible_by_five" ] ]
2
[]
false
[]
false
pytest
true
[]
true
88451c0dbf6af6f04a2b2b7669735e9df8e562d9
2c8c38a6f64e09d3a824483102b6374ce10a6de3
v1.0
complete
Prefill
Prefill_25455_C
def gcd(x, y): """ Helper function to find the greatest common divisor of x and y. >>> gcd(8, 12) == 4 >>> gcd(17, 13) == 1 >>> gcd(100, 10) == 10 >>> gcd(5, 5) == 5 """ pass def largest_unreachable_integer(a, b): """ Returns the largest positive integer that cannot be formed by any com...
def largest_unreachable_integer(a, b): """ Returns the largest positive integer that cannot be formed by any combination of given positive integers a and b. """ if a <= 0 or b <= 0: return 0 if a == 1 or b == 1: return None # Since a and b being 1 means we can form any integer ...
from solution import largest_unreachable_integer, gcd def test_gcd(): assert gcd(8, 12) == 4 assert gcd(17, 13) == 1 assert gcd(100, 10) == 10 assert gcd(5, 5) == 5 def test_largest_unreachable_integer(): assert largest_unreachable_integer(6, 9) == None # not coprime assert largest_unreachabl...
[ { "docstring": "Returns the largest positive integer that cannot be formed by any combination of given positive integers a and b.", "function_declaration": "def largest_unreachable_integer(a, b):", "function_name": "largest_unreachable_integer", "parameter_list": "(a, b)" }, { "docstring": "...
[ 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_unreachable(a, b):\n \"\"\"\n Returns the largest positive integer that cannot be formed by any combination of a and b.\n This is known as the Frobenius number when a and...
trial_gpt4o_4
{ "original_instruction": "Create a function that returns the largest positive integer that cannot be formed by any combination of given positive integers `a` and `b`.", "prompt_id": "00025455", "row_id": 25455, "seed_ids": "['magpie_prefill_25455']" }
0.81217
Prefill_25455
C
[ "largest_unreachable_integer", "gcd" ]
2
[ [ "largest_unreachable_integer", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
35d9eaaf3494dcb7f544bafde294af55991f8d21
9b11e36e8189e3f240eed14cf78cf0e30c1c9784
v1.0
complete
Prefill
Prefill_25672_C
from typing import List def factorial(n: int) -> int: """ Returns the factorial of n. >>> factorial(0) 1 >>> factorial(4) 24 """ pass def factorial_list(numbers: List[int]) -> List[int]: """ Returns the list of factorials for the given list of numbers. >>> factorial_list([...
def factorial(n): """ Returns the factorial of n. """ if n == 0: return 1 result = 1 for i in range(1, n + 1): result *= i return result def factorial_list(numbers): """ Returns the list of factorials for the given list of numbers. """ return [factorial(n) fo...
from solution import factorial, factorial_list def test_factorial_zero(): assert factorial(0) == 1 def test_factorial_positive_numbers(): assert factorial(1) == 1 assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 assert factorial(5) == 120 def test_factorial_list_emp...
[ { "docstring": "Returns the factorial of n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Returns the list of factorials for the given list of numbers.", "function_declaration": "def factorial_list(numbers):", ...
[ 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 given number n.\n \"\"\"\n if n == 0:\n return 1\n result = 1\n for i in range(1, n + 1):\n result *= i...
trial_gpt4o_9
{ "original_instruction": "Create a function that calculates the factorial of a given number. Then, extend it to calculate the factorial of a list of numbers. For example, if the input is [1, 2, 3, 4], the output should be [1, 2, 6, 24].", "prompt_id": "00025672", "row_id": 25672, "seed_ids": "['magpie_prefill_...
0.701793
Prefill_25672
C
[ "factorial", "factorial_list" ]
2
[ [ "factorial_list", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b39decfdd95791fa8556060e3705608b5855627f
ef775250e187a8ce4b88ebc2b5f0e98d5d6e637e
v1.0
complete
Prefill
Prefill_25646_C
def is_prime(num: int) -> bool: """ Returns True if num is a prime number, otherwise False. >>> is_prime(0) False >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True """ pass def print_primes_up_to(n: int) -> list: """ ...
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def print_primes_up_to(n): """ Returns a list of all prime numbers u...
from solution import is_prime, print_primes_up_to def test_is_prime(): assert not is_prime(0) assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) def test_print_primes_up_to(): assert print_primes_up_to(10) == [2, 3, 5, 7] assert print...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of all prime numbers up to n.", "function_declaration": "def print_primes_up_to...
[ 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 Returns True if num is a prime number, else False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num %...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes an integer n as input and prints all prime numbers up to n.", "prompt_id": "00025646", "row_id": 25646, "seed_ids": "['magpie_prefill_25646']" }
0.7982
Prefill_25646
C
[ "is_prime", "print_primes_up_to" ]
2
[ [ "print_primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cca6e41b9fa04064c6f9a61ce7f5c16119cafb08
e62843763fb02b74c379b3e67044f511a68592b8
v1.0
complete
Prefill
Prefill_25473_C
from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def prime_factors(num: int) -> List[int]: """ Calculate all prime factors of a number. >>> prime_factors(10) [2, 5] >>> prime_factors(...
def is_prime(num): if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def prime_factors(num): factors = [] for i in range(2, num + 1): if num % i == 0 and is_prime(i): factors.append(i) return...
from solution import intersection_with_prime_factors, is_prime, prime_factors, has_common_prime_factors def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(1) assert not is_prime(0) assert not is_prime(-5) def test_prime_...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def prime_factors(num):", "function_name": "prime_factors", "parameter_list": "(num)" }, { "docstring...
[ 1, 0, 1, 1, 0, 1, 0, 0, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n return True\n\ndef prime_factors...
trial_gpt4o_0
{ "original_instruction": "Create a function that takes in two lists of integers and returns a list that contains the intersection of the two lists, but only if the intersection contains at least one common prime factor. If there are no common prime factors, return an empty list.", "prompt_id": "00025473", "row_i...
0.703056
Prefill_25473
C
[ "is_prime", "prime_factors", "has_common_prime_factors", "intersection_with_prime_factors" ]
4
[ [ "has_common_prime_factors", "prime_factors" ], [ "intersection_with_prime_factors", "has_common_prime_factors" ], [ "prime_factors", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e120a2c5c4ed3737d02173cce57e5c77c12b70a8
bf83f1067cce71bb1af55076105c3517961c94bb
v1.0
complete
Prefill
Prefill_25693_C
def is_prime(n: int) -> bool: """ Helper function that returns True if n is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(4) False """ def primes_up_to(n: int) -> List[int]: """ Create a function that accepts an integer `n` and outputs a list of all prime numbers up to `n`....
def is_prime(n): """ Helper function that returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2 or n == 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0...
from solution import primes_up_to def test_primes_up_to_10(): assert primes_up_to(10) == [2, 3, 5, 7] def test_primes_up_to_1(): assert primes_up_to(1) == [] def test_primes_up_to_2(): assert primes_up_to(2) == [2] def test_primes_up_to_20(): assert primes_up_to(20) == [2, 3, 5, 7, 11, 13, 17, 19] ...
[ { "docstring": "Helper function that 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 of all prime numbers up to and including n.", "function_declarat...
[ 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 that returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n ...
trial_gpt4o_0
{ "original_instruction": "Create a function that accepts an integer `n` and outputs a list of all prime numbers up to `n`.", "prompt_id": "00025693", "row_id": 25693, "seed_ids": "['magpie_prefill_25693']" }
0.804544
Prefill_25693
C
[ "is_prime", "primes_up_to" ]
2
[ [ "primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b602163d1d9f3c476a5fbafa7458e1ea9232d3a8
77cdb642326b7e6e114c340da71a867f9802f944
v1.0
complete
Prefill
Prefill_25508_C
def find_kth_element(arr: List[int], start: int, end: int, k: int) -> List[int]: """ Perform a partial sort on the list such that the k-th element is in its final sorted position. Parameters: arr (List[int]): The input list of numbers. start (int): The starting index of the range to be sorted. ...
def partition(arr, low, high): i = low - 1 pivot = arr[high] for j in range(low, high): if arr[j] <= pivot: i += 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[high] = arr[high], arr[i + 1] return i + 1 def quickselect(arr, low, high, k): if low <= high: ...
def test_find_kth_element_full_range(): arr = [10, 4, 5, 8, 6, 11, 26] k = 3 result = find_kth_element(arr, 0, len(arr) - 1, k) assert result[k] == sorted(arr)[k] def test_find_kth_element_partial_range(): arr = [10, 4, 5, 8, 6, 11, 26] k = 2 result = find_kth_element(arr, 1, 5, k) asse...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quickselect(arr, low, high, k):", "function_name": "quickselect", "parameter_list...
[ 1, 0, 0, 1, 1, 0, 1, 1, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quickselect(arr, start, end, k):\n \"\"\"\n Rearranges the list such that the k-th element is in its correct position\n within a sorted list. All elements before the k-th element...
trial_gpt4o_9
{ "original_instruction": "Create a function that implements the quicksort algorithm, but instead of sorting an entire list, it performs a partial sort on the list. The function should take three arguments: a list of numbers, a start index, an end index, and a desired k-th position. The function should return a list ...
0.647418
Prefill_25508
C
[ "partition", "quickselect", "find_kth_element" ]
3
[ [ "find_kth_element", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
4471ea16bce1820a1f0b6c4fbdf03cdabc09014b
7b14dd9b1e2cac50c0d3cdd8315eb43a3b78b545
v1.0
complete
Prefill
Prefill_26403_C
import sys def factorial(n): """ Returns the factorial of n using recursion. Handles large numbers efficiently by adjusting the recursion limit and raises a ValueError for negative inputs. >>> factorial(0) == 1 >>> factorial(1) == 1 >>> factorial(5) == 120 >>> factorial(20) == 243...
import sys def factorial(n): """ Returns the factorial of n using recursion. Handles large numbers efficiently by adjusting the recursion limit and raises a ValueError for negative inputs. """ if n < 0: raise ValueError("Factorial is not defined for negative numbers.") if n == 0 or...
from solution import factorial import pytest def test_factorial_zero(): assert factorial(0) == 1 def test_factorial_one(): assert factorial(1) == 1 def test_factorial_small_number(): assert factorial(5) == 120 def test_factorial_large_number(): assert factorial(20) == 2432902008176640000 def test_f...
[ { "docstring": "Returns the factorial of n using recursion.\n\nHandles large numbers efficiently by adjusting the recursion limit and\nraises a ValueError for negative inputs.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring...
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\n\ndef factorial(n):\n \"\"\"\n Returns the factorial of a number using recursion with a safeguard against\n large input that could cause stack overflow.\n \n Args:\...
trial_gpt4o_7
{ "original_instruction": "Create a function that calculates the factorial of a number using recursion. The function should handle large numbers efficiently and manage potential stack overflow errors by setting a reasonable recursion limit (using a loop to call the function until the limit is reached). Additionally, ...
0.706958
Prefill_26403
C
[ "factorial", "_factorial_recursive" ]
2
[ [ "factorial", "_factorial_recursive" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00d9064005c77012d90cabd668703c67f289f810
1fbaaa27862b8176fcba0c3b5c7fa7ed59f83630
v1.0
complete
Prefill
Prefill_25297_C
csharp using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; public class StringConversion { /// <summary> /// Convert a snake_case string to PascalCase. /// </summary> /// <param name="snake_str">The input snake_case string.</param> ...
import re from multiprocessing import Pool def convert_snake_to_pascal(snake_str): """ Converts a given snake_case string to PascalCase. """ # Splitting by underscores and capitalizing each word. components = snake_str.split('_') pascal_str = ''.join(x.capitalize() for x in components) retu...
import pytest from solution import convert_snake_to_pascal, multithread_convert_snake_to_pascal def test_convert_simple_snake_case(): assert convert_snake_to_pascal('simple_case') == 'SimpleCase' def test_convert_single_word(): assert convert_snake_to_pascal('word') == 'Word' def test_convert_mixed_case(): ...
[ { "docstring": "Converts a given snake_case string to PascalCase.", "function_declaration": "def convert_snake_to_pascal(snake_str):", "function_name": "convert_snake_to_pascal", "parameter_list": "(snake_str)" }, { "docstring": "Uses multithreading to convert a list of snake_case strings to...
[ 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.25
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "csharp\nusing System;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\npublic class StringConverter\n{\n public static string SnakeCaseToPascalCase(string input)\n...
trial_gpt4o_8
{ "original_instruction": "Create a function that converts a given string in snake_case to PascalCase using C#. Speed up the conversion process using multithreading in C#.", "prompt_id": "00025297", "row_id": 25297, "seed_ids": "['magpie_prefill_25297']" }
0.614995
Prefill_25297
C
[ "convert_snake_to_pascal", "multithread_convert_snake_to_pascal" ]
2
[ [ "multithread_convert_snake_to_pascal", "convert_snake_to_pascal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a10cec53d99443fdd6a1fbfcad3b38036f3e0faf
268ab47b1995f1bc8a641593cc9de62586fd0644