version
stringclasses
1 value
style
stringclasses
2 values
subset
stringclasses
12 values
question_id
stringlengths
9
23
question
stringlengths
27
8.13k
solution
stringlengths
99
5.97k
test
stringlengths
105
4.45k
test_info
listlengths
0
13
gpt_pass_sequence
listlengths
1
10
gpt_pass_trial_num
int64
1
10
gpt_difficulty
stringclasses
3 values
gpt_pass_percentage
float64
0.1
1
trials
dict
chosen_trial
stringclasses
10 values
metadata
dict
benchmark_similarity
float64
0.16
0.93
benchmark_instruction
stringclasses
1 value
benchmark_task_id
stringclasses
1 value
filter_reason
stringclasses
1 value
base_id
stringlengths
7
21
variant
stringclasses
2 values
top_function_names
listlengths
2
13
n_top_functions
int64
2
13
helper_call_edges
listlengths
1
16
n_helper_call_edges
int64
1
16
harness_functions
listlengths
0
3
structural_wrapper
bool
1 class
class_names
listlengths
0
5
has_class
bool
2 classes
test_kind
stringclasses
1 value
test_has_solution_import
bool
2 classes
third_party_imports
listlengths
0
5
stdlib_only
bool
2 classes
question_norm_sha1
stringlengths
40
40
solution_ast_sha1
stringlengths
40
40
v1.0
instruct
Prefill
Prefill_15515_I
Create a function that takes a list of strings as input and returns a list of lists, where each sublist contains strings that can be formed by rotating the strings in the input list by a certain number of positions to the right. For example, if the input list is ["abc", "def", "ghi"], the output should be [["abc", "bca...
def rotate_string(s, n): """ Rotates a string s to the right by n positions. """ return s[-n:] + s[:-n] def rotate_strings(input_list): """ Returns a list of lists, where each sublist contains rotated versions of the strings from the input list. """ result = [] if not input_list: ...
from solution import rotate_strings def test_rotate_strings_single_element(): assert rotate_strings(["abc"]) == [["abc", "cab", "bca"]] def test_rotate_strings_multiple_elements(): assert rotate_strings(["abc", "def", "ghi"]) == [ ["abc", "cab", "bca"], ["def", "fde", "efd"], ["ghi", "...
[ { "docstring": "Rotates a string s to the right by n positions.", "function_declaration": "def rotate_string(s, n):", "function_name": "rotate_string", "parameter_list": "(s, n)" }, { "docstring": "Returns a list of lists, where each sublist contains rotated versions of the strings from the ...
[ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_string(s, n):\n \"\"\"\n Returns a new string that is the result of rotating the input string s by n positions to the right.\n \"\"\"\n n = n % len(s)\n return s[-n:...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00015515", "row_id": 15515, "seed_ids": "['magpie_prefill_15515']" }
0.668331
Prefill_15515
I
[ "rotate_string", "rotate_strings" ]
2
[ [ "rotate_strings", "rotate_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a921dbe791f1f021ea26e24d67745678c03e1bdc
3ea1a99cf156a754770c0fe3daeef978b4e99747
v1.0
instruct
Prefill
Prefill_15760_I
Create a function that takes two integers as input and returns the sum of all prime numbers between the two integers (inclusive). If the input integers are less than 2, the function should return 0.
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False limit = int(n ** 0.5) + 1 for divider in range(3, limit, 2): if n % divider == 0: return False return True def sum_primes_between(a, b): """ Returns th...
from solution import sum_primes_between def test_sum_primes_between_both_less_than_2(): assert sum_primes_between(0, 1) == 0 def test_sum_primes_between_a_less_than_2_b_greater_than_2(): assert sum_primes_between(1, 10) == 17 # 2, 3, 5, 7 def test_sum_primes_between_b_less_than_2_a_greater_than_2(): asse...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers between a and b (inclusive).\nIf the input integers are less than 2, the function returns 0.", "function_declarati...
[ 0, 0, 0, 0, 0, 1, 1, 0, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00015760", "row_id": 15760, "seed_ids": "['magpie_prefill_15760']" }
0.623093
Prefill_15760
I
[ "is_prime", "sum_primes_between" ]
2
[ [ "sum_primes_between", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3490270ab5e6daa068aa0549795363f2365bf1b3
c7be577ed970f93b32c16a830ddb0b65e8a1afc7
v1.0
instruct
Prefill
Prefill_15770_I
Create a function that takes in a string and then tests if that string can be split into two palindromes using a minimum of one cut. A palindrome is a word that reads the same backward as forward. If the string can be split into two palindromes using a single cut, the string should be returned concatenated with itself....
def is_palindrome(s): """ Check if a given string is a palindrome. """ return s == s[::-1] def split_into_two_palindromes(s): """ This function checks if a string can be split into two palindromes using a minimum of one cut. If possible, it returns the string concatenated with itself. Other...
from solution import is_palindrome, split_into_two_palindromes def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("") == True # An empty string is technically a palindrome def test_split_i...
[ { "docstring": "Check if a given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "This function checks if a string can be split into two palindromes using a minimum of one cut.\nIf possible...
[ 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 split_palindromes(s):\n \"\"\"\n This function checks if the string `s` can be split into two palindromes using a minimum of one cut.\n If yes, it returns the concatenation of th...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00015770", "row_id": 15770, "seed_ids": "['magpie_prefill_15770']" }
0.73463
Prefill_15770
I
[ "is_palindrome", "split_into_two_palindromes" ]
2
[ [ "split_into_two_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
18b43b6eb634b4cca777c6f5c4ae35267c40c607
c3512cc5d74f5c3bcc529e85a284375b92275f65
v1.0
instruct
Prefill
Prefill_15801_I
Create a function that merges two sorted linked lists and append the result to a given linked list.
class ListNode: def __init__(self, x): self.val = x self.next = None def merge_two_sorted_lists(l1, l2): """ Merges two sorted linked lists and returns the head of the combined sorted linked list. """ dummy = ListNode(0) current = dummy while l1 and l2: if l1.val < ...
import pytest from solution import ListNode, merge_two_sorted_lists, append_merged_lists def linked_list_to_list(head): result = [] current = head while current: result.append(current.val) current = current.next return result def list_to_linked_list(lst): dummy = ListNode(0) c...
[]
[ 1, 0, 1, 1, 1, 1, 1, 1, 0, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\nclass LinkedList:\n def __init__(self):\n self.head = None\n\n def...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00015801", "row_id": 15801, "seed_ids": "['magpie_prefill_15801']" }
0.580356
Prefill_15801
I
[ "merge_two_sorted_lists", "append_merged_lists" ]
2
[ [ "append_merged_lists", "merge_two_sorted_lists" ] ]
1
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
c4f0bb04c27987cce6070c705ee193dac10ea70e
c907840469cb6bf5110b8b306f2556b5a514ef62
v1.0
instruct
Prefill
Prefill_15815_I
Create a function that returns the minimum number of steps required to switch from one state to another state of a Rubik's cube. A step is defined as rotating a face of the cube. The two states are represented as 1-D arrays of length 54, where each element represents a color on the Rubik's cube. The first 9 elements re...
def min_steps_to_solve_rubiks_cube(start_state, end_state): """ Returns the minimum number of steps required to switch from one state to another state of a Rubik's cube. Parameters: - start_state: list of 54 integers representing the current state of the cube. - end_state: list of 54 intege...
from solution import min_steps_to_solve_rubiks_cube def test_min_steps_no_moves_needed(): start = [1] * 54 end = [1] * 54 assert min_steps_to_solve_rubiks_cube(start, end) == 0 def test_min_steps_one_move(): start = [1] * 54 end = [1] * 53 + [2] # Since we have no actual moves, we return -1; i...
[ { "docstring": "Returns the minimum number of steps required to switch from one state\nto another state of a Rubik's cube.\n\nParameters:\n- start_state: list of 54 integers representing the current state of the cube.\n- end_state: list of 54 integers representing the desired state of the cube.\n\nNote: This fu...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.222
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Prefill-43K_sanitized_prepared1_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef get_valid_moves(state):\n \"\"\"\n This is a placeholder function representing the generation of all possible states \n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00015815", "row_id": 15815, "seed_ids": "['magpie_prefill_15815']" }
0.536276
Prefill_15815
I
[ "min_steps_to_solve_rubiks_cube", "generate_possible_moves" ]
2
[ [ "min_steps_to_solve_rubiks_cube", "generate_possible_moves" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b74552a43e4ee2343d3099dbc86a14477fcdea85
5394223e3a2bd62aec50f0779577ee9368e4f842
v1.0
instruct
Prefill
Prefill_15817_I
Create a function that checks for minimum occurrence of characters in a string
def min_occurrence(input_string): """ Returns a dictionary with characters as keys and their minimum occurrence in the string as values. """ char_count = {} for char in input_string: if char in char_count: char_count[char] += 1 else: char_count[char] = 1 ...
from solution import min_occurrence, minimum_occurrence_character def test_empty_string(): assert min_occurrence("") == {} assert minimum_occurrence_character("") == None def test_single_character_string(): assert min_occurrence("a") == {'a': 1} assert minimum_occurrence_character("a") == ['a'] def t...
[ { "docstring": "Returns a dictionary with characters as keys and their minimum occurrence in the string as values.", "function_declaration": "def min_occurrence(input_string):", "function_name": "min_occurrence", "parameter_list": "(input_string)" }, { "docstring": null, "function_declar...
[ 0, 1, 1, 0, 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": "from collections import Counter\n\ndef min_occurrence(s):\n \"\"\"\n Returns the minimum occurrence of any character in the string s.\n \"\"\"\n if not s:\n return None\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00015817", "row_id": 15817, "seed_ids": "['magpie_prefill_15817']" }
0.748205
Prefill_15817
I
[ "min_occurrence", "minimum_occurrence_character" ]
2
[ [ "minimum_occurrence_character", "min_occurrence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
643c228fe0b9dbaa003860b239914eb1eadb30be
4b62bc280ea24ef0ee7d5cf65a17988b388259f7
v1.0
instruct
Prefill
Prefill_15853_I
Create a function that takes three arguments: nb1, nb2, and nb3, which represent three, non-negative integers. The function should return the greatest common divisor (GCD) of nb1 and nb2. However, the GCD should only be calculated if nb3 is a prime number. If nb3 is not a prime number, the function should return 0.
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return Tr...
from solution import gcd_if_prime def test_gcd_if_prime_prime(): # nb3 is a prime number assert gcd_if_prime(8, 12, 3) == 4 assert gcd_if_prime(100, 50, 5) == 50 assert gcd_if_prime(7, 14, 2) == 7 def test_gcd_if_prime_not_prime(): # nb3 is not a prime number assert gcd_if_prime(8, 12, 4) == 0...
[ { "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 greatest common divisor of two numbers a and b.", "function_declaration": "def gcd(a, b):", "functi...
[ 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 is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00015853", "row_id": 15853, "seed_ids": "['magpie_prefill_15853']" }
0.656539
Prefill_15853
I
[ "is_prime", "gcd", "gcd_if_prime" ]
3
[ [ "gcd_if_prime", "gcd" ], [ "gcd_if_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1614e4ab04b8071cb7c810f27a474c36b75ab11b
e39f3de64b36eaa3e3263c0d2813a0b709490106
v1.0
instruct
Prefill
Prefill_16020_I
Create a function that takes two positive integers, and returns their Least Common Multiple (LCM). The function should handle large integers effectively.
def gcd(a, b): """ Helper function to compute the Greatest Common Divisor (GCD) of two numbers. """ while b: a, b = b, a % b return a def lcm(a, b): """ Returns the Least Common Multiple (LCM) of a and b. """ if a == 0 or b == 0: return 0 return abs(a * b) // gcd...
from solution import lcm def test_lcm_small_numbers(): assert lcm(4, 5) == 20 assert lcm(7, 3) == 21 assert lcm(1, 1) == 1 assert lcm(6, 8) == 24 def test_lcm_with_zero(): assert lcm(0, 5) == 0 assert lcm(5, 0) == 0 def test_lcm_large_numbers(): assert lcm(123456, 789012) == 8117355456 ...
[ { "docstring": "Helper function to compute the Greatest Common Divisor (GCD) of two numbers.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the Least Common Multiple (LCM) of a and b.", "function_declaration": "de...
[ 1, 0, 1, 1, 1, 1, 0, 0, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Helper function to calculate the Greatest Common Divisor (GCD) of two numbers.\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00016020", "row_id": 16020, "seed_ids": "['magpie_prefill_16020']" }
0.591725
Prefill_16020
I
[ "gcd", "lcm" ]
2
[ [ "lcm", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c6f4a6a25fe580947af4535442e71dcdba318965
3642d54a807686157f32cf49a04da76b8a511674
v1.0
instruct
Prefill
Prefill_16026_I
Create a function that returns the smallest number that is evenly divisible by all numbers from 1 to 20.
import math def lcm(a, b): """ Returns the least common multiple of a and b. """ return abs(a*b) // math.gcd(a, b) def smallest_multiple(n): """ Returns the smallest positive number that is evenly divisible by all numbers from 1 to n. """ result = 1 for i in range(1, n+1): ...
from solution import lcm, smallest_multiple, smallest_multiple_1_to_20 def test_lcm(): assert lcm(4, 5) == 20 assert lcm(6, 8) == 24 assert lcm(5, 15) == 15 assert lcm(7, 3) == 21 def test_smallest_multiple(): assert smallest_multiple(1) == 1 assert smallest_multiple(2) == 2 assert smalles...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest positive number that is evenly divisible by all numbers from 1 to n.", "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": "import math\n\ndef lcm(a, b):\n \"\"\"\n Returns the least common multiple of a and b.\n \"\"\"\n return abs(a * b) // math.gcd(a, b)\n\ndef smallest_multiple():\n \"\"\"\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00016026", "row_id": 16026, "seed_ids": "['magpie_prefill_16026']" }
0.622397
Prefill_16026
I
[ "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
ad796a8f0573a1a289419ee1dd3dfa6a549bc2af
b9510a968b5463d1925fc13436378a5420c9367d
v1.0
instruct
Prefill
Prefill_16183_I
Create a function that processes an array of integers and returns the largest prime number in the array. If there are no prime numbers in the array, the function should return -1.
def is_prime(n): """ Returns true if n is a prime number, otherwise false. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return Fal...
from solution import largest_prime, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == Fal...
[ { "docstring": "Returns true if n is a prime number, otherwise false.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the largest prime number in the array.\nIf there are no prime numbers, returns -1.", "functi...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00016183", "row_id": 16183, "seed_ids": "['magpie_prefill_16183']" }
0.611432
Prefill_16183
I
[ "is_prime", "largest_prime" ]
2
[ [ "largest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd20f9f83aca6020dea409dbfd35d64f830cd651
58dd420f197a0f0e0d03cbb579fdd80a23c20ae1
v1.0
instruct
Prefill
Prefill_16254_I
Create a function that takes an integer array and a target number as inputs, and uses the Quick Sort algorithm to sort the array and then searches for the target number in the sorted array. If the target is found, return its index; otherwise, return -1.
def quick_sort(arr): """ Quick Sort algorithm implementation. """ 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 quick_sort(left) + middle + quic...
from solution import sort_and_search, quick_sort, binary_search def test_quick_sort(): assert quick_sort([3, 6, 8, 10, 1, 2, 1]) == [1, 1, 2, 3, 6, 8, 10] assert quick_sort([]) == [] assert quick_sort([5]) == [5] assert quick_sort([3, 3, 3]) == [3, 3, 3] def test_binary_search(): assert binary_sea...
[ { "docstring": "Quick Sort algorithm implementation.", "function_declaration": "def quick_sort(arr):", "function_name": "quick_sort", "parameter_list": "(arr)" }, { "docstring": "Binary Search algorithm implementation.", "function_declaration": "def binary_search(arr, target):", "fun...
[ 1, 0, 0, 0, 0, 1, 0, 0, 0 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quick_sort(arr):\n \"\"\"\n Sorts the array using the Quick Sort algorithm.\n \"\"\"\n if len(arr) <= 1:\n return arr\n else:\n pivot = arr[len(arr) // 2]\n ...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00016254", "row_id": 16254, "seed_ids": "['magpie_prefill_16254']" }
0.577257
Prefill_16254
I
[ "quick_sort", "binary_search", "sort_and_search" ]
3
[ [ "sort_and_search", "binary_search" ], [ "sort_and_search", "quick_sort" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9e97bf5e02a9e8893b39a14923a6693f55a54f70
1afd8cd230f82b7397be303b2b56aab60827bfe1
v1.0
instruct
Prefill
Prefill_16379_I
Create a function that calculates the sum of all integers from 1 to `n`. How would you implement this in Python and measure its performance for different values of `n`?
def sum_integers(n): """ Returns the sum of all integers from 1 to n. """ return n * (n + 1) // 2 import time def measure_performance(n): """ Measures the performance of the sum_integers function for a given n. """ start_time = time.time() result = sum_integers(n) end_time = ti...
from solution import sum_integers, measure_performance def test_sum_integers_small_n(): assert sum_integers(1) == 1 assert sum_integers(5) == 15 assert sum_integers(10) == 55 def test_sum_integers_large_n(): assert sum_integers(100) == 5050 assert sum_integers(1000) == 500500 def test_measure_per...
[ { "docstring": "Returns the sum of all integers from 1 to n.", "function_declaration": "def sum_integers(n):", "function_name": "sum_integers", "parameter_list": "(n)" }, { "docstring": "Measures the performance of the sum_integers function for a given n.", "function_declaration": "def m...
[ 1, 0, 1, 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 sum_integers(n):\n \"\"\"\n Returns the sum of all integers from 1 to n.\n \"\"\"\n return n * (n + 1) // 2\n\ndef measure_performance(n_values):\n \"\"\"\n Measures the...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00016379", "row_id": 16379, "seed_ids": "['magpie_prefill_16379']" }
0.758115
Prefill_16379
I
[ "sum_integers", "measure_performance" ]
2
[ [ "measure_performance", "sum_integers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e2e6b812da2d8e827a9f607f6b9a38db3b06575c
cd09e1e26da72d93cf0364eae95e7dd44e0915ab
v1.0
instruct
Prefill
Prefill_16487_I
Create a function that accepts a list of integers and returns the sum of all prime numbers in the list. If there are no prime numbers, the function should return 0.
def is_prime(num): """ Checks if a given 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 sum_of_prim...
from solution import sum_of_primes def test_sum_of_primes_normal_case(): assert sum_of_primes([2, 3, 4, 5, 6, 7, 8, 9]) == 17 def test_sum_of_primes_all_non_primes(): assert sum_of_primes([1, 4, 6, 8, 9, 10, 12, 15]) == 0 def test_sum_of_primes_all_primes(): assert sum_of_primes([2, 3, 5, 7, 11]) == 28 ...
[ { "docstring": "Checks if a given number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers in the given list.\nIf there are no prime numbers, returns 0.", "function_decl...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00016487", "row_id": 16487, "seed_ids": "['magpie_prefill_16487']" }
0.620808
Prefill_16487
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec9686f362bf08eb77bdb3b5d84461a246665ae7
59e020f901427116f92dff8c715904992a57cd83
v1.0
instruct
Prefill
Prefill_16872_I
Create a function that takes a list of lists of numbers called "matrix" as an input and checks if every element in the matrix is a prime number. If every element is prime, the function should return True. Otherwise, it should return False.
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def is_pri...
from solution import is_prime_matrix, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False def test_is_prime_matrix_al...
[ { "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": "Checks if every element in the given matrix is a prime number.\n\nArgs:\n matrix: List of lists of nu...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00016872", "row_id": 16872, "seed_ids": "['magpie_prefill_16872']" }
0.691971
Prefill_16872
I
[ "is_prime", "is_prime_matrix" ]
2
[ [ "is_prime_matrix", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
07ca6c15cdc1702e16e6f4cb883f897e21c55427
901d7fdb55488fab154898cf0a1b73e24866c845
v1.0
instruct
Prefill
Prefill_16888_I
Create a function that checks if a given list of integers contains a prime number. If it does, the function returns True; otherwise, it returns False. You need to do this without using any external libraries.
def is_prime(n): """ Checks if a given number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5)+1, 2): if n % i == 0: return False return True def contains_prime(lst): ...
from solution import contains_prime, 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(-1) == False assert is_prime(0) == False assert is_prime(1) == False assert is_prime(29) == Tru...
[ { "docstring": "Checks if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Checks if a given list of integers contains any prime numbers.", "function_declaration": "def contains_prime(lst):", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n 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_9
{ "original_instruction": "", "prompt_id": "00016888", "row_id": 16888, "seed_ids": "['magpie_prefill_16888']" }
0.692598
Prefill_16888
I
[ "is_prime", "contains_prime" ]
2
[ [ "contains_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d340991b512fee93ab2b0c068375c3f33be374a4
be894ac827363c56e3824a321797f4dc0d690838
v1.0
instruct
Prefill
Prefill_16933_I
Create a function that generates a tuple with the first 10 elements of the Fibonacci sequence. Each element in the tuple should be calculated using a recursive function. Also, make sure to include error handling in your recursive function to prevent infinite recursion and ensure that the function handles cases where th...
def fibonacci_recursive(n, memo={}): """ Returns the n-th Fibonacci number using recursion with memoization. Also includes error handling for invalid input. """ if n < 0: raise ValueError("Input cannot be negative.") elif n == 0: return 0 elif n == 1: return 1 if ...
from solution import generate_fibonacci_sequence, fibonacci_recursive def test_fibonacci_recursive(): assert fibonacci_recursive(0) == 0 assert fibonacci_recursive(1) == 1 assert fibonacci_recursive(2) == 1 assert fibonacci_recursive(3) == 2 assert fibonacci_recursive(4) == 3 assert fibonacci_r...
[ { "docstring": "Returns the n-th Fibonacci number using recursion with memoization.\nAlso includes error handling for invalid input.", "function_declaration": "def fibonacci_recursive(n, memo={}):", "function_name": "fibonacci_recursive", "parameter_list": "(n, memo={})" }, { "docstring": "R...
[ 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 fibonacci(n, memo={0: 0, 1: 1}):\n \"\"\"\n Returns the nth Fibonacci number using a recursive function with memoization.\n \"\"\"\n if n < 0:\n raise ValueError(\"Inpu...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00016933", "row_id": 16933, "seed_ids": "['magpie_prefill_16933']" }
0.707031
Prefill_16933
I
[ "fibonacci_recursive", "generate_fibonacci_sequence" ]
2
[ [ "generate_fibonacci_sequence", "fibonacci_recursive" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5dadd7420cd203513f3bafe7a84d1b7671b4986a
70a86c7267c00fe2146e4a051e6407e35ba2c07e
v1.0
instruct
Prefill
Prefill_17108_I
Create a function that takes a list of integers as input and returns a list of prime numbers found in the input list. Additionally, the function should also return the count of non-prime numbers in the input list.
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def find_primes_and_non_prime_count(numbers): """ Returns a tuple consisting of a l...
from solution import find_primes_and_non_prime_count def test_primes_and_non_prime_count(): assert find_primes_and_non_prime_count([2, 3, 4, 5, 6, 7]) == ([2, 3, 5, 7], 2) assert find_primes_and_non_prime_count([10, 11, 12, 13, 14, 15]) == ([11, 13], 4) assert find_primes_and_non_prime_count([1, 3, 5, 7, 9...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a tuple consisting of a list of prime numbers and the count of non-prime numbers.\n\n:param 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 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_9
{ "original_instruction": "", "prompt_id": "00017108", "row_id": 17108, "seed_ids": "['magpie_prefill_17108']" }
0.741155
Prefill_17108
I
[ "is_prime", "find_primes_and_non_prime_count" ]
2
[ [ "find_primes_and_non_prime_count", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7aafad67e0baabb80a4e965a616f58ef8423975
146c9a885df3de7bb82ec8f0e00b9a730210362b
v1.0
instruct
Prefill
Prefill_17173_I
Create a function that takes an integer as input and returns the largest prime number less than or equal to the input number. If there are no prime numbers less than or equal to the input, return -1.
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import largest_prime_leq def test_largest_prime_leq_prime_input(): assert largest_prime_leq(5) == 5 def test_largest_prime_leq_non_prime_input(): assert largest_prime_leq(10) == 7 def test_largest_prime_leq_no_prime_below(): assert largest_prime_leq(1) == -1 assert largest_prime_leq(0) ...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the largest prime number less than or equal to n.\nIf there are no prime numbers less than or equal...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017173", "row_id": 17173, "seed_ids": "['magpie_prefill_17173']" }
0.620131
Prefill_17173
I
[ "is_prime", "largest_prime_leq" ]
2
[ [ "largest_prime_leq", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bedff051de8c2958b7029380c628de7ecd3dfca0
3a3a609efb54ff8026386d3e23ac032b4f69d074
v1.0
instruct
Prefill
Prefill_17203_I
Create a function that calculates the Fibonacci sequence up to a given number \(N\). The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the two preceding ones. Given that the function is recursive, implement it using Python and ensure to handle the base cases properly.
def fibonacci(n): """ Recursive function to calculate the nth Fibonacci number. """ if n <= 0: return 0 elif n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) def fibonacci_sequence(N): """ Returns the Fibonacci sequence up to the Nth element....
from solution import fibonacci, fibonacci_sequence def test_fibonacci_base_cases(): assert fibonacci(0) == 0 assert fibonacci(1) == 1 def test_fibonacci_recursion(): assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(4) == 3 assert fibonacci(5) == 5 assert fibonacci(6) == 8...
[ { "docstring": "Recursive function to calculate the nth Fibonacci number.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Returns the Fibonacci sequence up to the Nth element.", "function_declaration": "def fibonacci...
[ 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 Fibonacci sequence up to the given number n using recursion.\n The sequence starts with 0 and 1, and each subsequent number is the sum of the...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00017203", "row_id": 17203, "seed_ids": "['magpie_prefill_17203']" }
0.772354
Prefill_17203
I
[ "fibonacci", "fibonacci_sequence" ]
2
[ [ "fibonacci_sequence", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6fb7e6281188e33ed258a741f410bb98f9d7d892
ce4c0dd47c01a6264980045a4904753effa92914
v1.0
instruct
Prefill
Prefill_17273_I
Create a function that generates a matrix with a single path taken from top to bottom, left to right. The path will consist of filled squares (denoted as 'filled') and empty squares (denoted as 'empty'). The function should also provide a method to move and print the path step-by-step on this matrix.
def generate_matrix_with_path(rows, cols, path): """ Generates a matrix with a specific path from top to bottom, left to right. 'path' parameter is a list of tuples representing the coordinates of the filled path. """ # Initialize the matrix with 'empty' matrix = [['empty' for _ in range(cols)] ...
from solution import generate_matrix_with_path, print_matrix, move_and_print_path def test_generate_matrix_with_path(): rows = 3 cols = 3 path = [(0, 0), (0, 1), (0, 2), (1, 2), (2, 2)] expected_matrix = [ ['filled', 'filled', 'filled'], ['empty', 'empty', 'filled'], ['empty', '...
[ { "docstring": "Generates a matrix with a specific path from top to bottom, left to right.\n'path' parameter is a list of tuples representing the coordinates of the filled path.", "function_declaration": "def generate_matrix_with_path(rows, cols, path):", "function_name": "generate_matrix_with_path", ...
[ 0, 0, 0, 0, 0, 1, 1, 0 ]
2
hard
0.25
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_matrix(rows, cols):\n \"\"\"\n Generate a matrix with a single path from top to bottom, left to right.\n 'filled' denotes the path, and 'empty' denotes the empty squares...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00017273", "row_id": 17273, "seed_ids": "['magpie_prefill_17273']" }
0.579389
Prefill_17273
I
[ "generate_matrix_with_path", "print_matrix", "move_and_print_path" ]
3
[ [ "move_and_print_path", "print_matrix" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3ff479343df6348d1a5e175bef4d72c0c3c61aae
f5198b9c9da23a0dddbeb401ab9796e9583a226a
v1.0
instruct
Prefill
Prefill_17450_I
Create a function that takes an integer `n` as an argument and returns the sum of all the integers from 1 to `n` that have a remainder of `r` when divided by `d`. The function should call another auxiliary function `remainder_finder(n, d)` that finds all numbers from 1 to `n` that produce the remainder `r` when divided...
def remainder_finder(n, d, r): """ Returns a list of numbers from 1 to n that produce a remainder r when divided by d. """ result = [] for i in range(1, n+1): if i % d == r: result.append(i) return result def sum_of_remainders(n, d, r): """ Returns the sum of all int...
from solution import sum_of_remainders, remainder_finder def test_remainder_finder(): assert remainder_finder(10, 3, 1) == [1, 4, 7, 10] assert remainder_finder(20, 5, 2) == [2, 7, 12, 17] assert remainder_finder(15, 4, 3) == [3, 7, 11, 15] assert remainder_finder(5, 1, 0) == [1, 2, 3, 4, 5] def test_...
[ { "docstring": "Returns a list of numbers from 1 to n that produce a remainder r when divided by d.", "function_declaration": "def remainder_finder(n, d, r):", "function_name": "remainder_finder", "parameter_list": "(n, d, r)" }, { "docstring": "Returns the sum of all integers from 1 to n th...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def remainder_finder(n, d, r):\n \"\"\"\n Given an integer n, finds all numbers from 1 to n that produce the remainder r when divided by d.\n Returns a list of such numbers.\n \"\...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00017450", "row_id": 17450, "seed_ids": "['magpie_prefill_17450']" }
0.656497
Prefill_17450
I
[ "remainder_finder", "sum_of_remainders" ]
2
[ [ "sum_of_remainders", "remainder_finder" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4bd63314c54c7ccdad051bb2dc6df837b68e9047
8fd898ca640914e384e21426a4d0f95f26a97e91
v1.0
instruct
Prefill
Prefill_17512_I
Create a function that takes in a list of integers and returns a string with each number followed by its corresponding English word.
def number_to_words(n): """ Helper function to convert a single digit number to its corresponding English word. """ words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] return words[n] def list_to_words(nums): """ Takes a list of integers and returns a st...
from solution import list_to_words def test_list_to_words_single_digit(): assert list_to_words([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == "0 zero 1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 eight 9 nine" def test_list_to_words_mixed_range(): assert list_to_words([1, 15, 3]) == "1 one 15 out_of_range 3 three" d...
[ { "docstring": "Helper function to convert a single digit number to its corresponding English word.", "function_declaration": "def number_to_words(n):", "function_name": "number_to_words", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a string with each numb...
[ 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 number_to_words(n):\n \"\"\"\n Converts a single digit number to its corresponding English word.\n \"\"\"\n words = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\",...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00017512", "row_id": 17512, "seed_ids": "['magpie_prefill_17512']" }
0.623462
Prefill_17512
I
[ "number_to_words", "list_to_words" ]
2
[ [ "list_to_words", "number_to_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c1ebeedba3e7034476b7cbbffc1dde0f6b5bad21
1442169aa93cc9814df0c7fc3d88b80b626c0e2f
v1.0
instruct
Prefill
Prefill_17513_I
Create a function that takes a list of numbers and return the sum of all prime numbers in the list. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. The function should ignore non-integer values and negative numbers.
def is_prime(n): """ Checks if the given number n is prime. """ if n <= 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def sum_of_primes(numbers): """ Returns the sum of all prime numbers in the list 'numbers'. ...
from solution import sum_of_primes def test_sum_of_primes_with_primes(): assert sum_of_primes([2, 3, 5, 7, 11]) == 28 def test_sum_of_primes_mixed(): assert sum_of_primes([2, 3, 4, 5, 6, 7]) == 17 def test_sum_of_primes_with_negatives(): assert sum_of_primes([-3, -2, 2, 3]) == 5 def test_sum_of_primes_w...
[ { "docstring": "Checks if the given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the list 'numbers'.", "function_declaration": "def sum_of_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 a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00017513", "row_id": 17513, "seed_ids": "['magpie_prefill_17513']" }
0.679336
Prefill_17513
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0f79496d896e8264f1d33d04ab1c7073f1b68ce
ddebc5f48c6b4629f0b0bae3dcc7abba068ba3d6
v1.0
instruct
Prefill
Prefill_17591_I
Create a function that takes the root of a binary tree and converts it to a binary search tree (BST) in-place. The conversion should maintain the original structure of the binary tree as much as possible. You can assume that the original binary tree does not contain duplicates.
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def inorder_traversal(node, values): if node: inorder_traversal(node.left, values) values.append(node.val) inorder_traversal(node.right, values) ...
from solution import TreeNode, binary_tree_to_bst def test_binary_tree_to_bst_single_node(): root = TreeNode(10) bst = binary_tree_to_bst(root) assert bst.val == 10 assert bst.left == None assert bst.right == None def test_binary_tree_to_bst_basic(): root = TreeNode(10) root.left = TreeNod...
[]
[ 0, 0, 1, 0, 1, 1, 1, 1, 0, 1 ]
6
medium
0.6
{ "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 binary_tree_to_bst(root):\n \"\"...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00017591", "row_id": 17591, "seed_ids": "['magpie_prefill_17591']" }
0.543872
Prefill_17591
I
[ "inorder_traversal", "rebuild_bst", "binary_tree_to_bst" ]
3
[ [ "binary_tree_to_bst", "inorder_traversal" ], [ "binary_tree_to_bst", "rebuild_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
32db18c813ac1dd6b5e57bb58c56078f10bcaef7
d5a294d742b42ea82183b9d0f84112571dc9f05c
v1.0
instruct
Prefill
Prefill_17636_I
Create a function that determines if a given binary tree is a binary search tree (BST). The function should accept a root node of a binary tree as its parameter and return True if the tree is a BST, otherwise False. In a binary search tree, for every node, the left child must have a value less than the node, and the ri...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def is_bst_helper(node, lower_bound, upper_bound): if node is None: return True if node.val <= lower_bound or node.val >= upper_bound: return False return (is_bst_helper(node.l...
from solution import TreeNode, is_bst def test_is_bst_true(): root = TreeNode(2) root.left = TreeNode(1) root.right = TreeNode(3) assert is_bst(root) == True def test_is_bst_false(): root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(3) assert is_bst(root) == False def t...
[]
[ 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": "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_bst_helper(node, lower=float('-i...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00017636", "row_id": 17636, "seed_ids": "['magpie_prefill_17636']" }
0.648419
Prefill_17636
I
[ "is_bst_helper", "is_bst" ]
2
[ [ "is_bst", "is_bst_helper" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
38f00be341c8ed3a8b5cfbbc02b273f1091ccb55
9e2aaa8da9e3eee2c75e2e50c6ee21fa0bb57c8d
v1.0
instruct
Prefill
Prefill_17798_I
Create a function that takes a list of integers and returns a new list of all the prime numbers in the input list. The order of the prime numbers in the output list should be the same as their order in the input list.
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True d...
from solution import extract_primes def test_extract_primes_all_primes(): assert extract_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_extract_primes_no_primes(): assert extract_primes([1, 4, 6, 8, 9, 10]) == [] def test_extract_primes_mixed(): assert extract_primes([10, 15, 3, 8, 7, 4, 11, 28]) ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a new list of the prime numbers in the input list.", "function_declaration": "def extract_pri...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00017798", "row_id": 17798, "seed_ids": "['magpie_prefill_17798']" }
0.655543
Prefill_17798
I
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ae9feb49f921fcca14b1ee4fe6aca5b7ec8eeb7a
08a96c476c0aa6eaf85a4c99eb404ce34b0cfca2
v1.0
instruct
Prefill
Prefill_17806_I
Create a function that takes a number as input and returns a string indicating whether the number is "Even", "Odd", or "Prime". If the number is prime, also indicate whether it is a "Composite Prime" or a "Single Prime". A "Composite Prime" is a number that is a prime and also has divisors other than 1 and itself (i.e....
def is_prime(num): if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def classify_number(num): if num % 2 == 0: if is_prime(num): return "Single Prime" if num in [2,3,5] else "Even Composite Prime" ...
from solution import classify_number def test_even_numbers(): assert classify_number(2) == "Single Prime" assert classify_number(4) == "Even" assert classify_number(6) == "Even" assert classify_number(10) == "Even" assert classify_number(8) == "Even" assert classify_number(12) == "Even" def te...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def classify_number(num):", "function_name": "classify_number", "parameter_list": "(num)" } ]
[ 0, 1, 0, 1, 1, 1, 1, 0, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_number_type(num):\n \"\"\"\n Checks if the given number is \"Even\", \"Odd\", or \"Prime\".\n If the number is prime, further classify it as \"Single Prime\" or \"Composite...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00017806", "row_id": 17806, "seed_ids": "['magpie_prefill_17806']" }
0.721624
Prefill_17806
I
[ "is_prime", "classify_number" ]
2
[ [ "classify_number", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f624ae82b33f42eca844e74de2afb4b01fc5de67
c54d78d9c7d9db90413acdec1859b3ba54215adb
v1.0
instruct
Prefill
Prefill_17849_I
Create a function that generates a list of prime numbers that are also Fibonacci numbers within a given range. For example, the function should take the range [2, 100] as input and return [2, 3, 5, 13], as these are the prime and Fibonacci numbers within the range. The function should be efficient and handle large rang...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def fibonacci_up_to(n): """ ...
from solution import prime_fibonacci_in_range def test_prime_fibonacci_in_range_standard_case(): assert prime_fibonacci_in_range(2, 100) == [2, 3, 5, 13, 89] def test_prime_fibonacci_in_range_no_primes(): assert prime_fibonacci_in_range(4, 4) == [] def test_prime_fibonacci_in_range_single_prime(): assert...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate Fibonacci numbers up to n.", "function_declaration": "def fibonacci_up_to(n):", "function_name": "fibonacci_up_to...
[ 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": "import sympy\n\ndef generate_fibonacci_primes(start, end):\n \"\"\"\n Returns a list of numbers that are both prime and Fibonacci within the given range.\n \"\"\"\n\n def is_fibon...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00017849", "row_id": 17849, "seed_ids": "['magpie_prefill_17849']" }
0.672774
Prefill_17849
I
[ "is_prime", "fibonacci_up_to", "prime_fibonacci_in_range" ]
3
[ [ "prime_fibonacci_in_range", "fibonacci_up_to" ], [ "prime_fibonacci_in_range", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f7b171c81864db5bfc4fe80c7c02f0a2f41d0fcc
6500e797099fed13890ac042521c5784f3b73c4a
v1.0
instruct
Prefill
Prefill_17854_I
Create a function that determines the total number of 3x3 magic squares within a 9x9 grid. A magic square is a square grid with a specific arrangement of its elements such that the sum of each column, each row, and both main diagonals are all the same. The elements of the magic square must always be integers between 1 ...
def is_magic_square(square): """ Check if a given 3x3 square is a magic square. """ s = 15 # The magic constant for a 3x3 magic square with numbers 1 to 9 # Check rows and columns for i in range(3): if sum(square[i]) != s or sum([row[i] for row in square]) != s: return False...
from solution import count_3x3_magic_squares def test_no_magic_squares(): grid = [[i for i in range(9)] for _ in range(9)] assert count_3x3_magic_squares(grid) == 0 def test_single_magic_square(): grid = [[8, 1, 6, 0, 0, 0, 0, 0, 0], [3, 5, 7, 0, 0, 0, 0, 0, 0], [4, 9, 2, 0, 0, 0, ...
[ { "docstring": "Check if a given 3x3 square is a magic square.", "function_declaration": "def is_magic_square(square):", "function_name": "is_magic_square", "parameter_list": "(square)" }, { "docstring": "Counts the number of 3x3 magic squares within a 9x9 grid.", "function_declaration":...
[ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magic_square(grid):\n \"\"\"\n Determines if a given 3x3 grid is a magic square.\n \"\"\"\n # Sum of all rows, columns and diagonals must be equal and be exactly 15.\n m...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017854", "row_id": 17854, "seed_ids": "['magpie_prefill_17854']" }
0.799432
Prefill_17854
I
[ "is_magic_square", "count_3x3_magic_squares" ]
2
[ [ "count_3x3_magic_squares", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5a3f574215791a8efcd3fd138a40f00ca4c4b22e
7e407fc17f88d44d2cbdea90b70c843fc6c5d193
v1.0
instruct
Prefill
Prefill_17929_I
Create a function that generates a list of all the prime numbers within a given range, including both the start and end numbers. The function should be efficient and handle large ranges effectively.
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def generate_primes(start, end): """ G...
from solution import generate_primes def test_generate_primes_range_with_primes(): assert generate_primes(10, 20) == [11, 13, 17, 19] def test_generate_primes_no_primes_in_range(): assert generate_primes(14, 16) == [] def test_generate_primes_single_prime_in_range(): assert generate_primes(25, 29) == [29...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of all prime numbers within the given range [start, end].\n\nParameters:\nstart (int): The starting number of the range.\nend (int): The e...
[ 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00017929", "row_id": 17929, "seed_ids": "['magpie_prefill_17929']" }
0.61349
Prefill_17929
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1451b365a45d1725b7454b57dcf8eb460f14fba6
24609855a06c250ebfaaa7c08809519a3b198efe
v1.0
instruct
Prefill
Prefill_18059_I
Create a function that generates a string containing all the prime numbers less than n, concatenated together in ascending order.
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def c...
from solution import concatenate_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(11) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_concatenate_pri...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a string containing all the prime numbers less than n, concatenated together in ascending order."...
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 =...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00018059", "row_id": 18059, "seed_ids": "['magpie_prefill_18059']" }
0.615809
Prefill_18059
I
[ "is_prime", "concatenate_primes" ]
2
[ [ "concatenate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bc35d53f6fd6daa3e2fe2a4d7da3637888dbbc27
f1b6222c5faf2703fd2936bad8079059e9a6cb10
v1.0
instruct
Prefill
Prefill_18123_I
Create a function that takes a length and a width and outputs a polygon with those dimensions. Assuming a square for simplicity. For additional programming practice, create a user interface where the user can input the length and width, and display the resulting polygon. You can use any library you prefer.
import matplotlib.pyplot as plt import numpy as np def create_polygon(length, width): """ Creates a polygon (for simplicity, a rectangle) with the given length and width. Parameters: - length: The length of the polygon. - width: The width of the polygon. Returns: - A list of vertices repr...
from solution import create_polygon, plot_polygon def test_create_polygon_square(): vertices = create_polygon(5, 5) expected_vertices = [(0, 0), (5, 0), (5, 5), (0, 5), (0, 0)] assert vertices == expected_vertices def test_create_polygon_rectangle(): vertices = create_polygon(3, 6) expected_vertic...
[ { "docstring": "Creates a polygon (for simplicity, a rectangle) with the given length and width.\n\nParameters:\n- length: The length of the polygon.\n- width: The width of the polygon.\n\nReturns:\n- A list of vertices representing the polygon.", "function_declaration": "def create_polygon(length, width):"...
[ 1, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_square(length, width):\n \"\"\"\n Generates a string representation of a polygon (square/rectangle).\n \"\"\"\n if length < 1 or width < 1:\n raise ValueError(...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00018123", "row_id": 18123, "seed_ids": "['magpie_prefill_18123']" }
0.562851
Prefill_18123
I
[ "create_polygon", "plot_polygon", "user_interface" ]
3
[ [ "user_interface", "create_polygon" ], [ "user_interface", "plot_polygon" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
a65a8838ef78609d169a9a9a5a34a91e9b4dccc5
5f1596fcd3d66659b25ee9762f5fd2cb171cbe90
v1.0
instruct
Prefill
Prefill_18259_I
Create a function that can generate the number of permutations for a given set of values. I want to understand the concept and implement it in Python. Could you walk me through the process step by-step?
def factorial(n): """ Returns the factorial of a given number n. """ if n == 0 or n == 1: return 1 result = 1 for i in range(2, n+1): result *= i return result def number_of_permutations(n): """ Returns the number of permutations for a set of n distinct values. "...
from solution import factorial, number_of_permutations def test_factorial_base_cases(): assert factorial(0) == 1 assert factorial(1) == 1 def test_factorial(): assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 assert factorial(5) == 120 assert factorial(6) == 720 ...
[ { "docstring": "Returns the factorial of a given number n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Returns the number of permutations for a set of n distinct values.", "function_declaration": "def number_of_p...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef number_of_permutations(n):\n \"\"\"\n Returns the number of permutations for a set of n elements.\n \"\"\"\n if n < 0:\n raise ValueError(\"The number of...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00018259", "row_id": 18259, "seed_ids": "['magpie_prefill_18259']" }
0.581058
Prefill_18259
I
[ "factorial", "number_of_permutations" ]
2
[ [ "number_of_permutations", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
406d59859000f7accd6cdcd827cb07d4c6040519
4d9ffe91b0d4527e7bad034007015970ab498dbd
v1.0
instruct
Prefill
Prefill_18301_I
Create a function that takes a list of integers and returns the number of integers that are prime. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 2, 3, 5, and 7 are prime numbers.
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def count_pri...
from solution import count_primes def test_count_primes_with_empty_list(): assert count_primes([]) == 0 def test_count_primes_all_primes(): assert count_primes([2, 3, 5, 7, 11]) == 5 def test_count_primes_no_primes(): assert count_primes([1, 4, 6, 8, 9, 10]) == 0 def test_count_primes_mixed_numbers(): ...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the count of prime numbers in the list nums.", "function_declaration": "def count_primes(nums):",...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 ==...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00018301", "row_id": 18301, "seed_ids": "['magpie_prefill_18301']" }
0.690382
Prefill_18301
I
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0ef2701491b467d743f04e3790739c0ddc6b0bb5
96a456a0dafd4bcd11605b89ee9e38785e873362
v1.0
instruct
Prefill
Prefill_18354_I
Create a function that takes an array of integers as an argument and returns the count of prime numbers in the array. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. For simplicity, assume the array will not contain any non-integer values or less than zero values.
import math def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def count_primes(...
from solution import count_primes def test_count_primes_all_primes(): assert count_primes([2, 3, 5, 7, 11]) == 5 def test_count_primes_mix(): assert count_primes([1, 2, 4, 5, 6, 7, 8, 9, 10, 11]) == 4 def test_count_primes_no_primes(): assert count_primes([4, 6, 8, 9, 10, 12]) == 0 def test_count_primes...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the count of prime numbers in an array of integers.", "function_declaration": "def count_primes(arr):", "function_name": "count_primes"...
[ 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00018354", "row_id": 18354, "seed_ids": "['magpie_prefill_18354']" }
0.74767
Prefill_18354
I
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e3e02509bcd0b8c6187a82ba44f3e64cc63290c5
e99350126e16f5cc7290dcf2f7781388f66b6775
v1.0
instruct
Prefill
Prefill_18375_I
Create a function that takes an array of integers and a target value as parameters. The function should use the quicksort algorithm to sort the array. After sorting, the function should search for the target value in the sorted array. If the target value is found, return the index of the target value; otherwise, return...
def quicksort(arr): """ Quicksort algorithm to sort the array. """ if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quicksort(left) + middle + quic...
from solution import quicksort_and_search def test_quicksort_and_search_found(): assert quicksort_and_search([4, 2, 6, 3, 1, 5], 3) == 2 # Sorted array is [1, 2, 3, 4, 5, 6] def test_quicksort_and_search_not_found(): assert quicksort_and_search([4, 2, 6, 3, 1, 5], 7) == -1 def test_quicksort_and_search_empt...
[ { "docstring": "Quicksort algorithm to sort the array.", "function_declaration": "def quicksort(arr):", "function_name": "quicksort", "parameter_list": "(arr)" }, { "docstring": "Binary search algorithm to find the target value in the sorted array.", "function_declaration": "def binary_s...
[ 0, 0, 1, 1, 1, 0, 0, 0, 1, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quicksort(arr):\n \"\"\"\n Implements the quicksort algorithm to sort an array in ascending order.\n \"\"\"\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) /...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00018375", "row_id": 18375, "seed_ids": "['magpie_prefill_18375']" }
0.547824
Prefill_18375
I
[ "quicksort", "binary_search", "quicksort_and_search" ]
3
[ [ "quicksort_and_search", "binary_search" ], [ "quicksort_and_search", "quicksort" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7f207b325d1adb7a544d4aff5440e7dcb3c3c88c
235864cbe679742b4b9ab178c803de8c160050f4
v1.0
instruct
Prefill
Prefill_18443_I
Create a function that generates a random five-letter word using the characters 'a', 'b', and 'c'. The function should return the word as a string. Additionally, you must ensure that the word generated by the function is not a subsequence of another previously generated word.
import random previously_generated_words = set() def generate_random_word(): chars = 'abc' while True: word = ''.join(random.choices(chars, k=5)) if not any(is_subsequence(word, prev_word) for prev_word in previously_generated_words): previously_generated_words.add(word) ...
from solution import generate_random_word, is_subsequence def test_is_subsequence(): assert is_subsequence("abc", "aabbcc") assert is_subsequence("abc", "abc") assert not is_subsequence("abc", "ab") assert not is_subsequence("abc", "bac") assert not is_subsequence("abc", "cab") def test_generate_r...
[ { "docstring": null, "function_declaration": "def generate_random_word():", "function_name": "generate_random_word", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def is_subsequence(sub, string):", "function_name": "is_subsequence", "parameter_list": "(s...
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\npreviously_generated_words = set()\n\ndef generate_random_word():\n chars = 'abc'\n while True:\n word = ''.join(random.choices(chars, k=5))\n if not any(...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00018443", "row_id": 18443, "seed_ids": "['magpie_prefill_18443']" }
0.711988
Prefill_18443
I
[ "generate_random_word", "is_subsequence" ]
2
[ [ "generate_random_word", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13a2b48b82b3b8e42a3b2916d9c7f0d6bbc87f4a
937a888aad1de62279df08a8134fed07d588b1a3
v1.0
instruct
Prefill
Prefill_18540_I
Create a function that generates a list of Fibonacci numbers up to a specified length. The function should take two parameters: the length of the list and the type of sequence (either 'fibonacci' or 'luhn'). The 'fibonacci' type should generate the traditional Fibonacci sequence, while the 'luhn' type should generate n...
def generate_sequence(length, sequence_type): """ Generates a sequence of numbers up to a specified length. Parameters: length (int): Length of the list (number of terms in the sequence). sequence_type (str): Type of sequence, either 'fibonacci' or 'luhn'. Returns: list: A list of ...
from solution import generate_sequence def test_generate_fibonacci_sequence(): assert generate_sequence(0, 'fibonacci') == [] assert generate_sequence(1, 'fibonacci') == [0] assert generate_sequence(2, 'fibonacci') == [0, 1] assert generate_sequence(5, 'fibonacci') == [0, 1, 1, 2, 3] assert generat...
[ { "docstring": "Generates a sequence of numbers up to a specified length.\n\nParameters:\nlength (int): Length of the list (number of terms in the sequence).\nsequence_type (str): Type of sequence, either 'fibonacci' or 'luhn'.\n\nReturns:\nlist: A list of numbers in the specified sequence.", "function_decl...
[ 1, 0, 0, 0, 0, 1, 0, 1, 1, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_sequence(length, sequence_type):\n \"\"\"\n Generates a list of numbers up to a specified length of the selected type of sequence.\n \n Parameters:\n - length (int...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00018540", "row_id": 18540, "seed_ids": "['magpie_prefill_18540']" }
0.696791
Prefill_18540
I
[ "generate_sequence", "generate_fibonacci", "generate_luhn" ]
3
[ [ "generate_sequence", "generate_fibonacci" ], [ "generate_sequence", "generate_luhn" ] ]
2
[]
false
[]
false
pytest
true
[]
true
796a74fa17f83310e8ad133fe188d4da6ba26110
c08449a7e5d8fe41104dd44318731125cbe15c87
v1.0
instruct
Prefill
Prefill_18564_I
Create a function that takes a list of integers as an input, and returns the sum of all prime numbers in the list. A prime number is defined as a number that is greater than 1 and has no divisors other than 1 and itself.
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def sum_prime...
from solution import sum_primes def test_sum_primes_basic(): assert sum_primes([1, 2, 3, 4, 5]) == 10 assert sum_primes([10, 11, 12, 13]) == 24 assert sum_primes([2, 3, 5, 7, 11]) == 28 def test_sum_primes_empty_list(): assert sum_primes([]) == 0 def test_sum_primes_no_primes(): assert sum_primes...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the provided list 'numbers'.", "function_declaration": "def sum_pri...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00018564", "row_id": 18564, "seed_ids": "['magpie_prefill_18564']" }
0.67668
Prefill_18564
I
[ "is_prime", "sum_primes" ]
2
[ [ "sum_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d8da38e7a881be2689d3b11659a505ad9d55a526
7c7ae2f6d599e71ca6d78ba160cfe0245a18f37c
v1.0
instruct
Prefill
Prefill_18638_I
Create a function that takes two integers num1 and num2 as input and returns true if the sum of num1 and num2 is a prime number, false otherwise. A function called "is_prime" is provided as a utility for checking primality.
def is_prime(n): """ Check if the number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, is_sum_prime def test_is_sum_prime_with_prime_sum(): assert is_sum_prime(2, 3) == True assert is_sum_prime(3, 4) == True def test_is_sum_prime_with_non_prime_sum(): assert is_sum_prime(2, 2) == False assert is_sum_prime(3, 3) == False def test_is_sum_prime_with_zero(): ...
[ { "docstring": "Check if the number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Check if the sum of num1 and num2 is a prime number.", "function_declaration": "def is_sum_prime(num1, num2):", ...
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00018638", "row_id": 18638, "seed_ids": "['magpie_prefill_18638']" }
0.699939
Prefill_18638
I
[ "is_prime", "is_sum_prime" ]
2
[ [ "is_sum_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ba662f2b90b2cc5359369c8e5460019be09eaf3
987dc47b55401d32e0fe01d47898b7232a2381a9
v1.0
instruct
Prefill
Prefill_18656_I
Create a function that generates the Fibonacci sequence up to the nth term. The function should be able to reach at least up to 100 terms without taking too long to compute. To achieve this, you can implement a caching mechanism to store previously computed terms of the Fibonacci sequence. This will help reduce the com...
def fibonacci(n, computed={0: 0, 1: 1}): """ Returns the Fibonacci sequence up to the nth term. This implementation uses caching to improve performance for larger values of n. """ if n not in computed: computed[n] = fibonacci(n - 1, computed) + fibonacci(n - 2, computed) return computed[...
from solution import generate_fibonacci_sequence def test_generate_fibonacci_sequence(): assert generate_fibonacci_sequence(1) == [0] assert generate_fibonacci_sequence(2) == [0, 1] assert generate_fibonacci_sequence(5) == [0, 1, 1, 2, 3] assert generate_fibonacci_sequence(10) == [0, 1, 1, 2, 3, 5, 8, ...
[ { "docstring": "Returns the Fibonacci sequence up to the nth term.\nThis implementation uses caching to improve performance for larger values of n.", "function_declaration": "def fibonacci(n, computed={0: 0, 1: 1}):", "function_name": "fibonacci", "parameter_list": "(n, computed={0: 0, 1: 1})" }, ...
[ 1, 1, 1, 1, 0, 1, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci(n, cache = {0: 0, 1: 1}):\n \"\"\"\n Generates the Fibonacci sequence up to the nth term using a caching mechanism.\n \"\"\"\n if n in cache:\n return cache[n...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00018656", "row_id": 18656, "seed_ids": "['magpie_prefill_18656']" }
0.661438
Prefill_18656
I
[ "fibonacci", "generate_fibonacci_sequence" ]
2
[ [ "generate_fibonacci_sequence", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9d2916abce1a33227c4765f67052995b9e1dd111
150c9e05fe835451b2ccdb7e19fdc83a802d524b
v1.0
instruct
Prefill
Prefill_18724_I
Create a function that takes a list of integers and returns a list of strings representing the integer values as Roman numerals. The function should also handle numbers in the range of 1 to 3999.
def int_to_roman(num): """ Converts an integer to a roman numeral string. :param num: int :return: str """ val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syb = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX",...
from solution import list_to_roman def test_list_to_roman_single_number(): assert list_to_roman([1]) == ['I'] assert list_to_roman([3999]) == ['MMMCMXCIX'] def test_list_to_roman_multiple_numbers(): assert list_to_roman([1, 2, 3, 4, 5]) == ['I', 'II', 'III', 'IV', 'V'] assert list_to_roman([10, 20, 30...
[ { "docstring": "Converts an integer to a roman numeral string.\n:param num: int\n:return: str", "function_declaration": "def int_to_roman(num):", "function_name": "int_to_roman", "parameter_list": "(num)" }, { "docstring": "Converts a list of integers to a list of roman numeral strings.\n:pa...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def int_to_roman(num):\n \"\"\"\n Convert an integer to a Roman numeral.\n \"\"\"\n val = [\n 1000, 900, 500, 400,\n 100, 90, 50, 40,\n 10, 9, 5, 4,\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00018724", "row_id": 18724, "seed_ids": "['magpie_prefill_18724']" }
0.64169
Prefill_18724
I
[ "int_to_roman", "list_to_roman" ]
2
[ [ "list_to_roman", "int_to_roman" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b1c182f8bdbf217925733c3cff65916327f5a4d1
db35757616e17235e85f925d69c650648d0ebdc7
v1.0
instruct
Prefill
Prefill_18749_I
Create a function that identifies all the prime numbers within a given list of integers. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself.
def is_prime(num): """ Returns True if num is a prime number, else False. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True d...
from solution import is_prime, identify_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(20) == False assert is_prime(1) == False assert is_prime(-5) == False assert is_prime(0) == F...
[ { "docstring": "Returns True if num is a prime number, else False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Identifies all the prime numbers within a given list of integers.\n\n:param numbers: List of integers\n...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise returns False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00018749", "row_id": 18749, "seed_ids": "['magpie_prefill_18749']" }
0.658812
Prefill_18749
I
[ "is_prime", "identify_primes" ]
2
[ [ "identify_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e62a8d7c01536d0e5dac06b7214d64a9d785560
d11296e72d8005cef8883fcc781d6d0fa9617960
v1.0
instruct
Prefill
Prefill_18773_I
Create a function that checks if a list of numbers contains only prime numbers. Return True if all numbers are prime, otherwise return False.
def is_prime(num): if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def all_primes(numbers): """ Checks if all numbers in the list are prime. Parameters: numbers (list of int): List of numbers to be ch...
from solution import all_primes def test_all_primes_with_only_prime_numbers(): assert all_primes([2, 3, 5, 7, 11]) == True def test_all_primes_with_one_non_prime_number(): assert all_primes([2, 3, 4, 5, 7]) == False def test_all_primes_with_empty_list(): assert all_primes([]) == True def test_all_pr...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Checks if all numbers in the list are prime.\n\nParameters:\nnumbers (list of int): List of numbers to be checked.\n\nReturns:\nbool: True if all numbe...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00018773", "row_id": 18773, "seed_ids": "['magpie_prefill_18773']" }
0.728945
Prefill_18773
I
[ "is_prime", "all_primes" ]
2
[ [ "all_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a783727eaffb264deafc64902faa4ea1674fadd9
b7c05e67c78c56135281bcc2bdfd866546ad1af7
v1.0
instruct
Prefill
Prefill_18774_I
Create a function that takes a variable amount of arguments and calculates their sum. If the sum is a prime number, return the sum, otherwise, return an array containing the sum and the next prime number after the sum.
def is_prime(n): """ Checks if the provided number 'n' is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import sum_and_check_prime def test_sum_and_check_prime_all_prime(): assert sum_and_check_prime(2, 3) == 5 def test_sum_and_check_prime_non_prime(): assert sum_and_check_prime(4, 6) == [10, 11] def test_sum_and_check_prime_empty(): assert sum_and_check_prime() == [0, 2] def test_sum_and_ch...
[ { "docstring": "Checks if the provided number 'n' is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds the next prime number greater than the provided number 'n'.", "function_declaration": "def next...
[ 1, 1, 0, 0, 1, 0, 0, 1, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Return True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00018774", "row_id": 18774, "seed_ids": "['magpie_prefill_18774']" }
0.678464
Prefill_18774
I
[ "is_prime", "next_prime", "sum_and_check_prime" ]
3
[ [ "next_prime", "is_prime" ], [ "sum_and_check_prime", "is_prime" ], [ "sum_and_check_prime", "next_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
9d680fc75de28cf49d8a9f885f9a73a64c5aebd9
089c83e6371690d2318baa2fa0ebcb245cf68754
v1.0
instruct
Prefill
Prefill_18814_I
Create a function that checks if a number is prime. The function should take two parameters: a start and an end number.
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def primes_in_range(start, end): """ Returns a list of prime numbers between s...
from solution import is_prime, primes_in_range def test_is_prime_basic(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False def test_is_prime_edge_cases(): assert is_prime(0) == False assert is_prime(1) == False assert is_prime(29) == True assert is_prime(87...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers between start and end, inclusive.", "function_declaration": "def pri...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1 ]
8
easy
0.889
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a single number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00018814", "row_id": 18814, "seed_ids": "['magpie_prefill_18814']" }
0.693306
Prefill_18814
I
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3cd2f61f2ae70dc1c880f192beb6ed52405c2b11
a39634b089580ddc2d01386d91923c8e20035185
v1.0
instruct
Prefill
Prefill_18882_I
Create a function that takes in a list of integers and returns the sum of the prime numbers in the list. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. If there are no prime numbers in the list, the function should return 0.
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False # other even numbers are not prime for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: ...
from solution import sum_of_primes def test_sum_of_primes_with_primes(): assert sum_of_primes([2, 3, 5, 7]) == 17 def test_sum_of_primes_with_non_primes(): assert sum_of_primes([4, 6, 8, 9]) == 0 def test_sum_of_primes_with_mixed_numbers(): assert sum_of_primes([2, 4, 5, 6, 7]) == 14 def test_sum_of_pri...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of prime numbers in the list.", "function_declaration": "def sum_of_primes(lst):", "function_name": "sum_o...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00018882", "row_id": 18882, "seed_ids": "['magpie_prefill_18882']" }
0.656358
Prefill_18882
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
45e53d371939beed1cc204fb662a423d449dc1e7
e5cf9c3397fa7ace5766ecd204a1e14be36c4f7e
v1.0
instruct
Prefill
Prefill_18966_I
Create a function that takes three integers as input and prints the greatest common divisor (GCD) of the three numbers using the Euclidean algorithm. The Euclidean algorithm to find the GCD of two numbers is based on the principle that the GCD of two numbers also divides their difference. Extend this concept to three n...
def gcd(a, b): while b: a, b = b, a % b return a def gcd_of_three(a, b, c): """ Returns the GCD of three numbers a, b, and c. """ first_gcd = gcd(a, b) return gcd(first_gcd, c) # Example usage gcd_of_three(48, 64, 80)
from solution import gcd_of_three, gcd def test_gcd(): assert gcd(48, 64) == 16 assert gcd(64, 80) == 16 assert gcd(100, 25) == 25 assert gcd(25, 0) == 25 assert gcd(0, 25) == 25 def test_gcd_of_three(): assert gcd_of_three(48, 64, 80) == 16 assert gcd_of_three(14, 21, 28) == 7 assert ...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the GCD of three numbers a, b, and c.", "function_declaration": "def gcd_of_three(a, b, c):", "function_name": "gcd_of_three", "parameter_l...
[ 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Returns the GCD of two numbers using the Euclidean algorithm.\n \"\"\"\n while b != 0:\n a, b = b, a % b\n return a\n\ndef gcd_of_three(a, b, c...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00018966", "row_id": 18966, "seed_ids": "['magpie_prefill_18966']" }
0.654264
Prefill_18966
I
[ "gcd", "gcd_of_three" ]
2
[ [ "gcd_of_three", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4088c78f0ef17ee40e47e5bcce1a53d3955dd14e
b85353e4ec49a544c2b438690299e2d966994234
v1.0
instruct
Prefill
Prefill_18984_I
Create a function that calculates the sum of all prime numbers up to but not including a given integer `n`.
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def sum_primes_below(n): """ Returns the sum of all prime numbers below a g...
from solution import sum_primes_below, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(0) == False assert is_prime(1) == False def test_sum_primes_below(): assert sum_primes_below(10)...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers below a given integer n.", "function_declaration": "def sum_pr...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime. \n Returns True if num is prime, False otherwise.\n \"\"\"\n if num <= 1:\n return False\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00018984", "row_id": 18984, "seed_ids": "['magpie_prefill_18984']" }
0.622344
Prefill_18984
I
[ "is_prime", "sum_primes_below" ]
2
[ [ "sum_primes_below", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a1ac905247bf0588221a8e1b61e0d021f580ea5
ebd7124fde4c59ac461853d40ebdbcd5f3d3b6da
v1.0
instruct
Prefill
Prefill_19088_I
Create a function that takes a list of integers and returns a new list with boolean values indicating the primality of each number in the input list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def list_prime_indicators(numbers...
from solution import list_prime_indicators def test_list_prime_indicators_with_mixed_numbers(): assert list_prime_indicators([2, 3, 4, 5, 10, 11, 13, 14, 17, 18]) == [True, True, False, True, False, True, True, False, True, False] def test_list_prime_indicators_with_primes_only(): assert list_prime_indicators...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a new list with boolean values indicating the primality of each number.", "function_de...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 ==...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00019088", "row_id": 19088, "seed_ids": "['magpie_prefill_19088']" }
0.705012
Prefill_19088
I
[ "is_prime", "list_prime_indicators" ]
2
[ [ "list_prime_indicators", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8ac9d0b51c1bb4d2cfd8f833cf4ef78cee7ff4fb
3573c7005c616396e5a1587611a75a29f22cdda6
v1.0
instruct
Prefill
Prefill_19121_I
Create a function that takes a list of strings and returns a new list containing the substrings from the given string list, but only if the substrings consonants are more than vowels.
def is_consonant(ch): """ Check if a character is a consonant. """ return ch.lower() in 'bcdfghjklmnpqrstvwxyz' def count_consonants_and_vowels(s): """ Return a tuple with counts of consonants and vowels in a given string. """ consonants_count = sum(1 for ch in s if is_consonant(ch)) ...
from solution import filter_strings_with_more_consonants def test_single_string_with_more_consonants(): assert filter_strings_with_more_consonants(['hello']) == ['hello'] def test_single_string_with_more_vowels(): assert filter_strings_with_more_consonants(['aerie']) == [] def test_multiple_strings_mixed(): ...
[ { "docstring": "Check if a character is a consonant.", "function_declaration": "def is_consonant(ch):", "function_name": "is_consonant", "parameter_list": "(ch)" }, { "docstring": "Return a tuple with counts of consonants and vowels in a given string.", "function_declaration": "def count...
[ 0, 0, 1, 1, 0, 0, 1, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def substrings_with_more_consonants_than_vowels(string_list):\n \"\"\"\n Returns a new list containing the substrings from the given string list,\n but only if the substrings have mo...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00019121", "row_id": 19121, "seed_ids": "['magpie_prefill_19121']" }
0.697243
Prefill_19121
I
[ "is_consonant", "count_consonants_and_vowels", "filter_strings_with_more_consonants" ]
3
[ [ "count_consonants_and_vowels", "is_consonant" ], [ "filter_strings_with_more_consonants", "count_consonants_and_vowels" ] ]
2
[]
false
[]
false
pytest
true
[]
true
57b4dfb333ef01f75a7dfeb1334349cea778486e
cdd0ba7c4ad56f1f28df3b8ac7099f9eedbaee13
v1.0
instruct
Prefill
Prefill_19154_I
Create a function that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. For example, given a list [1, 2, 3, 4, 5, 6], the function should return [2, 3, 5].
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def filter_...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_some_non_primes(): assert filter_primes([1, 2, 3, 4, 5, 6]) == [2, 3, 5] def test_filter_primes_no_primes(): assert filter_primes([1, 4, 6, 8, 9, 10]) ...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.", "function_declaration": ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\ndef filter_primes(numbers...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00019154", "row_id": 19154, "seed_ids": "['magpie_prefill_19154']" }
0.661006
Prefill_19154
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dc4a5f4a77e3dce3a2ff9c9183874b4c2a4ac6e4
8acfa219943cda011af65dec30e82f164f93f847
v1.0
instruct
Prefill
Prefill_19299_I
Create a function that receives a number and returns the smallest prime number that is greater or equal to the given number. If no such prime number exists (for example, if the input is less than 2), the function should return `None`.
def is_prime(n): """ Checks if a given number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5)+1, 2): if n % i == 0: return False return True def smallest_prime_greater_or...
from solution import is_prime, smallest_prime_greater_or_equal def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-7) == False def test_sm...
[ { "docstring": "Checks if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number that is greater or equal to the given number n.\nIf no such prime number exists, return...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while (i * i) <= n:\n ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00019299", "row_id": 19299, "seed_ids": "['magpie_prefill_19299']" }
0.598247
Prefill_19299
I
[ "is_prime", "smallest_prime_greater_or_equal" ]
2
[ [ "smallest_prime_greater_or_equal", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a2ece87a9719f231a604373ced8dcc55b6b62960
e97c58460a9d7f0470e80084d8df4a64a27d1793
v1.0
instruct
Prefill
Prefill_19388_I
Create a function that filters a list of numbers and returns only the prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 5 is a prime number because the only numbers that divide it exactly are 1 and 5.
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def filter_primes(numbers): """ Filters the input list of numbers, returning only the prime numbers. ...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False def test_filter_primes(): ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the input list of numbers, returning only the prime numbers.", "function_declaration": "def filter_primes(numbers):",...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00019388", "row_id": 19388, "seed_ids": "['magpie_prefill_19388']" }
0.604904
Prefill_19388
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
803a323942fe0968024dd55fac1fe5bf19d9bd39
6a842b704015f3e3f43430aa1a1141b5f05c532e
v1.0
instruct
Prefill
Prefill_19590_I
Create a function that takes two positive integers as arguments and returns their least common multiple. The function should use the greatest common divisor (GCD) method to calculate the LCM.
def gcd(a, b): """ Returns the greatest common divisor of a and b using Euclid's algorithm. """ while b: a, b = b, a % b return a def lcm(a, b): """ Returns the least common multiple of a and b using the GCD method. lcm(a, b) = abs(a*b) / gcd(a, b) """ return abs(a * b) ...
from solution import gcd, lcm def test_gcd(): assert gcd(54, 24) == 6 assert gcd(48, 18) == 6 assert gcd(101, 103) == 1 def test_lcm(): assert lcm(4, 5) == 20 assert lcm(12, 15) == 60 assert lcm(7, 3) == 21 assert lcm(9, 6) == 18 assert lcm(25, 10) == 50
[ { "docstring": "Returns the greatest common divisor of a and b using Euclid's algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the least common multiple of a and b using the GCD method.\nlcm(a, b) = abs(a*b) ...
[ 0, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Returns the greatest common divisor of a and b.\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n \"\"\"\n Returns the...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00019590", "row_id": 19590, "seed_ids": "['magpie_prefill_19590']" }
0.678269
Prefill_19590
I
[ "gcd", "lcm" ]
2
[ [ "lcm", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7140a80186423c735bd78937763d783ce906d53f
073b803e93270f1481bf112b78255373b79230f1
v1.0
instruct
Prefill
Prefill_19658_I
Create a function that takes in an integer array and returns a boolean value indicating whether the array contains a "lonely" number. A "lonely" number is defined as a number that is both greater than 10 and has exactly two distinct prime factors.
def is_prime(n): """Helper function to check if a number is prime.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def get_prime_factors(n): """Helper function to get the prime factors of a number.""" factors = s...
from solution import has_lonely_number from solution import get_prime_factors, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_get_prime_factors(): assert get_prime...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to get the prime factors of a number.", "function_declaration": "def get_prime_factors(n):"...
[ 0, 1, 0, 0, 0, 0, 0, 1, 1, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_lonely_number(num):\n \"\"\"\n Determines whether a number is \"lonely\".\n A lonely number is greater than 10 and has exactly two distinct prime factors.\n \"\"\"\n if ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00019658", "row_id": 19658, "seed_ids": "['magpie_prefill_19658']" }
0.548034
Prefill_19658
I
[ "is_prime", "get_prime_factors", "has_lonely_number" ]
3
[ [ "get_prime_factors", "is_prime" ], [ "has_lonely_number", "get_prime_factors" ] ]
2
[]
false
[]
false
pytest
true
[]
true
50ae2db42a7cb6263d5993777fea22641fa7463a
f15dda28736fe122ba5ebf012cea03fde8045f31
v1.0
instruct
Prefill
Prefill_19673_I
Create a function that returns the nth Fibonacci number with less than or equal to n digits. The function should use a generator to generate Fibonacci numbers and stop when the nth Fibonacci number with less than or equal to n digits is found. The function should also measure and return the time taken to generate this ...
import timeit def fibonacci_gen(): """ A generator function to generate Fibonacci numbers. """ a, b = 0, 1 while True: yield a a, b = b, a + b def nth_fibonacci_with_n_digits(n): """ Returns the nth Fibonacci number with less than or equal to n digits and the time taken to ...
from solution import nth_fibonacci_with_n_digits def test_nth_fibonacci_with_n_digits_for_n_1(): # 0 is the 1st fibonacci number with 1 or fewer digits fib_number, time_taken = nth_fibonacci_with_n_digits(1) assert fib_number == 0 assert time_taken >= 0 def test_nth_fibonacci_with_n_digits_for_n_2(): ...
[ { "docstring": "A generator function to generate Fibonacci numbers.", "function_declaration": "def fibonacci_gen():", "function_name": "fibonacci_gen", "parameter_list": "()" }, { "docstring": "Returns the nth Fibonacci number with less than or equal to n digits and the time taken to \ngener...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import timeit\n\ndef fibonacci_generator():\n a, b = 0, 1\n while True:\n yield a\n a, b = b, a + b\n\ndef nth_fibonacci_with_digits(n):\n \"\"\"\n Returns the nth F...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00019673", "row_id": 19673, "seed_ids": "['magpie_prefill_19673']" }
0.744778
Prefill_19673
I
[ "fibonacci_gen", "nth_fibonacci_with_n_digits" ]
2
[ [ "nth_fibonacci_with_n_digits", "fibonacci_gen" ] ]
1
[]
false
[]
false
pytest
true
[]
true
945f6df03a12023f55a979e2f3d6a4bbbb5d4308
f4878e4705378e7e20ff5e663939e4aff9fd5044
v1.0
instruct
Prefill
Prefill_19951_I
Create a function that implements the Caesar Cipher with a shift of 3. The function should take a string as input and return the encrypted string. Additionally, provide a Python code to decode the string using the Caesar Cipher with the same shift value.
def caesar_cipher_encrypt(text, shift=3): """ Encrypts the input text using Caesar Cipher with a shift of 3. Args: - text (str): The input text to encrypt. - shift (int): The number of positions to shift the alphabet. Default is 3. Returns: - str: The encrypted text. """ re...
from solution import caesar_cipher_encrypt, caesar_cipher_decrypt def test_caesar_cipher_encrypt_basic(): assert caesar_cipher_encrypt("HELLO") == "KHOOR" def test_caesar_cipher_encrypt_with_non_alpha(): assert caesar_cipher_encrypt("HELLO WORLD!") == "KHOOR ZRUOG!" def test_caesar_cipher_encrypt_lowercase()...
[ { "docstring": "Encrypts the input text using Caesar Cipher with a shift of 3.\n\nArgs:\n- text (str): The input text to encrypt.\n- shift (int): The number of positions to shift the alphabet. Default is 3.\n\nReturns:\n- str: The encrypted text.", "function_declaration": "def caesar_cipher_encrypt(text, sh...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher_encrypt(text, shift=3):\n \"\"\"\n Encrypts the given text using Caesar Cipher with a shift of 3.\n \"\"\"\n encrypted_text = \"\"\n for char in text:\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00019951", "row_id": 19951, "seed_ids": "['magpie_prefill_19951']" }
0.691608
Prefill_19951
I
[ "caesar_cipher_encrypt", "caesar_cipher_decrypt" ]
2
[ [ "caesar_cipher_decrypt", "caesar_cipher_encrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0eaf4a4894d9c2250ba4f3baac5da8029338231
1323b03459ca04e44dcab71d0d7acb0775b76e8e
v1.0
instruct
Prefill
Prefill_19955_I
Create a function that takes in an integer n and returns the list of all prime numbers between 1 and n (inclusive).
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def primes_up_to(n): """ Returns a list of all prime numbers between 1 and n (i...
from solution import primes_up_to def test_no_primes(): assert primes_up_to(1) == [] def test_primes_up_to_10(): assert primes_up_to(10) == [2, 3, 5, 7] def test_primes_up_to_20(): assert primes_up_to(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_primes_up_to_50(): assert primes_up_to(50) == [2, 3, 5...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of all prime numbers between 1 and n (inclusive).", "function_declaration": "def primes_...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00019955", "row_id": 19955, "seed_ids": "['magpie_prefill_19955']" }
0.689013
Prefill_19955
I
[ "is_prime", "primes_up_to" ]
2
[ [ "primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c17ba6afb3768a5a69db2fe7ea4dad1159e0f928
bc9893ea7972f58c06a5551ed3f63e9ab8271eab
v1.0
instruct
Prefill
Prefill_20065_I
Create a function that takes an integer and returns the factorial of that integer using recursion. To ensure the accuracy of your function, include a check function with provided data points to verify that the function works as intended. Additionally, add comments explaining each part of the function.
def factorial(n): """ Returns the factorial of a given integer n using recursion. """ # Base case: if n is 0 or 1, return 1 if n == 0 or n == 1: return 1 # Recursive case: n * factorial of (n-1) return n * factorial(n - 1) def check_factorial(): """ Check the accuracy of the...
from solution import factorial def test_factorial_base_cases(): assert factorial(0) == 1 assert factorial(1) == 1 def test_factorial_small_numbers(): assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 def test_factorial_medium_numbers(): assert factorial(5) == 120 ...
[ { "docstring": "Returns the factorial of a given integer n using recursion.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Check the accuracy of the factorial function with data points.", "function_declaration": "de...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorial(n):\n \"\"\"\n Returns the factorial of a non-negative integer n using recursion.\n \"\"\"\n # Base case: factorial of 0 or 1 is 1\n if n == 0 or n == 1:\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00020065", "row_id": 20065, "seed_ids": "['magpie_prefill_20065']" }
0.652122
Prefill_20065
I
[ "factorial", "check_factorial" ]
2
[ [ "check_factorial", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
38f0e4b126ef8a4e75241c73d9eb1ec2a3c7782e
4dc31cd4bf1ea7815ef86b668779f09a25cb4aef
v1.0
instruct
Prefill
Prefill_20068_I
Create a function that accepts an array of integers as a parameter and returns the largest integer in the array. Sort the array in ascending order using the bubble sort algorithm, then find the largest number in the array.
def bubble_sort(arr): """ Sorts an array in ascending order using the bubble sort algorithm. """ n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr def find_largest_integer(arr): ...
from solution import find_largest_integer def test_empty_array(): assert find_largest_integer([]) == None def test_single_element_array(): assert find_largest_integer([5]) == 5 def test_all_positive_numbers(): assert find_largest_integer([1, 2, 3, 4, 5]) == 5 def test_all_negative_numbers(): assert ...
[ { "docstring": "Sorts an array in ascending order using the bubble sort algorithm.", "function_declaration": "def bubble_sort(arr):", "function_name": "bubble_sort", "parameter_list": "(arr)" }, { "docstring": "Returns the largest integer in the array by first sorting it using bubble sort.",...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bubble_sort(arr):\n \"\"\"\n Bubble sort function that sorts an array in ascending order.\n \"\"\"\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00020068", "row_id": 20068, "seed_ids": "['magpie_prefill_20068']" }
0.674848
Prefill_20068
I
[ "bubble_sort", "find_largest_integer" ]
2
[ [ "find_largest_integer", "bubble_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a06e65c9f2baefce8b899c2b37d5ca87db6ac60
7489223104c76ada6c9d1f09e06d39730979db52
v1.0
instruct
Prefill
Prefill_20152_I
Create a function that takes an integer as an input and determines whether it is a prime number or not. If the input number is not a prime number, return the smallest prime number that is greater than the input number. If the input number is a prime number, return "PrimeNumber".
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def next_prime(n): """ Returns the smallest prime number greater than n. """ candidate = n + 1 ...
from solution import prime_or_next_prime def test_prime_number(): assert prime_or_next_prime(2) == "PrimeNumber" assert prime_or_next_prime(3) == "PrimeNumber" assert prime_or_next_prime(5) == "PrimeNumber" assert prime_or_next_prime(7) == "PrimeNumber" assert prime_or_next_prime(11) == "PrimeNumbe...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number greater than n.", "function_declaration": "def next_prime(n):", "function_name": "nex...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00020152", "row_id": 20152, "seed_ids": "['magpie_prefill_20152']" }
0.730756
Prefill_20152
I
[ "is_prime", "next_prime", "prime_or_next_prime" ]
3
[ [ "next_prime", "is_prime" ], [ "prime_or_next_prime", "is_prime" ], [ "prime_or_next_prime", "next_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
3de831984b4a23f9bd7b2e640794fac89b38e6aa
43aa5c71bf4a3f3061f9bf413134c1baffa5bece
v1.0
instruct
Prefill
Prefill_20318_I
Create a function that takes an integer `n` as input and returns the sum of all prime numbers less than `n`.
def is_prime(num): """ Returns True if num is a prime number, else False. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: retu...
from solution import is_prime, sum_of_primes_less_than def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(...
[ { "docstring": "Returns True if num is a prime number, else False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers less than n.", "function_declaration": "def sum_of_primes_less...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 =...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00020318", "row_id": 20318, "seed_ids": "['magpie_prefill_20318']" }
0.703316
Prefill_20318
I
[ "is_prime", "sum_of_primes_less_than" ]
2
[ [ "sum_of_primes_less_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eaebfa6f83f3eec20d724e12c6daf93dc086cfd5
971f39eb2e49adb4f1d1cd634ef6b95cee258b9c
v1.0
instruct
Prefill
Prefill_20331_I
Create a function that takes two numbers as input and returns the sum of the two numbers. However, the function should also check if either of the numbers is a prime number and return the string "One of the numbers is a prime number." if either number is prime. If both numbers are prime, return the string "Both numbers...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def sum_or_prime_check(a, b): """ Returns the sum of a and b, or a message if one or bo...
from solution import sum_or_prime_check def test_sum_or_prime_check_with_prime_numbers(): assert sum_or_prime_check(3, 5) == "Both numbers are prime numbers." assert sum_or_prime_check(2, 9) == "One of the numbers is a prime number." assert sum_or_prime_check(10, 7) == "One of the numbers is a prime number...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of a and b, or a message if one or both numbers are prime.", "function_declaration": "def s...
[ 0, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00020331", "row_id": 20331, "seed_ids": "['magpie_prefill_20331']" }
0.642878
Prefill_20331
I
[ "is_prime", "sum_or_prime_check" ]
2
[ [ "sum_or_prime_check", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
569a0c3f651fc2d9af9bcaf0d0fb30f8ac88e18c
77c94cdeaff68f09b88b6fe108e195f41ec11117
v1.0
instruct
Prefill
Prefill_20377_I
Create a function that takes a list of numbers and returns a new list with the numbers sorted in descending order using merge sort algorithm.
def merge_sort_descending(arr): """ Takes a list of numbers and returns a new list with the numbers sorted in descending order using the merge sort algorithm. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = merge_sort_descending(arr[:mid]) right_half = merge_sort_de...
from solution import merge_sort_descending def test_merge_sort_descending_with_positive_numbers(): assert merge_sort_descending([4, 1, 5, 3, 2]) == [5, 4, 3, 2, 1] def test_merge_sort_descending_with_negative_numbers(): assert merge_sort_descending([-1, -3, -2, -5, -4]) == [-1, -2, -3, -4, -5] def test_merge...
[ { "docstring": "Takes a list of numbers and returns a new list with the numbers sorted in descending order using the merge sort algorithm.", "function_declaration": "def merge_sort_descending(arr):", "function_name": "merge_sort_descending", "parameter_list": "(arr)" }, { "docstring": null, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort_descending(arr):\n \"\"\"\n Sorts a list in descending order using merge sort algorithm.\n \n Parameters:\n arr (list): List of numbers\n \n Returns:\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00020377", "row_id": 20377, "seed_ids": "['magpie_prefill_20377']" }
0.727593
Prefill_20377
I
[ "merge_sort_descending", "merge" ]
2
[ [ "merge_sort_descending", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3e40d6c1b6309ef14cc8bbe519d0a88cee0957fa
afe6c3a18d2d29c6e62fa717608effea6ea73447
v1.0
instruct
Prefill
Prefill_20515_I
Create a function that takes a number as an argument and prints out the first "n" prime numbers. How can this be achieved in Python?
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def...
from solution import first_n_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_first_n_primes(): ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of the first 'n' prime numbers.", "function_declaration": "def first_n_primes(n):", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if the number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i =...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00020515", "row_id": 20515, "seed_ids": "['magpie_prefill_20515']" }
0.708846
Prefill_20515
I
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
15a6ab8e31d6ee9ecc0aad56591530cc0a372e13
d928b627c6d238162e29343e41d8857309328b87
v1.0
instruct
Prefill
Prefill_20587_I
Create a function that takes the following arguments, customer_id, product_id, and quantity. This function should retrieve customer_details from the customer_details_table where customer_id matches. After that, it should validate the product_id against the products_available_table to ensure it is in stock. If the produ...
import sqlite3 def create_connection(): conn = sqlite3.connect(':memory:') # Create an in-memory database for demonstration purposes return conn def setup_database(conn): cursor = conn.cursor() cursor.execute('''CREATE TABLE customer_details_table ( customer_id INTEGER PRIMARY...
import pytest from solution import place_order, create_connection, setup_database @pytest.fixture(scope='module') def setup_test_db(): conn = create_connection() setup_database(conn) yield conn conn.close() def test_place_order_success(setup_test_db): customer_details, new_order_details = place_or...
[ { "docstring": null, "function_declaration": "def create_connection():", "function_name": "create_connection", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def setup_database(conn):", "function_name": "setup_database", "parameter_list": "(conn)" }, ...
[ 1, 1, 1, 1, 0, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def place_order(customer_id, product_id, quantity):\n \"\"\"\n Processes an order for a customer including stock validation, \n stock deduction, and updating order history.\n \n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00020587", "row_id": 20587, "seed_ids": "['magpie_prefill_20587']" }
0.32968
Prefill_20587
I
[ "create_connection", "setup_database", "place_order" ]
3
[ [ "place_order", "create_connection" ], [ "place_order", "setup_database" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ecb718dfa09fc6aa76cf3dc703bdd1c815c08015
fa6a24db4c43c021a7e73bf557c85ff409d80c2c
v1.0
instruct
Prefill
Prefill_20626_I
Create a function that receives an array of integers and returns the number of elements that are greater than 10 and are prime numbers.
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i...
from solution import count_greater_than_ten_and_prime, is_prime def test_is_prime(): assert is_prime(2) is True assert is_prime(3) is True assert is_prime(4) is False assert is_prime(5) is True assert is_prime(11) is True assert is_prime(15) is False def test_count_greater_than_ten_and_prime()...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the number of elements in the array that are greater than 10 and are prime numbers.", "function_d...
[ 1, 1, 1, 0, 1, 1, 0, 0, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import isqrt\n\ndef is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n re...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00020626", "row_id": 20626, "seed_ids": "['magpie_prefill_20626']" }
0.633158
Prefill_20626
I
[ "is_prime", "count_greater_than_ten_and_prime" ]
2
[ [ "count_greater_than_ten_and_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2e8cff5537ff527112a03c98df39e1203f6d4275
1961bc9f35d43e30439e0f5cf9a40f4fafafc276
v1.0
instruct
Prefill
Prefill_20688_I
Create a function that takes in an array of integers and returns the sum of all the prime numbers in the array. Prime numbers are numbers greater than 1 that have no divisors other than 1 and themselves.
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False ...
from solution import sum_of_primes def test_empty_array(): assert sum_of_primes([]) == 0 def test_array_with_no_primes(): assert sum_of_primes([1, 4, 6, 8, 9, 10]) == 0 def test_array_with_all_primes(): assert sum_of_primes([2, 3, 5, 7, 11]) == 28 def test_array_with_mixed_numbers(): assert sum_of_p...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the input array.", "function_declaration": "def sum_of_primes(arr):...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00020688", "row_id": 20688, "seed_ids": "['magpie_prefill_20688']" }
0.690177
Prefill_20688
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
944e125dab24d9e686bfea7f350d028404b0462f
64cd8214ee8cffab8fbe0832878a1bd1886b4050
v1.0
instruct
Prefill
Prefill_20723_I
Create a function that accepts a list of integers and returns a new list containing only the integers that are palindromic numbers. A palindromic number reads the same forward and backward. Additionally, the function should return the count of such palindromic numbers.
def is_palindrome(num): """ Check if a number is a palindrome. """ return str(num) == str(num)[::-1] def palindromic_numbers(nums): """ Return a list of palindromic numbers and the count of such numbers from the provided list of integers. Args: nums (list of int): The list of integ...
from solution import palindromic_numbers def test_palindromic_numbers_single_digit(): assert palindromic_numbers([1, 2, 3, 4, 5]) == ([1, 2, 3, 4, 5], 5) def test_palindromic_numbers_mixed(): assert palindromic_numbers([121, 123, 131, 1221, 12321, 12345]) == ([121, 131, 1221, 12321], 4) def test_palindromic_...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Return a list of palindromic numbers and the count of such numbers from the provided list of integers.\n\nArg...
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Helper function to check if an integer is a palindrome.\n \"\"\"\n s = str(n)\n return s == s[::-1]\n\ndef filter_palindromic_numbers(numbers):...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00020723", "row_id": 20723, "seed_ids": "['magpie_prefill_20723']" }
0.682899
Prefill_20723
I
[ "is_palindrome", "palindromic_numbers" ]
2
[ [ "palindromic_numbers", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
be125df6cb75247ab919ce0a74236afebe33a522
1ef2e7e1f53c491f54734d1e374af1c0e757cb7c
v1.0
instruct
Prefill
Prefill_20779_I
Create a function that finds the longest palindrome in a given string. A palindrome is a string that reads the same backward as forward, e.g., "radar" or "level". The function should return the longest palindrome found in the string. If there are multiple longest palindromes, return the first one found. If no palindrom...
def longest_palindrome(s): """ Returns the longest palindrome found in the string s. If there are multiple longest palindromes, it returns the first one found. If no palindrome is found, it returns an empty string. """ n = len(s) if n == 0: return "" longest = "" ...
from solution import longest_palindrome def test_single_character(): assert longest_palindrome("a") == "a" def test_multiple_characters(): assert longest_palindrome("babad") in ["bab", "aba"] assert longest_palindrome("cbbd") == "bb" def test_palindrome_at_end(): assert longest_palindrome("forgeekssk...
[ { "docstring": "Returns the longest palindrome found in the string s.\nIf there are multiple longest palindromes, it returns the first one found.\nIf no palindrome is found, it returns an empty string.", "function_declaration": "def longest_palindrome(s):", "function_name": "longest_palindrome", "pa...
[ 0, 0, 1, 0, 1, 0, 1, 0, 1, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindrome(s):\n \"\"\"\n Finds the longest palindrome in a given string.\n \n :param s: Input string\n :return: Longest palindromic substring\n \"\"\"\n if n...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00020779", "row_id": 20779, "seed_ids": "['magpie_prefill_20779']" }
0.787027
Prefill_20779
I
[ "longest_palindrome", "expand_around_center" ]
2
[ [ "longest_palindrome", "expand_around_center" ] ]
1
[]
false
[]
false
pytest
true
[]
true
323b964f6b8e2eb32de98762b12f3a63867e81f3
06dbe50a5008e88fdbcc3910b429d49a4f24dbed
v1.0
instruct
Prefill
Prefill_20836_I
Create a function that takes a list of numbers and returns their sum. You should then create another function that takes a list of numbers and returns their maximum value. Finally, create a function that takes a list of numbers and returns both the sum and the maximum value.
def sum_numbers(numbers): """ Returns the sum of the numbers in the list. """ return sum(numbers) def max_number(numbers): """ Returns the maximum number in the list. """ return max(numbers) def sum_and_max(numbers): """ Returns a tuple containing the sum and the maximum number...
from solution import sum_numbers, max_number, sum_and_max def test_sum_numbers_with_positive_numbers(): assert sum_numbers([1, 2, 3, 4, 5]) == 15 def test_sum_numbers_with_negative_numbers(): assert sum_numbers([-1, -2, -3, -4, -5]) == -15 def test_sum_numbers_with_mixed_numbers(): assert sum_numbers([-1...
[ { "docstring": "Returns the sum of the numbers in the list.", "function_declaration": "def sum_numbers(numbers):", "function_name": "sum_numbers", "parameter_list": "(numbers)" }, { "docstring": "Returns the maximum number in the list.", "function_declaration": "def max_number(numbers):"...
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\n\ndef sum_numbers(numbers: List[int]) -> int:\n \"\"\"\n Returns the sum of the numbers in the list.\n \"\"\"\n return sum(numbers)\n\ndef max_numb...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00020836", "row_id": 20836, "seed_ids": "['magpie_prefill_20836']" }
0.684214
Prefill_20836
I
[ "sum_numbers", "max_number", "sum_and_max" ]
3
[ [ "sum_and_max", "max_number" ], [ "sum_and_max", "sum_numbers" ] ]
2
[]
false
[]
false
pytest
true
[]
true
74173b74ea5ccedba623dcf5a494581d1fa7b082
6d0d2ca51f27f4aae3550c84fe494bbf3f2f9079
v1.0
instruct
Prefill
Prefill_21000_I
Create a function that takes in a list of numbers and returns the mean, median, and mode of the list.
from typing import List, Tuple from collections import Counter def calculate_mean(lst: List[float]) -> float: return sum(lst) / len(lst) def calculate_median(lst: List[float]) -> float: sorted_lst = sorted(lst) n = len(lst) mid = n // 2 if n % 2 == 0: return (sorted_lst[mid-1] + sorted_lst...
from solution import mean_median_mode def test_mean_median_mode_single_element(): assert mean_median_mode([3]) == (3.0, 3.0, [3]) def test_mean_median_mode_even_count(): assert mean_median_mode([1, 2, 3, 4]) == (2.5, 2.5, [1, 2, 3, 4]) def test_mean_median_mode_odd_count(): assert mean_median_mode([1, 2,...
[ { "docstring": null, "function_declaration": "def calculate_mean(lst):", "function_name": "calculate_mean", "parameter_list": "(lst)" }, { "docstring": null, "function_declaration": "def calculate_median(lst):", "function_name": "calculate_median", "parameter_list": "(lst)" }, ...
[ 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\nimport statistics\n\ndef calculate_mean_median_mode(numbers):\n \"\"\"\n Returns the mean, median, and mode of the list of numbers.\n \"\"\"\n if ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021000", "row_id": 21000, "seed_ids": "['magpie_prefill_21000']" }
0.72411
Prefill_21000
I
[ "calculate_mean", "calculate_median", "calculate_mode", "mean_median_mode" ]
4
[ [ "mean_median_mode", "calculate_mean" ], [ "mean_median_mode", "calculate_median" ], [ "mean_median_mode", "calculate_mode" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5b4b7aebdb21bc6bfccc72f79442e44ce85b5a9b
84f4de18ab0c2642f63231812535bcc78d7361eb
v1.0
instruct
Prefill
Prefill_21027_I
Create a function that takes two parameters, a project name and a version number, and generates a project name if it doesn't exist in the database, and returns the project ID. If the project exists, it should return the project ID of the existing project. The project name and version number should be validated to ensur...
import re DATABASE = { "projects": [] } def validate_project_name(name): """ Validates if the project name starts with a letter and contains only letters and digits. """ return bool(re.match(r'^[a-zA-Z][a-zA-Z0-9]*$', name)) def validate_version_number(version): """ Validates if the vers...
from solution import get_project_id, DATABASE import pytest def setup_module(module): """ Setup the module by clearing the database. """ DATABASE["projects"].clear() def test_valid_new_project(): setup_module(None) assert get_project_id("ProjectA", "1.0.0") == 1 def test_existing_project(): ...
[ { "docstring": "Validates if the project name starts with a letter and contains only letters and digits.", "function_declaration": "def validate_project_name(name):", "function_name": "validate_project_name", "parameter_list": "(name)" }, { "docstring": "Validates if the version number is in...
[ 1, 1, 0, 1, 0, 1, 1, 0, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndatabase = {}\nproject_id_counter = 1\n\ndef validate_project_name(name):\n if re.match(r\"^[A-Za-z][A-Za-z0-9]*$\", name):\n return True\n return False\n\ndef valid...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021027", "row_id": 21027, "seed_ids": "['magpie_prefill_21027']" }
0.346401
Prefill_21027
I
[ "validate_project_name", "validate_version_number", "get_project_id" ]
3
[ [ "get_project_id", "validate_project_name" ], [ "get_project_id", "validate_version_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
312be90ec8bc4a3e96bf36e6c36e1707d67fea6f
d2063559d9e29ca94bd56a3e0a9c791daf585182
v1.0
instruct
Prefill
Prefill_21138_I
Create a function that generates a list of prime numbers up to a given number n, where n is a positive integer. You want to use a helper function to check if a number is prime. The primes should be generated in ascending order. For example, for n=10, the function should return `[2, 3, 5, 7]`.
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True # 2 is the only even prime number if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: r...
from solution import is_prime, generate_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == F...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a list of prime numbers up to a given number n.", "function_declaration": "def generate_prime...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(number):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if number <= 1:\n return False\n if number == 2:\n return True\n if ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00021138", "row_id": 21138, "seed_ids": "['magpie_prefill_21138']" }
0.682778
Prefill_21138
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bd349d8123e2ca6e82ba1282b83559853ee92518
144c184160a17720d3987817911f6686e29688e6
v1.0
instruct
Prefill
Prefill_21169_I
Create a function that takes two numbers and returns the sum of all prime numbers between these two numbers (inclusive). Prime numbers are numbers greater than 1 that have no divisors other than 1 and themselves.
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def sum_of_primes(a, b): """...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == Fal...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers between a and b (inclusive).", "function_declaration": "def sum_of_primes(a, b):", "f...
[ 1, 0, 1, 1, 1, 0, 0, 1, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ==...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021169", "row_id": 21169, "seed_ids": "['magpie_prefill_21169']" }
0.609609
Prefill_21169
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5b5794d626456c82b48bc4396353281fc4980728
a55d5c17e51e576c9711a317f1e683951e70b4dd
v1.0
instruct
Prefill
Prefill_21220_I
Create a function that calculates the factorial of a number using both recursive and iterative methods. Then, compare the efficiency of both approaches.
import time def factorial_recursive(n): """ Returns the factorial of n using recursive method. """ if n == 0: return 1 else: return n * factorial_recursive(n-1) def factorial_iterative(n): """ Returns the factorial of n using iterative method. """ result = 1 fo...
from solution import factorial_recursive, factorial_iterative, compare_efficiency def test_factorial_recursive(): assert factorial_recursive(0) == 1 assert factorial_recursive(1) == 1 assert factorial_recursive(5) == 120 assert factorial_recursive(10) == 3628800 def test_factorial_iterative(): ass...
[ { "docstring": "Returns the factorial of n using recursive method.", "function_declaration": "def factorial_recursive(n):", "function_name": "factorial_recursive", "parameter_list": "(n)" }, { "docstring": "Returns the factorial of n using iterative method.", "function_declaration": "def...
[ 1, 0, 1, 0, 1, 1, 1, 0, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\ndef factorial_recursive(n):\n \"\"\"\n Returns the factorial of a given number n using recursion.\n \"\"\"\n if n <= 1:\n return 1\n else:\n return...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00021220", "row_id": 21220, "seed_ids": "['magpie_prefill_21220']" }
0.490496
Prefill_21220
I
[ "factorial_recursive", "factorial_iterative", "compare_efficiency" ]
3
[ [ "compare_efficiency", "factorial_iterative" ], [ "compare_efficiency", "factorial_recursive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e40dd5019b2f9ff5258953da6df0be4bbafd652b
36d4d9bdd4d26ddbaa8b04612c531a9056ce46a3
v1.0
instruct
Prefill
Prefill_21254_I
Create a function that takes in the number of items (n) and an array (arr) as arguments. The function should return an array of all prime numbers between the smallest and largest numbers in the given array.
def sieve_of_eratosthenes(max_num): primes = [True] * (max_num + 1) p = 2 while (p * p <= max_num): if primes[p] == True: for i in range(p * p, max_num + 1, p): primes[i] = False p += 1 prime_numbers = [] for p in range(2, max_num + 1): if primes[p...
from solution import find_primes_between_min_max def test_no_elements(): assert find_primes_between_min_max(0, []) == [] def test_single_element_array(): assert find_primes_between_min_max(1, [10]) == [] def test_all_same_elements(): assert find_primes_between_min_max(5, [7, 7, 7, 7, 7]) == [7] asser...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": null, "function_declaration": "def find_primes_between_min_max(n, arr):", "function_name": "find_primes_betwee...
[ 1, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if num is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021254", "row_id": 21254, "seed_ids": "['magpie_prefill_21254']" }
0.683232
Prefill_21254
I
[ "sieve_of_eratosthenes", "find_primes_between_min_max" ]
2
[ [ "find_primes_between_min_max", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
43361846b9b145fc52a250ce9119bbae34e84bcc
1953849bb0bbea2f3da14c5fb2dc6e204b63979a
v1.0
instruct
Prefill
Prefill_21370_I
Create a function that takes two numbers, a and b, and returns their sum. If a is not a number, convert it to a number before the operation. If b is also not a number, convert it to a number before the operation. If both a and b are not numbers, return 0.
def convert_to_number(value): """ Attempt to convert the value to a number. If it fails, return None. """ try: return float(value) except (ValueError, TypeError): return None def sum_with_conversion(a, b): """ Return the sum of a and b after converting them to numbers. ...
from solution import sum_with_conversion def test_sum_with_conversion_both_numbers(): assert sum_with_conversion(3, 4) == 7 assert sum_with_conversion(0, 5) == 5 def test_sum_with_conversion_string_numbers(): assert sum_with_conversion('3', '4') == 7 assert sum_with_conversion('0', '5') == 5 asser...
[ { "docstring": "Attempt to convert the value to a number.\nIf it fails, return None.", "function_declaration": "def convert_to_number(value):", "function_name": "convert_to_number", "parameter_list": "(value)" }, { "docstring": "Return the sum of a and b after converting them to numbers.\nIf...
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n \"\"\"\n Returns the sum of a and b converting them to numbers if necessary.\n If both a and b can't be converted to numbers, returns 0.\n \"\"\"\n try:\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021370", "row_id": 21370, "seed_ids": "['magpie_prefill_21370']" }
0.591284
Prefill_21370
I
[ "convert_to_number", "sum_with_conversion" ]
2
[ [ "sum_with_conversion", "convert_to_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8ec6d85b2ad13a2287eb823ba65b772100371ac7
dcc7f24d892717e6bb7ec2ca3da3ab091b0d46b2
v1.0
instruct
Prefill
Prefill_21407_I
Create a function that generates a list of all prime numbers between two integers, `start` and `end`. The function should include the start and end integers if they are prime. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False # Other even numbers are not prime max_divisor = int(n ** 0.5) + 1 for d in r...
from solution import generate_primes def test_primes_in_range(): assert generate_primes(10, 20) == [11, 13, 17, 19] assert generate_primes(5, 10) == [5, 7] assert generate_primes(30, 40) == [31, 37] assert generate_primes(1, 10) == [2, 3, 5, 7] def test_primes_at_bounds(): assert generate_primes(1...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate a list of all prime numbers between the integers start and end, inclusive.", "function_declara...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if the number `n` is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021407", "row_id": 21407, "seed_ids": "['magpie_prefill_21407']" }
0.640535
Prefill_21407
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9580c49649ae9fa361b36e4435f161da81da5c6f
34489b2469024b18c330178951ec211ea523b8ec
v1.0
instruct
Prefill
Prefill_21523_I
Create a function that generates a list of prime numbers between two given numbers, a and b (inclusive). The function should take two integers a and b as input and return a list of all prime numbers in the range [a, b].
def is_prime(n): """ Helper function to check if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i...
from solution import generate_primes_between, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(11) == True def test_generate_primes_between_single_value_range(...
[ { "docstring": "Helper function to check if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers between a and b (inclusive).", "function_declaration": "def generate_...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021523", "row_id": 21523, "seed_ids": "['magpie_prefill_21523']" }
0.58989
Prefill_21523
I
[ "is_prime", "generate_primes_between" ]
2
[ [ "generate_primes_between", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aa5f4c719b64628da5352c502d00e324b60d386c
b435ca2d17919944b735ed4fed2f4d851f4dc7c0
v1.0
instruct
Prefill
Prefill_21567_I
Create a function that supports a binary search based algorithm using recursion. I want a function that takes in two lists (list1 and list2) and uses binary search to find a target value in the combined list of list1 and list2. The combined list should not exceed 1000 elements.
def binary_search_recursive(arr, target, left, right): if left > right: return -1 mid = (left + right) // 2 if arr[mid] == target: return mid elif arr[mid] < target: return binary_search_recursive(arr, target, mid + 1, right) else: return binary_search_recursive(arr, ...
from solution import combined_binary_search def test_combined_binary_search_target_present(): list1 = [1, 3, 5, 7] list2 = [2, 4, 6, 8] target = 5 assert combined_binary_search(list1, list2, target) == 4 def test_combined_binary_search_target_not_present(): list1 = [1, 3, 5, 7] list2 = [2, 4, ...
[ { "docstring": null, "function_declaration": "def binary_search_recursive(arr, target, left, right):", "function_name": "binary_search_recursive", "parameter_list": "(arr, target, left, right)" }, { "docstring": null, "function_declaration": "def combined_binary_search(list1, list2, targ...
[ 1, 1, 1, 0, 0, 0, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def binary_search_combined(list1, list2, target):\n \"\"\"\n Performs binary search to find a target value in the combined sorted list of list1 and list2.\n\n Args:\n list1 (list ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00021567", "row_id": 21567, "seed_ids": "['magpie_prefill_21567']" }
0.615072
Prefill_21567
I
[ "binary_search_recursive", "combined_binary_search" ]
2
[ [ "combined_binary_search", "binary_search_recursive" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8f009fe34f75108133b7a46ffb624646d3a06834
d0e44bd514f1debed0b9869d34dea42f9416f893
v1.0
instruct
Prefill
Prefill_21696_I
Create a function that takes an integer N and returns the largest palindrome made from the product of two N-digit numbers.
def is_palindrome(number): """ Checks if a number is a palindrome. """ return str(number) == str(number)[::-1] def largest_palindrome_product(n): """ Find the largest palindrome made from the product of two n-digit numbers. """ max_num = 10**n - 1 min_num = 10**(n-1) max_palindr...
from solution import largest_palindrome_product def test_largest_palindrome_product_2_digits(): assert largest_palindrome_product(2) == 9009 # 91 * 99 = 9009 def test_largest_palindrome_product_3_digits(): assert largest_palindrome_product(3) == 906609 # 913 * 993 = 906609 def test_largest_palindrome_produ...
[ { "docstring": "Checks if a number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Find the largest palindrome made from the product of two n-digit numbers.", "function_declaration"...
[ 1, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Checks if the provided number n is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef largest_palindrome_product(n):\n \"\"\"\n R...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021696", "row_id": 21696, "seed_ids": "['magpie_prefill_21696']" }
0.795564
Prefill_21696
I
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
da6faf5181fedd08b0d4e51d52b9607ddf06e7c7
7b13631f6338a456de2d7e8263e0889dd89339c8
v1.0
instruct
Prefill
Prefill_21744_I
Create a function that generates a list of prime numbers within a given range. The range is defined by two integers, `start` and `end`.
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def g...
from solution import generate_primes def test_generate_primes_empty_range(): assert generate_primes(14, 16) == [] def test_generate_primes_single_prime(): assert generate_primes(10, 11) == [11] def test_generate_primes_multiple_primes(): assert generate_primes(10, 20) == [11, 13, 17, 19] def test_ge...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of prime numbers in the given range [start, end].", "function_declaration": "def generate_primes(start, end)...
[ 1, 1, 1, 1, 0, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021744", "row_id": 21744, "seed_ids": "['magpie_prefill_21744']" }
0.629305
Prefill_21744
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b32753b0de280ba401f25b0ae472db0dccb0f1d6
9790cbe91670fc792deb4f79c46769642e66c312
v1.0
instruct
Prefill
Prefill_21828_I
Create a function that takes a string and returns a new string with each word replaced by its longest palindrome substring.
def longest_palindrome_substring(word): """ Return the longest palindromic substring in the given word. """ def expand_around_center(s, left, right): while left >= 0 and right < len(s) and s[left] == s[right]: left -= 1 right += 1 return s[left + 1:right] if ...
from solution import longest_palindrome_substring, replace_words_with_longest_palindromes def test_longest_palindrome_substring(): assert longest_palindrome_substring("babad") == "bab" or longest_palindrome_substring("babad") == "aba" assert longest_palindrome_substring("cbbd") == "bb" assert longest_palin...
[ { "docstring": "Return the longest palindromic substring in the given word.", "function_declaration": "def longest_palindrome_substring(word):", "function_name": "longest_palindrome_substring", "parameter_list": "(word)" }, { "docstring": "Replace each word in the input string with its longe...
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindrome_substring(s):\n \"\"\"\n Given a string s, this function returns the longest palindromic substring in s.\n \"\"\"\n n = len(s)\n if n == 0:\n retu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021828", "row_id": 21828, "seed_ids": "['magpie_prefill_21828']" }
0.814501
Prefill_21828
I
[ "longest_palindrome_substring", "replace_words_with_longest_palindromes" ]
2
[ [ "replace_words_with_longest_palindromes", "longest_palindrome_substring" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f15845224514b2d7f6de9b5b5e896f4664460971
7e43244942d8488ceaacbf2b8dfc8d954781cddd
v1.0
instruct
Prefill
Prefill_21851_I
Create a function that takes an array of positive integers and returns an array containing the sum of all prime numbers found in the input array.
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) assert is_prime(3) assert is_prime(5) assert not is_prime(4) assert not is_prime(1) assert is_prime(29) assert not is_prime(49) def test_sum_of_primes_empty_array(): assert sum_of_primes([]) == 0 def ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the input array.", "function_declaration": "def sum_of_primes(arr):...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00021851", "row_id": 21851, "seed_ids": "['magpie_prefill_21851']" }
0.649362
Prefill_21851
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
033f16f3d74c6927e3f48ef82452831a150f13fa
f807ec79fd75e83f8270afcdb74deb8cd663d7bb
v1.0
instruct
Prefill
Prefill_21879_I
Create a function that validates if a given string is a palindrome (reads the same backward as forward). Also, check if this function can be used to determine if a number when converted to a string is a palindrome.
def is_palindrome(s): """ Returns True if the given string s is a palindrome, False otherwise. """ s = str(s) return s == s[::-1] # Test if a number when converted to a string is a palindrome def is_number_palindrome(n): """ Returns True if the given number n is a palindrome, False otherwis...
from solution import is_palindrome, is_number_palindrome def test_is_palindrome_with_palindromic_string(): assert is_palindrome("racecar") == True assert is_palindrome("madam") == True assert is_palindrome("a") == True assert is_palindrome("abba") == True def test_is_palindrome_with_non_palindromic_st...
[ { "docstring": "Returns True if the given string s is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns True if the given number n is a palindrome, False otherwise.", "fun...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(string):\n \"\"\"\n Checks if the provided string or number (after converting to string) is a palindrome.\n \n Parameters:\n string (str or int): The input st...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021879", "row_id": 21879, "seed_ids": "['magpie_prefill_21879']" }
0.728968
Prefill_21879
I
[ "is_palindrome", "is_number_palindrome" ]
2
[ [ "is_number_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63fbf4600fbe07f362c2a51bbc7814a6698d95c4
6247fd84dcdd0763657918433c39f0b4f571256c
v1.0
instruct
Prefill
Prefill_21903_I
Create a function that takes two integers as input parameters and add them together. Then, create a new function that calls this addition function and prints the result.
def add(a, b): """ Returns the sum of a and b. """ return a + b def add_and_print(a, b): """ Adds a and b using add function, and prints the result. """ result = add(a, b) print(result) return result
import sys from io import StringIO import pytest from solution import add, add_and_print def test_add_positive_numbers(): assert add(2, 3) == 5 def test_add_with_zero(): assert add(0, 5) == 5 assert add(5, 0) == 5 def test_add_negative_numbers(): assert add(-1, -1) == -2 def test_add_mixed_sign_numb...
[ { "docstring": "Returns the sum of a and b.", "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": "Adds a and b using add function, and prints the result.", "function_declaration": "def add_and_print(a, b):", "function_name":...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add_two_numbers(a, b):\n \"\"\"\n Returns the sum of a and b.\n \"\"\"\n return a + b\n\ndef print_sum_of_two_numbers(a, b):\n \"\"\"\n Calls add_two_numbers to add a an...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021903", "row_id": 21903, "seed_ids": "['magpie_prefill_21903']" }
0.705934
Prefill_21903
I
[ "add", "add_and_print" ]
2
[ [ "add_and_print", "add" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ea089af6357b7f1eae141dad21279e9995284763
16968d81a230325e9e47077011886aaf7859bec5
v1.0
instruct
Prefill
Prefill_21987_I
Create a function that implements the merge sort algorithm in Python.
def merge_sort(arr): """ Perform merge sort on the given list and return the sorted list. """ if len(arr) <= 1: return arr # Finding the middle of the array mid = len(arr) // 2 # Dividing the array elements into 2 halves left_half = merge_sort(arr[:mid]) right_half ...
from solution import merge_sort def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_two_elements(): assert merge_sort([2, 1]) == [1, 2] def test_merge_sort_multiple_elements(): assert merge_sort([3, 1, 4, 1,...
[ { "docstring": "Perform merge sort on the given list and return the sorted list.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merge two sorted lists into one sorted list.", "function_declaration": "def merge...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts an array using the merge sort algorithm.\n \"\"\"\n if len(arr) <= 1:\n return arr\n \n # Find the middle point and split the ar...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021987", "row_id": 21987, "seed_ids": "['magpie_prefill_21987']" }
0.688482
Prefill_21987
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13def9390b20b73872e7ecba7f1e42b33dc14da1
1ec635f6685fca6b3143a4616b9b288233e670df
v1.0
instruct
Prefill
Prefill_22014_I
Create a function that generates a list of prime numbers between a given range of numbers. Provide an example usage of the function.
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
from solution import generate_primes def test_generate_primes_standard_range(): assert generate_primes(10, 50) == [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47] def test_generate_primes_single_prime_range(): assert generate_primes(5, 10) == [5, 7] def test_generate_primes_no_primes_range(): assert generate...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate a list of prime numbers in the given range [start, end].", "function_declaration": "def generate_primes(start, end):"...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00022014", "row_id": 22014, "seed_ids": "['magpie_prefill_22014']" }
0.606643
Prefill_22014
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81b007e4ad69058e47233df89fc5fed63d3bc835
d65d60b1980255a7ca53cab9f3f826fe55123d9b
v1.0
instruct
Prefill
Prefill_22027_I
Create a function that can handle two inputs, an array of integers (each integer representing a number in a base system between 2 and 36) and a base system (between 2 and 36). The function should return an array of integers, each converted to the specified base.
def convert_number_to_base(number, base): """ Converts a given number to the specified base. :param number: The number to be converted, in base 10. :param base: The base to convert the number to, between 2 and 36. :return: A string representing the number in the specified base. """ if numbe...
from solution import convert_number_to_base, convert_array_to_base def test_convert_number_to_base(): assert convert_number_to_base(10, 2) == '1010' assert convert_number_to_base(10, 10) == '10' assert convert_number_to_base(255, 16) == 'FF' assert convert_number_to_base(31, 16) == '1F' assert conv...
[ { "docstring": "Converts a given number to the specified base.\n\n:param number: The number to be converted, in base 10.\n:param base: The base to convert the number to, between 2 and 36.\n:return: A string representing the number in the specified base.", "function_declaration": "def convert_number_to_base(...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def convert_bases(numbers, base):\n \"\"\"\n Convert a list of numbers to the specified base system.\n\n Parameters:\n numbers (list of int): List of integers representing numbers...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00022027", "row_id": 22027, "seed_ids": "['magpie_prefill_22027']" }
0.591463
Prefill_22027
I
[ "convert_number_to_base", "convert_array_to_base" ]
2
[ [ "convert_array_to_base", "convert_number_to_base" ] ]
1
[]
false
[]
false
pytest
true
[]
true
054ad76a2d85cfd915bc0033ff63cfdd9656f848
8cd4ab87f48b9829c0ca5471a86470ac59869e4b
v1.0
instruct
Prefill
Prefill_22042_I
Create a function that checks if the provided linked list is a palindrome or not. The function will take three parameters: the first node of the linked list, the length of the linked list, and a boolean flag to indicate whether the linked list is a palindrome or not.
class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def is_palindrome_util(head, length): if head is None or length <= 0: # Even length base case return True, head elif length == 1: # Odd length base case return True, head.next ...
from solution import ListNode, is_palindrome def create_linked_list(values): if not values: return None head = ListNode(values[0]) current = head for val in values[1:]: current.next = ListNode(val) current = current.next return head def test_empty_list(): assert is_pali...
[]
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef is_palindrome(head: ListNode, length: int) -> bool:\n \"\"\"\n Check ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022042", "row_id": 22042, "seed_ids": "['magpie_prefill_22042']" }
0.676126
Prefill_22042
I
[ "is_palindrome_util", "is_palindrome" ]
2
[ [ "is_palindrome", "is_palindrome_util" ] ]
1
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
ccca0bd1d90c3913f9259a0b94cef28d8a3b414c
c5b9bb76c19426cd9afd32b019df34379dace9b6
v1.0
instruct
Prefill
Prefill_22069_I
Create a function that takes no parameters and returns a string that contains the message "This is a test message." Is the function then called, it should print "Test passed.".
def get_test_message(): """ Returns the test message string. """ return "This is a test message." def print_test_passed(): """ Prints 'Test passed.' if `get_test_message` returns the correct message. """ if get_test_message() == "This is a test message.": print("Test passed.")
from solution import get_test_message, print_test_passed def test_get_test_message(): assert get_test_message() == "This is a test message." def test_print_test_passed(capsys): print_test_passed() captured = capsys.readouterr() assert captured.out.strip() == "Test passed."
[ { "docstring": "Returns the test message string.", "function_declaration": "def get_test_message():", "function_name": "get_test_message", "parameter_list": "()" }, { "docstring": "Prints 'Test passed.' if `get_test_message` returns the correct message.", "function_declaration": "def pri...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def test_message():\n \"\"\"\n Returns a test message.\n \"\"\"\n return \"This is a test message.\"\n\ndef call_and_verify():\n \"\"\"\n Calls test_message and prints \"Tes...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00022069", "row_id": 22069, "seed_ids": "['magpie_prefill_22069']" }
0.38881
Prefill_22069
I
[ "get_test_message", "print_test_passed" ]
2
[ [ "print_test_passed", "get_test_message" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4a4144b7e910c6c4e2c0a062e27d6128b3804cf6
aba82a91808c5a26b2e2bc94f481aae7f1cf847c
v1.0
instruct
Prefill
Prefill_22124_I
Create a function that takes a sequence of integers and returns the number of inversions in the sequence. An inversion is defined as a pair of indices i < j such that the value at index i is greater than the value at index j.
def count_inversions(arr): """ Count inversions in the array using a modified merge sort. :param arr: List[int] Sequence of integers. :return: int Number of inversions in the sequence. """ return merge_sort_and_count(arr, 0, len(arr) - 1) def merge_sort_and_count(a...
from solution import count_inversions def test_empty_array(): assert count_inversions([]) == 0 def test_single_element(): assert count_inversions([1]) == 0 def test_sorted_array(): assert count_inversions([1, 2, 3, 4, 5]) == 0 def test_reverse_sorted_array(): assert count_inversions([5, 4, 3, 2, 1])...
[ { "docstring": "Count inversions in the array using a modified merge sort.\n\n:param arr: List[int]\n Sequence of integers.\n \n:return: int\n Number of inversions in the sequence.", "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list":...
[ 1, 1, 1, 0, 1, 1, 1, 1, 0, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_inversions(sequence):\n \"\"\"\n Counts the number of inversions in the sequence.\n \n An inversion is a pair of indices (i, j) such that i < j and sequence[i] > sequenc...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00022124", "row_id": 22124, "seed_ids": "['magpie_prefill_22124']" }
0.726359
Prefill_22124
I
[ "count_inversions", "merge_sort_and_count", "merge_and_count" ]
3
[ [ "count_inversions", "merge_sort_and_count" ], [ "merge_sort_and_count", "merge_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
214c8788624fdd041757326b2322454f4fee1694
8ee519dd9a2f4fca6d95161e9e071b9ddf5ed254
v1.0
instruct
Prefill
Prefill_22216_I
Create a function that takes in a list of integers and returns a new list where each element is its factorial. The function should be able to handle large numbers efficiently and use an iterative approach for calculating the factorial.
def factorial(n): """ Returns the factorial of a number n. """ if n == 0: return 1 result = 1 for i in range(1, n + 1): result *= i return result def list_factorials(nums): """ Takes in a list of integers and returns a new list where each element is its factorial. ...
from solution import list_factorials def test_list_factorials_single_element(): assert list_factorials([5]) == [120] def test_list_factorials_multiple_elements(): assert list_factorials([0, 1, 2, 3, 4, 5]) == [1, 1, 2, 6, 24, 120] def test_list_factorials_with_large_number(): assert list_factorials([10])...
[ { "docstring": "Returns the factorial of a number n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Takes in a list of integers and returns a new list where each element is its factorial.", "function_declaration": "...
[ 1, 1, 1, 1, 1, 0, 1, 1, 0, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import factorial\n\ndef list_factorial(numbers):\n \"\"\"\n Takes a list of integers and returns a list where each element is its factorial.\n \n :param numbers: List of...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022216", "row_id": 22216, "seed_ids": "['magpie_prefill_22216']" }
0.724985
Prefill_22216
I
[ "factorial", "list_factorials" ]
2
[ [ "list_factorials", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d3e9865bb5b735c3b7d6255d66fc8b404cfffeae
3f6a293f987789ee13c4621da37efd7bf681bf0b
v1.0
instruct
Prefill
Prefill_22307_I
Create a function that generates a list of all the prime numbers between two given numbers (inclusive). A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import generate_primes def test_generate_primes_small_range(): assert generate_primes(1, 10) == [2, 3, 5, 7] def test_generate_primes_single_prime(): assert generate_primes(10, 11) == [11] def test_generate_primes_no_primes(): assert generate_primes(14, 16) == [] def test_generate_primes_l...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of all the prime numbers between start and end inclusive.", "function_declaration": "def g...
[ 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the onl...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022307", "row_id": 22307, "seed_ids": "['magpie_prefill_22307']" }
0.62258
Prefill_22307
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
14bfc0ca2d50f43fa52ff7ecfbbc651ce5b84c96
6fc66bd8e57e07a1ffbef8e29b3e0822cea6949f
v1.0
instruct
Prefill
Prefill_22389_I
Create a function that generates a list of all prime numbers up to a specified limit. The function should take two parameters: `start` and `end`, where `start` is the lower bound of the range (inclusive) and `end` is the upper bound of the range (inclusive). The function should return a list of prime numbers within thi...
def is_prime(n): """ Determines if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return...
from solution import generate_primes def test_generate_primes_within_range(): assert generate_primes(10, 20) == [11, 13, 17, 19] def test_generate_primes_single_prime(): assert generate_primes(17, 17) == [17] def test_generate_primes_no_primes_in_range(): assert generate_primes(8, 10) == [] asser...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of all prime numbers within the range [start, end].", "function_declaration": "def generate_primes(start...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_primes(start, end):\n \"\"\"\n Generates a list of all prime numbers within a specified range [start, end].\n \n Parameters:\n start (int): The lower bound of the ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022389", "row_id": 22389, "seed_ids": "['magpie_prefill_22389']" }
0.67902
Prefill_22389
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
990faecf783153db192b7119ab73192dd07c1712
1556342c209dadc1813cec00db50947183220057
v1.0
instruct
Prefill
Prefill_22396_I
Create a function that converts a given number into its corresponding word representation. For example, the number 123 should be converted to "one hundred twenty-three".
def number_to_words(n): if n == 0: return "zero" num_to_19 = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] tens = ['', '', 'twenty', 'thi...
from solution import number_to_words def test_single_digit(): assert number_to_words(3) == "three" def test_teens(): assert number_to_words(13) == "thirteen" def test_tens(): assert number_to_words(21) == "twenty-one" def test_hundreds(): assert number_to_words(105) == "one hundred five" assert ...
[ { "docstring": null, "function_declaration": "def number_to_words(n):", "function_name": "number_to_words", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def split_by_thousands(n):", "function_name": "split_by_thousands", "parameter_list": "(n)" }, ...
[ 1, 0, 0, 1, 1, 1, 1, 0, 1 ]
6
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def number_to_words(num):\n \"\"\"\n Converts a given number (0 <= num < 1000) into its word representation.\n \"\"\"\n if num == 0:\n return \"zero\"\n\n units = [\"\",...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022396", "row_id": 22396, "seed_ids": "['magpie_prefill_22396']" }
0.585398
Prefill_22396
I
[ "number_to_words", "split_by_thousands" ]
2
[ [ "number_to_words", "split_by_thousands" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d9c3c2dc80d6ce9943b96a203221e4b0d4070308
a7418dccbd44463e0a1bd648bf14e55839c0c4ea
v1.0
instruct
Prefill
Prefill_22442_I
Create a function that takes in a string and checks if it contains only letters or spaces. If it contains any other character, the function should return false. After that, it should determine if the string is a palindrome. A palindrome is a word, phrase, number, or other sequences of characters which reads the same ba...
def is_letter_or_space(s): """ Checks if the string contains only letters or spaces. """ return all(c.isalpha() or c.isspace() for c in s) def is_palindrome(s): """ Checks if the string is a palindrome, ignoring case, spaces and punctuation. """ # Filter only letters and make lowercase ...
def test_is_letter_or_space(): assert is_letter_or_space("Hello World") == True assert is_letter_or_space("Hello123") == False assert is_letter_or_space(" ") == True assert is_letter_or_space("H e l l o") == True assert is_letter_or_space("Hello!") == False def test_is_palindrome(): assert is_p...
[ { "docstring": "Checks if the string contains only letters or spaces.", "function_declaration": "def is_letter_or_space(s):", "function_name": "is_letter_or_space", "parameter_list": "(s)" }, { "docstring": "Checks if the string is a palindrome, ignoring case, spaces and punctuation.", "...
[ 1, 0, 1, 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 is_alpha_or_space(s):\n \"\"\"\n Check if the string contains only letters or spaces.\n \"\"\"\n return all(c.isalpha() or c.isspace() for c in s)\n\ndef is_palindrome(s):\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022442", "row_id": 22442, "seed_ids": "['magpie_prefill_22442']" }
0.765847
Prefill_22442
I
[ "is_letter_or_space", "is_palindrome", "check_string" ]
3
[ [ "check_string", "is_letter_or_space" ], [ "check_string", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
false
[]
true
7d4c24b08d5a354b34522f5773a1c93d6c56b28a
410593b49a0d616eb88669dc58e922eb6f1b7727
v1.0
instruct
Prefill
Prefill_22522_I
Create a function that takes a list of integers and returns a new list with only the prime numbers from the original list.
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def filter_primes(numbers): """ Returns a list of prime numbers from the given ...
from solution import filter_primes def test_filter_primes_with_mixed_numbers(): assert filter_primes([2, 3, 4, 5, 10, 11, 13]) == [2, 3, 5, 11, 13] def test_filter_primes_with_no_primes(): assert filter_primes([1, 4, 6, 8, 9, 10]) == [] def test_filter_primes_with_all_primes(): assert filter_primes([2, 3...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.", "function_declaration": "def filter_...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00022522", "row_id": 22522, "seed_ids": "['magpie_prefill_22522']" }
0.635027
Prefill_22522
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fa451c45b4a535ae0dbc715822050e8ed7007d84
17c8fe062c7e6e092e38182bf2412b5bf3c9c369