version stringclasses 1
value | style stringclasses 2
values | subset stringclasses 12
values | question_id stringlengths 9 23 | question stringlengths 27 8.13k | solution stringlengths 99 5.97k | test stringlengths 105 4.45k | test_info listlengths 0 13 | gpt_pass_sequence listlengths 1 10 | gpt_pass_trial_num int64 1 10 | gpt_difficulty stringclasses 3
values | gpt_pass_percentage float64 0.1 1 | trials dict | chosen_trial stringclasses 10
values | metadata dict | benchmark_similarity float64 0.16 0.93 | benchmark_instruction stringclasses 1
value | benchmark_task_id stringclasses 1
value | filter_reason stringclasses 1
value | base_id stringlengths 7 21 | variant stringclasses 2
values | top_function_names listlengths 2 13 | n_top_functions int64 2 13 | helper_call_edges listlengths 1 16 | n_helper_call_edges int64 1 16 | harness_functions listlengths 0 3 | structural_wrapper bool 1
class | class_names listlengths 0 5 | has_class bool 2
classes | test_kind stringclasses 1
value | test_has_solution_import bool 2
classes | third_party_imports listlengths 0 5 | stdlib_only bool 2
classes | question_norm_sha1 stringlengths 40 40 | solution_ast_sha1 stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
v1.0 | complete | Prefill | Prefill_22442_C | def is_letter_or_space(s: str) -> bool:
"""
Checks if the string contains only letters or spaces.
>>> is_letter_or_space("Hello World") == True
>>> is_letter_or_space("Hello123") == False
>>> is_letter_or_space(" ") == True
>>> is_letter_or_space("H e l l o") == True
>>> is_letter_or_space("... | 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": "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 chara... | 0.779186 | Prefill_22442 | C | [
"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 | a9cdee73ded078e51ee8ebc8c490a87d69854755 | 410593b49a0d616eb88669dc58e922eb6f1b7727 | |||
v1.0 | complete | Prefill | Prefill_24666_C | def is_prime(n: int) -> bool:
"""Checks if the number n is a prime number.
>>> is_prime(2) True
>>> is_prime(3) True
>>> is_prime(4) False
>>> is_prime(29) True
>>> is_prime(1) False
>>> is_prime(0) False
>>> is_prime(-1) False
"""
def sum_of_first_100_primes() -> int:
"""Calcul... | def is_prime(n):
"""
Checks 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, sum_of_first_100_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(29) == True
assert is_prime(1) == False
assert is_prime(0) == False
assert is_prime(-1) == False
def test_sum_of_fir... | [
{
"docstring": "Checks if the number n is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Calculates and returns the sum of the first 100 prime numbers.",
"function_declaration": "def sum_of_first_100_p... | [
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 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 == 0:\n retur... | trial_gpt4o_6 | {
"original_instruction": "Create a function that calculates and returns the sum of the first 100 prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.",
"prompt_id": "00024666",
"row_id": 24666,
"seed_ids": "['magpie_prefill_24666']"
} | 0.798401 | Prefill_24666 | C | [
"is_prime",
"sum_of_first_100_primes"
] | 2 | [
[
"sum_of_first_100_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 011c9c29743ccc55edd699f6b86fda5fc861de6a | f0d8ad9165208dd3b4112b9e94fe51fdb8dbea31 | |||
v1.0 | complete | Prefill | Prefill_33796_C | def is_prime(n: int) -> bool:
"""
Check if a number is a prime number.
>>> is_prime(1) == False
>>> is_prime(2) == True
>>> is_prime(3) == True
>>> is_prime(4) == False
>>> is_prime(17) == True
>>> is_prime(18) == False
"""
# Write your code here
def sum_of_proper_divisors(... | def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def sum_of_proper_divisors(n):
divisors_sum = 1
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
if i == n // i:
div... | from solution import is_weird_number, is_prime, sum_of_proper_divisors
def test_prime_checking():
assert not is_prime(1)
assert is_prime(2)
assert is_prime(3)
assert not is_prime(4)
assert is_prime(17)
assert not is_prime(18)
def test_sum_of_proper_divisors():
assert sum_of_proper_divisors... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def sum_of_proper_divisors(n):",
"function_name": "sum_of_proper_divisors",
"parameter_list": "(n)"
},
{
... | [
0,
0,
1,
1,
0,
1,
1,
0,
0,
1
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import sympy\n\ndef is_weird_number(n):\n \"\"\"\n Returns True if n is a weird number, else False.\n \n A weird number is defined as a positive integer greater than 20 that \n ... | trial_gpt4o_3 | {
"original_instruction": "Write a python function to check if a given number is a \"weird number.\" A weird number is defined as a positive integer greater than 20 that is not a prime number but has a sum of its proper divisors (excluding itself) (sumexv) that is greater than the number itself.",
"prompt_id": "000... | 0.742284 | Prefill_33796 | C | [
"is_prime",
"sum_of_proper_divisors",
"is_weird_number"
] | 3 | [
[
"is_weird_number",
"is_prime"
],
[
"is_weird_number",
"sum_of_proper_divisors"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | e21b78adbae8fbba2f25b29c484a32f036ad00b1 | 7a7dbada928c49bcc4c9851bc51b67b212b71ff1 | |||
v1.0 | complete | Prefill | Prefill_38742_C | def print_hello():
"""
Prints 'Hello, World!' and calls the print_goodbye function.
>>> print_hello()
Hello, World!
Goodbye, World!
"""
# Call the print_goodbye function
def print_goodbye():
"""
Prints 'Goodbye, World!'.
>>> print_goodbye()
Goodbye, World!
"""
# Prin... | def print_hello():
"""
Prints 'Hello, World!' and calls the print_goodbye function.
"""
print("Hello, World!")
print_goodbye()
def print_goodbye():
"""
Prints 'Goodbye, World!'.
"""
print("Goodbye, World!") | from solution import print_hello, print_goodbye
from io import StringIO
import sys
def test_print_hello():
captured_output = StringIO() # Create StringIO object to capture the output
sys.stdout = captured_output # Redirect stdout to the StringIO object
print_hello()
sys.stdout = sys.__stdout__ # Re... | [
{
"docstring": "Prints 'Hello, World!' and calls the print_goodbye function.",
"function_declaration": "def print_hello():",
"function_name": "print_hello",
"parameter_list": "()"
},
{
"docstring": "Prints 'Goodbye, World!'.",
"function_declaration": "def print_goodbye():",
"function... | [
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 print_hello_world():\n \"\"\"\n Prints 'Hello, World!' and then calls print_goodbye_world.\n \"\"\"\n print(\"Hello, World!\")\n print_goodbye_world()\n\ndef print_goodbye_... | trial_gpt4o_9 | {
"original_instruction": "Write a python function to print \"Hello, World!\" and then call a second function from the first function that prints \"Goodbye, World!\".",
"prompt_id": "00038742",
"row_id": 38742,
"seed_ids": "['magpie_prefill_38742']"
} | 0.465235 | Prefill_38742 | C | [
"print_hello",
"print_goodbye"
] | 2 | [
[
"print_hello",
"print_goodbye"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7c6668bb75f244fa42328626fd480b2438e9ba2f | 1347b2bd05e3432566461c35b35cdb6c73f44908 | |||
v1.0 | complete | Prefill | Prefill_39272_C | import time
def factorial_iterative(n):
"""
Calculate the factorial of a number iteratively.
>>> factorial_iterative(5) 120
>>> factorial_iterative(0) 1
>>> factorial_iterative(1) 1
>>> factorial_iterative(10) 3628800
"""
def factorial_recursive(n):
"""
Calculate the factoria... | import time
def factorial_iterative(n):
"""
Calculate the factorial of a number iteratively.
"""
result = 1
for i in range(1, n + 1):
result *= i
return result
def factorial_recursive(n):
"""
Calculate the factorial of a number recursively.
"""
if n == 0 or n == 1:
... | from solution import factorial_iterative, factorial_recursive, compare_performance, analyze_tradeoffs
import time
def test_factorial_iterative():
assert factorial_iterative(5) == 120
assert factorial_iterative(0) == 1
assert factorial_iterative(1) == 1
assert factorial_iterative(10) == 3628800
def tes... | [
{
"docstring": "Calculate the factorial of a number iteratively.",
"function_declaration": "def factorial_iterative(n):",
"function_name": "factorial_iterative",
"parameter_list": "(n)"
},
{
"docstring": "Calculate the factorial of a number recursively.",
"function_declaration": "def fac... | [
1,
1,
1,
0,
1,
0,
1,
0,
1,
1
] | 7 | easy | 0.7 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import time\n\ndef factorial_iterative(n):\n \"\"\"\n Calculate the factorial of a number using the iterative method.\n \"\"\"\n if n < 0:\n raise ValueError(\"Factorial is... | trial_gpt4o_8 | {
"original_instruction": "Write a python function to calculate the factorial of a number using both iterative and recursive methods and compare their performance for large numbers. Analyze the trade-offs between the two methods.",
"prompt_id": "00039272",
"row_id": 39272,
"seed_ids": "['magpie_prefill_39272']"... | 0.603041 | Prefill_39272 | C | [
"factorial_iterative",
"factorial_recursive",
"compare_performance",
"analyze_tradeoffs"
] | 4 | [
[
"compare_performance",
"factorial_iterative"
],
[
"compare_performance",
"factorial_recursive"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 4cac4b018d7de2a1ddca29e5c0082bc7f6e187a2 | 5ac7eb96d79dca2b43723c8371c44610fe160de8 | |||
v1.0 | complete | Prefill | Prefill_4037_C | class TreeNode:
def __init__(self, key):
self.left = None
self.right = None
self.val = key
def insert(root, key):
"""
Inserts a key into BST and returns the root of the modified tree.
Ensures the tree remains a valid BST.
"""
pass
def delete_node(root, key):
"""
... | class TreeNode:
def __init__(self, key):
self.left = None
self.right = None
self.val = key
def insert(root, key):
"""
Inserts a key into BST and returns the root of the modified tree.
"""
if root is None:
return TreeNode(key)
if key < root.val:
root.left ... | from solution import TreeNode, insert, delete_node, in_order_traversal
def test_insert_single_node():
root = None
root = insert(root, 10)
assert in_order_traversal(root) == [10]
def test_insert_multiple_nodes():
root = None
keys = [20, 10, 30, 5, 15, 25, 35]
for key in keys:
root = ins... | [] | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, key, left=None, right=None):\n self.key = key\n self.left = left\n self.right = right\n\nclass BST:\n def __init__(self):\n ... | trial_gpt4o_5 | {
"original_instruction": "Write a function to traverse a binary search tree in a specific manner. It should maintain the balance property of the tree after each insertion and deletion. The function should insert and delete nodes while ensuring the tree remains a valid binary search tree.",
"prompt_id": "00004037",... | 0.559042 | Prefill_4037 | C | [
"insert",
"find_min",
"delete_node",
"in_order_traversal"
] | 4 | [
[
"delete_node",
"find_min"
]
] | 1 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | 08df4a40fd555e5acbe0e943fa3a8e8fa9a7c933 | 6d9fcddcd7f4403187e32c1fa8c53ec9b7ecaa59 | |||
v1.0 | complete | Prefill | Prefill_4504_C | def is_prime(n):
"""
Returns True if n is a prime number, False otherwise.
"""
# Function implementation here
def sum_primes_in_range(start, end):
"""
Returns the sum of all prime numbers in the range from start to end (inclusive).
>>> sum_primes_in_range(1, 10) == 17 # primes are 2, 3... | def is_prime(n):
"""
Returns True if n is a prime number, False otherwise.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def sum_pr... | from solution import sum_primes_in_range
def test_sum_primes_in_small_range():
assert sum_primes_in_range(1, 10) == 17 # primes are 2, 3, 5, 7
def test_sum_primes_in_medium_range():
assert sum_primes_in_range(10, 20) == 60 # primes are 11, 13, 17, 19
def test_sum_primes_include_bounds():
assert sum_pri... | [
{
"docstring": "Returns True if n is a prime number, False otherwise.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns the sum of all prime numbers in the range from start to end (inclusive).",
"function_declara... | [
0,
1,
1,
1,
0,
1,
1,
0,
0,
0
] | 5 | medium | 0.5 | {
"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_5 | {
"original_instruction": "Write a function to calculate the sum of all prime numbers within a given range. The function should take two parameters: the start and end of the range (inclusive). Additionally, write a main function to test your prime sum function with specific test cases.",
"prompt_id": "00004504",
... | 0.803441 | Prefill_4504 | C | [
"is_prime",
"sum_primes_in_range"
] | 2 | [
[
"sum_primes_in_range",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 03198d330302b496474cc7e4a4b21be320f64d62 | 8e5992eadfb47adbb0431f7dcfd7a43b9ce78b6e | |||
v1.0 | complete | Prefill | Prefill_12421_C | def gcd(a, b):
"""
Compute the Greatest Common Divisor (GCD) of two numbers a and b using the Euclidean algorithm.
"""
while b:
a, b = b, a % b
return a
def lcm(a, b):
"""
Compute the Least Common Multiple (LCM) of two numbers a and b.
>>> lcm(12, 15)
60
>>> lcm(100, 10... | def gcd(a, b):
"""
Compute the Greatest Common Divisor (GCD) of two numbers a and b using the Euclidean algorithm.
"""
while b:
a, b = b, a % b
return a
def lcm(a, b):
"""
Compute the Least Common Multiple (LCM) of two numbers a and b.
"""
return abs(a * b) // gcd(a, b) | from solution import gcd, lcm
def test_gcd():
assert gcd(12, 15) == 3
assert gcd(100, 10) == 10
assert gcd(19, 5) == 1
assert gcd(0, 10) == 10
assert gcd(10, 0) == 10
def test_lcm():
assert lcm(12, 15) == 60
assert lcm(100, 10) == 100
assert lcm(19, 5) == 95
assert lcm(0, 10) == 0
... | [
{
"docstring": "Compute the Greatest Common Divisor (GCD) of two numbers a and b using the Euclidean algorithm.",
"function_declaration": "def gcd(a, b):",
"function_name": "gcd",
"parameter_list": "(a, b)"
},
{
"docstring": "Compute the Least Common Multiple (LCM) of two numbers a and b.",
... | [
1,
1,
1,
1,
1,
0,
0,
1,
0,
1
] | 7 | easy | 0.7 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef lcm(a, b):\n \"\"\"\n Compute the Least Common Multiple (LCM) of two numbers using the relationship between GCD and LCM.\n \n Args:\n a (int): First number.\... | trial_gpt4o_9 | {
"original_instruction": "Write a function to compute the Least Common Multiple (LCM) of two numbers using JavaScript, and explain the code.",
"prompt_id": "00012421",
"row_id": 12421,
"seed_ids": "['magpie_prefill_12421']"
} | 0.81847 | Prefill_12421 | C | [
"gcd",
"lcm"
] | 2 | [
[
"lcm",
"gcd"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3a142739cf3c0bb146137bfcef8a5aa3994ac105 | b7d2c72bd24484b2a705936b0cc90c9f05368913 | |||
v1.0 | complete | Prefill | Prefill_4223_C | def tic_tac_toe(moves: List[Tuple[str, Tuple[int, int]]]) -> None:
""" Write a function to implement the classic game "Tic-Tac-Toe". The function takes a list of moves as input. Each move is a tuple containing two elements: the first is the player ('X' or 'O') and the second is the tuple indicating the row and colu... | def print_board(board):
for row in board:
print(" | ".join(row))
print("-" * 5)
def check_winner(board, player):
# Check rows
for row in board:
if all([cell == player for cell in row]):
return True
# Check columns
for col in range(3):
if all([board[row][... | from solution import tic_tac_toe
def test_tic_tac_toe_x_wins_row():
moves = [('X', (0, 0)), ('O', (1, 1)), ('X', (0, 1)), ('O', (2, 2)), ('X', (0, 2))]
tic_tac_toe(moves)
def test_tic_tac_toe_o_wins_column():
moves = [('X', (0, 0)), ('O', (1, 1)), ('X', (0, 2)), ('O', (0, 1)), ('X', (2, 0)), ('O', (2, 1))... | [
{
"docstring": null,
"function_declaration": "def print_board(board):",
"function_name": "print_board",
"parameter_list": "(board)"
},
{
"docstring": null,
"function_declaration": "def check_winner(board, player):",
"function_name": "check_winner",
"parameter_list": "(board, play... | [
1,
1,
1,
0,
0,
1,
0,
1,
0,
0
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def print_board(board):\n for row in board:\n print(\" | \".join(row))\n print(\"-\" * 5)\n print()\n\ndef check_winner(board, player):\n for row in board:\n if ... | trial_gpt4o_7 | {
"original_instruction": "Write a function to implement the classic game \"Tic-Tac-Toe\". The function should take a list of moves as input. Each move is a tuple containing two elements: the first is the player ('X' or 'O') and the second is the tuple indicating the row and column of the board (0-indexed). The funct... | 0.575149 | Prefill_4223 | C | [
"print_board",
"check_winner",
"tic_tac_toe"
] | 3 | [
[
"tic_tac_toe",
"check_winner"
],
[
"tic_tac_toe",
"print_board"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | bd1f0dcf45c438e16683bf9c115faa9219344c2b | 9ee03b20a5009269ef4816e9b2cdc87cc70c59ac | |||
v1.0 | complete | Prefill | Prefill_12296_C | def is_prime(n: int) -> bool:
""" Returns True if n is a prime number, otherwise False.
"""
pass
def average_prime_numbers(n: int) -> float:
""" Returns the average of all prime numbers up to a given number n.
>>> average_prime_numbers(10) == (2 + 3 + 5 + 7) / 4
>>> average_prime_numbers(1) == ... | 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 average_prime_numbers(n):
"""
Returns the average of all prime numbers up ... | from solution import average_prime_numbers
def test_no_prime_numbers():
assert average_prime_numbers(1) == 0
def test_average_up_to_10():
assert average_prime_numbers(10) == (2 + 3 + 5 + 7) / 4
def test_average_up_to_2():
assert average_prime_numbers(2) == 2
def test_average_up_to_20():
assert avera... | [
{
"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 average of all prime numbers up to a given number n.",
"function_declaration": "def aver... | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n i... | trial_gpt4o_0 | {
"original_instruction": "Write a function to count the average of all prime numbers up to a given number. In Python.",
"prompt_id": "00012296",
"row_id": 12296,
"seed_ids": "['magpie_prefill_12296']"
} | 0.752588 | Prefill_12296 | C | [
"is_prime",
"average_prime_numbers"
] | 2 | [
[
"average_prime_numbers",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | da1088619aaae51de5e3663934814dac91fe2633 | 27571fc135f9329bbecd05f79d56b4f8f0309ef1 | |||
v1.0 | complete | Prefill | Prefill_10141_C | def is_leap_year(year: int) -> bool:
""" Determines if a given year is a leap year.
>>> is_leap_year(2020) True
>>> is_leap_year(2021) False
>>> is_leap_year(2000) True
>>> is_leap_year(1900) False
"""
pass
def days_in_month(year: int, month: int) -> int:
""" Returns the number of days ... | def is_leap_year(year):
"""
Determines if a given year is a leap year.
Args:
year (int): The year to check.
Returns:
bool: True if the year is a leap year, False otherwise.
"""
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
return True
return False
de... | import pytest
from solution import days_in_month, is_leap_year
def test_is_leap_year():
assert is_leap_year(2020) == True
assert is_leap_year(2021) == False
assert is_leap_year(2000) == True
assert is_leap_year(1900) == False
def test_days_in_month_regular_year():
assert days_in_month(2021, 1) == ... | [
{
"docstring": "Determines if a given year is a leap year.\n\nArgs:\nyear (int): The year to check.\n\nReturns:\nbool: True if the year is a leap year, False otherwise.",
"function_declaration": "def is_leap_year(year):",
"function_name": "is_leap_year",
"parameter_list": "(year)"
},
{
"docs... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_leap_year(year):\n \"\"\"\n Determines if a year is a leap year.\n \"\"\"\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n ... | trial_gpt4o_9 | {
"original_instruction": "Write a function to find the number of days in a month. You should handle both leap years and non-leap years properly.",
"prompt_id": "00010141",
"row_id": 10141,
"seed_ids": "['magpie_prefill_10141']"
} | 0.620525 | Prefill_10141 | C | [
"is_leap_year",
"days_in_month"
] | 2 | [
[
"days_in_month",
"is_leap_year"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e3b22599384cad1a2c89973d00b6d99454982c3b | ad97272e18dab4dafb55b4c22be0e24315b1924e | |||
v1.0 | complete | Prefill | Prefill_37411_C | def intersection_of_sorted_arrays(A: List[int], B: List[int]) -> List[int]:
""" Find the intersection of two sorted arrays A and B, and return the result as an array C.
The arrays A and B may contain duplicate elements.
The function should have a time complexity of O(log n + log m), where n and m are the le... | def binary_search(arr, target):
"""
Perform binary search to find the target in a sorted array.
"""
left, right = 0, len(arr) - 1
while left <= right:
mid = left + (right - left) // 2
if arr[mid] == target:
return True
elif arr[mid] < target:
left = mi... | def test_intersection_basic():
A = [1, 2, 2, 3, 4]
B = [2, 2, 3, 5]
C = intersection_of_sorted_arrays(A, B)
assert C == [2, 3]
def test_intersection_no_duplicates_in_result():
A = [1, 2, 3, 3, 5, 5, 6]
B = [3, 3, 4, 5, 5, 7]
C = intersection_of_sorted_arrays(A, B)
assert C == [3, 5]
de... | [
{
"docstring": "Perform binary search to find the target in a sorted array.",
"function_declaration": "def binary_search(arr, target):",
"function_name": "binary_search",
"parameter_list": "(arr, target)"
},
{
"docstring": "Find the intersection of two sorted arrays A and B.",
"function_... | [
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 binary_search(arr, x):\n \"\"\"\n Helper function to perform binary search in a sorted array 'arr'\n to find element 'x'. Returns the index if element is found, else -1.\n \"\... | trial_gpt4o_9 | {
"original_instruction": "Write a python function to find the intersection of twosorted arrays A and B, and return the result as an array called C. The arrays A and B may contain duplicate elements. The function should have a time complexity of O(log n + log m), where n and m are the lengths of arrays A and B, respe... | 0.648167 | Prefill_37411 | C | [
"binary_search",
"intersection_of_sorted_arrays"
] | 2 | [
[
"intersection_of_sorted_arrays",
"binary_search"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | df6cc9751d6107f96a6f447fc3329a61020770b2 | 265da7a962971aa9237c3fd85814cbea860295e6 | |||
v1.0 | complete | Prefill | Prefill_37352_C | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def char_to_binary_tree(char):
""" Converts a character to a binary tree, where each node has a value corresponding to the binary representation of the ASCII value of the... | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def char_to_binary_tree(char):
"""
Converts a character to a binary tree, where each node has a value
corresponding to the binary representation of the ASCII val... | from solution import TreeNode, string_to_binary_tree, char_to_binary_tree
def node_to_list(node):
""" Helper function to convert binary tree to list for easier testing """
if node is None:
return []
result = []
while node:
result.append(node.val)
node = node.right
return res... | [] | [
0,
0,
0,
0,
0,
1,
0,
0,
0
] | 1 | hard | 0.111 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Prefill-43K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef string_to_binary_tree(s):\n ... | trial_gpt4o_5 | {
"original_instruction": "Write a python function to convert a string to a binary tree. Each character in the string will correspond to a node in the binary tree. The function should create a binary tree, with each node having a value corresponding to the ASCII value of the character, and left and right children cor... | 0.569101 | Prefill_37352 | C | [
"char_to_binary_tree",
"string_to_binary_tree"
] | 2 | [
[
"string_to_binary_tree",
"char_to_binary_tree"
]
] | 1 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | ec2c5bc9ff9e336298d1c1828bec59067e03d1ae | d91546fcfb3b65317b830d7718513dcddcb18fc7 | |||
v1.0 | complete | Prefill | Prefill_30415_C | def count_elements_in_range(sorted_array, start, end):
"""
Returns the count of elements within the range [start, end] in a sorted array.
:param sorted_array: List[int] - A sorted list of integers
:param start: int - Start of the range (inclusive)
:param end: int - End of the range (inclusive)
... | def count_elements_in_range(sorted_array, start, end):
"""
Returns the count of elements within the range [start, end] in a sorted array.
:param sorted_array: List[int] - A sorted list of integers
:param start: int - Start of the range (inclusive)
:param end: int - End of the range (inclusive)
... | from solution import count_elements_in_range
def test_count_elements_in_range_all_inclusive():
assert count_elements_in_range([1, 2, 3, 4, 5], 2, 4) == 3
def test_count_elements_in_range_empty_array():
assert count_elements_in_range([], 1, 3) == 0
def test_count_elements_in_range_none_in_range():
assert ... | [
{
"docstring": "Returns the count of elements within the range [start, end] in a sorted array.\n\n:param sorted_array: List[int] - A sorted list of integers\n:param start: int - Start of the range (inclusive)\n:param end: int - End of the range (inclusive)\n:return: int - The count of elements within the range ... | [
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 count_elements_in_range(arr, start, end):\n \"\"\"\n Returns the number of elements between start and end (inclusive)\n in a sorted array.\n \n Parameters:\n - arr: list... | trial_gpt4o_9 | {
"original_instruction": "Write a python function to find the number of elements between a given start value and end value in a sorted array. The function should return the count of elements that are within the range [start, end], inclusive.",
"prompt_id": "00030415",
"row_id": 30415,
"seed_ids": "['magpie_pre... | 0.601777 | Prefill_30415 | C | [
"count_elements_in_range",
"binary_search_left",
"binary_search_right"
] | 3 | [
[
"count_elements_in_range",
"binary_search_left"
],
[
"count_elements_in_range",
"binary_search_right"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | f6cef17c3359ddee972bdd043e76cd06a4600af3 | 4948997ae2af4e844ff6c65a9e80bb0c9f33cdf2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.