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_27385_C
def is_valid(board, row, col, num): """ Check if it's valid to place a number in the board's cell. """ for x in range(9): if board[row][x] == num or board[x][col] == num: return False start_row, start_col = 3 * (row // 3), 3 * (col // 3) for i in range(3): for j in r...
def is_valid(board, row, col, num): for x in range(9): if board[row][x] == num or board[x][col] == num: return False start_row, start_col = 3 * (row // 3), 3 * (col // 3) for i in range(3): for j in range(3): if board[i + start_row][j + start_col] == num: ...
from solution import solve_sudoku def test_sudoku_solver(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, 0, 0,...
[ { "docstring": null, "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": null, "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_list...
[ 0, 0, 1, 1, 1, 1, 1, 0, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solve_sudoku(board):\n \"\"\"\n Solves a given Sudoku puzzle.\n \n :param board: List[List[int]] A 2D list representing the Sudoku board.\n :return: True if the Sudoku boar...
trial_gpt4o_9
{ "original_instruction": "Write a python function to solve the Sudoku puzzle.", "prompt_id": "00027385", "row_id": 27385, "seed_ids": "['magpie_prefill_27385']" }
0.605842
Prefill_27385
C
[ "is_valid", "solve_sudoku", "find_empty_location" ]
3
[ [ "solve_sudoku", "find_empty_location" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
455cedfa59b70f6cf41797e88eab89abb3aeaf20
90be1aec68eb81611fe135b8b31b13cd4309ce9d
v1.0
complete
Prefill
Prefill_34215_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. """ pass def sum_primes_in_range(start: int, end: int) -> int: """ Returns the sum of all prime numbers in the given range [start, end]. >>> sum_primes_in_range(1, 10) 17 >>> sum_primes_in_range(10...
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_primes_in_range(start, end): """ Returns the sum of all prime numbers in the gi...
from solution import sum_primes_in_range def test_sum_primes_in_small_range(): assert sum_primes_in_range(1, 10) == 17 # primes are 2, 3, 5, 7 def test_sum_primes_in_large_range(): assert sum_primes_in_range(10, 20) == 60 # primes are 11, 13, 17, 19 def test_sum_primes_with_no_primes(): assert sum_prim...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the given range [start, end].", "function_declaration": "def sum_pr...
[ 1, 0, 1, 1, 0, 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 is_prime(num):\n \"\"\"\n Helper function to determine if a number is a prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num...
trial_gpt4o_7
{ "original_instruction": "Write a python function to calculate the sum of all prime numbers in a given range.", "prompt_id": "00034215", "row_id": 34215, "seed_ids": "['magpie_prefill_34215']" }
0.762951
Prefill_34215
C
[ "is_prime", "sum_primes_in_range" ]
2
[ [ "sum_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e5d9cbce7d0954cd73ef51f4c1a6b7539e5a4171
9cfda592af22ebf19fbd04ff65dcf88ace26adad
v1.0
complete
Prefill
Prefill_34292_C
def remove_duplicates(lst: list) -> list: """ Removes duplicates from a list using list comprehension. Parameters: lst (list): The input list from which duplicates are to be removed. Returns: list: A new list without duplicates. Examples: >>> remove_duplicates([1, 2, 3, 4, 5])...
def remove_duplicates(lst): """ Removes duplicates from a list using list comprehension. Parameters: lst (list): The input list from which duplicates are to be removed. Returns: list: A new list without duplicates. """ seen = {} return [x for x in lst if not (x in seen or s...
from solution import remove_duplicates def test_remove_duplicates_with_no_duplicates(): assert remove_duplicates([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_remove_duplicates_with_all_duplicates(): assert remove_duplicates([1, 1, 1, 1]) == [1] def test_remove_duplicates_with_some_duplicates(): assert re...
[ { "docstring": "Removes duplicates from a list using list comprehension.\n\nParameters:\nlst (list): The input list from which duplicates are to be removed.\n\nReturns:\nlist: A new list without duplicates.", "function_declaration": "def remove_duplicates(lst):", "function_name": "remove_duplicates", ...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def remove_duplicates(lst):\n \"\"\"\n Removes duplicates from a list using list comprehension.\n \n Parameters:\n lst (list): The list from which to remove duplicates.\n \n...
trial_gpt4o_9
{ "original_instruction": "Write a python function to remove duplicates from a list. You should use a list comprehension and not the `set` data structure. You cannot use any built-in methods for removing duplicates (like `remove()`, `pop()`, `index()`, list slicing operations etc.). Additionally, your solution must b...
0.845121
Prefill_34292
C
[ "remove_duplicates", "seen_set" ]
2
[ [ "remove_duplicates", "seen_set" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ee3b2ca270114e4d607692615a4a6f9464a79fdb
b61e99f07fcd2d4ac0fbb8ffc330d37cdb9fe4d8
v1.0
complete
Prefill
Prefill_34160_C
def count_inversions(arr): """ Function to count number of inversions in the array. An inversion is when a pair of elements a[i], a[j] are in the wrong order a[i] > a[j] where i < j. """ pass def test_no_inversions(): assert count_inversions([1, 2, 3, 4, 5]) == 0 def test_all_inversions(): ...
def merge_count_split_inv(arr, temp_arr, left, mid, right): """ Helper function to merge two halves of the array and count the number of inversions. """ i = left # Starting index for the left subarray j = mid + 1 # Starting index for the right subarray k = left # Starting index for the to ...
from solution import count_inversions def test_no_inversions(): assert count_inversions([1, 2, 3, 4, 5]) == 0 def test_all_inversions(): assert count_inversions([5, 4, 3, 2, 1]) == 10 def test_mixed_inversions(): assert count_inversions([1, 3, 2, 4, 5]) == 1 assert count_inversions([1, 5, 4, 3, 2]) =...
[ { "docstring": "Helper function to merge two halves of the array and count the number of inversions.", "function_declaration": "def merge_count_split_inv(arr, temp_arr, left, mid, right):", "function_name": "merge_count_split_inv", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "...
[ 1, 1, 1, 1, 1, 0, 1, 0, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_inversions(arr):\n \"\"\"\n Returns the number of inversions in the array.\n \"\"\"\n def merge_and_count(arr, temp_arr, left, mid, right):\n i = left # Starti...
trial_gpt4o_8
{ "original_instruction": "Write a python function to count the number of inversions in an array.", "prompt_id": "00034160", "row_id": 34160, "seed_ids": "['magpie_prefill_34160']" }
0.823375
Prefill_34160
C
[ "merge_count_split_inv", "merge_sort_and_count", "count_inversions" ]
3
[ [ "count_inversions", "merge_sort_and_count" ], [ "merge_sort_and_count", "merge_count_split_inv" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c6a2a0803415c7905f7c09108b2f5690f1accf8b
a2ad055f45a9bc09651de0e93f8a664ff14e18e4
v1.0
complete
Prefill
Prefill_29728_C
def solve_sudoku(board: List[List[int]]) -> bool: """ Solve the Sudoku puzzle using backtracking. Args: board: List[List[int]] -- 2D list representing the Sudoku board, with 0 representing empty cells. Returns: bool -- True if the Sudoku puzzle is solved, otherwise False. """ def find_empty(b...
def solve_sudoku(board): """ Solves the Sudoku puzzle using backtracking. Args: board: List[List[int]] -- 2D list representing the Sudoku board, with 0 representing empty cells. Returns: bool -- True if the Sudoku puzzle is solved, otherwise False. """ find = find_empty(board) ...
from solution import solve_sudoku def test_solve_sudoku(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, 0, 0, ...
[ { "docstring": "Solves the Sudoku puzzle using backtracking.\n\nArgs:\nboard: List[List[int]] -- 2D list representing the Sudoku board, with 0 representing empty cells.\n\nReturns:\nbool -- True if the Sudoku puzzle is solved, otherwise False.", "function_declaration": "def solve_sudoku(board):", "funct...
[ 1, 1, 0, 1, 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 is_valid(board, row, col, num):\n \"\"\"\n Check if num can be placed at board[row][col] according to Sudoku rules.\n \"\"\"\n for i in range(9):\n if board[row][i] == ...
trial_gpt4o_7
{ "original_instruction": "Write a python function to solve a Sudoku puzzle. The function should take a 2D list representing a Sudoku board and solve it using backtracking.", "prompt_id": "00029728", "row_id": 29728, "seed_ids": "['magpie_prefill_29728']" }
0.52958
Prefill_29728
C
[ "solve_sudoku", "find_empty", "is_valid" ]
3
[ [ "solve_sudoku", "find_empty" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
103e995d53b09abcf9ac0d16f78e61f204501d80
aec68c49262833e6c68d026ac1bfd0c84960ecc2
v1.0
complete
Prefill
Prefill_34577_C
from typing import List, Tuple def is_prime(n: int) -> bool: """Checks if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ def find_prime_pairs(even_sum: int) -> List[Tuple[int, int]]: """Find all pairs of prime numbers whose sum is even. >>> find_prime_pairs(4) [(...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def find_prime_pairs(even_sum): if even_sum % 2 != 0 or even_sum < 4: ...
from solution import find_prime_pairs, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(30) == False def test_find_prime_pairs(): # Test with even sum 4 ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_prime_pairs(even_sum):", "function_name": "find_prime_pairs", "parameter_list": "(even_sum)" } ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 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 Check 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_7
{ "original_instruction": "Write a python function to find all pairs of prime numbers whose sum is even. In python, a prime number is a whole number that has only two distinct factors: 1 and itself. For example, 2, 3, 5, 7, 11, etc.", "prompt_id": "00034577", "row_id": 34577, "seed_ids": "['magpie_prefill_34577...
0.669599
Prefill_34577
C
[ "is_prime", "find_prime_pairs" ]
2
[ [ "find_prime_pairs", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
73e8be51600a40f65e5b48ed7a488f135c88af69
94d5915a5450635b7307dc9cec58b7ec9472b92d
v1.0
complete
Prefill
Prefill_34207_C
def subsets(nums: List[int]) -> List[List[int]]: """ Generates all unique subsets of an array. >>> subsets([]) [[]] >>> subsets([1]) [[], [1]] >>> subsets([1, 2]) [[], [1], [1, 2], [2]] >>> subsets([1, 2, 2]) [[], [1], [1, 2], [1, 2, 2], [2], [2, 2]] >>> subsets([1, 2, 3]) [[...
def subsets(nums): """ Generates all unique subsets of the array `nums`. """ nums.sort() # Sort to handle duplicates result = [] subset_helper(nums, 0, [], result) return result def subset_helper(nums, index, path, result): result.append(path) for i in range(index, len(nums)): ...
from solution import subsets def test_empty_array(): assert subsets([]) == [[]] def test_single_element(): assert subsets([1]) == [[], [1]] def test_two_elements(): assert subsets([1, 2]) == [[], [1], [1, 2], [2]] def test_duplicates(): assert subsets([1, 2, 2]) == [[], [1], [1, 2], [1, 2, 2], [2], ...
[ { "docstring": "Generates all unique subsets of the array `nums`.", "function_declaration": "def subsets(nums):", "function_name": "subsets", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def subset_helper(nums, index, path, result):", "function_name": "...
[ 0, 1, 1, 1, 0, 1, 1, 1, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def subsets_with_dup(nums):\n \"\"\"\n Generates all unique subsets of the given list 'nums'.\n \"\"\"\n nums.sort() # Sort the array to handle duplicates\n result = []\n g...
trial_gpt4o_8
{ "original_instruction": "Write a python function to generate all unique subsets of an array. The solution set must not contain duplicate subsets.", "prompt_id": "00034207", "row_id": 34207, "seed_ids": "['magpie_prefill_34207']" }
0.641877
Prefill_34207
C
[ "subsets", "subset_helper" ]
2
[ [ "subsets", "subset_helper" ] ]
1
[]
false
[]
false
pytest
true
[]
true
75db7243f3edc9cee1c86a9db8de6265b861bbc9
b2bbe23255674ec21033b2146be6f1c042e17d75
v1.0
complete
Prefill
Prefill_34535_C
def is_beautiful_number(n: int) -> bool: """Returns True if the given number n is a beautiful number. A beautiful number is defined as a number that is both a palindrome (reads the same backward as forward) and the sum of its digits is also a palindrome. >>> is_beautiful_number(5) == True >>> is_beautif...
def is_palindrome(n): """ Helper function to check if a given number n is a palindrome. """ return str(n) == str(n)[::-1] def sum_of_digits(n): """ Helper function to calculate the sum of the digits of a given number n. """ return sum(int(digit) for digit in str(n)) def is_beautiful_nu...
from solution import is_beautiful_number def test_beautiful_number_single_digit(): assert is_beautiful_number(5) == True def test_beautiful_number_double_digit(): assert is_beautiful_number(33) == True def test_beautiful_number_not_palindrome(): assert is_beautiful_number(123) == False def test_beautifu...
[ { "docstring": "Helper function to check if a given number n is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Helper function to calculate the sum of the digits of a given number n.", "functio...
[ 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 is_palindrome(n):\n \"\"\"\n Helper function to check if a given number n is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef sum_of_digits(n):\n \"\"\"\n H...
trial_gpt4o_0
{ "original_instruction": "Write a python function to test if a given number is a beautiful number. A beautiful number is defined as a number that is both a palindrome (reads the same backward as forward) and the sum of its digits is also a palindrome.", "prompt_id": "00034535", "row_id": 34535, "seed_ids": "['...
0.65945
Prefill_34535
C
[ "is_palindrome", "sum_of_digits", "is_beautiful_number" ]
3
[ [ "is_beautiful_number", "is_palindrome" ], [ "is_beautiful_number", "sum_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5ca980b31dbcdfec56018a4f837d75a319a3efb7
18ac24c4b8d163f7f6eacf1bb2ddcc5cfafc44d8
v1.0
complete
Prefill
Prefill_34109_C
import datetime # List of holidays as date objects (year, month, day) HOLIDAYS = [ datetime.date(2023, 1, 1), # New Year's Day datetime.date(2023, 7, 4), # Independence Day datetime.date(2023, 12, 25), # Christmas ] def is_business_day(date): """ Check if a given date is a business day (i.e., no...
import datetime # List of holidays as date objects (year, month, day) HOLIDAYS = [ datetime.date(2023, 1, 1), # New Year's Day datetime.date(2023, 7, 4), # Independence Day datetime.date(2023, 12, 25), # Christmas ] def is_business_day(date): """ Check if a given date is a business day (i.e., no...
import datetime from solution import next_business_day, HOLIDAYS def test_next_business_day_on_weekday(): date = datetime.date(2023, 10, 17) # Tuesday assert next_business_day(date) == datetime.date(2023, 10, 18) # Wednesday def test_next_business_day_on_friday(): date = datetime.date(2023, 10, 20) # Frid...
[ { "docstring": "Check if a given date is a business day (i.e., not a weekend or a holiday).", "function_declaration": "def is_business_day(date):", "function_name": "is_business_day", "parameter_list": "(date)" }, { "docstring": "Given a date, returns the next business day considering weeken...
[ 1, 1, 0, 1, 1, 1, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\n\ndef next_business_day(start_date):\n \"\"\"\n Returns the next business day date string, considering weekends and holidays.\n \"\"\"\n holidays = [\n dat...
trial_gpt4o_8
{ "original_instruction": "Write a python function to generate a valid date string representing the next business day using the datetime module, considering weekends and holidays. The function should also print this date string. Additionally, create a list of holidays that your function will take into consideration."...
0.84022
Prefill_34109
C
[ "is_business_day", "next_business_day", "print_next_business_day" ]
3
[ [ "next_business_day", "is_business_day" ], [ "print_next_business_day", "next_business_day" ] ]
2
[]
false
[]
false
pytest
true
[]
true
00e1dc09a21a5814e45cd30ee3e2b2d2270c5a26
cccf8ddbf601ab2e759c92339211dfcdf287e6a1
v1.0
complete
Prefill
Prefill_34918_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, else False. """ # Implementation here def contains_only_primes(lst: List[int]) -> bool: """ Returns True if all elements in the list are prime numbers, else False. >>> contains_only_primes([]) == True >>> contains_only_prime...
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 contains_only_primes(lst): """ Returns True if all elements in the list are prime...
from solution import contains_only_primes def test_empty_list(): assert contains_only_primes([]) == True def test_single_element_prime(): assert contains_only_primes([2]) == True assert contains_only_primes([3]) == True assert contains_only_primes([13]) == True def test_single_element_non_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 True if all elements in the list are prime numbers, else False.", "function_declaration": "def co...
[ 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 == 2:\n return True\n if n % 2 == 0:\n ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to check if a list contains only primes", "prompt_id": "00034918", "row_id": 34918, "seed_ids": "['magpie_prefill_34918']" }
0.799833
Prefill_34918
C
[ "is_prime", "contains_only_primes" ]
2
[ [ "contains_only_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a37125f53b9b54e49704f480ccb5804f7cc2ecb7
8a4cc725601169a2ce98e220d853cebaed87f4c4
v1.0
complete
Prefill
Prefill_34202_C
def find_maximum_subarray(arr): """ Write a python function to find the maximum subarray problem using a divide-and-conquer strategy. The function should take in a list of integers. >>> find_maximum_subarray([1]) (0, 0, 1) >>> find_maximum_subarray([-1]) (0, 0, -1) >>> find_maximum_subarray([1, 2, 3, 4,...
def max_crossing_subarray(arr, low, mid, high): left_sum = float('-inf') total = 0 max_left = mid for i in range(mid, low - 1, -1): total += arr[i] if total > left_sum: left_sum = total max_left = i right_sum = float('-inf') total = 0 max_right = ...
from solution import find_maximum_subarray def test_single_element(): assert find_maximum_subarray([1]) == (0, 0, 1) assert find_maximum_subarray([-1]) == (0, 0, -1) def test_all_positive_elements(): assert find_maximum_subarray([1, 2, 3, 4, 5]) == (0, 4, 15) def test_all_negative_elements(): assert ...
[ { "docstring": null, "function_declaration": "def max_crossing_subarray(arr, low, mid, high):", "function_name": "max_crossing_subarray", "parameter_list": "(arr, low, mid, high)" }, { "docstring": null, "function_declaration": "def max_subarray(arr, low, high):", "function_name": "m...
[ 1, 1, 0, 1, 0, 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 find_max_crossing_subarray(arr, low, mid, high):\n left_sum = float('-inf')\n sum = 0\n max_left = mid\n for i in range(mid, low-1, -1):\n sum = sum + arr[i]\n i...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the maximum subarray problem using a divide-and-conquer strategy. The function should take in a list of integers.", "prompt_id": "00034202", "row_id": 34202, "seed_ids": "['magpie_prefill_34202']" }
0.755434
Prefill_34202
C
[ "max_crossing_subarray", "max_subarray", "find_maximum_subarray" ]
3
[ [ "find_maximum_subarray", "max_subarray" ], [ "max_subarray", "max_crossing_subarray" ] ]
2
[]
false
[]
false
pytest
true
[]
true
20b643ecbb559c6f77d5e7ec7de50adb4703f9a5
b10b4ba3d96aa7d877fa1133a66d645d3d63dc8c
v1.0
complete
Prefill
Prefill_34388_C
def sum_digits(number: int) -> int: """ Returns the sum of digits of a number. """ return sum(int(digit) for digit in str(number)) def calculate_matrix(n: int) -> List[List[int]]: """ Returns an n x n matrix where each element at position [i, j] is the sum of digits of i*j. >>> calculate_matr...
def sum_digits(number): """ Returns the sum of digits of a number. """ return sum(int(digit) for digit in str(number)) def calculate_matrix(n): """ Returns an n x n matrix where each element at position [i, j] is the sum of digits of i*j. """ matrix = [] for i in range(1, n + 1): ...
from solution import calculate_matrix def test_calculate_matrix_1x1(): assert calculate_matrix(1) == [[1]] def test_calculate_matrix_2x2(): assert calculate_matrix(2) == [ [1, 2], [2, 4] ] def test_calculate_matrix_3x3(): assert calculate_matrix(3) == [ [1, 2, 3], [2, ...
[ { "docstring": "Returns the sum of digits of a number.", "function_declaration": "def sum_digits(number):", "function_name": "sum_digits", "parameter_list": "(number)" }, { "docstring": "Returns an n x n matrix where each element at position [i, j] is the sum of digits of i*j.", "functio...
[ 0, 1, 0, 1, 1, 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 sum_of_digits(num):\n \"\"\"\n Returns the sum of digits of a given number.\n \"\"\"\n return sum(int(digit) for digit in str(num))\n\ndef generate_matrix(n):\n \"\"\"\n ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to calculate an n x n matrix (2D array) where each element at position [i, j] is the sum of digits of i*j (1 <= i <= n, 1 <= j <= n).", "prompt_id": "00034388", "row_id": 34388, "seed_ids": "['magpie_prefill_34388']" }
0.680297
Prefill_34388
C
[ "sum_digits", "calculate_matrix" ]
2
[ [ "calculate_matrix", "sum_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0a86d13b39c6a7fd292bf23d4045271729726aec
4537d763e775daa7fec66ecbf482a546e35afec6
v1.0
complete
Prefill
Prefill_34824_C
def is_prime(n): """ Helper function to check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(37) == True >>> is_prime(38) == False """ def find_primes_in_range(start, end): """ Retu...
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 find_primes_in_range, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(37) == True assert is_prime(38) == False def test_find_primes_in_range(): assert find_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 a list of all prime numbers within a given range [start, end].", "function_declaration": "def find_...
[ 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 == 2:\n return True\n if n % 2 == 0:\n ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to find all prime numbers within a range given by two integers, `start` and `end`. The function should return a list of all prime numbers in this range, inclusive.", "prompt_id": "00034824", "row_id": 34824, "seed_ids": "['magpie_prefill_34824']" }
0.790817
Prefill_34824
C
[ "is_prime", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a049b2e8ff1871bfcc5f3863716623718e6d1477
5446a2a31043d41bd59edafb853b506012a8c31c
v1.0
complete
Prefill
Prefill_33988_C
import math def sum_of_digits_in_factorial(n): """ Calculates the sum of the digits in the factorial of a given number n. :param n: An integer n :return: Sum of the digits in n! """ pass def sum_of_digits_in_100_factorial(): """ Calculates the sum of the digits in the number 100! ...
import math def sum_of_digits_in_factorial(n): """ Calculates the sum of the digits in the factorial of a given number n. :param n: An integer n :return: Sum of the digits in n! """ factorial_result = math.factorial(n) digits_sum = sum(int(digit) for digit in str(factorial_result)) ...
from solution import sum_of_digits_in_factorial, sum_of_digits_in_100_factorial def test_sum_of_digits_in_factorial_5(): assert sum_of_digits_in_factorial(5) == 3 # 5! = 120, sum of digits = 1 + 2 + 0 = 3 def test_sum_of_digits_in_factorial_10(): assert sum_of_digits_in_factorial(10) == 27 # 10! = 3628800, ...
[ { "docstring": "Calculates the sum of the digits in the factorial of a given number n.\n\n:param n: An integer n\n:return: Sum of the digits in n!", "function_declaration": "def sum_of_digits_in_factorial(n):", "function_name": "sum_of_digits_in_factorial", "parameter_list": "(n)" }, { "docs...
[ 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 sum_of_digits_in_factorial(n):\n \"\"\"\n Returns the sum of the digits in the factorial of n.\n \"\"\"\n factorial = math.factorial(n)\n return sum(int(digi...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the sum of the digits in the number 100!", "prompt_id": "00033988", "row_id": 33988, "seed_ids": "['magpie_prefill_33988']" }
0.638579
Prefill_33988
C
[ "sum_of_digits_in_factorial", "sum_of_digits_in_100_factorial" ]
2
[ [ "sum_of_digits_in_100_factorial", "sum_of_digits_in_factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cda2fdf7e75fe335449fe325b827da6b4dc0602e
ced5783613d2ec439de57c7eced9d9b421d83a4f
v1.0
complete
Prefill
Prefill_31627_C
def is_valid(board, row, col, num): """ Check whether it is legal to assign num to the given row, col. """ # Check the row for j in range(9): if board[row][j] == num: return False # Check the column for i in range(9): if board[i][col] == num: retu...
def is_valid(board, row, col, num): """ Check whether it is legal to assign num to the given row, col. """ # Check the row for j in range(9): if board[row][j] == num: return False # Check the column for i in range(9): if board[i][col] == num: retu...
from solution import solve_sudoku def test_valid_sudoku_solution(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, ...
[ { "docstring": "Check whether it is legal to assign num to the given row, col.", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Solve the Sudoku puzzle using DFS.", "function_declar...
[ 1, 0, 1, 0, 0, 1, 1, 1, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, row, col, num):\n for x in range(9):\n if board[row][x] == num:\n return False\n\n for x in range(9):\n if board[x][col] == num:\n ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to solve the Sudoku puzzle using depth-first search (DFS). The function should take a 2D list representing the Sudoku puzzle and return the solved puzzle. The empty cells are denoted by 0.", "prompt_id": "00031627", "row_id": 31627, "seed_ids": "['magpie_prefil...
0.633181
Prefill_31627
C
[ "is_valid", "solve_sudoku", "find_empty_cell" ]
3
[ [ "solve_sudoku", "find_empty_cell" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
32dea5c032ed24cf06bcdef56ea9f821fa9cbd6e
4501a20951f548c53ed0aad3b07e3adcf4880a7c
v1.0
complete
Prefill
Prefill_33945_C
import math from typing import List, Tuple, Optional def distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float: """ Calculate the Euclidean distance between two points p1 and p2. """ pass def closest_pair_of_points(points: List[Tuple[int, int]]) -> Tuple[Tuple[Optional[Tuple[int, int]], Optional...
import math from itertools import combinations def distance(p1, p2): """ Calculate the Euclidean distance between two points p1 and p2. """ return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def closest_pair_of_points(points): """ Returns the two closest points and the distance betw...
from solution import closest_pair_of_points def test_closest_pair_simple_case(): points = [(0, 0), (3, 4), (1, 1)] assert closest_pair_of_points(points) == (((0, 0), (1, 1)), math.sqrt(2)) def test_closest_pair_with_same_points(): points = [(0, 0), (3, 4), (0, 0)] assert closest_pair_of_points(points)...
[ { "docstring": "Calculate the Euclidean distance between two points p1 and p2.", "function_declaration": "def distance(p1, p2):", "function_name": "distance", "parameter_list": "(p1, p2)" }, { "docstring": "Returns the two closest points and the distance between them.", "function_declara...
[ 0, 1, 0, 1, 0, 0, 0, 0, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom typing import List, Tuple\n\ndef euclidean_distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float:\n \"\"\"\n Returns the Euclidean distance between two p...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the closest pair of points in a 2D plane. The function should take a list of tuples representing the points and return a tuple containing the two closest points and the distance between them.", "prompt_id": "00033945", "row_id": 33945, "seed_ids": "['ma...
0.722418
Prefill_33945
C
[ "distance", "closest_pair_of_points" ]
2
[ [ "closest_pair_of_points", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
60113d419688f01f24b99c6a34a8e16bb376919a
2c065d6d3ca604929d183295f981ee7de0d10120
v1.0
complete
Prefill
Prefill_35256_C
def is_palindrome(s: str) -> bool: """ Helper function to check if a given string is a palindrome. """ pass def is_binary_decimal_palindrome(n: int) -> bool: """ Check if a given number is a palindrome in both binary and decimal representation. >>> is_binary_decimal_palindrome(9) == True ...
def is_palindrome(s): """ Helper function to check if a given string is a palindrome. """ return s == s[::-1] def is_binary_decimal_palindrome(n): """ Check if a given number is a palindrome in both binary and decimal representation. Parameters: n (int): The number to check ...
from solution import is_binary_decimal_palindrome def test_number_9(): assert is_binary_decimal_palindrome(9) == True # 9 is '1001' in binary and both 9 and '1001' are palindromes. def test_number_33(): assert is_binary_decimal_palindrome(33) == True # 33 is '100001' in binary and both 33 and '100001' are p...
[ { "docstring": "Helper function to check if a given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Check if a given number is a palindrome in both binary and decimal representation.\n\nPa...
[ 0, 1, 1, 0, 0, 0, 0, 0, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(value):\n \"\"\"\n Checks if the given value is a palindrome.\n \"\"\"\n value_str = str(value)\n return value_str == value_str[::-1]\n\ndef is_palindrome_bot...
trial_gpt4o_9
{ "original_instruction": "Write a python function to check if a given number is a palindrome in both binary and decimal representation.", "prompt_id": "00035256", "row_id": 35256, "seed_ids": "['magpie_prefill_35256']" }
0.801713
Prefill_35256
C
[ "is_palindrome", "is_binary_decimal_palindrome" ]
2
[ [ "is_binary_decimal_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f3a303dc17c32bdebc07ea18ff5a8dd07729f783
792cf95ecfc2677a97e554416a04c18af2dc91d2
v1.0
complete
Prefill
Prefill_34340_C
def merge_sort(arr): """ Perform merge sort on the input list and return the sorted list. >>> merge_sort([]) == [] >>> merge_sort([5]) == [5] >>> merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] >>> merge_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] >>> merge_sort([3, 1, 4, 1, 5, 9, 2]) == [1, 1, ...
def merge_sort(arr): """ Perform merge sort on the input list and return the sorted list. """ if len(arr) <= 1: return arr # Split the array into two halves mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] # Recursively sort both halves left_sorted = mer...
from solution import merge_sort def test_merge_sort_empty_list(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([5]) == [5] def test_merge_sort_sorted_list(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_sorted_list(): assert...
[ { "docstring": "Perform merge sort on the input 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 a list in ascending order using the merge sort algorithm.\n \n Parameters:\n arr (list): The list to sort.\n \n Returns:\n list: ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to sort a list in ascending order using the merge sort algorithm.", "prompt_id": "00034340", "row_id": 34340, "seed_ids": "['magpie_prefill_34340']" }
0.668042
Prefill_34340
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8ffff9d9827fb93a1afb7bba8d6176bcc6cbe91
8fd73742802070b271bac0ade114869e8e711b51
v1.0
complete
Prefill
Prefill_35300_C
class TreeNode: def __init__(self, key, left=None, right=None): self.key = key self.left = left self.right = right def search_in_bst(root, key): """ Search for a key in an in-order traversal result of a binary search tree (BST). The function should return the first occurrence of the...
class TreeNode: def __init__(self, key, left=None, right=None): self.key = key self.left = left self.right = right def inorder_traversal(root, result=None): if result is None: result = [] if root is not None: inorder_traversal(root.left, result) result.a...
from solution import TreeNode, search_in_bst def test_search_existing_key(): # Create a sample BST root = TreeNode(2, TreeNode(1), TreeNode(3)) assert search_in_bst(root, 1) == 1 assert search_in_bst(root, 2) == 2 assert search_in_bst(root, 3) == 3 def test_search_non_existing_key(): # Create ...
[]
[ 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": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef inorder_search(root, key):\n \"\...
trial_gpt4o_9
{ "original_instruction": "Write a python function to search for a key in an in-order traversal result of a binary search tree (BST). The function should return the first occurrence of the key if it exists, and `None` if it doesn't. Assume the BST is not empty.", "prompt_id": "00035300", "row_id": 35300, "seed_...
0.571702
Prefill_35300
C
[ "inorder_traversal", "search_in_bst" ]
2
[ [ "search_in_bst", "inorder_traversal" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
f318fcbcf7f1de65ea423b3128efb515ff72255b
ee507f57daf545bf797646a6aaf9372fc19675ad
v1.0
complete
Prefill
Prefill_34979_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, False otherwise. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(29) True """ def prime_factors(n: int) -> List[int]: """ Returns a list of all prime factors of a number if it is a prime number. ...
def is_prime(n): """ Returns 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: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, prime_factors 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 assert is_prime(37) == Tru...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime factors of n if n is a prime number.\nIf n is not a prime number, returns an...
[ 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 a prime number.\n \n Args:\n n (int): The number to check.\n \n Returns:\n bool: True if n is a prime number, False o...
trial_gpt4o_5
{ "original_instruction": "Write a python function to check if a number is a prime number and then return the list of all prime factors of the number if it is a prime.", "prompt_id": "00034979", "row_id": 34979, "seed_ids": "['magpie_prefill_34979']" }
0.777837
Prefill_34979
C
[ "is_prime", "prime_factors" ]
2
[ [ "prime_factors", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1476727b41fd63d4f483ef3c06971d56c0124e17
950f18d5b247b8b29e23e83eb978140e486f479f
v1.0
complete
Prefill
Prefill_34819_C
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2 or 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: ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2 or 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: ...
from solution import prime_numbers_in_range def test_primes_in_small_range(): assert prime_numbers_in_range(1, 10) == [2, 3, 5, 7] def test_primes_with_zero_and_negative(): assert prime_numbers_in_range(-10, 10) == [2, 3, 5, 7] def test_primes_in_large_range(): assert prime_numbers_in_range(10, 50) == [1...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers within the given range [s, t].", "function_declaration": "def prime_num...
[ 1, 1, 0, 1, 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 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": "Write a python function to print prime numbers within a given range s and t. The function should consider both inclusive start and end values.", "prompt_id": "00034819", "row_id": 34819, "seed_ids": "['magpie_prefill_34819']" }
0.795373
Prefill_34819
C
[ "is_prime", "prime_numbers_in_range" ]
2
[ [ "prime_numbers_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
afa77898e67c8f0e31a24bf9184a162292bad299
e45636fe70b7995f7dd82fba9b3edcf57b39cecd
v1.0
complete
Prefill
Prefill_35156_C
def radix_sort(arr): """ Sorts an array using the radix sort algorithm. >>> radix_sort([]) == [] >>> radix_sort([5]) == [5] >>> radix_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] >>> radix_sort([4, 2, 9, 1, 5, 6]) == [1, 2, 4, 5, 6, 9] >>> radix_sort([3, 3, 2, 1, 4, 3]) == [1, 2, 3, 3, 3, 4] ...
def radix_sort(arr): """ Sorts an array using the radix sort algorithm. """ if len(arr) == 0: return arr # Find the maximum number to decide number of digits max_num = max(arr) # Start with the least significant digit exp = 1 while max_num // exp > 0: counting_s...
from solution import radix_sort def test_radix_sort_empty(): assert radix_sort([]) == [] def test_radix_sort_single_element(): assert radix_sort([5]) == [5] def test_radix_sort_sorted(): assert radix_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_radix_sort_unsorted(): assert radix_sort([4, 2, 9,...
[ { "docstring": "Sorts an array using the radix sort algorithm.", "function_declaration": "def radix_sort(arr):", "function_name": "radix_sort", "parameter_list": "(arr)" }, { "docstring": "A utility function to do counting sort of arr[] according to\nthe digit represented by exp.", "func...
[ 0, 1, 1, 0, 0, 1, 0, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def counting_sort(arr, exp):\n \"\"\"\n A function to do counting sort of arr[] according to\n the digit represented by exp (i.e., the exponent of 10).\n \"\"\"\n n = len(arr)\...
trial_gpt4o_5
{ "original_instruction": "Write a python function to sort an array using the radix sort algorithm.", "prompt_id": "00035156", "row_id": 35156, "seed_ids": "['magpie_prefill_35156']" }
0.671244
Prefill_35156
C
[ "radix_sort", "counting_sort" ]
2
[ [ "radix_sort", "counting_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
016e7961368515235c960291ae176af198708654
d1852c08d6ff8c177344ac14ee2caff970684e28
v1.0
complete
Prefill
Prefill_35264_C
def is_prime(num): """ Check if a number is prime. """ pass def largest_prime_in_range(m, n): """ Returns the largest prime number in the range [m, n]. If no primes are found, return -1. >>> largest_prime_in_range(10, 20) == 19 >>> largest_prime_in_range(15, 30) == 29 >>> large...
def is_prime(num): """ 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 largest_prime_in_ran...
from solution import largest_prime_in_range def test_prime_within_range(): assert largest_prime_in_range(10, 20) == 19 assert largest_prime_in_range(15, 30) == 29 def test_no_prime_in_range(): assert largest_prime_in_range(14, 16) == -1 assert largest_prime_in_range(0, 1) == -1 def test_entire_ran...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the largest prime number in the range [m, n]. If no primes are found, return -1.", "function_declaration": "def la...
[ 0, 1, 1, 1, 1, 1, 1, 0, 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 check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True # 2 is the only ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the largest prime number within a given range [m, n] where m and n are both inclusive. If there are no prime numbers in the range, the function should return -1.", "prompt_id": "00035264", "row_id": 35264, "seed_ids": "['magpie_prefill_35264']" }
0.817714
Prefill_35264
C
[ "is_prime", "largest_prime_in_range" ]
2
[ [ "largest_prime_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e629d540cd06f814e5fc3cd55bde81cb4132c71
9fe2b11dc21bcae9b7b61d3cbb9071c9b327b116
v1.0
complete
Prefill
Prefill_34590_C
def all_4_char_combinations(): """ Returns a list of all 4-characters long strings composed of ['A', 'B', 'C']. >>> len(all_4_char_combinations()) == 3**4 True >>> set(all_4_char_combinations()) == set(['AAAA', 'AAAB', 'AAAC', 'AABA', 'AABB', 'AABC', '...
from itertools import product def generate_combinations(chars, length): """ Returns a list of all strings of given length composed of given characters. """ return [''.join(p) for p in product(chars, repeat=length)] def all_4_char_combinations(): """ Returns a list of all 4-characters long stri...
from solution import all_4_char_combinations def test_all_4_char_combinations_length(): result = all_4_char_combinations() assert len(result) == 3**4 # 3 characters, 4 positions def test_all_4_char_combinations_content(): result = all_4_char_combinations() expected_set = set(['AAAA', 'AAAB', 'AAAC', ...
[ { "docstring": "Returns a list of all strings of given length composed of given characters.", "function_declaration": "def generate_combinations(chars, length):", "function_name": "generate_combinations", "parameter_list": "(chars, length)" }, { "docstring": "Returns a list of all 4-characte...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import product\n\ndef generate_4_char_strings():\n \"\"\"\n Returns a list of all 4-characters long strings composed of characters 'A', 'B', 'C'.\n \"\"\"\n charact...
trial_gpt4o_9
{ "original_instruction": "Write a python function to produce a list of all 4-characters long strings composed of ['A', 'B', 'C'].", "prompt_id": "00034590", "row_id": 34590, "seed_ids": "['magpie_prefill_34590']" }
0.614184
Prefill_34590
C
[ "generate_combinations", "all_4_char_combinations" ]
2
[ [ "all_4_char_combinations", "generate_combinations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4dd4482f34c3160bf6532eb7c079d99154cac55d
ccfc90d5b425b07391037d04cc85f5c14ac74c16
v1.0
complete
Prefill
Prefill_35428_C
from typing import List def max_sum_subarray_2d(arr: List[List[int]]) -> int: """ Write a python function to find the maximum sum of a subarray in a 2D array. You are allowed to move in four directions: up, down, left, and right. The function should take a 2D array of integers as input and return the ...
def max_sum_subarray_2d(arr): """ Finds the maximum sum of a subarray in a 2D array allowing moves in all four directions. Implementation uses Kadane's Algorithm for 2D arrays. """ if not arr or not arr[0]: return 0 rows = len(arr) cols = len(arr[0]) max_sum = float('-inf') ...
from solution import max_sum_subarray_2d def test_max_sum_subarray_2d_all_positive(): arr = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert max_sum_subarray_2d(arr) == 45 def test_max_sum_subarray_2d_all_negative(): arr = [ [-1, -2, -3], [-4, -5, -6], [-7, -8...
[ { "docstring": "Finds the maximum sum of a subarray in a 2D array allowing moves in all four directions.\nImplementation uses Kadane's Algorithm for 2D arrays.", "function_declaration": "def max_sum_subarray_2d(arr):", "function_name": "max_sum_subarray_2d", "parameter_list": "(arr)" }, { "d...
[ 0, 0, 0, 0, 1, 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 max_subarray_sum_2d(arr):\n \"\"\"\n Returns maximum sum of a subarray in a 2D array.\n \"\"\"\n if not arr or not arr[0]:\n return 0\n\n def kadane(arr):\n m...
trial_gpt4o_4
{ "original_instruction": "Write a python function to find the maximum sum of a subarray in a 2D array. You are allowed to move in four directions: up, down, left, and right. The function should take a 2D array of integers as input and return the maximum sum.", "prompt_id": "00035428", "row_id": 35428, "seed_id...
0.726986
Prefill_35428
C
[ "max_sum_subarray_2d", "kadane" ]
2
[ [ "max_sum_subarray_2d", "kadane" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a3d778c77472512c854e568d11b731e15d7d4ae6
ee7a10a2115bf3283b6c2a9ce426823e5b7a16c7
v1.0
complete
Prefill
Prefill_35655_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(19) True """ def primes_in_range(start: int, end: int) -> List[int]: """ Returns a list of prime numbers in the range [start, end] (inclusive). >>>...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, primes_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(30) == False assert is_prime(-1) == False assert is_prime(0) == False assert is_prime(1) == F...
[ { "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 in the range [start, end] (inclusive).", "function_declaration": "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 Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to identify prime numbers in a range of numbers.", "prompt_id": "00035655", "row_id": 35655, "seed_ids": "['magpie_prefill_35655']" }
0.75858
Prefill_35655
C
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
07aee32b7b5238bf4653fbb8f3bcef2aa789cff3
af8f1fd567323d537cc091dd93ddb96479db2376
v1.0
complete
Prefill
Prefill_35088_C
import numpy as np from collections import Counter def euclidean_distance(point1: float, point2: float) -> float: """ Calculate the Euclidean distance between two 1D points. >>> euclidean_distance(1, 2) 1 >>> euclidean_distance(5, 5) 0 >>> euclidean_distance(-1, 1) 2 >>> euclidean_dista...
import numpy as np from collections import Counter def euclidean_distance(point1, point2): """ Calculate the Euclidean distance between two 1D points. """ return np.abs(point1 - point2) def knn_predict(X_train, y_train, x_test, k): """ Implement K-Nearest Neighbors algorithm. Paramete...
import numpy as np from solution import euclidean_distance, knn_predict def test_euclidean_distance(): assert euclidean_distance(1, 2) == 1 assert euclidean_distance(5, 5) == 0 assert euclidean_distance(-1, 1) == 2 assert euclidean_distance(0, 0) == 0 def test_knn_predict(): X_train = np.array([1,...
[ { "docstring": "Calculate the Euclidean distance between two 1D points.", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Implement K-Nearest Neighbors algorithm.\n\nParameters:\...
[ 0, 1, 1, 0, 0, 0, 0, 0, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\nimport math\n\ndef euclidean_distance(point1, point2):\n \"\"\"\n Computes the Euclidean distance between two 1D points.\n \"\"\"\n return math.fa...
trial_gpt4o_9
{ "original_instruction": "Write a python function to implement K-Nearest Neighbors algorithm. The function should use 1D Euclidean distance as the metric for finding nearest neighbors.", "prompt_id": "00035088", "row_id": 35088, "seed_ids": "['magpie_prefill_35088']" }
0.694133
Prefill_35088
C
[ "euclidean_distance", "knn_predict" ]
2
[ [ "knn_predict", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
cd95cea6cd928e7ae2987a08222ac8c057035ecb
812be4507dc263d8bfecc0facc0d42ed5a9bf0c5
v1.0
complete
Prefill
Prefill_35003_C
def merge_sort(arr): """ Function to perform merge sort on an array. Parameters: arr (list): List of elements to be sorted. Returns: list: Sorted list. """ def merge(left, right): """ Function to merge two sorted lists. Parameters: left (list): First sorted list. righ...
def merge_sort(arr): """ Function to perform merge sort on an array. Parameters: arr (list): List of elements to be sorted. Returns: list: Sorted list. """ if len(arr) <= 1: return arr # Finding the mid of the array mid = len(arr) // 2 # Dividing the elements into...
from solution import merge_sort def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([6]) == [6] def test_merge_sort_sorted_list(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_sorted_list(): assert merg...
[ { "docstring": "Function to perform merge sort on an array.\n\nParameters:\narr (list): List of elements to be sorted.\n\nReturns:\nlist: Sorted list.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Function to mer...
[ 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 Implementation of merge sort algorithm.\n :param arr: List of elements to be sorted.\n :return: Sorted list of elements.\n \"\"\"\n if len(ar...
trial_gpt4o_9
{ "original_instruction": "Write a python function to implement merge sort. Merge sort is a divide-and-conquer algorithm that splits the input array into n subarrays, each containing one element (an array with one element is considered sorted), and then repeatedly merges subarrays to produce new sorted subarrays unti...
0.633267
Prefill_35003
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
74c4c1be3fd61b1db26871e69c5ddcfa1d5c0314
0451ce2a8cb283345d03fd917c33331f97d5cd4d
v1.0
complete
Prefill
Prefill_35306_C
def is_prime(num): """ Check if a number is prime. :param num: integer to check :return: True if num is prime, else False """ def first_10_primes(): """ Print the first 10 prime numbers. :return: A list of the first 10 prime numbers """ # Example usage: # >>> firs...
def is_prime(num): """ Check if a number is prime. :param num: integer to check :return: True if num is prime, else 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 first_10_primes(...
from solution import is_prime, first_10_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False def test_first_10_primes(): ...
[ { "docstring": "Check if a number is prime.\n\n:param num: integer to check\n:return: True if num is prime, else False", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Print the first 10 prime numbers.", "function_d...
[ 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 first_10_primes():\n \"\"\"\n Returns a list of the first 10 prime numbers.\n \"\"\"\n primes = []\n num = 2 # Start with the first prime number\n \n while len(prime...
trial_gpt4o_6
{ "original_instruction": "Write a python function to print the first 10 prime numbers. How can I approach this problem?", "prompt_id": "00035306", "row_id": 35306, "seed_ids": "['magpie_prefill_35306']" }
0.798474
Prefill_35306
C
[ "is_prime", "first_10_primes" ]
2
[ [ "first_10_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f44c8d3104414539641c9c4bd942026e76ea0e7b
d726d7941fa82af3171e5c397d86269f4305cb9d
v1.0
complete
Prefill
Prefill_35757_C
from typing import List def find_primes_in_list(numbers: List[int]) -> List[int]: """Returns a list of prime numbers from the given list of numbers. >>> find_primes_in_list([2, 3, 5, 7, 11]) [2, 3, 5, 7, 11] >>> find_primes_in_list([4, 6, 8, 10, 12]) [] >>> find_primes_in_list([2, 3,...
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_div = int(n ** 0.5) + 1 for i in range(3, max_div, 2): if n % i == 0: return False return...
from solution import find_primes_in_list def test_find_primes_in_list_all_primes(): assert find_primes_in_list([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_find_primes_in_list_no_primes(): assert find_primes_in_list([4, 6, 8, 10, 12]) == [] def test_find_primes_in_list_mixed_numbers(): assert find_prim...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of numbers.", "function_declaration": "def find_primes_...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return Fal...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find all the prime numbers in a given list of numbers.", "prompt_id": "00035757", "row_id": 35757, "seed_ids": "['magpie_prefill_35757']" }
0.708811
Prefill_35757
C
[ "is_prime", "find_primes_in_list" ]
2
[ [ "find_primes_in_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0eb1f8bf66ab5ae5e63cbddc2b323448515f23f
7dfa7f0b699d71e6096b75757b352ea6dacb11c8
v1.0
complete
Prefill
Prefill_35983_C
from typing import List def can_partition(nums: List[int], k: int, max_sum: int) -> bool: """ Helper function to check if we can partition the nums array into k subsets with each subset sum <= max_sum. """ pass def min_max_partition_sum(nums: List[int], k: int) -> int: """ Write a python f...
def can_partition(nums, k, max_sum): """ Helper function to check if we can partition the nums array into k subsets with each subset sum <= max_sum. """ current_sum = 0 required_subsets = 1 for num in nums: if current_sum + num > max_sum: required_subsets += 1 ...
from solution import min_max_partition_sum def test_partition_single_element(): assert min_max_partition_sum([5], 1) == 5 def test_partition_equal_elements(): assert min_max_partition_sum([5, 5, 5, 5], 2) == 10 def test_partition_varied_elements(): assert min_max_partition_sum([1, 2, 3, 4, 5], 2) == 9 d...
[ { "docstring": "Helper function to check if we can partition the nums array into k subsets\nwith each subset sum <= max_sum.", "function_declaration": "def can_partition(nums, k, max_sum):", "function_name": "can_partition", "parameter_list": "(nums, k, max_sum)" }, { "docstring": "Returns t...
[ 1, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_partition(nums, k, max_sum_limit):\n count = 0\n current_sum = 0\n for num in nums:\n if current_sum + num > max_sum_limit:\n count += 1\n curren...
trial_gpt4o_8
{ "original_instruction": "Write a python function to partition an array into k subsets such that the maximum sum of any subset is minimum.", "prompt_id": "00035983", "row_id": 35983, "seed_ids": "['magpie_prefill_35983']" }
0.678134
Prefill_35983
C
[ "can_partition", "min_max_partition_sum" ]
2
[ [ "min_max_partition_sum", "can_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
701feab2864889d2b7df9a498e34aa24c3a3e906
ccfd6044a040028dceeea6162b2bf95a4f9e446e
v1.0
complete
Prefill
Prefill_35992_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def sorted_array_to_bst(arr): """ Convert a sorted array to a balanced BST """ if not arr: return None mid = len(arr) // 2 root = TreeNode(arr[mid]) root.lef...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def sorted_array_to_bst(arr): if not arr: return None mid = len(arr) // 2 root = TreeNode(arr[mid]) root.left = sorted_array_to_bst(arr[:mid]) root.right = s...
from solution import convert_list_to_bst_and_inorder def test_balanced_bst_inorder(): assert convert_list_to_bst_and_inorder([4, 2, 5, 1, 3]) == [1, 2, 3, 4, 5] def test_empty_list(): assert convert_list_to_bst_and_inorder([]) == [] def test_single_element(): assert convert_list_to_bst_and_inorde...
[]
[ 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": "class TreeNode:\n def __init__(self, val):\n self.val = val\n self.left = None\n self.right = None\n\ndef sorted_array_to_bst(nums):\n if not nums:\n return ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to create a Binary Search Tree (BST) and perform an InOrder traversal on it. Given a list of integers as input, convert the list into a balanced BST, and then perform an InOrder traversal to print the elements in sorted order.", "prompt_id": "00035992", "row_id":...
0.593798
Prefill_35992
C
[ "sorted_array_to_bst", "inorder_traversal", "convert_list_to_bst_and_inorder" ]
3
[ [ "convert_list_to_bst_and_inorder", "inorder_traversal" ], [ "convert_list_to_bst_and_inorder", "sorted_array_to_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
97fdf978a36e9898facf858f9be3f95deb9a1339
38b10dd76c02447e09ffa9d52ba20e70cb57d6a8
v1.0
complete
Prefill
Prefill_36551_C
def merge_sort(arr): """ Sorts a list of integers using the merge sort algorithm and returns the sorted list. >>> merge_sort([]) [] >>> merge_sort([1]) [1] >>> merge_sort([1, 2, 3, 4, 5]) [1, 2, 3, 4, 5] >>> merge_sort([5, 4, 3, 2, 1]) [1, 2, 3, 4, 5] >>> merge_sort([3, 1, 4...
def merge_sort(arr): """ Sorts a list of integers using the merge sort algorithm and returns the sorted list. """ if len(arr) <= 1: return arr # Split the list in half mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] # Recursively sort each half left...
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_sorted_list(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_sorted_list(): assert merg...
[ { "docstring": "Sorts a list of integers using the merge sort algorithm and returns the sorted list.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted lists into one sorted list.", "function_dec...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts a list of integers using the merge sort algorithm and returns the sorted list.\n \"\"\"\n if len(arr) > 1:\n mid = len(arr) // 2\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to sort a list of integers using the merge sort algorithm. The function should return the sorted list.", "prompt_id": "00036551", "row_id": 36551, "seed_ids": "['magpie_prefill_36551']" }
0.648302
Prefill_36551
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
89c7b28a99612a476d13a48612d96159e9fcf3fc
236c621f7556000b49ff77f6b6979f53c4633ddc
v1.0
complete
Prefill
Prefill_36777_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(11) True >>> is_prime(15) False """ def is_palindrome(n: int) -> bool: """ Check if a number is a palindrome. >>> is_palindrome(1) True >>> is_palindrome(22) Tru...
def is_prime(n): """Check if a number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def is...
from solution import is_prime, is_palindrome, largest_prime_palindrome def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(11) assert not is_prime(15) def test_is_palindrome(): assert is_palindrome(1) assert is_palind...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", ...
[ 1, 1, 0, 0, 0, 0, 0, 0, 1, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def 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_1
{ "original_instruction": "Write a python function to find the largest prime number less than n that is also a palindrome.", "prompt_id": "00036777", "row_id": 36777, "seed_ids": "['magpie_prefill_36777']" }
0.702958
Prefill_36777
C
[ "is_prime", "is_palindrome", "largest_prime_palindrome" ]
3
[ [ "largest_prime_palindrome", "is_palindrome" ], [ "largest_prime_palindrome", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e324a0aef7219eaf9107c7adece4815a58ac0ded
5c6ad0290e0724ec3d0e422506e7c1dc9c7ea11a
v1.0
complete
Prefill
Prefill_37234_C
def list_to_roman(lst: List[int]) -> List[str]: """ Convert a list of integers to their corresponding Roman numerals. Handles numbers from 1 to 3999. >>> list_to_roman([1]) == ["I"] >>> list_to_roman([3999]) == ["MMMCMXCIX"] >>> list_to_roman([1, 2, 3]) == ["I", "II", "III"] >>> list_to_rom...
def int_to_roman(num): """ Convert an integer to a Roman numeral. Only handles numbers from 1 to 3999. """ val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syms = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX"...
from solution import list_to_roman def test_list_to_roman_single_element(): assert list_to_roman([1]) == ["I"] assert list_to_roman([3999]) == ["MMMCMXCIX"] def test_list_to_roman_multiple_elements(): assert list_to_roman([1, 2, 3]) == ["I", "II", "III"] assert list_to_roman([4, 5, 6]) == ["IV", "...
[ { "docstring": "Convert an integer to a Roman numeral.\nOnly handles numbers from 1 to 3999.", "function_declaration": "def int_to_roman(num):", "function_name": "int_to_roman", "parameter_list": "(num)" }, { "docstring": "Convert a list of integers to their corresponding Roman numerals.\nHa...
[ 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 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": "Write a python function to convert a list of integers to their corresponding roman numerals. The function should handle numbers from 1 to 3999.", "prompt_id": "00037234", "row_id": 37234, "seed_ids": "['magpie_prefill_37234']" }
0.718733
Prefill_37234
C
[ "int_to_roman", "list_to_roman" ]
2
[ [ "list_to_roman", "int_to_roman" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b2ed77a81ad50818c7f8431cef851ad01a99e336
3cc3107a991013331418749512c60b79f79686b8
v1.0
complete
Prefill
Prefill_37658_C
def caesar_cipher_encode(text: str, shift: int) -> str: """ Encodes the given text using Caesar cipher with the given shift. >>> caesar_cipher_encode('abc', 3) 'def' >>> caesar_cipher_encode('xyz', 3) 'abc' >>> caesar_cipher_encode('AbC', 1) 'BcD' >>> caesar_cipher_encode('abc123!', 2) 'cde123!' ...
def caesar_cipher_encode(text, shift): """ Encodes the given text using Caesar cipher with the given shift. """ result = "" for char in text: if char.isalpha(): shift_base = ord('A') if char.isupper() else ord('a') result += chr((ord(char) - shift_base + shift) % 26 +...
from solution import caesar_cipher_encode, caesar_cipher_decode def test_caesar_cipher_encode_simple(): assert caesar_cipher_encode('abc', 3) == 'def' def test_caesar_cipher_encode_wrap_around(): assert caesar_cipher_encode('xyz', 3) == 'abc' def test_caesar_cipher_encode_with_capitals(): assert caesar_c...
[ { "docstring": "Encodes the given text using Caesar cipher with the given shift.", "function_declaration": "def caesar_cipher_encode(text, shift):", "function_name": "caesar_cipher_encode", "parameter_list": "(text, shift)" }, { "docstring": "Decodes the encoded text using Caesar cipher with...
[ 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 caesar_cipher_encode(s, shift):\n \"\"\"\n Encodes a string using the Caesar cipher with a given shift.\n \n :param s: The input string to encode\n :param shift: The number...
trial_gpt4o_9
{ "original_instruction": "Write a python function to encode a string with a given Caesar cipher and decrypt the same using the same cipher.", "prompt_id": "00037658", "row_id": 37658, "seed_ids": "['magpie_prefill_37658']" }
0.724463
Prefill_37658
C
[ "caesar_cipher_encode", "caesar_cipher_decode" ]
2
[ [ "caesar_cipher_decode", "caesar_cipher_encode" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0b524e84c8fba20e06c5d77d4a057e3cbdba839
308f1583418dcd806d13406767acd2db74f11bdb
v1.0
complete
Prefill
Prefill_36267_C
def counting_sort(arr, exp): """ A function to perform counting sort on arr based on the digit represented by exp (10^i) """ pass def radix_sort(arr): """ The function to sort arr[] of size n using Radix Sort. Radix Sort is a non-comparative sorting algorithm that sorts numbers digit by dig...
def counting_sort(arr, exp): """ A function to perform counting sort on arr based on the digit represented by exp (10^i) """ n = len(arr) output = [0] * n # Output array to store sorted numbers count = [0] * 10 # Count array to store count of occurrences of digits (0 to 9) # Store the cou...
from solution import radix_sort def test_radix_sort_already_sorted(): assert radix_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_radix_sort_reverse_sorted(): assert radix_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] def test_radix_sort_with_duplicates(): assert radix_sort([4, 2, 2, 8, 3, 3, 1]) == [1, 2,...
[ { "docstring": "A function to perform counting sort on arr based on the digit represented by exp (10^i)", "function_declaration": "def counting_sort(arr, exp):", "function_name": "counting_sort", "parameter_list": "(arr, exp)" }, { "docstring": "The function to sort arr[] of size n using Rad...
[ 1, 0, 0, 0, 0, 1, 0, 0, 1 ]
3
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def counting_sort_for_radix(arr, exp):\n n = len(arr)\n output = [0] * n # Output array to be filled\n count = [0] * 10 # Buckets for each digit (0-9)\n\n # Count occurrences of...
trial_gpt4o_8
{ "original_instruction": "Write a python function to sort a list of integers using the radix sort algorithm. Provide a step-by-step explanation of how the radix sort algorithm works.", "prompt_id": "00036267", "row_id": 36267, "seed_ids": "['magpie_prefill_36267']" }
0.66089
Prefill_36267
C
[ "counting_sort", "radix_sort" ]
2
[ [ "radix_sort", "counting_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
880a3ab218d74432f32b8850332ef0edf9e46fe2
52c0edc74ffcc744e18986d8b869a039be9d67fc
v1.0
complete
Prefill
Prefill_36881_C
def reverse_stack(stack): """ Reverses a stack using recursion. The function takes a stack as input and returns the reversed stack without using any additional data structures like lists or arrays. >>> reverse_stack([]) == [] >>> reverse_stack([1]) == [1] >>> reverse_stack([1, 2]) =...
def reverse_stack(stack): """ Reverses a stack using recursion. Parameters: stack (list): A list representing a stack where the last element is the top. Returns: list: The reversed stack. """ if len(stack) == 0: return [] # Pop the top element top = stack.p...
from solution import reverse_stack def test_reverse_stack_empty(): assert reverse_stack([]) == [] def test_reverse_stack_single_element(): assert reverse_stack([1]) == [1] def test_reverse_stack_two_elements(): assert reverse_stack([1, 2]) == [2, 1] def test_reverse_stack_multiple_elements(): assert...
[ { "docstring": "Reverses a stack using recursion.\n\nParameters:\nstack (list): A list representing a stack where the last element is the top.\n\nReturns:\nlist: The reversed stack.", "function_declaration": "def reverse_stack(stack):", "function_name": "reverse_stack", "parameter_list": "(stack)" ...
[ 1, 1, 1, 1, 0, 1, 1, 1, 1 ]
8
easy
0.889
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def reverse_stack(stack):\n \"\"\"\n Reverses a stack using recursion.\n \n :param stack: list, a stack to be reversed\n :return: reversed stack\n \"\"\"\n if not stack:\...
trial_gpt4o_9
{ "original_instruction": "Write a python function to reverse a stack using recursion. The function should take a stack as input and return the reversed stack without using any additional data structures like lists or arrays.", "prompt_id": "00036881", "row_id": 36881, "seed_ids": "['magpie_prefill_36881']" }
0.542278
Prefill_36881
C
[ "reverse_stack", "insert_at_bottom" ]
2
[ [ "reverse_stack", "insert_at_bottom" ] ]
1
[]
false
[]
false
pytest
true
[]
true
be857dabeedf03890d9eaa778caa014b5c37a09f
c01bf2dcc89fd682484a4a4fc2bacf5fc998250f
v1.0
complete
Prefill
Prefill_37547_C
from itertools import combinations from typing import List, Tuple def max_triangle_area(points: List[Tuple[int, int]]) -> float: """ Write a python function to find the maximum area of a triangle formed by connecting any three points from a given list of points. >>> max_triangle_area([(0, 0), (0, 3), (4, ...
from itertools import combinations def triangle_area(p1, p2, p3): """ Returns the area of a triangle given its vertex points p1, p2, p3 using the Shoelace formula. p1, p2, p3 are tuples of the form (x, y). """ x1, y1 = p1 x2, y2 = p2 x3, y3 = p3 return 0.5 * abs(x1*(y2 - y3) + x2*(y3 - ...
from solution import max_triangle_area def test_max_triangle_area(): points = [(0, 0), (0, 3), (4, 0), (1, 1)] assert max_triangle_area(points) == 6.0 def test_no_valid_triangle(): points = [(0, 0), (1, 0), (2, 0)] assert max_triangle_area(points) == 0.0 def test_single_point_multiple_times(): po...
[ { "docstring": "Returns the area of a triangle given its vertex points p1, p2, p3 using the Shoelace formula.\np1, p2, p3 are tuples of the form (x, y).", "function_declaration": "def triangle_area(p1, p2, p3):", "function_name": "triangle_area", "parameter_list": "(p1, p2, p3)" }, { "docstr...
[ 0, 0, 1, 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": "from itertools import combinations\n\ndef max_area_of_triangle(points):\n \"\"\"\n Returns the maximum area of a triangle formed by any three points from the list.\n \"\"\"\n def ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the maximum area of a triangle formed by connecting any three points from a given list of points.", "prompt_id": "00037547", "row_id": 37547, "seed_ids": "['magpie_prefill_37547']" }
0.734487
Prefill_37547
C
[ "triangle_area", "max_triangle_area" ]
2
[ [ "max_triangle_area", "triangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5d9fec95db1a85859ecb54b4b6c88a28f5a95839
ae7aa4d6c45fd50b2a3328325f0474cb72e47bd0
v1.0
complete
Prefill
Prefill_36669_C
import math from typing import List def generate_primes_between(a: int, b: int) -> List[int]: """ Returns a list of all prime numbers between a and b (both inclusive). >>> generate_primes_between(1, 10) [2, 3, 5, 7] >>> generate_primes_between(10, 20) [11, 13, 17, 19] >>> generate_primes_between(50...
import math 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_between(a, b)...
from solution import generate_primes_between def test_primes_between_1_and_10(): assert generate_primes_between(1, 10) == [2, 3, 5, 7] def test_primes_between_10_and_20(): assert generate_primes_between(10, 20) == [11, 13, 17, 19] def test_primes_between_50_and_60(): assert generate_primes_between(50, 60...
[ { "docstring": null, "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 (both inclusive).", "function_declaration": "def generate_primes_between(a, b):", "function_nam...
[ 1, 1, 0, 1, 1, 1, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_primes(start, end):\n \"\"\"\n Returns a list of all prime numbers between start and end (both inclusive).\n \"\"\"\n if start > end:\n return []\n \n # ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to generate a list of all prime numbers between two given numbers (both inclusive). The function should be optimized for large numbers.", "prompt_id": "00036669", "row_id": 36669, "seed_ids": "['magpie_prefill_36669']" }
0.744196
Prefill_36669
C
[ "is_prime", "generate_primes_between" ]
2
[ [ "generate_primes_between", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8dda8b7199cc556b51f946ca74e5ab5a77e768db
899c94b6bf2a4bbd7bb92a20014d4d711819514c
v1.0
complete
Prefill
Prefill_37101_C
def caesar_cipher_encrypt(plain_text: str, shift: int) -> str: """ Encrypts the plain_text using Caesar Cipher with the given shift. >>> caesar_cipher_encrypt("hello", 3) "khoor" >>> caesar_cipher_encrypt("HELLO", 3) "KHOOR" >>> caesar_cipher_encrypt("HelloWorld", 3) "KhoorZruog" >>> cae...
def caesar_cipher_encrypt(plain_text, shift): """ Encrypts the plain_text using Caesar Cipher with the given shift. """ encrypted_text = [] for char in plain_text: if char.isalpha(): shift_base = 65 if char.isupper() else 97 encrypted_text.append(chr((ord(char) - shif...
from solution import caesar_cipher_encrypt, caesar_cipher_decrypt def test_caesar_cipher_encrypt_lowercase(): assert caesar_cipher_encrypt("hello", 3) == "khoor" def test_caesar_cipher_encrypt_uppercase(): assert caesar_cipher_encrypt("HELLO", 3) == "KHOOR" def test_caesar_cipher_encrypt_mixed_case(): as...
[ { "docstring": "Encrypts the plain_text using Caesar Cipher with the given shift.", "function_declaration": "def caesar_cipher_encrypt(plain_text, shift):", "function_name": "caesar_cipher_encrypt", "parameter_list": "(plain_text, shift)" }, { "docstring": "Decrypts the cipher_text using Cae...
[ 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(message, shift):\n \"\"\"\n Encrypts the message using Caesar Cipher with the given shift.\n \"\"\"\n encrypted_message = \"\"\n for char in message:\...
trial_gpt4o_9
{ "original_instruction": "Write a python function to encrypt and decrypt a message using the Caesar Cipher.", "prompt_id": "00037101", "row_id": 37101, "seed_ids": "['magpie_prefill_37101']" }
0.696584
Prefill_37101
C
[ "caesar_cipher_encrypt", "caesar_cipher_decrypt" ]
2
[ [ "caesar_cipher_decrypt", "caesar_cipher_encrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e057c0abd53761a5118bc6b15863b28b0cc7b57
f4ba57cd27d6ba7a44259d65eab47c21f73f66f5
v1.0
complete
Prefill
Prefill_38183_C
def is_palindrome(s: str) -> bool: """ Checks if a given string s is a palindrome. """ return s == s[::-1] def count_palindrome_substrings(s: str) -> int: """ Returns the number of substrings of s that are palindromes. >>> count_palindrome_substrings("a") 1 >>> count_palindrome_substr...
def is_palindrome(s): """ Checks if a given string s is a palindrome. """ return s == s[::-1] def count_palindrome_substrings(s): """ Returns the number of substrings of s that are palindromes. """ n = len(s) count = 0 for i in range(n): for j in range(i+1, n+1): ...
from solution import count_palindrome_substrings def test_single_character(): assert count_palindrome_substrings("a") == 1 assert count_palindrome_substrings("b") == 1 def test_double_character(): assert count_palindrome_substrings("aa") == 3 assert count_palindrome_substrings("ab") == 2 def test_mul...
[ { "docstring": "Checks if a given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns the number of substrings of s that are palindromes.", "function_declaration": "def count_pal...
[ 0, 0, 0, 1, 1, 1, 0, 0, 1, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Helper function to check if a string is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef count_palindrome_substrings(s):\n \"\"\"\n Retur...
trial_gpt4o_9
{ "original_instruction": "Write a python function to return the number of substrings of a string that will form a palindrome when reversed and unpalindrome when not reversed. Let's call a function `count_palindrome_substrings(s)` where `s` is the input string. The function should return the count of such substrings....
0.776754
Prefill_38183
C
[ "is_palindrome", "count_palindrome_substrings" ]
2
[ [ "count_palindrome_substrings", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2e47c746d080a0c058240f93c32d9b408e8dda23
e4bfc0fe02aa8a432a6744f1fa68bf5085ed2cff
v1.0
complete
Prefill
Prefill_37694_C
from math import gcd from typing import Any def lcm(a: int, b: int) -> int: """ Return the least common multiple of a and b. """ return a * b // gcd(a, b) def smallest_multiple(n: int) -> int: """ Returns the smallest positive integer that is evenly divisible by all the numbers from 1 to n. ...
from math import gcd def lcm(a, b): """ Return the least common multiple of a and b. """ return a * b // gcd(a, b) def smallest_multiple(n): """ Returns the smallest positive integer that is evenly divisible by all the numbers from 1 to n. """ multiple = 1 for i in range(1, n + 1):...
from solution import smallest_multiple, smallest_multiple_1_to_20 def test_smallest_multiple_1_to_10(): assert smallest_multiple(10) == 2520 def test_smallest_multiple_1_to_20(): assert smallest_multiple_1_to_20() == 232792560 def test_smallest_multiple_1_to_1(): assert smallest_multiple(1) == 1 def tes...
[ { "docstring": "Return the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest positive integer that is evenly divisible by all the numbers from 1 to n.", "function_declar...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef lcm(a, b):\n return abs(a * b) // math.gcd(a, b)\n\ndef smallest_multiple(n):\n multiple = 1\n for i in range(1, n + 1):\n multiple = lcm(multiple, i)\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the smallest positive integer that is evenly divisible by all the numbers from 1 to 20.", "prompt_id": "00037694", "row_id": 37694, "seed_ids": "['magpie_prefill_37694']" }
0.702023
Prefill_37694
C
[ "lcm", "smallest_multiple", "smallest_multiple_1_to_20" ]
3
[ [ "smallest_multiple", "lcm" ], [ "smallest_multiple_1_to_20", "smallest_multiple" ] ]
2
[]
false
[]
false
pytest
true
[]
true
73024f635ffd36db163d9915f08e3936fd521e38
aca2e8d185f08b85147f32ef77459e7358b1fa92
v1.0
complete
Prefill
Prefill_38304_C
from math import gcd from functools import reduce def lcm(a, b): return abs(a * b) // gcd(a, b) def smallest_multiple(n): """ Returns the smallest multiple that is evenly divisible by all numbers from 1 to n. >>> smallest_multiple(1) == 1 >>> smallest_multiple(2) == 2 >>> smallest_multiple(3) ...
from math import gcd from functools import reduce def lcm(a, b): return abs(a * b) // gcd(a, b) def smallest_multiple(n): """ Returns the smallest multiple that is evenly divisible by all numbers from 1 to n. """ return reduce(lcm, range(1, n + 1))
from solution import smallest_multiple def test_smallest_multiple_1(): assert smallest_multiple(1) == 1 def test_smallest_multiple_2(): assert smallest_multiple(2) == 2 def test_smallest_multiple_3(): assert smallest_multiple(3) == 6 def test_smallest_multiple_4(): assert smallest_multiple(4) == 12 ...
[ { "docstring": null, "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest multiple that is evenly divisible by all numbers from 1 to n.", "function_declaration": "def smallest_multiple(n):", "function_nam...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef lcm(a, b):\n \"\"\"\n Returns the least common multiple of a and b.\n \"\"\"\n return a * b // math.gcd(a, b)\n\ndef smallest_multiple(n):\n \"\"\"\n Retu...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the smallest number that is evenly divisible by all numbers in a given range.", "prompt_id": "00038304", "row_id": 38304, "seed_ids": "['magpie_prefill_38304']" }
0.675534
Prefill_38304
C
[ "lcm", "smallest_multiple" ]
2
[ [ "smallest_multiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
70038ca97db82490c69fe79ca637d13fb25e36a8
6fa1632e37cce93bc6eb4b8b07715a96d52a86f0
v1.0
complete
Prefill
Prefill_37581_C
def is_prime(num: int) -> bool: """ Checks if a number is prime. """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Filters and returns the prime numbers from a given list of integers. >>> filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] >>> filter_primes([1, 4, 6, 8, 9...
def is_prime(num): """ Checks 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): """ Filters and returns the prime numbers from a given list of inte...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_no_primes(): assert filter_primes([1, 4, 6, 8, 9, 10]) == [] def test_filter_primes_mixed_numbers(): assert filter_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 1...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Filters and returns the prime numbers from a given list of integers.", "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 Helper function to determine if n is a prime number.\n Returns True if n is prime, else False.\n \"\"\"\n if n <= 1:\n return False\n if n...
trial_gpt4o_9
{ "original_instruction": "Write a python function to filter and return prime numbers from a given list of integers. The function should take a single parameter which is the list of integers. It should return a list containing only the prime numbers from the input list.", "prompt_id": "00037581", "row_id": 37581,...
0.785976
Prefill_37581
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4d0c5489797911f24f28ea112bcda8b5c162c049
1cdca9f05521962c30299c1b4de975f55129e010
v1.0
complete
Prefill
Prefill_38085_C
def unique_subsets(nums: List[int]) -> List[List[int]]: """ Generates all unique subsets of the given list. >>> unique_subsets([]) == [[]] >>> unique_subsets([1]) == [[], [1]] >>> unique_subsets([1, 2]) == [[], [1], [1, 2], [2]] >>> unique_subsets([1, 2, 2]) == [[], [1], [1, 2], [1, 2, 2], [2], ...
def unique_subsets(nums): """ Generates all unique subsets of the given list. """ nums.sort() subsets = [] backtrack(nums, 0, [], subsets) return subsets def backtrack(nums, index, path, res): res.append(path) for i in range(index, len(nums)): if i > index and nums[i] == num...
from solution import unique_subsets def test_unique_subsets_empty(): assert unique_subsets([]) == [[]] def test_unique_subsets_single_element(): assert unique_subsets([1]) == [[], [1]] def test_unique_subsets_two_elements(): assert unique_subsets([1, 2]) == [[], [1], [1, 2], [2]] def test_unique_subsets...
[ { "docstring": "Generates all unique subsets of the given list.", "function_declaration": "def unique_subsets(nums):", "function_name": "unique_subsets", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def backtrack(nums, index, path, res):", "function_nam...
[ 0, 0, 1, 1, 1, 1, 1, 1, 1 ]
7
easy
0.778
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef unique_subsets(nums):\n \"\"\"\n Generates all unique subsets of a given list.\n \"\"\"\n nums = sorted(nums)\n subsets = set()\n\n ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to generate all unique subsets of a given list. The function should not contain duplicate subsets in the output.", "prompt_id": "00038085", "row_id": 38085, "seed_ids": "['magpie_prefill_38085']" }
0.607468
Prefill_38085
C
[ "unique_subsets", "backtrack" ]
2
[ [ "unique_subsets", "backtrack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2e4e3a5115b054cbccbab7567d393d2ec16b1bf3
3979154d307913127224c04b45ea0c46f25747d9
v1.0
complete
Prefill
Prefill_37952_C
def primes_up_to(n): """ Helper function to generate a list of primes up to n (inclusive). """ pass def count_prime_sum_ways(n): """ Returns the number of ways to represent the given number 'n' as a sum of positive integers where each integer in the sum must be a prime number. >>> count...
def primes_up_to(n): """ Helper function to generate a list of primes up to n (inclusive). """ if n < 2: return [] sieve = [True] * (n + 1) sieve[0] = sieve[1] = False for start in range(2, int(n**0.5) + 1): if sieve[start]: for i in range(start*start, n + 1, star...
from solution import count_prime_sum_ways def test_count_prime_sum_ways_0(): assert count_prime_sum_ways(0) == 1 def test_count_prime_sum_ways_2(): assert count_prime_sum_ways(2) == 1 # 2 def test_count_prime_sum_ways_3(): assert count_prime_sum_ways(3) == 1 # 3 def test_count_prime_sum_ways_4(): ...
[ { "docstring": "Helper function to generate a list of primes up to n (inclusive).", "function_declaration": "def primes_up_to(n):", "function_name": "primes_up_to", "parameter_list": "(n)" }, { "docstring": "Returns the number of ways to represent the given number 'n'\nas a sum of positive i...
[ 0, 0, 1, 1, 1, 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 count_prime_sums(n):\n \"\"\"\n Returns the number of ways to represent the given number n as a sum of positive prime integers.\n \"\"\"\n def sieve(limit):\n is_prime ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to find the number of ways to represent a given number as a sum of positive integers where each number in the sum must be a prime number.", "prompt_id": "00037952", "row_id": 37952, "seed_ids": "['magpie_prefill_37952']" }
0.852305
Prefill_37952
C
[ "primes_up_to", "count_prime_sum_ways" ]
2
[ [ "count_prime_sum_ways", "primes_up_to" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5ab02061c490f1532227202425881751c2946f11
f40e800fe776cd7c6b932096bb7718922695584c
v1.0
complete
Prefill
Prefill_38136_C
def is_prime(n: int) -> bool: """ Checks if a number n is prime. """ # Function body here def find_primes_in_range(start: int, end: int) -> List[int]: """ Returns a list of all prime numbers within the range [start, end]. >>> find_primes_in_range(10, 20) [11, 13, 17, 19] >>> find_primes...
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return T...
from solution import find_primes_in_range def test_find_primes_in_range_start_greater_than_end(): assert find_primes_in_range(10, 5) == [] def test_find_primes_in_range_no_primes(): assert find_primes_in_range(14, 16) == [] def test_find_primes_in_range_one_prime(): assert find_primes_in_range(10, 11) ==...
[ { "docstring": "Checks 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 within the range [start, end].", "function_declaration": "def find_primes_in_range(star...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if the number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 =...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find all the prime numbers within a given range [start, end].", "prompt_id": "00038136", "row_id": 38136, "seed_ids": "['magpie_prefill_38136']" }
0.792047
Prefill_38136
C
[ "is_prime", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b363e567cf6508b23b71c705b86a7d396b87ccf5
ce429c9184f56c353f2a41eff216afe28139ea1b
v1.0
complete
Prefill
Prefill_37327_C
def fibonacci(n, computed={0: 0, 1: 1}): """ Returns the n-th Fibonacci number using memoization to optimize recursive calls. """ if n not in computed: computed[n] = fibonacci(n - 1, computed) + fibonacci(n - 2, computed) return computed[n] def generate_fibonacci_numbers(count): """ ...
def fibonacci(n, computed={0: 0, 1: 1}): """ Returns the n-th Fibonacci number using memoization to optimize recursive calls. """ if n not in computed: computed[n] = fibonacci(n - 1, computed) + fibonacci(n - 2, computed) return computed[n] def generate_fibonacci_numbers(count): """ ...
from solution import generate_fibonacci_numbers def test_generate_fibonacci_first_ten(): expected = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] assert generate_fibonacci_numbers(10) == expected def test_generate_fibonacci_first_twenty(): expected = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...
[ { "docstring": "Returns the n-th Fibonacci number using memoization to optimize recursive calls.", "function_declaration": "def fibonacci(n, computed={0: 0, 1: 1}):", "function_name": "fibonacci", "parameter_list": "(n, computed={0: 0, 1: 1})" }, { "docstring": "Generates the first 'count' F...
[ 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 fibonacci_recursive(n, computed={0: 0, 1: 1}):\n \"\"\"\n Returns the nth Fibonacci number using recursion with memoization.\n \"\"\"\n if n not in computed:\n computed...
trial_gpt4o_9
{ "original_instruction": "Write a python function to generate the first 100 Fibonacci numbers using recursion. The function should return a list of the numbers.", "prompt_id": "00037327", "row_id": 37327, "seed_ids": "['magpie_prefill_37327']" }
0.811514
Prefill_37327
C
[ "fibonacci", "generate_fibonacci_numbers" ]
2
[ [ "generate_fibonacci_numbers", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
39dae3f80c6bb455b8eb5da8a7e09c2a29b6e794
0192ad18f29f19ee84bd8070f1569f20fa902bec
v1.0
complete
Prefill
Prefill_37093_C
def nCr_mod_P(n: int, r: int, P: int) -> int: """ Write a python function to return the value of nCr % P, where nCr is 'n choose r' and P is a prime number. The function should efficiently handle large values of n, r, and P up to 10^6, 10^6, and 10^9+7 respectively. >>> P = 1000000007 >>> nCr_mod_P...
def mod_inverse(a, P): """ Returns the modular inverse of a under modulo P using Fermat's Little Theorem. P must be a prime number. """ return pow(a, P - 2, P) def nCr_mod_P(n, r, P): """ Returns the value of nCr % P, where nCr is 'n choose r' and P is a prime number. """ if r > n:...
from solution import nCr_mod_P def test_nCr_mod_P_small_numbers(): P = 1000000007 assert nCr_mod_P(5, 2, P) == 10 assert nCr_mod_P(5, 0, P) == 1 assert nCr_mod_P(5, 5, P) == 1 assert nCr_mod_P(6, 3, P) == 20 def test_nCr_mod_P_large_numbers(): P = 1000000007 assert nCr_mod_P(10**6, 500000,...
[ { "docstring": "Returns the modular inverse of a under modulo P using Fermat's Little Theorem.\nP must be a prime number.", "function_declaration": "def mod_inverse(a, P):", "function_name": "mod_inverse", "parameter_list": "(a, P)" }, { "docstring": "Returns the value of nCr % P, where nCr ...
[ 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 mod_inverse(x, p):\n \"\"\"\n Calculate modular multiplicative inverse of x under modulo p using\n Fermat's little theorem.\n \"\"\"\n return pow(x, p - 2, p)\n\ndef nCr_mo...
trial_gpt4o_2
{ "original_instruction": "Write a python function to return the value of nCr % P, where nCr is 'n choose r' and P is a prime number. The function should efficiently handle large values of n, r, and P up to 10^6, 10^6, and 10^9+7 respectively.", "prompt_id": "00037093", "row_id": 37093, "seed_ids": "['magpie_pr...
0.700073
Prefill_37093
C
[ "mod_inverse", "nCr_mod_P" ]
2
[ [ "nCr_mod_P", "mod_inverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
016503c053d9cf6b4a43d6fe5560398fe0cee30b
37c59002a03407b425bd2c9ce0560e49341c7311
v1.0
complete
Prefill
Prefill_37788_C
def is_armstrong_number(number): """ Checks if a given number is an Armstrong number. An Armstrong number (also called a narcissistic number) is a number that is equal to the sum of its own digits each raised to the power of the number of digits. For a 3-digit number abc, it is an Armstrong number if a^...
def is_armstrong_number(number): """ Checks if a given number is an Armstrong number. An Armstrong number (also called a narcissistic number) is a number that is equal to the sum of its own digits each raised to the power of the number of digits. For a 3-digit number abc, it is an Armstrong number if a^...
from solution import is_armstrong_number, find_armstrong_numbers def test_is_armstrong_number(): assert is_armstrong_number(153) == True assert is_armstrong_number(370) == True assert is_armstrong_number(371) == True assert is_armstrong_number(407) == True assert is_armstrong_number(100) == False ...
[ { "docstring": "Checks if a given number is an Armstrong number.\nAn Armstrong number (also called a narcissistic number) is a number that is equal to the sum of its own digits each raised to the power of the number of digits.\nFor a 3-digit number abc, it is an Armstrong number if a^3 + b^3 + c^3 == abc.", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_armstrong_numbers():\n \"\"\"\n Returns a list of all Armstrong numbers between 100 and 999.\n \"\"\"\n armstrong_numbers = []\n for num in range(100, 1000):\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find all Armstrong numbers between 100 and 999.", "prompt_id": "00037788", "row_id": 37788, "seed_ids": "['magpie_prefill_37788']" }
0.552814
Prefill_37788
C
[ "is_armstrong_number", "find_armstrong_numbers" ]
2
[ [ "find_armstrong_numbers", "is_armstrong_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9663c523d0eef5c4526d30151eed2b5fcf9598c2
f419d7cde9186ab404f20216ad8345c963627933
v1.0
complete
Prefill
Prefill_38168_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(101) True >>> is_prime(102) False """ def primes_between_100_and_200() -> List[int]: """ Finds all the prime numbers between 100 and 200. >>> primes_between_100_and_200() [101, 103, 107, 109, 113, 127, 131, 137, 139, 149...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def primes_between_100_and_200(): """ Finds all the prime numbers between 100 and 200. """ prime...
from solution import is_prime, primes_between_100_and_200 def test_is_prime(): assert is_prime(101) == True assert is_prime(102) == False assert is_prime(103) == True assert is_prime(104) == False assert is_prime(2) == True assert is_prime(1) == False def test_primes_between_100_and_200(): ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds all the prime numbers between 100 and 200.", "function_declaration": "def primes_between_100_and_200():", "function_...
[ 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 find_primes_100_to_200():\n \"\"\"\n Returns a list of prime numbers from 100 to 200.\n \"\"\"\n def is_prime(n):\n if n <= 1:\n return False\n if n <...
trial_gpt4o_4
{ "original_instruction": "Write a python function to find all the prime numbers from 100 to 200.", "prompt_id": "00038168", "row_id": 38168, "seed_ids": "['magpie_prefill_38168']" }
0.775448
Prefill_38168
C
[ "is_prime", "primes_between_100_and_200" ]
2
[ [ "primes_between_100_and_200", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c60f5232b1983b2fd24b1ef901c0c15ccf9b603e
d5d8ee81b4cabc422ddc3e5cb6bc7bf49f2f2c24
v1.0
complete
Prefill
Prefill_38541_C
def matrix_mult(A, B): """ Multiplies two 2x2 matrices A and B. """ return [[A[0][0] * B[0][0] + A[0][1] * B[1][0], A[0][0] * B[0][1] + A[0][1] * B[1][1]], [A[1][0] * B[0][0] + A[1][1] * B[1][0], A[1][0] * B[0][1] + A[1][1] * B[1][1]]] def matrix_pow(M, n): """ Raises matrix M to th...
def matrix_mult(A, B): """ Multiplies two 2x2 matrices A and B. """ return [[A[0][0] * B[0][0] + A[0][1] * B[1][0], A[0][0] * B[0][1] + A[0][1] * B[1][1]], [A[1][0] * B[0][0] + A[1][1] * B[1][0], A[1][0] * B[0][1] + A[1][1] * B[1][1]]] def matrix_pow(M, n): """ Raises matrix M to th...
from solution import fibonacci def test_fibonacci_0(): assert fibonacci(0) == 0 def test_fibonacci_1(): assert fibonacci(1) == 1 def test_fibonacci_2(): assert fibonacci(2) == 1 def test_fibonacci_3(): assert fibonacci(3) == 2 def test_fibonacci_10(): assert fibonacci(10) == 55 def test_fibona...
[ { "docstring": "Multiplies two 2x2 matrices A and B.", "function_declaration": "def matrix_mult(A, B):", "function_name": "matrix_mult", "parameter_list": "(A, B)" }, { "docstring": "Raises matrix M to the power of n using binary exponentiation.", "function_declaration": "def matrix_pow(...
[ 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 matrix_mult(A, B):\n return [\n [A[0][0] * B[0][0] + A[0][1] * B[1][0], A[0][0] * B[0][1] + A[0][1] * B[1][1]],\n [A[1][0] * B[0][0] + A[1][1] * B[1][0], A[1][0] * B[0][1...
trial_gpt4o_9
{ "original_instruction": "Write a python function to calculate the nth Fibonacci number using the matrix exponentiation method. Matrix exponentiation provides an efficient way to compute Fibonacci numbers with a time complexity of O(log(n)).", "prompt_id": "00038541", "row_id": 38541, "seed_ids": "['magpie_pre...
0.664121
Prefill_38541
C
[ "matrix_mult", "matrix_pow", "fibonacci" ]
3
[ [ "fibonacci", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1e1e61a7175224cba11c9f5a297dd095df4e0df5
6fabfaa9adc694e93772c17228db06bcd721d8ea
v1.0
complete
Prefill
Prefill_38842_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_symmetric(root: TreeNode) -> bool: """ Determine if a binary tree is symmetric. >>> node = TreeNode(1) >>> node.left = TreeNode(2) >>> node.right =...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_mirror(left, right): if left is None and right is None: return True if left is None or right is None: return False return (left.val == righ...
from solution import TreeNode, is_symmetric def test_symmetric_tree(): node = TreeNode(1) node.left = TreeNode(2) node.right = TreeNode(2) node.left.left = TreeNode(3) node.left.right = TreeNode(4) node.right.left = TreeNode(4) node.right.right = TreeNode(3) assert is_symmetric(node) ==...
[]
[ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef is_symmetric(root):\n \"\"\"\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to identify if a given binary tree is Symmetric (mirrored symmetry).", "prompt_id": "00038842", "row_id": 38842, "seed_ids": "['magpie_prefill_38842']" }
0.635726
Prefill_38842
C
[ "is_mirror", "is_symmetric" ]
2
[ [ "is_symmetric", "is_mirror" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
33c3f858a2c21eefde837088f394cdf4428411ea
da108d6c4e378bf22b755b6b11a7cf4f3be558ec
v1.0
complete
Prefill
Prefill_39015_C
def gcd(a: int, b: int) -> int: """ Calculate the Greatest Common Divisor of a and b. >>> gcd(48, 18) == 6 >>> gcd(1071, 462) == 21 >>> gcd(5, 10) == 5 """ def lcm(a: int, b: int) -> int: """ Calculate the Least Common Multiple of a and b. >>> lcm(4, 5) == 20 >>> lcm(21, 6) == 4...
def gcd(a, b): """ Calculate the Greatest Common Divisor of a and b. """ while b: a, b = b, a % b return a def lcm(a, b): """ Calculate the Least Common Multiple of a and b. """ return a * b // gcd(a, b) def smallest_multiple(n): """ Returns the smallest number that...
from solution import gcd, lcm, smallest_multiple def test_gcd(): assert gcd(48, 18) == 6 assert gcd(1071, 462) == 21 assert gcd(5, 10) == 5 def test_lcm(): assert lcm(4, 5) == 20 assert lcm(21, 6) == 42 assert lcm(3, 7) == 21 def test_smallest_multiple(): assert smallest_multiple(10) == 2...
[ { "docstring": "Calculate the Greatest Common Divisor of a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Calculate the Least Common Multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_na...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\n\ndef lcm(a, b):\n \"\"\"\n Returns the least common multiple of a and b.\n \"\"\"\n return a * b // gcd(a, b)\n\ndef smallest_multiple(n):\n \"\"\"\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the smallest number that is evenly divisible by all numbers from 1 to n. What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?", "prompt_id": "00039015", "row_id": 39015, "seed_ids": "['magpie_prefill_39015']" }
0.797037
Prefill_39015
C
[ "gcd", "lcm", "smallest_multiple" ]
3
[ [ "lcm", "gcd" ], [ "smallest_multiple", "lcm" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a1f6e62fa00d77486788bf7f772308ad7abe4c89
365eaf98f7df44805140ed1143b53e50d9a64418
v1.0
complete
Prefill
Prefill_38628_C
def sum_of_squares_of_primes(numbers: List[int]) -> int: """ Write a function to return the sum of squares of all prime numbers in a given list of integers. >>> sum_of_squares_of_primes([2, 3, 5, 7]) == 4 + 9 + 25 + 49 >>> sum_of_squares_of_primes([2, 4, 6, 7]) == 4 + 49 >>> sum_of_squares_of_primes...
import math def is_prime(n): """ Check if n is a prime number. """ if n <= 1: return False for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def sum_of_squares_of_primes(numbers): """ Returns the sum of squares of all prime nu...
from solution import sum_of_squares_of_primes def test_sum_of_squares_of_primes_only_primes(): assert sum_of_squares_of_primes([2, 3, 5, 7]) == 4 + 9 + 25 + 49 def test_sum_of_squares_of_primes_mixed_numbers(): assert sum_of_squares_of_primes([2, 4, 6, 7]) == 4 + 49 def test_sum_of_squares_of_primes_no_prime...
[ { "docstring": "Check if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of squares of all prime numbers in the given list of integers.", "function_declaration": "def sum_of_squares...
[ 0, 1, 1, 0, 1, 1, 1, 1, 0, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n p = 3\n while p * p <= n:\n if n % p == 0:...
trial_gpt4o_9
{ "original_instruction": "Write a python function to return the sum of squares of all prime numbers in a given list of integers.", "prompt_id": "00038628", "row_id": 38628, "seed_ids": "['magpie_prefill_38628']" }
0.752958
Prefill_38628
C
[ "is_prime", "sum_of_squares_of_primes" ]
2
[ [ "sum_of_squares_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7540e33ab60f8a01dc280f6fa6d7d7db2297e95a
86cae088fc2f62c64eb2871ed2a9ee0e5315cf81
v1.0
complete
Prefill
Prefill_38549_C
def is_prime(n: int) -> bool: """ Checks if a number is prime. Parameters: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. >>> is_prime(2) True >>> is_prime(4) False """ ... def generate_primes(start: int, end: in...
def is_prime(n): """ Checks if a number is prime. Parameters: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False ...
from solution import generate_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(0) == False assert is_prime(1) == False def test_generate_primes_general_case(): assert generate_...
[ { "docstring": "Checks if a number is prime.\n\nParameters:\nn (int): The number to check.\n\nReturns:\nbool: True if the number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list 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 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": "Write a python function to generate a list of prime numbers between two given numbers (inclusive).", "prompt_id": "00038549", "row_id": 38549, "seed_ids": "['magpie_prefill_38549']" }
0.702878
Prefill_38549
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f1190cc9ca0773151362abc2734240a545944f90
de21e8a31be29cf21dd950794c2a87da254ed7c8
v1.0
complete
Prefill
Prefill_39018_C
def caesar_cipher_encrypt(text: str, shift: int) -> str: """ Encrypts the text using Caesar Cipher with the given shift. >>> caesar_cipher_encrypt("abc", 1) == "bcd" >>> caesar_cipher_encrypt("xyz", 3) == "abc" >>> caesar_cipher_encrypt("AbC", 2) == "CdE" >>> caesar_cipher_encrypt("Hello, World...
def caesar_cipher_encrypt(text, shift): """ Encrypts the text using Caesar Cipher with the given shift. """ encrypted_text = [] for char in text: if char.isupper(): encrypted_text.append(chr((ord(char) + shift - 65) % 26 + 65)) elif char.islower(): encrypted_t...
from solution import caesar_cipher_encrypt, caesar_cipher_decrypt def test_caesar_cipher_encrypt_basic(): assert caesar_cipher_encrypt("abc", 1) == "bcd" def test_caesar_cipher_encrypt_wrap_around(): assert caesar_cipher_encrypt("xyz", 3) == "abc" def test_caesar_cipher_encrypt_mixed_case(): assert caesa...
[ { "docstring": "Encrypts the text using Caesar Cipher with the given shift.", "function_declaration": "def caesar_cipher_encrypt(text, shift):", "function_name": "caesar_cipher_encrypt", "parameter_list": "(text, shift)" }, { "docstring": "Decrypts the text using Caesar Cipher with the given...
[ 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 caesar_cipher_encrypt(plaintext, shift):\n \"\"\"\n Encrypts plaintext using Caesar Cipher with a given shift.\n :param plaintext: The text to be encrypted.\n :param shift: Th...
trial_gpt4o_8
{ "original_instruction": "Write a python function to implement the simple Caesar cipher encryption and decryption.", "prompt_id": "00039018", "row_id": 39018, "seed_ids": "['magpie_prefill_39018']" }
0.693643
Prefill_39018
C
[ "caesar_cipher_encrypt", "caesar_cipher_decrypt" ]
2
[ [ "caesar_cipher_decrypt", "caesar_cipher_encrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54bd97d9cf6f6b60d09394f8355500166995892d
478b53671f3168159c283a65ea596fe8e0f4bcdc
v1.0
complete
Prefill
Prefill_38482_C
def is_prime(num): """ Helper function to check if a number is prime. Returns True if num is a prime number, else 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 get_primes_in_range(start, e...
def is_prime(num): """ Helper function to check if a number is prime. Returns True if num is a prime number, else 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 get_primes_in_range(start, e...
from solution import get_primes_in_range def test_primes_in_small_range(): assert get_primes_in_range(1, 10) == [2, 3, 5, 7] def test_primes_in_large_range(): assert get_primes_in_range(10, 20) == [11, 13, 17, 19] def test_primes_with_no_primes(): assert get_primes_in_range(14, 16) == [] def test_primes...
[ { "docstring": "Helper function to check if a number is prime.\nReturns True if num is a prime number, else False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of all prime numbers in the range [start...
[ 0, 1, 1, 1, 0, 0, 1, 0, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_primes_in_range(start, end):\n \"\"\"\n Returns a list of all prime numbers within the range [start, end], inclusive.\n \"\"\"\n def is_prime(n):\n /// Helper funct...
trial_gpt4o_6
{ "original_instruction": "Write a python function to get all prime numbers in a range. The function will take two arguments: start and end. It should return a list of all prime numbers within that range, inclusive. Follow Python conventions for function and variable names. Additionally, comment your code to explain ...
0.771959
Prefill_38482
C
[ "is_prime", "get_primes_in_range" ]
2
[ [ "get_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c0e784decb0699085ef16a742550ba5987245f0
ea10dacbcdb9dcc25beee048d75bfe260cf5c37e
v1.0
complete
Prefill
Prefill_40168_C
def is_prime(num: int) -> bool: """Helper function to check if a number is prime. >>> is_prime(101) == True >>> is_prime(102) == False >>> is_prime(103) == True >>> is_prime(1) == False >>> is_prime(2) == True >>> is_prime(200) == False >>> is_prime(199) == True """ pass def pri...
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_between_100_and_200(): """ Returns a list of all prime numbers bet...
from solution import is_prime, primes_between_100_and_200 def test_is_prime(): assert is_prime(101) == True assert is_prime(102) == False assert is_prime(103) == True assert is_prime(1) == False assert is_prime(2) == True assert is_prime(200) == False assert is_prime(199) == True def test_...
[ { "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 100 and 200.", "function_declaration": "def primes_between_...
[ 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 get_primes_between_100_and_200():\n \"\"\"\n Returns a list of all prime numbers between 100 and 200.\n \"\"\"\n def is_prime(n):\n \"\"\"Check if a number is prime.\"\...
trial_gpt4o_6
{ "original_instruction": "Write a python function to print all the prime numbers between 100 and 200.", "prompt_id": "00040168", "row_id": 40168, "seed_ids": "['magpie_prefill_40168']" }
0.803786
Prefill_40168
C
[ "is_prime", "primes_between_100_and_200" ]
2
[ [ "primes_between_100_and_200", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f4ec332188763a766bda407f6d886e75c3b63747
8c800647825044cdc0c1b05832245198007183e0
v1.0
complete
Prefill
Prefill_39845_C
def compute_lps(pattern: str) -> List[int]: """ Computes the Longest Proper Prefix which is also suffix array for the pattern. """ pass def kmp_search(text: str, pattern: str) -> int: """ Finds the first occurrence of the pattern in the text using the KMP algorithm. Returns the index of the...
def compute_lps(pattern): """ Computes the Longest Proper Prefix which is also suffix array for the pattern. """ lps = [0] * len(pattern) length = 0 # length of the previous longest prefix suffix i = 1 while i < len(pattern): if pattern[i] == pattern[length]: length += ...
from solution import kmp_search def test_kmp_search_found(): assert kmp_search("abxabcabcaby", "abcaby") == 6 assert kmp_search("hello", "ll") == 2 assert kmp_search("abcabcabc", "cab") == 2 def test_kmp_search_not_found(): assert kmp_search("abcdef", "gh") == -1 assert kmp_search("abcdef", "xyz")...
[ { "docstring": "Computes the Longest Proper Prefix which is also suffix array for the pattern.", "function_declaration": "def compute_lps(pattern):", "function_name": "compute_lps", "parameter_list": "(pattern)" }, { "docstring": "Finds the first occurrence of the pattern in the text using t...
[ 0, 0, 0, 1, 0, 1, 1, 1, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def kmp_search(pattern, text):\n \"\"\"\n Returns the index of the first occurrence of the pattern in text using the KMP algorithm.\n If the pattern is not found, return -1.\n \"\...
trial_gpt4o_7
{ "original_instruction": "Write a python function to find the first occurrence of a pattern in a string using the Knuth-Morris-Pratt (KMP) algorithm. The function should return the index of the first occurrence of the pattern or -1 if the pattern is not found.", "prompt_id": "00039845", "row_id": 39845, "seed_...
0.628468
Prefill_39845
C
[ "compute_lps", "kmp_search" ]
2
[ [ "kmp_search", "compute_lps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6a9c4e32b5c7ce7de4f17d46a70fdf6af7c68265
a52a943c90574d4b96241adbfc2bbba5e7737e97
v1.0
complete
Prefill
Prefill_39744_C
import sympy as sp def find_roots(f_expr, x0, tolerance=1e-7, max_iters=1000): """Finds a root of the polynomial f using Newton's method starting from x0. Args: f_expr (sympy.Expr): The polynomial expression. x0 (float): Initial guess for the root. tolerance (float): The tolerance for convergence. ...
import sympy as sp def find_roots(f_expr, x0, tolerance=1e-7, max_iters=1000): """ Finds a root of the polynomial f using Newton's method starting from x0. Parameters: f_expr (sympy.Expr): The polynomial expression. x0 (float): Initial guess for the root. tolerance (float): The...
import pytest from solution import find_all_roots import sympy as sp def polynomial_expr(coeffs): """ Creates a polynomial expression from a list of coefficients. Parameters: coeffs (list): List of coefficients [a_n, a_(n-1), ..., a_1, a_0] Returns: sympy.Expr: Polynomial expr...
[ { "docstring": "Finds a root of the polynomial f using Newton's method starting from x0.\n\nParameters:\n f_expr (sympy.Expr): The polynomial expression.\n x0 (float): Initial guess for the root.\n tolerance (float): The tolerance for convergence.\n max_iters (int): Maximum number of iterations.\n\n...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from sympy import symbols, diff, N\n\ndef newton_raphson_roots(coefficients, initial_guess, tolerance=1e-7, max_iterations=1000):\n \"\"\"\n Finds the roots of a polynomial using Newton...
trial_gpt4o_5
{ "original_instruction": "Write a python function to find all the roots of a polynomial equation using the Newton's method.", "prompt_id": "00039744", "row_id": 39744, "seed_ids": "['magpie_prefill_39744']" }
0.717095
Prefill_39744
C
[ "find_roots", "find_all_roots" ]
2
[ [ "find_all_roots", "find_roots" ] ]
1
[]
false
[]
false
pytest
true
[ "sympy" ]
false
6739137974a35c6448e37bea642903a5eed1dde7
0143d4730938589946c41f6c01b19cb04414e6df
v1.0
complete
Prefill
Prefill_39413_C
from typing import List def is_prime(num: int) -> bool: """ Checks 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 >>> is_prime(29) True """ pass def nth_prime(n: int) -> int:...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += ...
from solution import is_prime, nth_prime, first_prime_after_1000 def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(29) == True def test_nt...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds the nth prime number.", "function_declaration": "def nth_prime(n):", "function_name": "nth_prime", "paramet...
[ 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 find_nth_prime(n):\n \"\"\"\n Returns the nth prime number.\n \"\"\"\n if n < 1:\n raise ValueError(\"n must be a positive integer\")\n \n primes = []\n num = ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the nth prime number. What's the first prime number after 1000?", "prompt_id": "00039413", "row_id": 39413, "seed_ids": "['magpie_prefill_39413']" }
0.793681
Prefill_39413
C
[ "is_prime", "nth_prime", "first_prime_after_1000" ]
3
[ [ "first_prime_after_1000", "is_prime" ], [ "nth_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ac36b709651ebe73fef628737864f5bac871c06d
1214dfaf546a5973066e4fb52fdee7e8ae2f7548
v1.0
complete
Prefill
Prefill_39971_C
import random from typing import List def partition(arr: List[int], left: int, right: int, pivot_index: int) -> int: """Partition the array around the pivot element.""" pass def quickselect(arr: List[int], left: int, right: int, k: int) -> int: """Quickselect function to find the k-th smallest element."""...
import random def partition(arr, left, right, pivot_index): pivot_value = arr[pivot_index] arr[pivot_index], arr[right] = arr[right], arr[pivot_index] store_index = left for i in range(left, right): if arr[i] < pivot_value: arr[store_index], arr[i] = arr[i], arr[store_index] ...
from solution import find_kth_largest def test_find_kth_largest(): assert find_kth_largest([3,2,1,5,6,4], 2) == 5 assert find_kth_largest([3,2,3,1,2,4,5,5,6], 4) == 4 assert find_kth_largest([3,2,1], 1) == 3 assert find_kth_largest([7,6,5,4,3,2,1], 7) == 1 assert find_kth_largest([5,5,5,5,5,5,5], 3...
[ { "docstring": null, "function_declaration": "def partition(arr, left, right, pivot_index):", "function_name": "partition", "parameter_list": "(arr, left, right, pivot_index)" }, { "docstring": null, "function_declaration": "def quickselect(arr, left, right, k):", "function_name": "q...
[ 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quickselect(arr, k):\n def partition(left, right, pivot_index):\n pivot_value = arr[pivot_index]\n arr[pivot_index], arr[right] = arr[right], arr[pivot_index] \n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the kth largest number in an unsorted array using the quickselect algorithm with a time complexity of O(n).", "prompt_id": "00039971", "row_id": 39971, "seed_ids": "['magpie_prefill_39971']" }
0.695231
Prefill_39971
C
[ "partition", "quickselect", "find_kth_largest" ]
3
[ [ "find_kth_largest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c36f071fe8617bde4e275644a3a2044ea2e28497
8df6c07c9191e38e9ed6147074e02b20e739c5f7
v1.0
complete
Prefill
Prefill_40070_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(13) True >>> is_prime(1) False >>> is_prime(-7) False """ pass def product_of_primes(nums: List[int]) -> int: """ R...
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 product_of_primes(nums): """ Returns the product of all the prime numbe...
from solution import is_prime, product_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(1) == False assert is_prime(-7) == False def test_product_of_primes_no_primes(): assert produc...
[ { "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 product of all the prime numbers in the given list.\nIf there are no prime numbers, returns...
[ 1, 1, 1, 1, 1, 1, 0, 0, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the product of all the prime numbers in a given list.", "prompt_id": "00040070", "row_id": 40070, "seed_ids": "['magpie_prefill_40070']" }
0.76742
Prefill_40070
C
[ "is_prime", "product_of_primes" ]
2
[ [ "product_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
94c525d04bd781dd452e541b991752efb7dfe9fc
3ebb9e5ccc48fe2e2d4a3e5e0a9a767d8fe81283
v1.0
complete
Prefill
Prefill_39553_C
import math from typing import List, Tuple def euclidean_distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float: """ Calculate the Euclidean distance between two points. Each point is represented by a tuple (x, y). >>> euclidean_distance((0, 0), (0, 0)) 0.0 >>> euclidean_distance(...
import math def euclidean_distance(point1, point2): """ Calculate the Euclidean distance between two points. Each point is represented by a tuple (x, y). """ return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) def closest_pairs(points): """ Find the closest pair of po...
def test_euclidean_distance(): assert euclidean_distance((0, 0), (0, 0)) == 0 assert euclidean_distance((0, 0), (3, 4)) == 5 assert euclidean_distance((1, 1), (4, 5)) == 5 def test_closest_pairs_single_pair(): assert closest_pairs([(0, 0), (1, 1)]) == ((0, 0), (1, 1)) def test_closest_pairs_multiple_p...
[ { "docstring": "Calculate the Euclidean distance between two points.\nEach point is represented by a tuple (x, y).", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Find the clos...
[ 0, 1, 0, 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 euclidean_distance(point1, point2):\n \"\"\"\n Computes the Euclidean distance between two points represented as tuples (x1, y1) and (x2, y2).\n \"\"\"\n return ((point1[0] - ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the closest pairs from a given list of tuples, where the distance is calculated based on Euclidean distance formula. The list of tuples represents points in a two-dimensional space.", "prompt_id": "00039553", "row_id": 39553, "seed_ids": "['magpie_prefi...
0.72375
Prefill_39553
C
[ "euclidean_distance", "closest_pairs" ]
2
[ [ "closest_pairs", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
74620d9766f627b0d23f5e55bce9ee398e962fec
aee4252d3e809a9eaaf4886e77f6d6af4ec3ea67
v1.0
complete
Prefill
Prefill_39726_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(10) == False >>> is_prime(11) == True >>> is_prime(1) == False >>> is_prime(0) == F...
def is_prime(num): """ Helper function to determine 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: retu...
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(5) == True assert is_prime(10) == False assert is_prime(11) == True assert is_prime(1) == False assert is_prime(0) == Fals...
[ { "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 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 \"\"\"Helper function to check if a number is prime.\"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:...
trial_gpt4o_2
{ "original_instruction": "Write a python function to find the first n prime numbers.", "prompt_id": "00039726", "row_id": 39726, "seed_ids": "['magpie_prefill_39726']" }
0.854623
Prefill_39726
C
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4e9df9efeaafcf445c5be22a4813afd903686e2e
e25b6d093233ae23331fa623f4e983900d504069
v1.0
complete
Prefill
Prefill_40768_C
def is_prime(n: int) -> bool: """ Determine if a given number is prime or not. >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(29) True >>> is_prime(30) False >>> is_prime(0) False >>> is_prime(-1) False >>> is_prime(97)...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime def test_is_prime_small_numbers(): assert is_prime(1) == False assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False def test_is_prime_larger_primes(): assert is_prime(29) == True assert is_prime(89) == True def test_is_prime_large...
[ { "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": "Prints whether each number from 1 to 100 is prime or not.", "function_declaration": "def print_prime...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines 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 =...
trial_gpt4o_3
{ "original_instruction": "Write a python function to determine if a given number is prime or not, and iterate over all the numbers from 1 to 100 to print whether each number is prime or not.", "prompt_id": "00040768", "row_id": 40768, "seed_ids": "['magpie_prefill_40768']" }
0.879798
Prefill_40768
C
[ "is_prime", "print_prime_status_up_to_100" ]
2
[ [ "print_prime_status_up_to_100", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
78f8628c28a5c7d5c027c35d69b0ff926924d908
c781910e61f0929e614ed8281ae1371c61e6aa81
v1.0
complete
Prefill
Prefill_39765_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_symmetric(root): """ Check whether a binary tree is symmetric. :param root: TreeNode :return: bool """ def is_mirror(left, right): """ ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_symmetric(root): """ Check whether a binary tree is symmetric. :param root: TreeNode :return: bool """ if root is None: return True ...
from solution import TreeNode, is_symmetric def test_symmetric_tree(): # Create a symmetric tree # 1 # / \ # 2 2 # / \ / \ # 3 4 4 3 root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(2) root.left.left = TreeNode(3) root.le...
[]
[ 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": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef is_symmetric(root):\n \"\"\"\n Checks whether a binary tree...
trial_gpt4o_9
{ "original_instruction": "Write a python function to check whether a binary tree is symmetric.", "prompt_id": "00039765", "row_id": 39765, "seed_ids": "['magpie_prefill_39765']" }
0.63361
Prefill_39765
C
[ "is_symmetric", "is_mirror" ]
2
[ [ "is_symmetric", "is_mirror" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
7556e8407dddcd47e6108a1c6761ae46032259e9
4e5394e8bb0ff00b90001cae79bd052c276400ed
v1.0
complete
Prefill
Prefill_41127_C
def is_even(number): """ Returns True if number is even, otherwise returns False. >>> is_even(2) == True >>> is_even(1) == False """ def filter_even_numbers(numbers): """ Filters out odd numbers from a list and returns only even numbers. >>> filter_even_numbers([1, 2, 3, 4, 5]) == [2, 4...
def is_even(number): """ Returns True if number is even, otherwise returns False. """ return number % 2 == 0 # Sample usage scenario: def filter_even_numbers(numbers): """ Filters out odd numbers from a list and returns only even numbers. """ return [num for num in numbers if is_even(nu...
from solution import is_even, filter_even_numbers def test_is_even_with_even_numbers(): assert is_even(2) == True assert is_even(0) == True assert is_even(100) == True def test_is_even_with_odd_numbers(): assert is_even(1) == False assert is_even(7) == False assert is_even(55) == False def te...
[ { "docstring": "Returns True if number is even, otherwise returns False.", "function_declaration": "def is_even(number):", "function_name": "is_even", "parameter_list": "(number)" }, { "docstring": "Filters out odd numbers from a list and returns only even numbers.", "function_declaratio...
[ 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_even_or_odd(number):\n \"\"\"\n Returns 'even' if the number is even, otherwise returns 'odd'.\n \"\"\"\n if number % 2 == 0:\n return 'even'\n else:\n ret...
trial_gpt4o_9
{ "original_instruction": "Write a python function to check if a number is even or odd. How would you use this function in your code? Provide a sample usage scenario.", "prompt_id": "00041127", "row_id": 41127, "seed_ids": "['magpie_prefill_41127']" }
0.731415
Prefill_41127
C
[ "is_even", "filter_even_numbers" ]
2
[ [ "filter_even_numbers", "is_even" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f00421d3968289b271b0db16df6f8ba8b0ffa020
5f60702e380569045690d506573589146b11ad30
v1.0
complete
Prefill
Prefill_41283_C
def reverse_string(s: str) -> str: """ Returns the reversed string of 's' using slicing. >>> reverse_string("hello") "olleh" >>> reverse_string("world") "dlrow" >>> reverse_string("a") "a" >>> reverse_string("") "" >>> reverse_string("madam") "madam" """ def is_palindrome(s: str) -> boo...
def reverse_string(s): """ Returns the reversed string of 's' using slicing. """ return s[::-1] def is_palindrome(s): """ Returns True if the string 's' is a palindrome, False otherwise. A string is a palindrome if it reads the same forwards and backwards. """ return s == reverse_st...
from solution import reverse_string, is_palindrome def test_reverse_string(): assert reverse_string("hello") == "olleh" assert reverse_string("world") == "dlrow" assert reverse_string("a") == "a" assert reverse_string("") == "" assert reverse_string("madam") == "madam" def test_is_palindrome(): ...
[ { "docstring": "Returns the reversed string of 's' using slicing.", "function_declaration": "def reverse_string(s):", "function_name": "reverse_string", "parameter_list": "(s)" }, { "docstring": "Returns True if the string 's' is a palindrome, False otherwise.\nA string is a palindrome if it...
[ 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 reverse_string(s):\n \"\"\"\n Reverses the given string using slicing.\n \"\"\"\n return s[::-1]\n\ndef is_palindrome(s):\n \"\"\"\n Checks if the given string is a pali...
trial_gpt4o_9
{ "original_instruction": "Write a python function to reverse a string using slicing, then write a function to check if the string is a palindrome or not.", "prompt_id": "00041283", "row_id": 41283, "seed_ids": "['magpie_prefill_41283']" }
0.823295
Prefill_41283
C
[ "reverse_string", "is_palindrome" ]
2
[ [ "is_palindrome", "reverse_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dd45992f0777e3a00f7c25150be5e5a20f161f31
970a7e5915fb699a41e33c8b335b2dbfcb7683df
v1.0
complete
Prefill
Prefill_41269_C
def fibonacci(n: int) -> int: """ Returns the nth Fibonacci number. The nth Fibonacci number is defined as the sum of the two preceding ones, usually starting with 0 and 1. >>> fibonacci(0) 0 >>> fibonacci(1) 1 >>> fibonacci(2) 1 >>> fibonacci(3) 2 >>> fibonacci(4) 3 >>> fibonacci(...
def multiply_matrices(A, B): """ Multiplies two matrices A and B. """ return [ [A[0][0] * B[0][0] + A[0][1] * B[1][0], A[0][0] * B[0][1] + A[0][1] * B[1][1]], [A[1][0] * B[0][0] + A[1][1] * B[1][0], A[1][0] * B[0][1] + A[1][1] * B[1][1]], ] def matrix_power(matrix, n): """ C...
from solution import fibonacci def test_fibonacci_base_cases(): assert fibonacci(0) == 0 assert fibonacci(1) == 1 def test_fibonacci_small_inputs(): assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(4) == 3 assert fibonacci(5) == 5 def test_fibonacci_larger_inputs(): asse...
[ { "docstring": "Multiplies two matrices A and B.", "function_declaration": "def multiply_matrices(A, B):", "function_name": "multiply_matrices", "parameter_list": "(A, B)" }, { "docstring": "Computes the power of a 2x2 matrix using exponentiation by squaring.", "function_declaration": "d...
[ 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 fibonacci(n):\n \"\"\"\n Returns the nth Fibonacci number using matrix exponentiation.\n \"\"\"\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n\n def m...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the nth Fibonacci number. The nth Fibonacci number is defined as the sum of the two preceding ones, usually starting with 0 and 1. Your function should be optimized to reduce its time complexity to logarithmic.", "prompt_id": "00041269", "row_id": 41269, ...
0.91086
Prefill_41269
C
[ "multiply_matrices", "matrix_power", "fibonacci" ]
3
[ [ "fibonacci", "matrix_power" ], [ "matrix_power", "multiply_matrices" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5b4d5c0c5f2f63e848190474f6c2974b20ecd1f2
c69d51d28b24a3e96422a1c45a22818b3ae9365e
v1.0
complete
Prefill
Prefill_39984_C
import os import re from typing import List def extract_emails_from_file(file_path: str) -> List[str]: """ Extracts emails from a given text file. Parameters: - file_path: str, the path to the text file. Returns: - List[str], a list of emails found in the text file. """ pass def extr...
import os import re def extract_emails_from_file(file_path): """ Extracts emails from a given text file. Parameters: - file_path: str, the path to the text file. Returns: - List[str], a list of emails found in the text file. """ with open(file_path, 'r', encoding='utf-8') as file:...
import pytest import os from solution import extract_emails_from_file, extract_emails_from_directory # Setup directories and files for testing @pytest.fixture def setup_test_files(tmpdir): dir = tmpdir.mkdir('Emails') file1 = dir.join('file1.txt') file2 = dir.join('file2.txt') file1.write("Here ar...
[ { "docstring": "Extracts emails from a given text file.\n\nParameters:\n- file_path: str, the path to the text file.\n\nReturns:\n- List[str], a list of emails found in the text file.", "function_declaration": "def extract_emails_from_file(file_path):", "function_name": "extract_emails_from_file", "...
[ 1, 0, 0, 1, 1, 0, 1, 1, 1 ]
6
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nimport os\n\ndef extract_emails_from_file(file_path):\n \"\"\"\n Extracts emails from a given text file and returns a list of emails found.\n \n :param file_path: Path ...
trial_gpt4o_8
{ "original_instruction": "Write a python function to extract emails from a given text file. The text files are in a directory named \"Emails\" in the user's home directory. The function should return a list of all emails found.", "prompt_id": "00039984", "row_id": 39984, "seed_ids": "['magpie_prefill_39984']" ...
0.665912
Prefill_39984
C
[ "extract_emails_from_file", "extract_emails_from_directory" ]
2
[ [ "extract_emails_from_directory", "extract_emails_from_file" ] ]
1
[]
false
[]
false
pytest
true
[]
true
942c8c06cea2e5a1ccc7e7f1aa9c0da1a0b627da
7b79605a0eae5e32a8e4d6d321816d99d69952f1
v1.0
complete
Prefill
Prefill_40751_C
def flatten(nested_list): """ Flattens a nested list. Non-iterable elements are left unchanged. Dictionaries are unpacked into tuples of (key, value) pairs. >>> flatten([1, 2, 3]) [1, 2, 3] >>> flatten([1, [2, 3], 'a', {'k': 'v'}]) [1, 2, 3, 'a', ('k', 'v')] >>> flatten([1, [2, [3, 4], ...
def is_non_iterable(element): """ Check if the element is non-iterable (besides strings). """ return isinstance(element, (int, float, complex, bool, bytes, type(None))) def flatten(nested_list): """ Flattens a nested list. Non-iterable elements are left unchanged. Dictionaries are unpacked into tup...
from solution import flatten def test_flatten_simple_list(): assert flatten([1, 2, 3]) == [1, 2, 3] def test_flatten_mixed_list(): assert flatten([1, [2, 3], 'a', {'k': 'v'}]) == [1, 2, 3, 'a', ('k', 'v')] def test_flatten_nested_list(): assert flatten([1, [2, [3, 4], 5], 6]) == [1, 2, 3, 4, 5, 6] def t...
[ { "docstring": "Check if the element is non-iterable (besides strings). ", "function_declaration": "def is_non_iterable(element):", "function_name": "is_non_iterable", "parameter_list": "(element)" }, { "docstring": "Flattens a nested list. Non-iterable elements are left unchanged.\nDictiona...
[ 0, 1, 0, 1, 1, 1, 1, 1, 0, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def flatten(nested_list):\n \"\"\"\n Flattens a nested list. The function takes a list that may contain integers, strings, other lists,\n and dictionaries as elements, and returns a ...
trial_gpt4o_7
{ "original_instruction": "Write a python function to flatten a nested list. The function should take a list that may contain integers, strings, other lists, and dictionaries as elements, and return a flat list with no nested structures. Non-iterable elements should remain unchanged. Dictionaries will be unpacked int...
0.734955
Prefill_40751
C
[ "is_non_iterable", "flatten" ]
2
[ [ "flatten", "is_non_iterable" ] ]
1
[]
false
[]
false
pytest
true
[]
true
144fd8b0910515f9010db17891da7a07195f2f80
b7a569db85ebaf0ef318759ecb33bc6aa3c0306a
v1.0
complete
Prefill
Prefill_40013_C
def solve_n_queens(n: int): """ Write a python function to solve the N-Queens puzzle using backtracking. The function should take an integer 'n' as input and return all possible configurations of the Queen's positions. >>> solve_n_queens(4) [[1, 3, 0, 2], [2, 0, 3, 1]] >>> solve_n_queens(1) ...
def solve_n_queens(n): def is_valid(board, row, col): # Check this column for i in range(row): if board[i] == col or \ board[i] - i == col - row or \ board[i] + i == col + row: return False return True def solve(row, board): ...
from solution import solve_n_queens, solve_n_queens_boards def test_solve_n_queens_4(): result = solve_n_queens(4) assert sorted(result) == sorted([ [1, 3, 0, 2], [2, 0, 3, 1] ]) def test_solve_n_queens_boards_4(): result = solve_n_queens_boards(4) expected = [ ['.Q..', '...
[ { "docstring": null, "function_declaration": "def solve_n_queens(n):", "function_name": "solve_n_queens", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def generate_board(configuration):", "function_name": "generate_board", "parameter_list": "(configura...
[ 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 solve_n_queens(n):\n \"\"\"\n Solves the n-queens puzzle and returns all unique solutions.\n Each solution contains one line for each queen.\n Each line contains the queen's c...
trial_gpt4o_7
{ "original_instruction": "Write a python function to solve the N-Queens puzzle using backtracking. The function should take an integer `n` as input and return all possible configurations of the Queen's positions.", "prompt_id": "00040013", "row_id": 40013, "seed_ids": "['magpie_prefill_40013']" }
0.499095
Prefill_40013
C
[ "solve_n_queens", "generate_board", "solve_n_queens_boards" ]
3
[ [ "solve_n_queens_boards", "generate_board" ], [ "solve_n_queens_boards", "solve_n_queens" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f73d10f805f00ae46538de5dd07a5691664b5af6
558759116ceded1b9e3adcffa2820ef130b9c27b
v1.0
complete
Prefill
Prefill_41446_C
def is_fibonacci_number(n): """ Check if a number is a Fibonacci number using the property that a number n is Fibonacci if and only if one or both of (5*n^2 + 4) or (5*n^2 - 4) is a perfect square. """ return is_perfect_square(5 * n * n + 4) or is_perfect_square(5 * n * n - 4) def is_perfect_squar...
def is_fibonacci_number(n): """ Check if a number is a Fibonacci number using the property that a number n is Fibonacci if and only if one or both of (5*n^2 + 4) or (5*n^2 - 4) is a perfect square. """ return is_perfect_square(5 * n * n + 4) or is_perfect_square(5 * n * n - 4) def is_perfect_squar...
from solution import largest_fibonacci_as_sum def test_largest_fibonacci_as_sum(): result = largest_fibonacci_as_sum() assert result == 832040, f"Expected 832040 but got {result}" def test_is_fibonacci_number(): assert is_fibonacci_number(8) == True assert is_fibonacci_number(13) == True assert is...
[ { "docstring": "Check if a number is a Fibonacci number using the property that a number n \nis Fibonacci if and only if one or both of (5*n^2 + 4) or (5*n^2 - 4) is a perfect square.", "function_declaration": "def is_fibonacci_number(n):", "function_name": "is_fibonacci_number", "parameter_list": "...
[ 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci_sum_max(limit):\n \"\"\"\n Returns the largest Fibonacci number that can be written as the sum of two smaller Fibonacci numbers, up to a given limit.\n \n Parameters...
trial_gpt4o_6
{ "original_instruction": "Write a python function to find the biggest Fibonacci numbers that can be written as the sum of two smaller Fibonacci numbers.", "prompt_id": "00041446", "row_id": 41446, "seed_ids": "['magpie_prefill_41446']" }
0.764277
Prefill_41446
C
[ "is_fibonacci_number", "is_perfect_square", "generate_fibonacci_up_to", "largest_fibonacci_as_sum" ]
4
[ [ "is_fibonacci_number", "is_perfect_square" ], [ "largest_fibonacci_as_sum", "generate_fibonacci_up_to" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e3928bf3dc5068db96f14b713ae8ee8ae6b0eb3b
156fbb2117e8a2e7c3f1006f8618fe81737f2fbe
v1.0
complete
Prefill
Prefill_41302_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ pass # Implement this function def prime_pairs_sum(N: int): """ Find and return all the pairs of prime numbers that sum up to N. >>> prime_pairs_sum(10) [(3, 7), (5, 5)] >>> prime_pairs_sum(12)...
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 prime_pairs_sum(N): """ Returns a list of all pairs of prime numbers that...
from solution import prime_pairs_sum def test_prime_pairs_sum_with_valid_pairs(): assert prime_pairs_sum(10) == [(3, 7), (5, 5)] assert prime_pairs_sum(12) == [(5, 7)] assert prime_pairs_sum(26) == [(3, 23), (7, 19), (13, 13)] def test_prime_pairs_sum_no_pairs(): assert prime_pairs_sum(2) == "No such ...
[ { "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 pairs of prime numbers that sum up to N.\nIf no such pairs exist, returns an empty li...
[ 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_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_0
{ "original_instruction": "Write a python function to find and print all the pairs of prime numbers that sum up to N, where N is a given even number. If no such pairs exist, print \"No such pair exists\".", "prompt_id": "00041302", "row_id": 41302, "seed_ids": "['magpie_prefill_41302']" }
0.743229
Prefill_41302
C
[ "is_prime", "prime_pairs_sum" ]
2
[ [ "prime_pairs_sum", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ce6017f3d0d75b79bdbcfe841d748ecea1591d19
2e2b4e5d6d05aeaa7a43b0ee6ec0483f19dc7e40
v1.0
complete
Prefill
Prefill_40319_C
def quick_sort(arr: List[int]) -> List[int]: """ Sorts a list of integers in ascending order using the Quick Sort algorithm. """ if len(arr) <= 1: return arr else: pivot = arr[0] less_than_pivot = [x for x in arr[1:] if x <= pivot] greater_than_pivot = [x for x in arr...
def quick_sort(arr): """ Sorts a list of integers in ascending order using the Quick Sort algorithm. Prints the sorted array. """ if len(arr) <= 1: return arr else: pivot = arr[0] less_than_pivot = [x for x in arr[1:] if x <= pivot] greater_than_pivot = [x for x i...
from solution import sort_and_print def test_sort_empty_list(): assert sort_and_print([]) == [] def test_sort_single_element(): assert sort_and_print([5]) == [5] def test_sort_sorted_list(): assert sort_and_print([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_sort_reverse_sorted_list(): assert sort_an...
[ { "docstring": "Sorts a list of integers in ascending order using the Quick Sort algorithm.\nPrints the sorted array.", "function_declaration": "def quick_sort(arr):", "function_name": "quick_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def sort_and_p...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quick_sort(arr):\n \"\"\"\n Sorts a list of integers in ascending order using the Quick Sort algorithm.\n \"\"\"\n if len(arr) <= 1:\n return arr\n else:\n pi...
trial_gpt4o_8
{ "original_instruction": "Write a python function to sort a list of integers in Ascending Order using the Quick Sort Algorithm. The function should also print the sorted array.", "prompt_id": "00040319", "row_id": 40319, "seed_ids": "['magpie_prefill_40319']" }
0.582111
Prefill_40319
C
[ "quick_sort", "sort_and_print" ]
2
[ [ "sort_and_print", "quick_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
70dc2d0a7c432981cb85eaaeeed508e841eee6a9
db53ac546ad087d67dd5d901f5324579b9b95783
v1.0
complete
Prefill
Prefill_41058_C
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def linked_list_to_balanced_bst_with_insertion(head, va...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def sorted_list_to_bst(head): """ Converts a so...
from solution import TreeNode, ListNode, linked_list_to_balanced_bst_with_insertion def test_linked_list_to_balanced_bst_with_insertion(): head = ListNode(1) head.next = ListNode(2) head.next.next = ListNode(3) head.next.next.next = ListNode(4) head.next.next.next.next = ListNode(5) new_va...
[]
[ 1, 1, 1, 1, 1, 0, 1, 0, 0, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, value=0, next=None):\n self.value = value\n self.next = next\n\nclass TreeNode:\n def __init__(self, value=0, left=None, right=None):\...
trial_gpt4o_9
{ "original_instruction": "Write a python function to convert a linked list to a binary tree, and then add an element to the binary tree, making sure the tree remains balanced.", "prompt_id": "00041058", "row_id": 41058, "seed_ids": "['magpie_prefill_41058']" }
0.662921
Prefill_41058
C
[ "sorted_list_to_bst", "insert_into_bst", "balance_bst", "linked_list_to_balanced_bst_with_insertion" ]
4
[ [ "linked_list_to_balanced_bst_with_insertion", "balance_bst" ], [ "linked_list_to_balanced_bst_with_insertion", "insert_into_bst" ], [ "linked_list_to_balanced_bst_with_insertion", "sorted_list_to_bst" ] ]
3
[]
false
[ "TreeNode", "ListNode" ]
true
pytest
true
[]
true
3e931c1508e960cd181ea15928e1d58f14e302ef
744395474defb5f2a19ee64befef45ca80e5c918
v1.0
complete
Prefill
Prefill_40983_C
def largest_contiguous_sum_2d(array): """ Write a python function to find the largest sum of contiguous subarray within a 2D array. >>> largest_contiguous_sum_2d([ ... [1, 2, -1, -4, -20], ... [-8, -3, 4, 2, 1], ... [3, 8, 10, 1, 3], ... [-4, -1, 1, 7, -6] ... ]) == 29 ...
def largest_contiguous_sum_2d(array): """ Function to find the largest sum of contiguous subarray within a 2D array. """ if not array or not array[0]: return 0 rows, cols = len(array), len(array[0]) max_sum = float('-inf') for left in range(cols): temp = [0] * rows ...
from solution import largest_contiguous_sum_2d def test_largest_contiguous_sum_2d(): assert largest_contiguous_sum_2d([ [1, 2, -1, -4, -20], [-8, -3, 4, 2, 1], [3, 8, 10, 1, 3], [-4, -1, 1, 7, -6] ]) == 29 assert largest_contiguous_sum_2d([ [-1, -2, -3], [-4...
[ { "docstring": "Function to find the largest sum of contiguous subarray within a 2D array.", "function_declaration": "def largest_contiguous_sum_2d(array):", "function_name": "largest_contiguous_sum_2d", "parameter_list": "(array)" }, { "docstring": "Helper function to find the largest sum o...
[ 0, 0, 0, 0, 1, 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 max_subarray_sum(arr):\n def kadane_algorithm(lst):\n # Helper function for finding max sum of 1D array using Kadane's algorithm\n max_current = max_global = lst[0]\n ...
trial_gpt4o_4
{ "original_instruction": "Write a python function to find the largest sum of contiguous subarray within a 2D array, following LeetCode problem 213. House Robber II.", "prompt_id": "00040983", "row_id": 40983, "seed_ids": "['magpie_prefill_40983']" }
0.699823
Prefill_40983
C
[ "largest_contiguous_sum_2d", "max_sum_1d" ]
2
[ [ "largest_contiguous_sum_2d", "max_sum_1d" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b19aa29d04eb2572043ca6059ff5c9401b0a844c
ab89f96c019bfb9f44ec1bcbf2650d7c15980d16
v1.0
complete
Prefill
Prefill_42088_C
def largest_palindrome_product(n: int) -> int: """ Returns the largest palindrome made from the product of two n-digit numbers. >>> largest_palindrome_product(1) 9 >>> largest_palindrome_product(2) 9009 >>> largest_palindrome_product(3) 906609 """
def is_palindrome(num): return str(num) == str(num)[::-1] def largest_palindrome_product(n): """ Returns the largest palindrome made from the product of two n-digit numbers. """ if n < 1: raise ValueError("n must be greater than or equal to 1") start = 10 ** (n - 1) end = 10 **...
from solution import largest_palindrome_product def test_largest_palindrome_product_1_digit(): assert largest_palindrome_product(1) == 9 # 1 * 9 = 9 or 3 * 3 = 9 def test_largest_palindrome_product_2_digits(): assert largest_palindrome_product(2) == 9009 # 91 * 99 = 9009 def test_largest_palindrome_product...
[ { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Returns the largest palindrome made from the product of two n-digit numbers.", "function_declaration": "def largest_palindrome_product(n)...
[ 1, 0, 1, 1, 1, 1, 0, 0, 0, 0 ]
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 Checks if a given number is a palindrome.\n \"\"\"\n return str(number) == str(number)[::-1]\n\ndef largest_palindrome_product(n):\n \"\"\...
trial_gpt4o_5
{ "original_instruction": "Write a python function to find the largest palindrome which is a product of two n-digit numbers. For example, if n=2, the function should return the largest palindrome product of two 2-digit numbers (i.e., between 10 and 99).", "prompt_id": "00042088", "row_id": 42088, "seed_ids": "[...
0.716372
Prefill_42088
C
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c695a6102525be78b01051da0d74c13aa9a96a0
7a241959717a31db6e775421ed2f517f49c3d942
v1.0
complete
Prefill
Prefill_40052_C
def merge_sort(arr): """ Sort an array in-place using merge sort. >>> 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([0, -1, 5, 3, 8, -2]) [-2, -1, 0, 3, 5, 8] >>> merge_sort([]) [] >>> merge_sort([5]) [5] >>> merge_sort([1, 2, 3, 4...
def merge_sort(arr): if len(arr) > 1: mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] merge_sort(left_half) merge_sort(right_half) i = j = k = 0 while i < len(left_half) and j < len(right_half): if left_h...
from solution import merge_sort, quick_sort def test_merge_sort(): assert merge_sort([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9] assert merge_sort([0, -1, 5, 3, 8, -2]) == [-2, -1, 0, 3, 5, 8] assert merge_sort([]) == [] assert merge_sort([5]) == [5] assert merge_sort([1...
[ { "docstring": null, "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def quick_sort(arr):", "function_name": "quick_sort", "parameter_list": "(arr)" }, { "docstring":...
[ 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 merge_sort(arr):\n \"\"\"\n Sorts the array in-place using merge sort.\n \"\"\"\n def merge(left, right):\n result = []\n i = j = 0\n \n while i < ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to sort an array in-place using both merge sort and quick sort. Both sorting algorithms should return the sorted array.", "prompt_id": "00040052", "row_id": 40052, "seed_ids": "['magpie_prefill_40052']" }
0.644684
Prefill_40052
C
[ "merge_sort", "quick_sort", "_quick_sort", "partition" ]
4
[ [ "_quick_sort", "partition" ], [ "quick_sort", "_quick_sort" ] ]
2
[]
false
[]
false
pytest
true
[]
true
96da7242e4b5d1df32109ca32a3839d759f26df1
6031d5a27475fc58d22f88261cc9db7e3c763885
v1.0
complete
Prefill
Prefill_41295_C
import math from typing import List, Tuple def closest_pair_of_points(points: List[Tuple[int, int]]) -> float: """ Write a python function to find the closest pair of points in a 2D plane. The function should return the distance between the two closest points. >>> points = [(0,0), (1,1), (4,5), (13,14...
import math def distance(point1, point2): """ Returns the Euclidean distance between two points. """ return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def closest_pair_of_points(points): """ Returns the smallest distance between two closest points in a given list of...
from solution import closest_pair_of_points def test_closest_pair_basic(): points = [(0,0), (1,1), (4,5), (13,14)] assert math.isclose(closest_pair_of_points(points), math.sqrt(2), rel_tol=1e-9) def test_closest_pair_single(): points = [(0,0)] assert closest_pair_of_points(points) == float('inf') def...
[ { "docstring": "Returns the Euclidean distance between two points.", "function_declaration": "def distance(point1, point2):", "function_name": "distance", "parameter_list": "(point1, point2)" }, { "docstring": "Returns the smallest distance between two closest points in a given list of 2D po...
[ 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": "import math\n\ndef euclidean_distance(point1, point2):\n \"\"\"\n Calculate the Euclidean distance between two points.\n \"\"\"\n return math.sqrt((point1[0] - point2[0]) ** 2 + (...
trial_gpt4o_9
{ "original_instruction": "Write a python function to implement the find the closest pair of points in a 2D plane. The function should return the distance between the two closest points.", "prompt_id": "00041295", "row_id": 41295, "seed_ids": "['magpie_prefill_41295']" }
0.722692
Prefill_41295
C
[ "distance", "closest_pair_of_points" ]
2
[ [ "closest_pair_of_points", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
af2be16d5272f0c190e05fbbe53b042cfb46177e
4a949aa0820d60c226c614e5a4e2d9ef740caa0f
v1.0
complete
Prefill
Prefill_41007_C
import random from typing import List, Tuple def create_deck() -> List[Tuple[str, str]]: """ Creates a deck of cards, doubling to make 120 cards (two full decks). >>> len(create_deck()) == 120 """ suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] ranks = ['2', '3', '4', '5', '6', '7', '8', '9'...
import random from collections import Counter def create_deck(): """ Creates a deck of cards, doubling to make 120 cards (two full decks). """ suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'] deck = [(rank, ...
from solution import create_deck, deal_cards, simulate_bidding, deuces_wild def test_create_deck(): deck = create_deck() assert len(deck) == 104 # 2 decks of 52 cards each def test_deal_cards(): deck = create_deck() hands = deal_cards(deck, 4) assert len(hands) == 4 assert all(len(hand) == 26...
[ { "docstring": "Creates a deck of cards, doubling to make 120 cards (two full decks).", "function_declaration": "def create_deck():", "function_name": "create_deck", "parameter_list": "()" }, { "docstring": "Shuffles the deck and deals cards to the specified number of players.", "functio...
[ 0, 1, 0, 1, 1, 1, 0, 1, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_deck():\n \"\"\"\n Generates and returns a deck of pinochle cards including two decks combined.\n \"\"\"\n suits = ['hearts', 'diamonds', 'clubs', 's...
trial_gpt4o_9
{ "original_instruction": "Write a python function to simulate the board game \"Deuces Wild,\" a pinochle variant where the deck is composed of two full decks of cards (60 cards in total), and wild cards are treated as deuces (2s). The function should deal cards to a specified number of players and simulate a round o...
0.71576
Prefill_41007
C
[ "create_deck", "deal_cards", "simulate_bidding", "deuces_wild" ]
4
[ [ "deuces_wild", "create_deck" ], [ "deuces_wild", "deal_cards" ], [ "deuces_wild", "simulate_bidding" ] ]
3
[]
false
[]
false
pytest
true
[]
true
a236a036be5cd1a34e76b18a932053c43961fbfb
e19f019150be19d6bea1211a6082194afa56256a
v1.0
complete
Prefill
Prefill_41526_C
def is_prime(n: int) -> bool: """Check if a given number n is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(13) True >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-5) False """ def print_primes_between(a: int, b: int) -> None: """...
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 print_primes_between(a, b): """ Prints all prime numbers between two given number...
from solution import is_prime, print_primes_between def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_print_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": "Prints all prime numbers between two given numbers a and b inclusive.", "function_declaration": "def print_...
[ 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_between(a, b):\n \"\"\"\n Prints all prime numbers between two given numbers (inclusive).\n \"\"\"\n def is_prime(n):\n if n <= 1:\n return Fals...
trial_gpt4o_8
{ "original_instruction": "Write a python function to print all prime numbers between two given numbers. The function should take two integers as arguments and print all the prime numbers that fall between the smaller number and the larger number, inclusive.", "prompt_id": "00041526", "row_id": 41526, "seed_ids...
0.741517
Prefill_41526
C
[ "is_prime", "print_primes_between" ]
2
[ [ "print_primes_between", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
27c9cea48562172ce4fab4c70dcf65bec7c47969
1935f7a403cabd7d3f130fb0967b55c4c3424715
v1.0
complete
Prefill
Prefill_40866_C
def is_perfect_number(n: int) -> bool: """ Check if the given number n is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors excluding itself. Args: n (int): The number to be checked. Returns: bool: True if n is a perfect number, False ...
def is_perfect_number(n): """ Check if the given number n is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors excluding itself. """ if n < 2: return False divisors_sum = sum(i for i in range(1, n) if n % i == 0) return divisors_...
from solution import is_perfect_number, find_perfect_numbers_in_range def test_is_perfect_number(): assert is_perfect_number(6) == True assert is_perfect_number(28) == True assert is_perfect_number(496) == True assert is_perfect_number(12) == False assert is_perfect_number(1) == False assert is...
[ { "docstring": "Check if the given number n is a perfect number.\nA perfect number is a positive integer that is equal to the sum of its proper divisors excluding itself.", "function_declaration": "def is_perfect_number(n):", "function_name": "is_perfect_number", "parameter_list": "(n)" }, { ...
[ 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_perfect_number(n):\n \"\"\"\n Check if a given number is a perfect number.\n A perfect number is a positive integer that is equal to the sum of its proper divisors,\n exclu...
trial_gpt4o_8
{ "original_instruction": "Write a python function to check if a given number is perfect or not. Write a script to test the function and print all perfect numbers between a user-input range.", "prompt_id": "00040866", "row_id": 40866, "seed_ids": "['magpie_prefill_40866']" }
0.61789
Prefill_40866
C
[ "is_perfect_number", "find_perfect_numbers_in_range" ]
2
[ [ "find_perfect_numbers_in_range", "is_perfect_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8d1e8f64c991e26f5c708f8b5b5d778b8744ad1
f822717c0a26bcd1af3a837f0233e2f6b5f8e474
v1.0
complete
Prefill
Prefill_41530_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(29) True >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-5) False """ def sum_of_primes_in_range(star...
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import is_prime, sum_of_primes_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5)...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculate the sum of prime numbers within a given range [start, end].", "function_declaration": "def sum_of_primes_in...
[ 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ]
6
medium
0.6
{ "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_9
{ "original_instruction": "Write a python function to calculate the sum of the prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.", "prompt_id": "00041530", "row_id": 41530, "seed_ids": "['magpie_prefill_41530']" }
0.731799
Prefill_41530
C
[ "is_prime", "sum_of_primes_in_range" ]
2
[ [ "sum_of_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6cf54ef3298e20b9e433c8341781df21ecd9b7ff
871a1435c4175fbf9b03ef7c148a90e7e77952ab
v1.0
complete
Prefill
Prefill_40482_C
import numpy as np def sigmoid(x): """Apply sigmoid activation function.""" return 1 / (1 + np.exp(-x)) def feed_forward_nn(input_features, hidden_layers, hidden_neurons, output_classes): """Initialize and return a feed-forward neural network with specified parameters. Args: - input_features ...
import numpy as np def sigmoid(x): return 1 / (1 + np.exp(-x)) def feed_forward_nn(input_features, hidden_layers, hidden_neurons, output_classes): np.random.seed(0) # Initialize weights and biases for the input to first hidden layer weights_hidden = [np.random.randn(input_features, hidden_neurons...
from solution import feed_forward_nn def test_single_input(): nn = feed_forward_nn(3, 2, 4, 2) X = np.array([1.0, 2.0, 3.0]) result = nn(X) assert result.shape == (2,) def test_multiple_inputs(): nn = feed_forward_nn(4, 3, 5, 3) X = np.array([[1.0, 2.0, 3.0, 4.0], [0.5, 0.6, 0.7, 0.8]]) re...
[ { "docstring": null, "function_declaration": "def sigmoid(x):", "function_name": "sigmoid", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def feed_forward_nn(input_features, hidden_layers, hidden_neurons, output_classes):", "function_name": "feed_forward_nn...
[ 0, 1, 0, 1, 1, 1, 0, 1, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef sigmoid(x):\n return 1 / (1 + np.exp(-x))\n\ndef sigmoid_derivative(x):\n return x * (1 - x)\n\ndef feed_forward_nn(input_features, hidden_layers, neurons_per_...
trial_gpt4o_8
{ "original_instruction": "Write a python function to implement a basic feed-forward neural network from scratch using numpy. The function should take parameters for the number of input features, number of hidden layers, number of neurons in hidden layers, and number of output classes.", "prompt_id": "00040482", ...
0.684893
Prefill_40482
C
[ "sigmoid", "feed_forward_nn" ]
2
[ [ "feed_forward_nn", "sigmoid" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
ceaaf487205773c1fa91edd6218c6b380fadc69c
ebc5b2b3708f6f299d6153ada02261cd706e653b
v1.0
complete
Prefill
Prefill_42191_C
def kth_smallest(arr, l, r, k): """ Write a python function to find the k-th smallest element in an array using a divide and conquer approach. >>> kth_smallest([12, 3, 5, 7, 19], 0, 4, 2) 5 >>> kth_smallest([10], 0, 0, 1) 10 >>> kth_smallest([4, 2, 6, 3, 9], 0, 4, 5) 9 >>> kth_smallest([...
def kth_smallest(arr, l, r, k): """ Finds the k-th smallest element in the array using the QuickSelect algorithm. """ if k > 0 and k <= r - l + 1: pos = partition(arr, l, r) if pos - l == k - 1: return arr[pos] if pos - l > k - 1: return kth_smallest(arr,...
from solution import kth_smallest def test_kth_smallest_basic(): arr = [12, 3, 5, 7, 19] assert kth_smallest(arr, 0, len(arr) - 1, 2) == 5 def test_kth_smallest_single_element(): arr = [10] assert kth_smallest(arr, 0, len(arr) - 1, 1) == 10 def test_kth_smallest_large_k(): arr = [4, 2, 6, 3, 9] ...
[ { "docstring": "Finds the k-th smallest element in the array using the QuickSelect algorithm.", "function_declaration": "def kth_smallest(arr, l, r, k):", "function_name": "kth_smallest", "parameter_list": "(arr, l, r, k)" }, { "docstring": null, "function_declaration": "def partition(ar...
[ 0, 1, 1, 1, 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 kth_smallest(arr, k):\n \"\"\"\n Returns the k-th smallest element in the array using the Quickselect algorithm.\n \"\"\"\n def partition(low, high):\n pivot = arr[high...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the k-th smallest element in an array using a divide and conquer approach.", "prompt_id": "00042191", "row_id": 42191, "seed_ids": "['magpie_prefill_42191']" }
0.688014
Prefill_42191
C
[ "kth_smallest", "partition" ]
2
[ [ "kth_smallest", "partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
732f281b0d6892093dab75168aba09936e065935
7da512420fe403d5bb804df39a6c2974cbde1e80
v1.0
complete
Prefill
Prefill_42480_C
def sum_first_n_primes(N: int) -> int: """ Returns the sum of the first N prime numbers. >>> sum_first_n_primes(1) == 2 >>> sum_first_n_primes(2) == 5 >>> sum_first_n_primes(3) == 10 >>> sum_first_n_primes(4) == 17 >>> sum_first_n_primes(5) == 28 >>> sum_first_n_primes(0) == 0 >>> sum_fi...
def is_prime(num): """ Returns True if the given number is a prime number, otherwise 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...
from solution import sum_first_n_primes def test_sum_first_n_primes(): assert sum_first_n_primes(1) == 2 # First prime number is 2 assert sum_first_n_primes(2) == 5 # First two primes: 2 + 3 assert sum_first_n_primes(3) == 10 # First three primes: 2 + 3 + 5 assert sum_first_n_primes(4) == 17 # First ...
[ { "docstring": "Returns True if the given number is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of the first N prime numbers.", "function_declaration": "def sum_...
[ 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 < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if nu...
trial_gpt4o_5
{ "original_instruction": "Write a python function to Sum the first N prime numbers. Here N is an input to the function.", "prompt_id": "00042480", "row_id": 42480, "seed_ids": "['magpie_prefill_42480']" }
0.774207
Prefill_42480
C
[ "is_prime", "sum_first_n_primes" ]
2
[ [ "sum_first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb151dec24311b052a42e833d2c20592ce83f8ec
44d5ba0d29a6510347b878f53cfa88512db55a5c
v1.0
complete
Prefill
Prefill_42177_C
def reverse_stack(stack): """ Reverses the elements of the stack. Parameters: stack (list): A list representing the stack. Returns: list: The stack with its elements reversed. """ pass def insert_at_bottom(stack, item): pass # Test cases def test_reverse_stack_empty(): ...
def reverse_stack(stack): """ Reverses the elements of the stack. Parameters: stack (list): A list representing the stack. Returns: list: The stack with its elements reversed. """ if not stack: return [] temp = stack.pop() reversed_stack = reverse_stack(stack) ...
from solution import reverse_stack def test_reverse_stack_empty(): assert reverse_stack([]) == [] def test_reverse_stack_single_element(): assert reverse_stack([1]) == [1] def test_reverse_stack_two_elements(): assert reverse_stack([1, 2]) == [2, 1] def test_reverse_stack_multiple_elements(): assert...
[ { "docstring": "Reverses the elements of the stack.\n\nParameters:\nstack (list): A list representing the stack.\n\nReturns:\nlist: The stack with its elements reversed.", "function_declaration": "def reverse_stack(stack):", "function_name": "reverse_stack", "parameter_list": "(stack)" }, { ...
[ 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": "class Stack:\n def __init__(self):\n self.items = []\n \n def is_empty(self):\n return len(self.items) == 0\n \n def push(self, item):\n self.items.append(...
trial_gpt4o_9
{ "original_instruction": "Write a python function to reverse the elements of a stack.", "prompt_id": "00042177", "row_id": 42177, "seed_ids": "['magpie_prefill_42177']" }
0.588592
Prefill_42177
C
[ "reverse_stack", "insert_at_bottom" ]
2
[ [ "reverse_stack", "insert_at_bottom" ] ]
1
[]
false
[]
false
pytest
true
[]
true
296dc7d7475351ff10f07978e48d00ecbc517198
9a38c89971a6fd6f770db7940b0c28f4d85b0093
v1.0
complete
Prefill
Prefill_42949_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ pass def sum_of_primes(n: int) -> int: """ Returns the sum of all the prime numbers from 1 to n (inclusive). >>> sum_of_primes(10) 17 >>> sum_of_primes(0) 0 >>> sum_of_primes(1) 0 >>> sum_of_p...
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 sum_of_primes def test_sum_of_primes_within_10(): assert sum_of_primes(10) == 17 # Primes are 2, 3, 5, 7 def test_sum_of_primes_within_0(): assert sum_of_primes(0) == 0 # No primes in the range def test_sum_of_primes_within_1(): assert sum_of_primes(1) == 0 # No primes in the rang...
[ { "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 the prime numbers from 1 to n (inclusive).", "function_declaration": "def sum_of...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 =...
trial_gpt4o_4
{ "original_instruction": "Write a python function to find the sum of all the prime numbers in a given range from 1 to n (both inclusive).", "prompt_id": "00042949", "row_id": 42949, "seed_ids": "['magpie_prefill_42949']" }
0.80861
Prefill_42949
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b7d8e218861b157af994238c1e1c19cff1ecbc3e
95513055abac3ebc0b655e562420ca817fad290f
v1.0
complete
Prefill
Prefill_42528_C
def is_pangram(s: str) -> bool: """ Check if the string s is a pangram by verifying it contains every letter of the alphabet at least once. >>> is_pangram("The quick brown fox jumps over the lazy dog") True >>> is_pangram("Hello World") False """ def find_pangram_substrings(s: str) -> list:...
def is_pangram(s): """ Check if the string s is a pangram. A pangram contains every letter of the alphabet at least once. """ alphabet = set("abcdefghijklmnopqrstuvwxyz") return set(s.lower()) >= alphabet def find_pangram_substrings(s): """ Returns all substrings of s that are pangrams....
from solution import find_pangram_substrings, is_pangram def test_is_pangram(): assert is_pangram("The quick brown fox jumps over the lazy dog") assert not is_pangram("Hello World") def test_find_pangram_substrings(): result = find_pangram_substrings("The quick brown fox jumps over the lazy dog") asse...
[ { "docstring": "Check if the string s is a pangram.\nA pangram contains every letter of the alphabet at least once.", "function_declaration": "def is_pangram(s):", "function_name": "is_pangram", "parameter_list": "(s)" }, { "docstring": "Returns all substrings of s that are pangrams.", "...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import string\n\ndef find_pangram_substrings(s):\n \"\"\"\n Returns a list of substrings of the given string 's' which are pangrams.\n \"\"\"\n alphabet_set = set(string.ascii_low...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find all the substrings of a given string that contain all the letters from the alphabet at least once, also known as pangrams.", "prompt_id": "00042528", "row_id": 42528, "seed_ids": "['magpie_prefill_42528']" }
0.611539
Prefill_42528
C
[ "is_pangram", "find_pangram_substrings" ]
2
[ [ "find_pangram_substrings", "is_pangram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ba011c4c858d3be447ab4b2a856f79fd987c25f8
572cf3043d3ee20cef0640c586783439fa985eaf
v1.0
complete
Prefill
Prefill_41731_C
def merge_sort(arr): """ Implements the merge sort algorithm on the input list. Parameters: - arr (list): The list of elements to be sorted. Returns: - list: A new sorted list. """ def merge(left, right): """ Merges two sorted lists into a single sorted list. ...
def merge_sort(arr): """ Implements the merge sort algorithm on the input list. Parameters: - arr (list): The list of elements to be sorted. Returns: - list: A new sorted list. """ if len(arr) <= 1: return arr # Divide the array into two halves mid = len(ar...
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_sorted_list(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_list(): assert merge_sort(...
[ { "docstring": "Implements the merge sort algorithm on the input list.\n\nParameters:\n- arr (list): The list of elements to be sorted.\n\nReturns:\n- list: A new sorted list.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "doc...
[ 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 merge_sort(arr):\n \"\"\"\n Implement merge sort algorithm to sort an array.\n \n :param arr: List of integers\n :return: New sorted list of integers\n \"\"\"\n if le...
trial_gpt4o_9
{ "original_instruction": "Write a python function to implement the mergesort algorithm. Merge sort is a divide-and-conquer algorithm that divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves. The merge() function is used for merging two halves.", "prompt_i...
0.599702
Prefill_41731
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e2c12a1c863109f38afe6ea1e9a78761957bc573
3f87e27ab4bda1c9bfaf1f4e0c55be50016359a4
v1.0
complete
Prefill
Prefill_43024_C
def is_palindrome(n): """ Helper function to check if a number n is a palindrome. """ # Your code here pass def find_non_palindromes(lst): """ Iterates over the given list lst and returns a list containing non-palindrome numbers. >>> find_non_palindromes([123, 456, 789]) == [123, 4...
def is_palindrome(n): """ Helper function to check if a number n is a palindrome """ s = str(n) return s == s[::-1] def find_non_palindromes(lst): """ Iterates over the given list lst and returns a list containing non-palindrome numbers. """ non_palindromes = [] for num in ...
from solution import find_non_palindromes, is_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True assert is_palindrome(12321) == True assert is_palindrome(12345) == False def ...
[ { "docstring": "Helper function to check if a number n is a palindrome", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Iterates over the given list lst and returns a list containing \nnon-palindrome numbers.", ...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(number):\n \"\"\"\n Check if a given number is a palindrome.\n A number is a palindrome if it reads the same backward as forward.\n \"\"\"\n str_num = str(num...
trial_gpt4o_9
{ "original_instruction": "Write a python function to iterate over a list and check if each number is a palindrome. If a number is not a palindrome, append it to a separate list. After the loop, return the list containing non-palindrome numbers.", "prompt_id": "00043024", "row_id": 43024, "seed_ids": "['magpie_...
0.787837
Prefill_43024
C
[ "is_palindrome", "find_non_palindromes" ]
2
[ [ "find_non_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
710664039c2e646d8c0917ee71c115bd24d4d634
18019d618823a7d4b6c46b3545215de3a60f10b6
v1.0
complete
Prefill
Prefill_42754_C
import numpy as np from scipy.optimize import minimize_scalar def f(x): """ Function to evaluate f(x) = (x^2) * sin(x). """ return (x**2) * np.sin(x) def find_minimum_value() -> float: """ Find the minimum value of the function f(x) = (x^2) * sin(x) in the range [0, pi]. Test cases: ...
import numpy as np from scipy.optimize import minimize_scalar def f(x): """ Function to evaluate f(x) = (x^2) * sin(x). """ return (x**2) * np.sin(x) def find_minimum_value(): """ Find the minimum value of the function f(x) = (x^2) * sin(x) in the range [0, pi]. """ # Define the range ...
from solution import find_minimum_value def test_minimum_value(): min_value = find_minimum_value() # The minimum value of f(x) = (x^2) * sin(x) in the range [0, pi] should be at the boundaries or at critical points. # After analyzing, the minimum value in the given range should be 0 when x = 0. as...
[ { "docstring": "Function to evaluate f(x) = (x^2) * sin(x).", "function_declaration": "def f(x):", "function_name": "f", "parameter_list": "(x)" }, { "docstring": "Find the minimum value of the function f(x) = (x^2) * sin(x) in the range [0, pi].", "function_declaration": "def find_minim...
[ 0, 0, 0, 1, 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": "import numpy as np\nfrom scipy.optimize import minimize_scalar\n\ndef f(x):\n \"\"\"\n Returns the value of the function f(x) = x^2 * sin(x)\n \"\"\"\n return (x**2) * np.sin(x)\n...
trial_gpt4o_8
{ "original_instruction": "Write a python function to find the minimum value of the f[x] = (x^2) * sin(x) function in the range [0, pi].", "prompt_id": "00042754", "row_id": 42754, "seed_ids": "['magpie_prefill_42754']" }
0.575465
Prefill_42754
C
[ "f", "find_minimum_value" ]
2
[ [ "find_minimum_value", "f" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy", "scipy" ]
false
141cf004ae11487f6b1a8bf5d6cf1f9eb3ac90d6
a2ae7667de9051de6d57a93b0f3b8ea8d9f233bb
v1.0
complete
Prefill
Prefill_42280_C
from collections import deque # Representation of Puzzle Board (3x3) GOAL_STATE = (1, 2, 3, 4, 5, 6, 7, 8, 0) # Goal state represented in a 1D tuple with 0 as the blank space def get_possible_moves(state): """ Return a list of possible moves for the blank space. """ size = 3 # Since it's 8-puzzle, s...
from collections import deque # Representation of Puzzle Board (3x3) GOAL_STATE = (1, 2, 3, 4, 5, 6, 7, 8, 0) # Goal state represented in a 1D tuple with 0 as the blank space def get_possible_moves(state): """ Return a list of possible moves for the blank space. """ size = 3 # Since it's 8-puzzle, s...
from solution import bfs_solve_8_puzzle, GOAL_STATE def test_solved_puzzle(): start_state = GOAL_STATE assert bfs_solve_8_puzzle(start_state) == [] def test_one_move_to_solve(): start_state = (1, 2, 3, 4, 5, 6, 7, 0, 8) assert bfs_solve_8_puzzle(start_state) == [GOAL_STATE] def test_already_solved():...
[ { "docstring": "Return a list of possible moves for the blank space.", "function_declaration": "def get_possible_moves(state):", "function_name": "get_possible_moves", "parameter_list": "(state)" }, { "docstring": "Solve the 8-puzzle using Breadth-First Search Algorithm.\nReturn the sequence...
[ 0, 0, 1, 1, 0, 0, 1, 0, 1, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_solvable(puzzle):\n \"\"\"\n Check if the 8-puzzle is solvable.\n \"\"\"\n puzzle = puzzle.replace(' ', '')\n inv_count = sum(\n ...
trial_gpt4o_6
{ "original_instruction": "Write a python function to solve the 8 puzzle problem using a breadth-first search algorithm.", "prompt_id": "00042280", "row_id": 42280, "seed_ids": "['magpie_prefill_42280']" }
0.671836
Prefill_42280
C
[ "get_possible_moves", "bfs_solve_8_puzzle" ]
2
[ [ "bfs_solve_8_puzzle", "get_possible_moves" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6eacacec7388aaae0bd7b034b84c966020362703
f6f5c4a78724da4c94f877c0a719d9f7efb6f3d2
v1.0
complete
Prefill
Prefill_42244_C
def is_valid(board, row, col, num): """ Check if 'num' is not in the current row, column and 3x3 sub-board. """ def solve_sudoku(board): """ Solves the Sudoku puzzle using backtracking. >>> board = [ ... [5, 3, 0, 0, 7, 0, 0, 0, 0], ... [6, 0, 0, 1, 9, 5, 0, 0, 0], ... ...
def is_valid(board, row, col, num): """ Check if 'num' is not in the current row, column and 3x3 sub-board. """ # Check the row for x in range(9): if board[row][x] == num: return False # Check the column for x in range(9): if board[x][col] == num: ret...
def test_solve_sudoku(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, 0, 0, 0, 2, 8, 0], [0, 0, 0, 4, 1...
[ { "docstring": "Check if 'num' is not in the current row, column and 3x3 sub-board.", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Solves the Sudoku puzzle using backtracking.", "...
[ 1, 0, 0, 1, 1, 1, 1, 1, 1 ]
7
easy
0.778
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solve_sudoku(board):\n \"\"\"\n Solves the given Sudoku puzzle using backtracking.\n \n Parameters:\n board (list of list of int): A 9x9 grid representing the Sudoku pu...
trial_gpt4o_9
{ "original_instruction": "Write a python function to solve a known hard puzzle, such as the classic \"Sudoku\". Explain your code step-by-step.", "prompt_id": "00042244", "row_id": 42244, "seed_ids": "['magpie_prefill_42244']" }
0.57457
Prefill_42244
C
[ "is_valid", "solve_sudoku" ]
2
[ [ "solve_sudoku", "is_valid" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2d8aa903aac3d2d01024feae32959b092f5b7ceb
e71f44829d02a021e6077dd0da64f4353bb34b1b
v1.0
complete
Prefill
Prefill_42828_C
from typing import List def quicksort(arr: List[int]) -> List[int]: """ Quicksort algorithm implementation to sort the list. """ pass def find_n_smallest_elements(arr: List[int], n: int) -> List[int]: """ Find the N smallest elements in a list using the quicksort algorithm. >>> find_...
def quicksort(arr): """ Quicksort algorithm implementation to sort the list. """ 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) +...
from solution import find_n_smallest_elements def test_find_n_smallest_elements_typical_case(): assert find_n_smallest_elements([5, 2, 9, 1, 5, 6], 3) == [1, 2, 5] def test_find_n_smallest_elements_with_duplicates(): assert find_n_smallest_elements([5, 2, 9, 1, 5, 6, 2, 1], 4) == [1, 1, 2, 2] def test_find_n...
[ { "docstring": "Quicksort algorithm implementation to sort the list.", "function_declaration": "def quicksort(arr):", "function_name": "quicksort", "parameter_list": "(arr)" }, { "docstring": "Returns the N smallest elements in a list using the quicksort algorithm.", "function_declaratio...
[ 1, 1, 0, 0, 0, 1, 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, n):\n \"\"\"\n Returns the N smallest elements in the list using a modified quicksort algorithm.\n \"\"\"\n if n <= 0:\n return []\n if n >= len(arr...
trial_gpt4o_9
{ "original_instruction": "Write a python function to find the N smallest elements in a list using the quicksort algorithm.", "prompt_id": "00042828", "row_id": 42828, "seed_ids": "['magpie_prefill_42828']" }
0.71319
Prefill_42828
C
[ "quicksort", "find_n_smallest_elements" ]
2
[ [ "find_n_smallest_elements", "quicksort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ae476c61672843b5d55f775a31649f2166286e4e
dd27c95a11470f5efa3678b7725987b370ba0a3a
v1.0
complete
Prefill
Prefill_42520_C
def solve_sudoku(board: List[List[int]]) -> bool: """ Solve the given Sudoku puzzle. The Sudoku puzzle is provided as a 9x9 grid of integers, where 0 represents empty cells that need to be filled. Modify the input board in-place. >>> board = [ ... [5, 3, 0, 0, 7, 0, 0, 0, 0], ... [6, 0...
def is_valid(board, row, col, num): for x in range(9): if board[row][x] == num: return False for x in range(9): if board[x][col] == num: return False start_row, start_col = 3 * (row // 3), 3 * (col // 3) for i in range(3): for j in range(3): ...
from solution import solve_sudoku def test_solve_sudoku(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, 0, 0, ...
[ { "docstring": null, "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": null, "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_list...
[ 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, row, col, num):\n \"\"\"\n Check if num can be placed at board[row][col].\n \"\"\"\n # check row\n for y in range(9):\n if board[row][y] == num:\n ...
trial_gpt4o_9
{ "original_instruction": "Write a python function to solve a given Sudoku puzzle. The Sudoku puzzle is provided as a 9x9 grid of integers, where 0 represents empty cells that need to be filled.", "prompt_id": "00042520", "row_id": 42520, "seed_ids": "['magpie_prefill_42520']" }
0.610919
Prefill_42520
C
[ "is_valid", "solve_sudoku", "find_empty_location" ]
3
[ [ "solve_sudoku", "find_empty_location" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a490b17d6979b460212f381b97aafb1e9a1455a9
543bccb6a341a029aac839d2ac51c4af01a492bb