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
Evol
Evol_147_C
from typing import List, Tuple def filter_and_sort_primes(lst: List[int]) -> Tuple[List[int], int]: """ Write a function that accepts a list of integers and returns the list with all its elements removed except for the prime numbers, but with the primes sorted in descending order. Additionally, the function sh...
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 filter_and_sort_primes(lst): primes = [x for x in lst if is_prime(x)] primes.sort(reverse=True) prime_sum = sum(primes) return primes, prime_s...
from solution import filter_and_sort_primes def test_filter_and_sort_primes_with_mixed_numbers(): assert filter_and_sort_primes([12, 3, 17, 4, 2, 8, 5, 11]) == ([17, 11, 5, 3, 2], 38) def test_filter_and_sort_primes_all_primes(): assert filter_and_sort_primes([2, 3, 5, 7]) == ([7, 5, 3, 2], 17) def test_filt...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def filter_and_sort_primes(lst):", "function_name": "filter_and_sort_primes", "parameter_list": "(lst)" } ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\n\ndef is_prime(n: int) -> bool:\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n ...
trial_gpt4o_9
{ "original_instruction": "Write a function in Python that accepts a list of integers and returns the list with all its elements removed except for the prime numbers, but with the primes sorted in descending order. Additionally, the function should return the sum of these prime numbers.\n\nExample input: [12, 3, 17, ...
0.667839
Evol_147
C
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13c451cf1a9103464d1f87b39f833946dffe49dc
d32a8dad91917eaaa84394620a712405078be3df
v1.0
complete
Evol
Evol_110_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. >>> is_prime(2) == True >>> is_prime(4) == False >>> is_prime(17) == True >>> is_prime(18) == False """ def filter_primes(numbers: List[int]) -> List[int]: """ Return...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, filter_primes, range_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(15) == False assert is_prime(1) == False assert is_prime(0) == False assert is_pr...
[ { "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 from the provided list of integers.", "function_declaration": "def f...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Additionally, write a function that accepts a starting and ending integer, generates a list of all integers within that range, and uses your prime-filtering...
0.710306
Evol_110
C
[ "is_prime", "filter_primes", "range_primes" ]
3
[ [ "filter_primes", "is_prime" ], [ "range_primes", "filter_primes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0c0d491ef1ae82fe29bf0230236ec9f52908eb3d
354003d3a499e26b4204a0bbd2eb55d4be063ccd
v1.0
complete
Evol
Evol_39_C
def read_integers(file_path): """ Reads a file containing a list of integers, one per line. Yields each integer. """ pass def write_moving_averages(file_path, moving_averages): """ Writes the moving averages to a file, one per line. """ pass def calculate_moving_averages(integers, ...
def read_integers(file_path): """ Reads a file containing a list of integers, one per line. Yields each integer. """ with open(file_path, 'r') as file: for line in file: yield int(line.strip()) def write_moving_averages(file_path, moving_averages): """ Writes the moving ...
import os from solution import read_integers, write_moving_averages, calculate_moving_averages, process_file def test_read_integers(tmp_path): # Setup input_file = tmp_path / "input.txt" input_file.write_text("1\n2\n3\n4\n5\n") # Function call and assertion expected_result = [1, 2, 3, 4, 5] ...
[ { "docstring": "Reads a file containing a list of integers, one per line.\nYields each integer.", "function_declaration": "def read_integers(file_path):", "function_name": "read_integers", "parameter_list": "(file_path)" }, { "docstring": "Writes the moving averages to a file, one per line."...
[ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def read_integers_from_file(file_path):\n \"\"\"\n Generator to read integers from a file, one per line.\n \"\"\"\n with open(file_path, 'r') as file:\...
trial_gpt4o_9
{ "original_instruction": "Design a program that reads a text file containing a list of integers, one per line, and calculates the moving average of those integers with a specified window size. The program should then write the moving average results to a new file. Each result should be on a new line. To ensure memor...
0.601694
Evol_39
C
[ "read_integers", "write_moving_averages", "calculate_moving_averages", "process_file" ]
4
[ [ "process_file", "calculate_moving_averages" ], [ "process_file", "read_integers" ], [ "process_file", "write_moving_averages" ] ]
3
[]
false
[]
false
pytest
true
[]
true
d11c5961e0af97cad907e1c2d06405ae3e52153d
2043b86f43e7205a290d9ca8897cd1a023207593
v1.0
complete
Evol
Evol_119_C
def transpose(matrix): """ Returns the transpose of a given matrix. """ # Your code here def determinant(matrix): """ Returns the determinant of the given square matrix. """ # Your code here def transpose_and_determinant(matrix): """ Returns the transpose of the matrix and the ...
def transpose(matrix): """ Returns the transpose of a given matrix. """ return [list(row) for row in zip(*matrix)] def determinant(matrix): """ Returns the determinant of the given square matrix. """ n = len(matrix) if n == 1: return matrix[0][0] if n == 2: retur...
from solution import transpose, determinant, transpose_and_determinant def test_transpose_square_matrix(): assert transpose([[1, 2], [3, 4]]) == [[1, 3], [2, 4]] def test_transpose_rectangular_matrix(): assert transpose([[1, 2, 3], [4, 5, 6]]) == [[1, 4], [2, 5], [3, 6]] def test_determinant_2x2_matrix(): ...
[ { "docstring": "Returns the transpose of a given matrix.", "function_declaration": "def transpose(matrix):", "function_name": "transpose", "parameter_list": "(matrix)" }, { "docstring": "Returns the determinant of the given square matrix.", "function_declaration": "def determinant(matrix...
[ 1, 1, 0, 0, 0, 1, 1, 1, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def transpose(matrix):\n \"\"\"\n Returns the transpose of the given matrix.\n \"\"\"\n return [list(row) for row in zip(*matrix)]\n\ndef determinant(m...
trial_gpt4o_6
{ "original_instruction": "Design a function that takes a matrix of integers and returns the transpose of the matrix. The transpose of a matrix is a new matrix whose rows are the columns of the original. Additionally, write a function to calculate the determinant of the transposed matrix if it is a square matrix. Ens...
0.558157
Evol_119
C
[ "transpose", "determinant", "transpose_and_determinant" ]
3
[ [ "transpose_and_determinant", "determinant" ], [ "transpose_and_determinant", "transpose" ] ]
2
[]
false
[]
false
pytest
true
[]
true
98a2648a78fc1f8fa954004f00b287f6708237fc
b12fc40ba6ec4d4644971232e8a69ca0bead2108
v1.0
complete
Evol
Evol_234_C
def is_prime(num: int) -> bool: """ Determine if a given number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False """ def find_largest_prime(n: int) -> int: """ Finds the largest prime number less than or equal to n. >>> find_largest_prime(10) 7 >>> fin...
def is_prime(num): """ Checks 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 find_largest_prime(...
from solution import is_prime, find_largest_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(17) == True assert is_prime(18) ==...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds the largest prime number less than or equal to n.", "function_declaration": "def find_largest_prime(n):", "func...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if the input number is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n i...
trial_gpt4o_8
{ "original_instruction": "Write a Python function called `find_largest_prime` that takes a single integer argument `n` and returns the largest prime number that is less than or equal to `n`. If no such prime exists (i.e., if `n` is less than 2), the function should return `None`. To complete this task, implement a h...
0.735514
Evol_234
C
[ "is_prime", "find_largest_prime" ]
2
[ [ "find_largest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
de72c8fcd9fbd1679c7f08a2e9900af1809278fe
eaa0f6916469c9a98426bd7b01bd625d9452f689
v1.0
complete
Evol
Evol_225_C
def sum_of_ones_in_hex_binary(lst): """ Takes a list of integers, converts each to its hexadecimal equivalent, counts the number of 1's in its binary representation, and returns the sum of these counts for all elements in the list. >>> sum_of_ones_in_hex_binary([10]) == 2 >>> sum_of_ones_in_he...
def count_ones_in_binary_of_hex(num): """ Takes an integer number and returns the number of 1's in the binary representation of its hexadecimal equivalent. """ # Convert to hexadecimal and remove '0x' prefix hex_num = hex(num)[2:] # Convert each hexadecimal digit to its binary form and count th...
from solution import sum_of_ones_in_hex_binary def test_single_number(): assert sum_of_ones_in_hex_binary([10]) == 2 # hexadecimal 'a' -> binary '1010' assert sum_of_ones_in_hex_binary([15]) == 4 # hexadecimal 'f' -> binary '1111' def test_multiple_numbers(): assert sum_of_ones_in_hex_binary([10, 15]) =...
[ { "docstring": "Takes an integer number and returns the number of 1's in the binary representation of its hexadecimal equivalent.", "function_declaration": "def count_ones_in_binary_of_hex(num):", "function_name": "count_ones_in_binary_of_hex", "parameter_list": "(num)" }, { "docstring": "Ta...
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def count_ones_in_hexadecimal_binary(my_list):\n \"\"\"\n For each integer in the list, converts it to its hexadecimal equivalent, counts the \n number of...
trial_gpt4o_9
{ "original_instruction": "Create a Python function that receives a list of integers. For each element in the list, perform the following operations:\n1. Convert the integer to its hexadecimal equivalent.\n2. Count the number of `1`s in the binary representation of this hexadecimal number.\n3. Calculate the sum of th...
0.6246
Evol_225
C
[ "count_ones_in_binary_of_hex", "sum_of_ones_in_hex_binary" ]
2
[ [ "sum_of_ones_in_hex_binary", "count_ones_in_binary_of_hex" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ff92efdd6383be1ca19503698414d3da502035a
970274cb92ef2d6568b7cdd38d63670326b9bd39
v1.0
complete
Evol
Evol_228_C
def filter_and_sort_primes(lst: List[int]) -> List[int]: """ Filters the prime numbers from the list and sorts them in descending order. >>> filter_and_sort_primes([10, 3, 5, 8, 15, 2]) [5, 3, 2] >>> filter_and_sort_primes([4, 6, 8, 10, 15]) [] >>> filter_and_sort_primes([11, 13, 5, 7, 3]) [13, 11, 7, 5...
def is_prime(n): """Helper function to check if a number is a prime number.""" if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p +...
from solution import filter_and_sort_primes def test_filter_and_sort_primes_with_mixed_numbers(): assert filter_and_sort_primes([10, 3, 5, 8, 15, 2]) == [5, 3, 2] def test_filter_and_sort_primes_with_no_primes(): assert filter_and_sort_primes([4, 6, 8, 10, 15]) == [] def test_filter_and_sort_primes_with_only...
[ { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the prime numbers from the list and sorts them in descending order.", "function_declaratio...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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, in...
trial_gpt4o_9
{ "original_instruction": "Craft a Python function that accepts a list of integers and returns a new list containing only the prime numbers from the original list. The result list should be sorted in descending order. For example, given the input list [10, 3, 5, 8, 15, 2], your function should return [5, 3, 2].", "...
0.676461
Evol_228
C
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c6949d484cb8cffc202e630de736e7e82ee4440d
2882009b027ccead8a7b8703366245ffc647ad54
v1.0
complete
Evol
Evol_278_C
def restore_ip_addresses(s: str) -> List[str]: """ Write a Python function that takes a string as input and returns a list of all valid IP addresses that can be formed by inserting three dots into the string. A valid IP address consists of exactly four integers (each ranging from 0 to 255), separated...
def is_valid(segment): """ Check if the segment is a valid IP address segment. """ return int(segment) <= 255 and (segment == "0" or segment[0] != "0") def restore_ip_addresses(s): """ Restore valid IP addresses from a string by inserting three dots. """ n = len(s) result = [] ...
from solution import restore_ip_addresses def test_restore_ip_addresses_example(): assert restore_ip_addresses("25525511135") == ["255.255.11.135", "255.255.111.35"] def test_restore_ip_addresses_empty(): assert restore_ip_addresses("") == [] def test_restore_ip_addresses_short_string(): assert restore_i...
[ { "docstring": "Check if the segment is a valid IP address segment.", "function_declaration": "def is_valid(segment):", "function_name": "is_valid", "parameter_list": "(segment)" }, { "docstring": "Restore valid IP addresses from a string by inserting three dots.", "function_declaration"...
[ 1, 1, 0, 0, 0, 0, 1, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def restore_ip_addresses(s: str):\n \"\"\"\n Returns a list of all valid IP addresses that can be formed by inserting three dots into the string.\n \"\"\"...
trial_gpt4o_6
{ "original_instruction": "Write a Python function that takes a string as input and returns a list of all valid IP addresses that can be formed by inserting three dots into the string. A valid IP address consists of exactly four integers (each ranging from 0 to 255), separated by dots. Each integer must not have lead...
0.622427
Evol_278
C
[ "is_valid", "restore_ip_addresses" ]
2
[ [ "restore_ip_addresses", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9b60b95965cc04194dce0da327c6b48551dbffcb
c8646caa75a8d00059f836e904ccda59dd9c2b55
v1.0
complete
Evol
Evol_387_C
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ pass def filter_primes(numbers): """ Returns a list of prime numbers from the given list `numbers`. >>> filter_primes([2, 3, 4, 5, 10, 17, 18, 19]) [2, 3, 5, 17, 19] >>> filter_primes([0, 1, -3, -1, -5, 22, 2...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter...
from solution import filter_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(-7) == 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 a list of prime numbers from the given list `numbers`.", "function_declaration": "def filter...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ret...
trial_gpt4o_6
{ "original_instruction": "Implement a function that takes a list of integers and returns a new list with only the prime numbers from the original list. A prime number is a natural number greater than 1 that has no divisors other than 1 and itself.\n\n```python\ndef filter_primes(numbers):\n # Your code here\n\n# ...
0.837943
Evol_387
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ab12d9d6e702ef8a0809d5f4ff1d72277a8ecf50
d1d7c9d58409eba8df9dd93b32e8bebc0ded6061
v1.0
complete
Evol
Evol_264_C
from typing import List, Tuple def fibonacci(n: int) -> int: """ Returns the n-th Fibonacci number. If n is a negative integer, it raises a ValueError. >>> fibonacci(0) 0 >>> fibonacci(1) 1 >>> fibonacci(2) 1 >>> fibonacci(3) 2 >>> fibonacci(4) 3 >>> try: ... fibonacci(-1) ...
def fibonacci(n): """ Returns the n-th Fibonacci number. """ if n < 0: raise ValueError("Fibonacci number is not defined for negative integers.") elif n == 0: return 0 elif n == 1: return 1 else: a, b = 0, 1 for _ in range(2, n + 1): a, b =...
from solution import fibonacci, list_fibonacci_values def test_fibonacci(): assert fibonacci(0) == 0 assert fibonacci(1) == 1 assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(4) == 3 assert fibonacci(5) == 5 assert fibonacci(10) == 55 def test_fibonacci_negative(): tr...
[ { "docstring": "Returns the n-th Fibonacci number.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Returns a list of tuples. Each tuple consists of an integer from the input list and its corresponding Fibonacci value.", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def fib(n):\n \"\"\"\n Returns the n-th Fibonacci number.\n \"\"\"\n if n < 0:\n raise ValueError(\"Negative integers are not allowed\")\n el...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that accepts a list of integers and returns a list of tuples. Each tuple consists of an integer from the input list and its corresponding Fibonacci value. The Fibonacci value of an integer `n` is defined as the `n`-th Fibonacci number in the sequence, where the 0th a...
0.789316
Evol_264
C
[ "fibonacci", "list_fibonacci_values" ]
2
[ [ "list_fibonacci_values", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c0ff6a610524795698cd551292177bbf784d6897
142e2c6a632c30e542604203fe500d3df82a0f09
v1.0
complete
Evol
Evol_261_C
def is_prime(n: int) -> bool: """ Determine if a given number n is a prime number. >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(9) False >>> is_prime(13) True """ def find_primes_in_range(start: int, end: int...
def is_prime(n): """ Determines if the given 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 is_prime, find_primes_in_range, count_primes_in_range def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(13) def test_find_primes_in_range(): assert find...
[ { "docstring": "Determines if the given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers in the given range [start, end).", "function_declaration": "def fi...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n 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 % ...
trial_gpt4o_9
{ "original_instruction": "Write a Python program to find all the prime numbers in a given range of integers without using any libraries. Additionally, your program should be able to count the number of prime numbers found in the given range.\n\nYour task:\n1. Write a function that checks whether a given number is pr...
0.765723
Evol_261
C
[ "is_prime", "find_primes_in_range", "count_primes_in_range" ]
3
[ [ "count_primes_in_range", "find_primes_in_range" ], [ "find_primes_in_range", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ccc944baff2e3f195d6249ec01268b464c26cccc
dfd2d7dc0e15a3f11442bbe76b5346e037e946a1
v1.0
complete
Evol
Evol_362_C
def prime_frequencies(lst: List[int]) -> List[Tuple[int, int]]: """ Implement a function that receives a list of integers and returns a new list containing only the prime numbers from the input list, paired with their frequencies in ascending order. >>> prime_frequencies([7, 3, 5, 7, 3, 2, 7, 11, 5, 13, 2]...
def is_prime(n): 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 prime_frequencies(lst): prime_counts = {} for number in lst: ...
from solution import prime_frequencies def test_primes_mixed_frequencies(): assert prime_frequencies([7, 3, 5, 7, 3, 2, 7, 11, 5, 13, 2]) == [(2, 2), (3, 2), (5, 2), (7, 3), (11, 1), (13, 1)] def test_single_prime(): assert prime_frequencies([2, 2, 2]) == [(2, 3)] def test_no_primes(): assert prime_frequ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_frequencies(lst):", "function_name": "prime_frequencies", "parameter_list": "(lst)" } ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if the number n is prime.\n \"\"\"\n if n <= 1:\n return False\n elif n <= 3:\n r...
trial_gpt4o_9
{ "original_instruction": "Implement a function in Python that receives a list of integers and returns a new list containing only the prime numbers from the input list. Additionally, for each prime number found, attach the number of times it appears in the input list. Present the prime numbers in ascending order in t...
0.647723
Evol_362
C
[ "is_prime", "prime_frequencies" ]
2
[ [ "prime_frequencies", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86163341042edf6e703bd3acede48af37f81f01c
b440cf684492fb8651ec19a9cd79c4a799ebe823
v1.0
complete
Evol
Evol_311_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(-1) False >>> is_prime(0) False >>> is_prime(1) False """ def sum_primes_in_range(lst: List[int...
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 p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def sum_primes_in_range(lst, mi...
from solution import is_prime, sum_primes_in_range def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(-1) assert not is_prime(0) assert not is_prime(1) def test_sum_primes_in_range_no_primes(): assert sum_primes_in_r...
[ { "docstring": "Checks 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 within the range [min_value, max_value] from the list.", "function_declaration": "def sum_pr...
[ 0, 0, 1, 0, 0, 1, 1, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Check if a number n is prime.\"\"\"\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": "Write a Python function that takes a list of integers and returns the sum of the elements that are both prime numbers and lie within a given range [min_value, max_value], inclusive. If no such elements exist in the list, return 0. Consider the list may contain negative numbers and non-prime...
0.708045
Evol_311
C
[ "is_prime", "sum_primes_in_range" ]
2
[ [ "sum_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2c6291565d6bd999d577f08f3f8fc38d345485cd
d37dfcbae119abe2fa29af2d667f2799def21922
v1.0
complete
Evol
Evol_332_C
import random import numpy as np from typing import List, Tuple def initialize_centroids(k: int, data: List[List[float]]) -> List[List[float]]: """ Randomly initializes centroids by selecting k unique points from the dataset. """ # [Implementation goes here] def assign_points_to_clusters(centroids: Li...
import random import numpy as np def initialize_centroids(k, data): """ Randomly initializes centroids by selecting k unique points from the dataset. """ centroids = random.sample(data, k) return centroids def assign_points_to_clusters(centroids, data): """ Assigns each data point to the n...
from solution import k_means_clustering def test_initialize_centroids(): data = [[1, 2], [2, 3], [3, 4]] k = 2 centroids = initialize_centroids(k, data) assert len(centroids) == k assert all(c in data for c in centroids) def test_assign_points_to_clusters(): centroids = [[1, 2], [8, 7]] ...
[ { "docstring": "Randomly initializes centroids by selecting k unique points from the dataset.", "function_declaration": "def initialize_centroids(k, data):", "function_name": "initialize_centroids", "parameter_list": "(k, data)" }, { "docstring": "Assigns each data point to the nearest centr...
[ 0, 1, 1, 0, 1, 0, 1, 1, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import random\nimport math\n\ndef euclidean_distance(p1, p2):\n \"\"\"\n Calculate the Euclidean distance between two points.\n \"\"\"\n return math.sq...
trial_gpt4o_7
{ "original_instruction": "Write a function in Python to perform k-means clustering on a given dataset. The function should take the number of clusters `k`, the dataset (a list of coordinates in two-dimensional space), and the number of iterations. Your implementation should showcase the initialization of centroids, ...
0.827281
Evol_332
C
[ "initialize_centroids", "assign_points_to_clusters", "update_centroids", "k_means_clustering" ]
4
[ [ "k_means_clustering", "assign_points_to_clusters" ], [ "k_means_clustering", "initialize_centroids" ], [ "k_means_clustering", "update_centroids" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy" ]
false
718fa9594675e20e6bb2ba2ae42c79870a6dbafe
2c03e2e63dca7d742564dcd4c77d4a3bff3076e1
v1.0
complete
Evol
Evol_408_C
def merge(left: List[int], right: List[int]) -> List[int]: """ Merges two sorted lists into one sorted list. >>> merge([1, 3, 5], [2, 4, 6]) [1, 2, 3, 4, 5, 6] """ pass def merge_sort(numbers: List[int]) -> List[int]: """ Sorts a list of numbers in ascending order using the merge sort algor...
def merge(left, right): """ Merges two sorted lists into one sorted list. """ result = [] i = j = 0 # Traverse both lists and insert the smallest element from either list into the result list while i < len(left) and j < len(right): if left[i] <= right[j]: result.appe...
from solution import merge_sort def test_merge_sort_simple(): assert merge_sort([34, 7, 23, 32, 5, 62]) == [5, 7, 23, 32, 34, 62] def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_sorted(): assert merge_so...
[ { "docstring": "Merges two sorted lists into one sorted list.", "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" }, { "docstring": "Sorts a list of numbers in ascending order using the merge sort algorithm.", "function_declara...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def merge(left, right):\n \"\"\"\n Merge two sorted lists into one sorted list.\n \"\"\"\n result = []\n i = j = 0\n\n # Merge the two lists toge...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of numbers and returns the list sorted in ascending order. Use the merge sort algorithm to implement this function. \n\nExample:\n```\nInput: [34, 7, 23, 32, 5, 62]\nOutput: [5, 7, 23, 32, 34, 62]\n```\n\nHints:\n1. Merge sort is a divide-and-conque...
0.563561
Evol_408
C
[ "merge", "merge_sort" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0311fb68e23dc7d0336cb624a3634fd91e02fdad
415137a5aebbde363ac5a9efec790dddae740420
v1.0
complete
Evol
Evol_417_C
import re operators = set(['+', '-', '*', '/', '(', ')']) priority = {'+': 1, '-': 1, '*': 2, '/': 2} def infix_to_postfix(expression): """ Convert infix expression to postfix expression. """ def evaluate_postfix(expression): """ Evaluate a postfix expression. """ def validate_expression(expression): ...
import re operators = set(['+', '-', '*', '/', '(', ')']) priority = {'+': 1, '-': 1, '*': 2, '/': 2} def infix_to_postfix(expression): stack = [] output = '' for char in expression: if char not in operators: output+= char elif char=='(': stack.append...
from solution import compute_expression, validate_expression def test_simple_addition(): assert compute_expression("2+3") == 5 def test_simple_subtraction(): assert compute_expression("5-3") == 2 def test_simple_multiplication(): assert compute_expression("4*2") == 8 def test_simple_division(): asse...
[ { "docstring": null, "function_declaration": "def infix_to_postfix(expression):", "function_name": "infix_to_postfix", "parameter_list": "(expression)" }, { "docstring": null, "function_declaration": "def evaluate_postfix(expression):", "function_name": "evaluate_postfix", "param...
[ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import re\n\ndef evaluate_expression(expression):\n \"\"\"\n Evaluates a given arithmetic expression with integers and operators +, -, *, and /.\n It hand...
trial_gpt4o_7
{ "original_instruction": "Write a program that takes a string containing an arithmetic expression with integers and the operators +, -, *, and /. The program should parse the string and compute the resulting value, taking into account the correct order of operations (PEMDAS/BODMAS rules). Additionally, enhance the p...
0.648873
Evol_417
C
[ "infix_to_postfix", "evaluate_postfix", "validate_expression", "compute_expression" ]
4
[ [ "compute_expression", "evaluate_postfix" ], [ "compute_expression", "infix_to_postfix" ], [ "compute_expression", "validate_expression" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8cc640733f915f8eb793304358b24a4c7dfbf2bc
8336d5d8ef0bebfddd6e6f8372652ae3132714c0
v1.0
complete
Evol
Evol_534_C
def is_perfect_square(n: int) -> bool: """ Checks if a given integer n is a perfect square. >>> is_perfect_square(0) True >>> is_perfect_square(1) True >>> is_perfect_square(4) True >>> is_perfect_square(26) False """ def filter_perfect_squares(lst: List[int]) -> List[int]: """ Retu...
def is_perfect_square(n): """ Checks if a given integer n is a perfect square. """ if n < 0: return False root = int(n**0.5) return root*root == n def filter_perfect_squares(lst): """ Returns a list of perfect squares from the original list of integers. """ return [x for...
from solution import is_perfect_square, filter_perfect_squares def test_is_perfect_square(): assert is_perfect_square(0) == True assert is_perfect_square(1) == True assert is_perfect_square(4) == True assert is_perfect_square(9) == True assert is_perfect_square(16) == True assert is_perfect_squ...
[ { "docstring": "Checks if a given integer n is a perfect square.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Returns a list of perfect squares from the original list of integers.", "function_decla...
[ 1, 1, 1, 1, 1, 1, 1, 0, 0, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(n):\n \"\"\"\n This function checks if a number n is a perfect square.\n \"\"\"\n if n < 0:\n return False\...
trial_gpt4o_9
{ "original_instruction": "Design a Python program that takes a list of integers and returns a new list containing only the elements that are perfect squares from the original list. Constraints: Do not use any built-in functions that directly identify or check for perfect squares.", "prompt_id": "00000534", "row_...
0.652683
Evol_534
C
[ "is_perfect_square", "filter_perfect_squares" ]
2
[ [ "filter_perfect_squares", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d14a8de94c77c568b633c90c73e4f868825fb6c7
1c8e9249c401201bf36374eadbf2c8241ef821af
v1.0
complete
Evol
Evol_504_C
def is_prime(n: int) -> bool: """ Check if a given number n is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False >>> is_prime(19) True """ def list_primes_in_range(start: int, end: int) -> List[int]: """ List...
def is_prime(n): """ Check if a given 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 += ...
from solution import list_primes_in_range, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True def test_list_primes_in_range(): assert list_prime...
[ { "docstring": "Check if a given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Lists all prime numbers in the given range [start, end].", "function_declaration": "def list_primes_in_range(...
[ 1, 1, 1, 0, 1, 0, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_9
{ "original_instruction": "將給定範圍內的所有質數列出來。\n範圍:[10, 50]", "prompt_id": "00000504", "row_id": 504, "seed_ids": "[45980]" }
0.760326
Evol_504
C
[ "is_prime", "list_primes_in_range" ]
2
[ [ "list_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0a743eee64ac3dc4575ea6fd9d71ae1c0633469b
b38cbe869bdd018ea7efc018ae64c7c478d7c79c
v1.0
complete
Evol
Evol_456_C
def generate_pascals_triangle(num_rows): """ Generates Pascal's Triangle up to the given number of rows using recursion. >>> generate_pascals_triangle(0) == [] >>> generate_pascals_triangle(1) == [[1]] >>> generate_pascals_triangle(2) == [[1], [1, 1]] >>> generate_pascals_triangle(3) == [[1], [1, 1]...
def generate_pascals_triangle(num_rows): """ Generates Pascal's Triangle up to the given number of rows using recursion. """ if num_rows < 0: raise ValueError("Number of rows must be a non-negative integer.") def generate_row(previous_row): row = [1] for i in range(1, le...
from solution import generate_pascals_triangle, formatted_pascals_triangle def test_generate_pascals_triangle(): assert generate_pascals_triangle(0) == [] assert generate_pascals_triangle(1) == [[1]] assert generate_pascals_triangle(2) == [[1], [1, 1]] assert generate_pascals_triangle(3) == [[1], [1, 1...
[ { "docstring": "Generates Pascal's Triangle up to the given number of rows using recursion.", "function_declaration": "def generate_pascals_triangle(num_rows):", "function_name": "generate_pascals_triangle", "parameter_list": "(num_rows)" }, { "docstring": "Generates and prints Pascal's Tria...
[ 1, 1, 0, 1, 0, 0, 0, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def get_pascals_triangle_row(row_num):\n \"\"\"\n Recursively generates the row of Pascal's Triangle.\n \"\"\"\n if row_num == 0:\n return [1]\n...
trial_gpt4o_8
{ "original_instruction": "Design a Python function that takes an integer input representing the number of rows, and prints a Pascal's Triangle up to that row, using recursion. The function should handle invalid inputs gracefully by prompting the user to enter a valid integer if a non-numeric or negative value is pro...
0.535182
Evol_456
C
[ "generate_pascals_triangle", "formatted_pascals_triangle" ]
2
[ [ "formatted_pascals_triangle", "generate_pascals_triangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5e874e95708013178fef7f6234eda713a9dd39a5
7d1445a29bcb4e3e2002de739bdc45c7fb77a4b1
v1.0
complete
Evol
Evol_465_C
def is_prime(num: int) -> bool: """ Determines if a given number is a prime number. A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(11) True >>...
def is_prime(num): 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_primes_less_than(N): """ Returns the sum of all prime...
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(11) == True assert is_prime(97) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers less than a given positive integer N.", "function_declaration": "def sum_of_primes_less_than(N):", "functi...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_8
{ "original_instruction": "Write a function that calculates the sum of all prime numbers less than a given positive integer N. A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. The function should take an integer N as input and return the sum of all pr...
0.828571
Evol_465
C
[ "is_prime", "sum_of_primes_less_than" ]
2
[ [ "sum_of_primes_less_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
74b7a6322c854aea324676cd725c053d6915b0f2
35a3683ca3e60fb3354049a0bf0dfce4df598ced
v1.0
complete
Evol
Evol_272_C
import pandas as pd from sklearn.ensemble import IsolationForest from sklearn.preprocessing import StandardScaler from datetime import datetime def preprocess_data(df): """ Preprocess the transaction data by converting the 'timestamp' to datetime components and performing one-hot encoding on categorical fe...
import pandas as pd from sklearn.ensemble import IsolationForest from sklearn.preprocessing import StandardScaler from datetime import datetime def preprocess_data(df): """ Preprocess the transaction data. """ # Convert 'timestamp' to datetime and extract important features df['timestamp'] = pd.to_...
import pandas as pd from solution import preprocess_data, detect_anomalies, update_model_with_new_data def test_preprocess_data(): data = { 'timestamp': ['2023-09-01 10:05:00', '2023-09-02 15:16:30'], 'amount': [100, 250], 'category': ['groceries', 'utilities'] } df = pd.DataFrame(d...
[ { "docstring": "Preprocess the transaction data.", "function_declaration": "def preprocess_data(df):", "function_name": "preprocess_data", "parameter_list": "(df)" }, { "docstring": "Detect anomalies in the transaction data using the IsolationForest algorithm.", "function_declaration": "...
[ 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import pandas as pd\nfrom sklearn.ensemble import IsolationForest\nfrom sklearn.preprocessing import StandardScaler\nfrom datetime import datetime\n\nclass Anomaly...
trial_gpt4o_4
{ "original_instruction": "Design and implement a system that detects and classifies anomalies in a series of time-stamped transactions using Python and scikit-learn. The system should be able to read data from a CSV file containing transaction details including 'timestamp', 'amount', 'category', etc. Your task inclu...
0.593508
Evol_272
C
[ "preprocess_data", "detect_anomalies", "update_model_with_new_data" ]
3
[ [ "detect_anomalies", "preprocess_data" ], [ "update_model_with_new_data", "detect_anomalies" ] ]
2
[]
false
[]
false
pytest
true
[ "pandas", "sklearn" ]
false
08b80486205b1ff323302657369766a2eee0f6c5
5729a6676ef1f85c780071ab672406964501fa10
v1.0
complete
Evol
Evol_702_C
def prime_numbers_up_to_n(n: int) -> List[int]: """ Write a function that takes an integer `n` and returns a list of all prime numbers up to and including `n`. Do not use any built-in libraries for checking prime numbers, and implement the function from scratch. >>> prime_numbers_up_to_n(10) ...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += ...
from solution import prime_numbers_up_to_n def test_primes_up_to_10(): assert prime_numbers_up_to_n(10) == [2, 3, 5, 7] def test_primes_up_to_1(): assert prime_numbers_up_to_n(1) == [] def test_primes_up_to_2(): assert prime_numbers_up_to_n(2) == [2] def test_primes_up_to_3(): assert prime_numbers_u...
[ { "docstring": "Checks 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 up to and including n.", "function_declaration": "def prime_numbers_up_to_n(n):", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes an integer `n` and returns a list of all prime numbers up to and including `n`. Do not use any built-in libraries for checking prime numbers, and implement the function from scratch.", "prompt_id": "00000702", "row_id": 702, "seed_ids": "[5067]" }
0.827084
Evol_702
C
[ "is_prime", "prime_numbers_up_to_n" ]
2
[ [ "prime_numbers_up_to_n", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc68121cc77d01885b33a6647b5c68135f7869b4
433b0551b45f86ffb9d80ea5819b8e593a88c9b4
v1.0
complete
Evol
Evol_661_C
def is_palindrome(s: str) -> bool: """ Helper function to check if a given string is a palindrome. >>> is_palindrome("a") True >>> is_palindrome("aba") True >>> is_palindrome("abc") False >>> is_palindrome("abba") True """ def palindromic_substrings(string: str) -> List[str]...
def is_palindrome(s): """ Helper function to check if a given string is a palindrome. """ return s == s[::-1] def palindromic_substrings(string): """ Finds and returns all palindromic substrings in a given string. """ n = len(string) palindromes = [] for i in range(n): #...
from solution import palindromic_substrings, is_palindrome def test_single_character(): assert palindromic_substrings("a") == ["a"] def test_no_palindromic_substring(): assert palindromic_substrings("abc") == ["a", "b", "c"] def test_all_same_characters(): assert palindromic_substrings("aaa") == ["a", "a...
[ { "docstring": "Helper function to check if a given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Finds and returns all palindromic substrings in a given string.", "function_declarat...
[ 0, 0, 0, 0, 1, 0, 0, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Checks if a given string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef palindromic_substrings(s):\n \"\"...
trial_gpt4o_9
{ "original_instruction": "Design a procedure, employing a programming language of your choice, to evaluate and display all palindromic substrings present within a specified string, such as \"racecar\".", "prompt_id": "00000661", "row_id": 661, "seed_ids": "[20596]" }
0.800708
Evol_661
C
[ "is_palindrome", "palindromic_substrings" ]
2
[ [ "palindromic_substrings", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54c2da9cc07f0a0a15d9af857caa729ff8033373
ee9e2128aea9d76f761b8f4d8e9f85c6812684c9
v1.0
complete
Evol
Evol_855_C
def is_prime(n: int) -> bool: """Determines if the given number n is a prime number. >>> is_prime(2) True >>> is_prime(4) False """ def filter_and_sort_primes(numbers: List[int]) -> List[int]: """Filters the prime numbers from the input list and returns them sorted in ascending order. >...
import math def is_prime(n): """ Determines if the given 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...
from solution import is_prime, filter_and_sort_primes 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 assert is_prime(1...
[ { "docstring": "Determines if the given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the prime numbers from the input list and returns them sorted in ascending order.", "function_...
[ 1, 1, 0, 1, 1, 1, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_8
{ "original_instruction": "Create a Python function that takes an unsorted list of integers and returns a new list containing only the prime numbers from the input list, sorted in ascending order. Implement a helper function to determine if a number is prime. Use efficient algorithms to handle large lists and numbers...
0.758252
Evol_855
C
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a9af650637ed53fbb9b9ae26e5b2d1566c1e781
a36843c359eafee36067054c7d2dbee0ec44e20d
v1.0
complete
Evol
Evol_605_C
import string def clean_string(s: str) -> str: """ Cleans the input string by removing spaces, punctuation, and converting to lowercase. """ pass def are_anagrams(s1: str, s2: str) -> bool: """ Determines if two strings are anagrams of each other, ignoring case, spaces, and punctuation. >>> are_anagra...
import string def clean_string(s): """ Cleans the input string by removing spaces, punctuation, and converting to lowercase. """ return ''.join(e for e in s if e.isalnum()).lower() def are_anagrams(s1, s2): """ Determines if two strings are anagrams of each other, ignoring case, spaces, and pu...
from solution import are_anagrams, are_anagrams_strict def test_are_anagrams(): assert are_anagrams("The eyes", "They see") assert are_anagrams("A gentleman", "Elegant man") assert are_anagrams("Hello, World!", "world Hello!") assert are_anagrams("Dormitory", "Dirty room") assert are_anagrams("Dorm...
[ { "docstring": "Cleans the input string by removing spaces, punctuation, and converting to lowercase.", "function_declaration": "def clean_string(s):", "function_name": "clean_string", "parameter_list": "(s)" }, { "docstring": "Determines if two strings are anagrams of each other, ignoring c...
[ 1, 0, 0, 1, 1, 1, 0, 0, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import re\nfrom collections import Counter\n\ndef clean_string(s):\n \"\"\"\n Helper function to clean the string by removing spaces, punctuations,\n and ...
trial_gpt4o_9
{ "original_instruction": "Write a function to determine if two strings are anagrams of each other. Two strings are anagrams if they are made up of the same characters with the same frequencies, but in a different order. Your solution should be case-insensitive and should ignore spaces and punctuation. Additionally, ...
0.616397
Evol_605
C
[ "clean_string", "are_anagrams", "are_anagrams_strict" ]
3
[ [ "are_anagrams", "clean_string" ], [ "are_anagrams_strict", "clean_string" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1a5423bad7275428f2bd0c15f7fa2441753c6c8f
614d8dcde6b7d9d99adec85d91c6526cf5c59c58
v1.0
complete
Evol
Evol_577_C
def filter_primes(input_list): """ Takes a list of integers and returns a new list containing only the prime numbers from the input list. Excludes negative numbers, zero, and non-numeric data. Raises ValueError for non-list input. >>> filter_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes...
import pytest from solution import filter_primes def test_filter_primes_with_positive_numbers(): assert filter_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_with_negative_numbers_and_zero(): assert filter_primes([-10, -5, 0, 1, 2, 3, 11]) == [2, 3, 11] def test_filter_primes_...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the input list.\nExcludes negative numbers, zero, and...
[ 0, 1, 0, 1, 1, 1, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is a prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ...
trial_gpt4o_8
{ "original_instruction": "Write a function that takes a list of integers and returns a new list containing only the prime numbers from the input list. Ensure the function handles negative numbers and zero correctly by excluding them, and validate input to handle non-numeric data.\ndef filter_primes(input_list):", ...
0.642742
Evol_577
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd826cda00565057633f6b5fd63ae1ac9a607dfe
eaca01ceebf50061cec4d11c022f13e0cb8c0f18
v1.0
complete
Evol
Evol_732_C
def is_prime(num): """ Check if a number is a prime number. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(7) == True >>> is_prime(9) == False """ pass def filter_primes(lst): """ Filter prime numbers from the input list. >>> filter...
def is_prime(num): """ Check if a number is a prime number. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def filter_primes(lst): """ Filter prime numbers from the input list. """ return ...
from solution import is_prime, filter_primes def test_is_prime_with_primes(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(7) == True assert is_prime(11) == True def test_is_prime_with_non_primes(): assert is_prime(1) == False assert is_p...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Filter prime numbers from the input list.", "function_declaration": "def filter_primes(lst):", "function_name...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n retu...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of integers and returns a new list containing only the prime numbers from the input list. Then, using this function, filter the prime numbers from the list `[12, 15, 7, 5, 8, 17]` and display the resulting list in the console. Make sure to include n...
0.693795
Evol_732
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ffc15d21eafeef95ee8baa503fb525d60e0e51e8
f10cda82f40824331c390efd7a0b00b8f861f562
v1.0
complete
Evol
Evol_760_C
def validate_input(lst): """ Ensure the input list is non-empty and does not contain nested lists. Raises: ValueError: If the input list is empty or contains non-integer elements. """ def max_subarray(lst): """ Given a list of integers, identify and return the subarray with the maximum sum....
def validate_input(lst): if not lst: raise ValueError("Input list must not be empty") if not all(isinstance(i, int) for i in lst): raise ValueError("Input list must only contain integers") def max_subarray(lst): validate_input(lst) max_sum = float('-inf') current_sum = 0 end = s...
from solution import max_subarray, validate_input def test_max_subarray_positive(): assert max_subarray([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_max_subarray_mixed(): assert max_subarray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == [4, -1, 2, 1] def test_max_subarray_single_element(): assert max_subarray([5])...
[ { "docstring": null, "function_declaration": "def validate_input(lst):", "function_name": "validate_input", "parameter_list": "(lst)" }, { "docstring": null, "function_declaration": "def max_subarray(lst):", "function_name": "max_subarray", "parameter_list": "(lst)" } ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def validate_input(lst):\n \"\"\"\n Validates that the input list is non-empty and does not contain nested lists.\n \"\"\"\n if not isinstance(lst, lis...
trial_gpt4o_5
{ "original_instruction": "Given a list of integers, write a function to identify and return the subarray with the maximum sum. If there are multiple subarrays with the same maximum sum, return the one that appears latest in the list. Additionally, provide a helper function to ensure the input list is non-empty and d...
0.687329
Evol_760
C
[ "validate_input", "max_subarray" ]
2
[ [ "max_subarray", "validate_input" ] ]
1
[]
false
[]
false
pytest
true
[]
true
99a4bb9c9441aafb1c26669aa502920f2d0b3fbb
6f1132d7435487d22e8c544e7d5c09a4826ea9d0
v1.0
complete
Evol
Evol_775_C
import random # Sample dataset target = "HELLO, WORLD!" population_size = 200 mutation_rate = 0.01 generations = 1000 # Genetic Algorithm functions def create_individual(length): """ Create random individual with given length >>> len(create_individual(len(target))) == len(target) """ def calculate_fi...
import random # Sample dataset target = "HELLO, WORLD!" population_size = 200 mutation_rate = 0.01 generations = 1000 # Genetic Algorithm functions def create_individual(length): # Create random individual with given length return ''.join(random.choice("ABCDEFGHIJKLMNOPQRSTUVWXYZ, !") for _ in range(length)) ...
from solution import create_individual, calculate_fitness, mutate, crossover, genetic_algorithm def test_create_individual(): individual = create_individual(10) assert len(individual) == 10 assert all(char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ, !" for char in individual) def test_calculate_fitness(): assert ...
[ { "docstring": null, "function_declaration": "def create_individual(length):", "function_name": "create_individual", "parameter_list": "(length)" }, { "docstring": null, "function_declaration": "def calculate_fitness(individual):", "function_name": "calculate_fitness", "parameter...
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import random\n\n# Parameters for the Genetic Algorithm\ntarget = \"HELLO, WORLD!\"\npopulation_size = 200\nmutation_rate = 0.01\ngenerations = 1000\n\n# Genetic A...
trial_gpt4o_7
{ "original_instruction": "Develop a function in Python to implement a simple genetic algorithm based on the following specifications:\n\n```python\nimport random\n\n# Sample dataset\ntarget = \"HELLO, WORLD!\"\npopulation_size = 200\nmutation_rate = 0.01\ngenerations = 1000\n\n# Genetic Algorithm functions\ndef crea...
0.523166
Evol_775
C
[ "create_individual", "calculate_fitness", "mutate", "crossover", "genetic_algorithm" ]
5
[ [ "genetic_algorithm", "calculate_fitness" ], [ "genetic_algorithm", "create_individual" ], [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "mutate" ] ]
4
[]
false
[]
false
pytest
true
[]
true
94f80d9369271aa08d5332e125c934591fe8aabd
742a5fe8d62d5015d45e91cd4520025823a9b558
v1.0
complete
Evol
Evol_435_C
class InvalidInputException(Exception): pass def is_prime(n: int) -> bool: """ Check if a number is prime. """ pass def sort_misplaced_primes(input_list: list) -> list: """ This function takes a list of integers and returns the list sorted in ascending order with all prime numbers posi...
class InvalidInputException(Exception): pass 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 for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False ...
from solution import sort_misplaced_primes, InvalidInputException def test_sort_simple_case(): assert sort_misplaced_primes([10, 3, 5, 7, 2, 1]) == [1, 10, 3, 5, 7, 2] def test_sort_with_only_non_primes(): assert sort_misplaced_primes([8, 10, 4, 1]) == [1, 4, 8, 10] def test_sort_with_only_primes(): asse...
[]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "class InputError(Exception):\n \"\"\"Custom error for invalid inputs\"\"\"\n pass\n\ndef is_prime(num):\n \"\"\"Returns True if the number is prime, else ...
trial_gpt4o_8
{ "original_instruction": "Write a function that takes a list of integers and returns the list sorted in ascending order, but with all prime numbers positioned at the end of the list. The function should handle erroneous inputs gracefully: it should throw a custom error if the input is not a list, or if any element i...
0.625207
Evol_435
C
[ "is_prime", "sort_misplaced_primes" ]
2
[ [ "sort_misplaced_primes", "is_prime" ] ]
1
[]
false
[ "InvalidInputException" ]
true
pytest
true
[]
true
e6d848c3071c0f1faaaebd2266aaf8034101c8af
886326641d85cb06ef0a825807bb8bc5a4763bb4
v1.0
complete
Evol
Evol_728_C
def partition(arr, low, high): """ Helper function to partition the array on the basis of pivot element for quicksort. """ pass def quickSort(arr, low, high): """ Implement quicksort algorithm to sort a list of integers in ascending order. >>> arr = [3, 7, 8, 5, 2, 1, 9, 5, 4] >>> quick...
def partition(arr, low, high): i = (low-1) pivot = arr[high] for j in range(low, high): if arr[j] < pivot: i = i+1 arr[i], arr[j] = arr[j], arr[i] arr[i+1], arr[high] = arr[high], arr[i+1] return (i+1) def quickSort(arr, low, high): if low < high: pi = pa...
from solution import quickSort, mergeSort, compare_efficiency def test_quickSort(): arr = [3, 7, 8, 5, 2, 1, 9, 5, 4] quickSort(arr, 0, len(arr)-1) assert arr == [1, 2, 3, 4, 5, 5, 7, 8, 9] def test_mergeSort(): arr = [3, 7, 8, 5, 2, 1, 9, 5, 4] mergeSort(arr, 0, len(arr)-1) assert arr == [1, ...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quickSort(arr, low, high):", "function_name": "quickSort", "parameter_list": "(ar...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def partition(arr, low, high):\n i = (low-1)\n pivot = arr[high]\n for j in range(low, high):\n if arr[j] < pivot:\n i = i+1\n ...
trial_gpt4o_9
{ "original_instruction": "Given a list of integers, implement both the quicksort algorithm and the merge sort algorithm. Compare their efficiencies by analyzing the time complexities and suggesting which algorithm will perform better on average for large datasets. Correct any errors you might find in the following c...
0.592186
Evol_728
C
[ "partition", "quickSort", "merge", "mergeSort", "compare_efficiency" ]
5
[ [ "mergeSort", "merge" ], [ "quickSort", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0207ebc506a61d12a459810a77bba6ddedd8bab8
a5045024aa626ca44975eb53809bca3bcbce1f88
v1.0
complete
Evol
Evol_848_C
def get_primes(numbers: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from the given list. >>> get_primes([1, 4, 6, 8, 9, 10, 12]) [] >>> get_primes([2, 3, 5, 7, 11, 13, 17]) [2, 3, 5, 7, 11, 13, 17] >>> get_primes([10, 11, 12, 13, 14, 15, 16, 17]) [1...
def is_prime(n): """ Checks if a number is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False limit = int(n ** 0.5) + 1 for i in range(3, limit, 2): if n % i == 0: return False return True def g...
from solution import get_primes def test_get_primes_with_no_primes(): assert get_primes([1, 4, 6, 8, 9, 10, 12]) == [] def test_get_primes_with_all_primes(): assert get_primes([2, 3, 5, 7, 11, 13, 17]) == [2, 3, 5, 7, 11, 13, 17] def test_get_primes_with_mixed_values(): assert get_primes([10, 11, 12, 13,...
[ { "docstring": "Checks if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list.", "function_declaration": "def get_primes(numbers):", "func...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_1_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\...
trial_gpt4o_8
{ "original_instruction": "Write a function that takes a list of integers and returns a new list containing only the prime numbers from the given list. Implement the prime-checking function as a helper function within your main function. Optimize the solution to minimize the number of divisibility checks.", "prompt...
0.827795
Evol_848
C
[ "is_prime", "get_primes" ]
2
[ [ "get_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81617caa7a772ee855a87e42544daecb14c85324
6413d73c8c6a210b30600314ac43b2f7509bb18e
v1.0
complete
Evol
Evol_938_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. Returns True if n is prime, False otherwise. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(11) True """ pass def sort_with_primes_first(arr: List[int]) -> List[int]: """ Tak...
def is_prime(n): """ Check if a number is a prime number. Returns True if n is prime, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) =...
from solution import is_prime, sort_with_primes_first 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(-1) == False assert is_prime(2...
[ { "docstring": "Check if a number is a prime number.\nReturns True if n is prime, False otherwise.", "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\nthe integers sorted i...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from math import sqrt\n\ndef is_prime(n):\n \"\"\"\n Returns True if n is a prime number, and False otherwise.\n \"\"\"\n if n <= 1:\n return Fa...
trial_gpt4o_8
{ "original_instruction": "Write a Python function that takes a list of integers and returns a new list with the integers sorted in ascending order, but with all prime numbers appearing before non-prime numbers.\n\nExample:\n- Input: [3, 8, 5, 2, 11, 4]\n- Output: [2, 3, 5, 11, 4, 8]\n\nNote: To check if a number is ...
0.726381
Evol_938
C
[ "is_prime", "sort_with_primes_first" ]
2
[ [ "sort_with_primes_first", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e5362fb3b5e63958f4523519d85c03d40c457c8e
d4fae67fb8563c7e7cfe0aa927d87038b3e0a117
v1.0
complete
Evol
Evol_730_C
def next_date(date_str: str) -> str: """ Calculate the next date given a date string in the format "DD-MM-YYYY". Ensure your function takes into account leap years and the varying number of days in each month. >>> next_date("28-02-2020") '29-02-2020' >>> next_date("31-12-2021") '01-01-2022'...
def is_leap_year(year): """ Check if a given year is a leap year. """ return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) def next_date(date_str): """ Calculate the next date given a date string in the format "DD-MM-YYYY". """ days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 3...
from solution import next_date def test_next_date_simple_cases(): assert next_date("01-01-2022") == "02-01-2022" assert next_date("28-02-2021") == "01-03-2021" assert next_date("31-03-2021") == "01-04-2021" assert next_date("30-04-2021") == "01-05-2021" assert next_date("31-12-2021") == "01-01-2022...
[ { "docstring": "Check if a given year is a leap year.", "function_declaration": "def is_leap_year(year):", "function_name": "is_leap_year", "parameter_list": "(year)" }, { "docstring": "Calculate the next date given a date string in the format \"DD-MM-YYYY\".", "function_declaration": "d...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_leap_year(year):\n \"\"\"Checks if a year is a leap year.\"\"\"\n return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)\n\ndef next_date(date_...
trial_gpt4o_9
{ "original_instruction": "Write a function that calculates the next date given a date string in the format \"DD-MM-YYYY\". Ensure your function takes into account leap years and the varying number of days in each month. For example, given the input \"28-02-2020\", the output should be \"29-02-2020\" and for \"31-12-...
0.721861
Evol_730
C
[ "is_leap_year", "next_date" ]
2
[ [ "next_date", "is_leap_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
27c3a9832ef41dd1fcde36c30243e5d95ee4fa7c
7eed6bcce22da4098b4e25de5046086d02dc1c40
v1.0
complete
Evol
Evol_945_C
def is_prime(n: int) -> bool: """ Determines if a number is prime. >>> is_prime(1) == False >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(7) == True >>> is_prime(9) == False """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a...
def is_prime(n): """ Determines 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): """ Returns a new list containing only the prime numbers from the origi...
from solution import filter_primes, is_prime def test_is_prime(): assert not is_prime(1) # 1 is not prime assert is_prime(2) # 2 is prime assert is_prime(3) # 3 is prime assert not is_prime(4) # 4 is not prime assert is_prime(7) # 7 is prime assert not is_prime(9) # 9 is not p...
[ { "docstring": "Determines 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": "def filter_primes...
[ 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 for i in range(2, n):\n ...
trial_gpt4o_8
{ "original_instruction": "Write a Python function that, given a list of integers, returns a new list containing only the prime numbers from the original list. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. Avoid using built-in functions or libraries specifically desi...
0.767838
Evol_945
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
47b87b445a7d32f5d689135560a090da61082143
9d4fb29f5f307b1db4f1088d418e528c83e79856
v1.0
complete
Evol
Evol_371_C
import random def f(x): """ The function to be maximized: f(x) = -x^2 + 6x - 5 """ return -x**2 + 6*x - 5 def hill_climb(start=None, step_size=0.1, interval=(0, 5)): """ Basic hill climbing algorithm to find the maximum value of f(x) on the interval [0, 5]. Parameters: - start: Initia...
import random def f(x): """ The function to be maximized: f(x) = -x^2 + 6x - 5 """ return -x**2 + 6*x - 5 def hill_climb(start=None, step_size=0.1, interval=(0, 5)): """ Basic hill climbing algorithm to find the maximum value of f(x) on the interval [0, 5]. """ if start is None: ...
from solution import hill_climb, f import numpy as np def test_is_in_interval(): x, value = hill_climb(start=2.5) assert 0 <= x <= 5, f"x = {x} not within the interval [0, 5]." def test_maximum_value(): x, value = hill_climb(start=2.5) # As per the given quadratic function, maximum should be around x=...
[ { "docstring": "The function to be maximized: f(x) = -x^2 + 6x - 5", "function_declaration": "def f(x):", "function_name": "f", "parameter_list": "(x)" }, { "docstring": "Basic hill climbing algorithm to find the maximum value of f(x) on the interval [0, 5].", "function_declaration": "de...
[ 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import random\n\ndef hill_climbing(f, start, step_size, lower_bound, upper_bound):\n \"\"\"\n Hill climbing algorithm to find the maximum value of the functi...
trial_gpt4o_7
{ "original_instruction": "Write a program that implements a basic hill climbing algorithm to find the maximum value of a given mathematical function. The function to be maximized is f(x) = -x^2 + 6x - 5 on the interval [0, 5]. \n\nParameters and requirements:\n1. Start the search from a random point within the inter...
0.507338
Evol_371
C
[ "f", "hill_climb" ]
2
[ [ "hill_climb", "f" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
d0b6df68798b91ebdf36c85100d94c67cd85e43e
ba0f53d4f7ab63784a06f37bc09bfd4d1be47904
v1.0
complete
Evol
Evol_996_C
from typing import List def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ pass def prime_diff(lst: List[int], n: int) -> int: """ Given a list lst and its length n, returns the difference between the smallest prime number and the largest prime number i...
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 p...
from solution import prime_diff def test_no_primes(): assert prime_diff([4, 6, 8, 10], 4) == -1 def test_mixed_numbers(): assert prime_diff([10, 15, 3, 7, 2, 8, 5], 7) == 5 def test_only_primes(): assert prime_diff([3, 2, 5, 7], 4) == 5 def test_single_prime(): assert prime_diff([3], 1) == 0 def te...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Given a list lst and its length n, returns the difference between the smallest \nprime number and the large...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_9
{ "original_instruction": "Given a list of integers and the length n, write a Python function that performs the following operations:\n\n- Create a new list that contains only the prime numbers from the given list.\n- Next, return the difference between the smallest prime number in the list and the largest prime numb...
0.778408
Evol_996
C
[ "is_prime", "prime_diff" ]
2
[ [ "prime_diff", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
92602772f394112b054a09a813d2c517f8d32949
d398d10e68c0e223b8ab4c89ced85e1acc52261c
v1.0
complete
Evol
Evol_354_C
import random import math import matplotlib.pyplot as plt from typing import List, Tuple def generate_cities(num_cities: int, seed: int = 42) -> List[Tuple[float, float]]: """ Generates a list of randomly placed cities represented by (x, y) coordinates. >>> generate_cities(10, seed=42) [(63.942679845788376...
import random import math import matplotlib.pyplot as plt def generate_cities(num_cities, seed=42): """ Generates a list of randomly placed cities represented by (x, y) coordinates. """ random.seed(seed) return [(random.uniform(0, 100), random.uniform(0, 100)) for _ in range(num_cities)] def dista...
from solution import generate_cities, distance, total_distance, generate_initial_population from solution import selection, crossover, mutate, genetic_algorithm, plot_tsp def test_generate_cities(): cities = generate_cities(10, seed=42) assert len(cities) == 10 assert cities[0] == (63.942679845788376, 2.50...
[ { "docstring": "Generates a list of randomly placed cities represented by (x, y) coordinates.", "function_declaration": "def generate_cities(num_cities, seed=42):", "function_name": "generate_cities", "parameter_list": "(num_cities, seed=42)" }, { "docstring": "Calculates the Euclidean dista...
[ 1, 0, 0, 0, 0, 0, 0, 1 ]
2
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import random\nimport math\nimport matplotlib.pyplot as plt\n\ndef generate_cities(num_cities, seed=42):\n \"\"\"\n Generates a list of randomly placed citie...
trial_gpt4o_0
{ "original_instruction": "Design and implement a genetic algorithm to solve the Traveling Salesman Problem (TSP). Begin by creating a function to generate a random set of cities (each represented by x and y coordinates). Then, implement the genetic algorithm, which includes the following components: initialization, ...
0.770314
Evol_354
C
[ "generate_cities", "distance", "total_distance", "generate_initial_population", "selection", "crossover", "mutate", "genetic_algorithm", "plot_tsp" ]
9
[ [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "generate_initial_population" ], [ "genetic_algorithm", "mutate" ], [ "genetic_algorithm", "selection" ], [ "genetic_algorithm", "total_distance" ], [ "total_distance", "distance" ] ]
6
[]
false
[]
false
pytest
true
[ "matplotlib" ]
false
0e1e6966d6c8d05e452d9d8a57b184b8e98de78f
69c8c461805fefd157543659659031db667595a4
v1.0
complete
Evol
Evol_1157_C
def read_records(file_path): """ Reads student records from a text file and returns a list of dictionaries. :param file_path: Path to the input file :return: List of student records as dictionaries """ pass def get_student_average(student): """ Calculates the average grade of a student. ...
def read_records(file_path): """ Reads student records from a text file and returns a list of dictionaries. :param file_path: Path to the input file :return: List of student records as dictionaries """ students = [] with open(file_path, 'r') as file: for line in file: ...
import pytest from solution import ( read_records, get_student_average, get_average_grades, get_highest_scorer, ) @pytest.fixture def dummy_data(tmp_path): data = """John Doe, 21, 90, 85, 92 Jane Smith, 22, 88, 79, 85 Alice Johnson, 23, 95, 92, 98""" file_path = tmp_path / "students.txt" fi...
[ { "docstring": "Reads student records from a text file and returns a list of dictionaries.\n\n:param file_path: Path to the input file\n:return: List of student records as dictionaries", "function_declaration": "def read_records(file_path):", "function_name": "read_records", "parameter_list": "(file...
[ 1, 0, 0, 0, 1, 1, 0, 1, 0 ]
4
medium
0.444
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def read_records(file_path):\n \"\"\"\n Reads student records from a text file and returns a list of dictionaries, \n where each dictionary represents a s...
trial_gpt4o_6
{ "original_instruction": "Create a Python program that reads a list of student records from a text file and performs various operations on the data. Each student record consists of a name, ID, and a list of grades. The file format is as follows, with each student record on a separate line:\n\n```\nJohn Doe, 21, 90, ...
0.659885
Evol_1157
C
[ "read_records", "get_student_average", "get_average_grades", "get_highest_scorer" ]
4
[ [ "get_average_grades", "get_student_average" ], [ "get_highest_scorer", "get_student_average" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d9303ae21746f0d3f8d1cc2a14c407a8ad3a01f5
83455027bbe2e732619ef691451a41c71bef3fa0
v1.0
complete
Evol
Evol_879_C
def sum_of_primes(n): """ Write a function that calculates the sum of all prime numbers up to and including a given number `n`. If the input is invalid (e.g., not a positive integer), the function should return 0. You are not allowed to use any external libraries or built-in functions for this task. Ens...
def is_prime(num): """ Helper function to determine 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 # Check for factors from 3 to sqrt(num), using step of 2 to skip even num...
from solution import sum_of_primes def test_sum_of_primes_with_small_number(): assert sum_of_primes(10) == 17 def test_sum_of_primes_with_large_number(): assert sum_of_primes(20) == 77 def test_sum_of_primes_with_negative_number(): assert sum_of_primes(-5) == 0 def test_sum_of_primes_with_non_integer():...
[ { "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 up to and including 'n'.\nReturns 0 if the input is not a positive...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def sum_of_primes(n):\n if not isinstance(n, int) or n < 2:\n return 0\n\n def is_prime(num):\n if num <= 1:\n return False\n ...
trial_gpt4o_2
{ "original_instruction": "Write a function that calculates the sum of all prime numbers up to and including a given number `n`. If the input is invalid (e.g., not a positive integer), the function should return 0. You are not allowed to use any external libraries or built-in functions for this task. Ensure your solu...
0.715969
Evol_879
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0fd93c8cca9ba0cbf937a3612bb590d889531d1
cb7e723530f173c8c75432d1da640c030cf355c5
v1.0
complete
Evol
Evol_1218_C
def filter_non_primes(numbers: List[int]) -> List[int]: """ Returns a list of integers with all prime numbers filtered out. >>> filter_non_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) [1, 4, 6, 8, 9, 10] >>> filter_non_primes([2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) [] >>> filter_non_primes([1, 4, 6, 8, 9, 10, ...
def is_prime(num): """ Helper function to determine 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 d...
from solution import filter_non_primes # Helper function to check if a number is prime should not be tested directly # Tests to validate the filter_non_primes function def test_filter_non_primes_with_primes(): assert filter_non_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 4, 6, 8, 9, 10] def test_filter_non_pr...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of integers with all prime numbers filtered out.", "function_declaration": "def filt...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_9
{ "original_instruction": "Write a function that takes a list of integers and returns the same list with all prime numbers filtered out. You are not allowed to use any external libraries or built-in functions that directly identify or filter prime numbers.\n\nExample:\n\nInput: \nnumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9,...
0.68652
Evol_1218
C
[ "is_prime", "filter_non_primes" ]
2
[ [ "filter_non_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c61e8830b5c8c1b5a987b09bac39159d50923551
837b6e229ad6a0390927a6e01a67988f4a15f805
v1.0
complete
Evol
Evol_756_C
from typing import List def solve_n_queens(n: int) -> List[List[str]]: """ Solves the N-Queens problem and returns a list of all distinct solutions. Each solution is represented as a list of strings. """ def convert_solutions_to_strings(solutions: List[List[int]], n: int) -> List[List[str]]: """ ...
def solve_n_queens(n): """ Solves the N-Queens problem and returns a list of solutions. Each solution is represented as a list of strings. """ def is_valid(board, row, col): for i in range(row): # Check the column if board[i] == col: return False ...
from solution import solve_n_queens, validate_solutions def test_solve_n_queens_n1(): solutions = solve_n_queens(1) expected = [["Q"]] assert solutions == expected assert validate_solutions(1, [[0]]) def test_solve_n_queens_n2(): solutions = solve_n_queens(2) expected = [] assert solutions...
[ { "docstring": "Solves the N-Queens problem and returns a list of solutions. \nEach solution is represented as a list of strings.", "function_declaration": "def solve_n_queens(n):", "function_name": "solve_n_queens", "parameter_list": "(n)" }, { "docstring": "Converts the list of solutions f...
[ 1, 0, 0, 0, 1, 0, 1, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def solve_n_queens(n):\n \"\"\"\n Solves the N-Queens problem and returns all distinct solutions.\n Each solution is represented by a list of strings wher...
trial_gpt4o_9
{ "original_instruction": "Write a function to solve the N-Queens problem. The N-Queens problem involves placing N queens on an N x N chessboard in such a way that no two queens threaten each other.\n\nYour implementation should return all distinct solutions to the N-Queens puzzle, and each solution should be a permu...
0.545401
Evol_756
C
[ "solve_n_queens", "convert_solutions_to_strings", "validate_solutions" ]
3
[ [ "solve_n_queens", "convert_solutions_to_strings" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b416b55945d1ea52169ed15432860ff827a53b15
341e3f7fb1e401a0ce26d977cc3a318089d59cd1
v1.0
complete
Evol
Evol_1021_C
import math from typing import List def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from the input list. ...
import math def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import filter_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(49) == False def test_filter_primes(): assert filter_primes([2, 3, 4, 5...
[ { "docstring": "Check if a number is a prime number.", "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 input list.", "function_declaration": "def filter_prime...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the on...
trial_gpt4o_9
{ "original_instruction": "Design a function that takes as input a list of integers and returns a new list containing only the prime numbers from the original list. Additionally, implement a method to optimize the prime number detection process. Finally, demonstrate the efficiency of your solution with a runtime anal...
0.777676
Evol_1021
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
43d3207357eaf23d185c6876e063c0f36028f9cb
58c01f5079d66dae053c6ae18daaceffaf641553
v1.0
complete
Evol
Evol_1075_C
import statistics from typing import List, Tuple, Union def prime_numbers_with_stats(nums: List[int]) -> Tuple[List[int], Union[float, None], Union[float, None]]: """Write a function that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. Addition...
import statistics def is_prime(n): 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 prime_numbers_with_stats(nums...
from solution import prime_numbers_with_stats def test_prime_numbers_with_stats(): assert prime_numbers_with_stats([4, 6, 7, 9, 11, 13, 15, 18, 19]) == ([7, 11, 13, 19], 12.5, 12.0) assert prime_numbers_with_stats([4, 6, 8, 9, 10, 12]) == ([], None, None) assert prime_numbers_with_stats([2, 3, 5, 7, 11]) =...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_numbers_with_stats(nums):", "function_name": "prime_numbers_with_stats", "parameter_list": "(nums)" }...
[ 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import statistics\n\ndef is_prime(n):\n \"\"\" Checks if a number is prime. \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_6
{ "original_instruction": "Write a function that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. Additionally, the function should calculate and return the mean and median of these prime numbers. If there are no prime numbers in the input list, return...
0.688518
Evol_1075
C
[ "is_prime", "prime_numbers_with_stats" ]
2
[ [ "prime_numbers_with_stats", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bae5ec008b0dd9d4dc5f41c597b93fdb4c459304
c1c7d4b5eae73c6c2258df2f483401279e42b2d1
v1.0
complete
Evol
Evol_1092_C
import random from typing import Tuple def roll_dice() -> int: """ Simulate rolling two six-sided dice and return their sum. """ return random.randint(1, 6) + random.randint(1, 6) def simulate_rolls(num_rolls: int) -> Tuple[int, int, float]: """ Simulate rolling two six-sided dice num_rolls ti...
import random def roll_dice(): """ Simulate rolling two six-sided dice and return their sum. """ return random.randint(1, 6) + random.randint(1, 6) def simulate_rolls(num_rolls): """ Simulate rolling two six-sided dice num_rolls times and determine the probability of rolling a sum of 7 or...
from solution import simulate_rolls def test_simulate_rolls_with_1000(): result = simulate_rolls(1000) assert result[0] == 1000 assert 0 <= result[1] <= 1000 assert 0 <= result[2] <= 1 def test_simulate_rolls_with_5000(): result = simulate_rolls(5000) assert result[0] == 5000 assert 0 <= r...
[ { "docstring": "Simulate rolling two six-sided dice and return their sum.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulate rolling two six-sided dice num_rolls times and \ndetermine the probability of rolling a sum...
[ 0, 0, 0, 0, 1, 0, 0, 1, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice(num_rolls):\n \"\"\"\n Simulates rolling two six-sided dice a specified number of times and calculates the probability \n o...
trial_gpt4o_8
{ "original_instruction": "Write a program to determine the probability of rolling a sum of 7 or 11 with two six-sided dice. The program should simulate the rolling of the dice a specified number of times and calculate how often sums of 7 or 11 occur. Ensure the output includes the total number of rolls, the number o...
0.622464
Evol_1092
C
[ "roll_dice", "simulate_rolls" ]
2
[ [ "simulate_rolls", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
60ebdd97510c3bf72cebec455b4dc7431014a9ec
72127b088889e8d0733f095735a48f71789cdf75
v1.0
complete
Evol
Evol_860_C
from typing import List def can_form_palindrome(s: str) -> bool: """ Determines if a given string can be rearranged to form a palindrome. >>> can_form_palindrome("civic") True >>> can_form_palindrome("ivicc") True >>> can_form_palindrome("hello") False >>> can_form_palindrome("aabb...
from collections import Counter def can_form_palindrome(s): """ Determines if a given string can be rearranged to form a palindrome. """ count = Counter(s) odd_count = sum(1 for cnt in count.values() if cnt % 2 != 0) return odd_count <= 1 def can_form_palindrome_with_removal(s): """ De...
from solution import can_form_palindrome, can_form_palindrome_with_removal def test_can_form_palindrome(): assert can_form_palindrome("civic") == True assert can_form_palindrome("ivicc") == True assert can_form_palindrome("hello") == False assert can_form_palindrome("aabb") == True assert can_form_...
[ { "docstring": "Determines if a given string can be rearranged to form a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": "Determines if a given string can be rearranged to form a palindrome...
[ 0, 0, 1, 1, 1, 0, 1, 0, 0, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def can_form_palindrome(s):\n \"\"\"\n Checks if a given string can be rearranged to form a palindrome.\n \"\"\"\n from collections import Counter\n ...
trial_gpt4o_9
{ "original_instruction": "Write a function to determine if a given string can be rearranged to form a palindrome. The function should return `True` if it is possible and `False` otherwise. After that, extend your function to consider if the given string can be rearranged to form a palindrome by removing at most one ...
0.722408
Evol_860
C
[ "can_form_palindrome", "can_form_palindrome_with_removal" ]
2
[ [ "can_form_palindrome_with_removal", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7d2c7bfccfd033447f5a8e5ddd22987669a5ae12
a7101374eae3e2170e5a6c97ba33dd3e8013f647
v1.0
complete
Evol
Evol_792_C
def sieve_of_eratosthenes(n: int) -> List[int]: """ Returns a list of prime numbers less than n using the Sieve of Eratosthenes algorithm. >>> sieve_of_eratosthenes(10) [2, 3, 5, 7] >>> sieve_of_eratosthenes(30) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] """ def erroneous_prime_list(n: int) -> Li...
def sieve_of_eratosthenes(n): """ Returns a list of prime numbers less than n using the Sieve of Eratosthenes algorithm. """ if n <= 2: return [] sieve = [True] * n sieve[0] = sieve[1] = False # 0 and 1 are not prime numbers for start in range(2, int(n**0.5) + 1): ...
from solution import sieve_of_eratosthenes, erroneous_prime_list, corrected_prime_list def test_sieve_of_eratosthenes_basic(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] def test_sieve_of_eratosthenes_edge_case(): assert sieve_of_eratosthenes(0) == [] assert sieve_of_eratosthenes(1) == [] assert...
[ { "docstring": "Returns a list of prime numbers less than n using the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Erroneous method to return list of prime numb...
[ 1, 1, 1, 0, 1, 1, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(n):\n \"\"\"\n Returns a list of all prime numbers less than n.\n \"\"\"\n if n <= 2:\n return []\n \n prime = [...
trial_gpt4o_9
{ "original_instruction": "Create a function in Python that takes an integer `n` as input and returns a list of the prime numbers less than `n`. Ensure that your function is optimized for performance, using appropriate algorithms to minimize time complexity. Additionally, provide a piece of erroneous sample code rela...
0.614309
Evol_792
C
[ "sieve_of_eratosthenes", "erroneous_prime_list", "corrected_prime_list" ]
3
[ [ "corrected_prime_list", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
33931a7a42c6b30ca30e58454747837032889b15
7fe87d13996bc8282a44bd205b318c115e78cc87
v1.0
complete
Evol
Evol_626_C
class TrieNode: def __init__(self): self.children = {} self.is_end_of_word = False class Trie: def __init__(self): self.root = TrieNode() def insert(self, word): """ Insert a word into the Trie """ node = self.root for char in word: if char n...
class TrieNode: def __init__(self): self.children = {} self.is_end_of_word = False class Trie: def __init__(self): self.root = TrieNode() def insert(self, word): node = self.root for char in word: if char not in node.children: node.ch...
from solution import correct_spelling def test_correct_spelling_no_mistakes(): dictionary = ["apple", "banana", "cherry"] words = ["apple", "banana"] result = correct_spelling(words, dictionary) assert result == ["apple", "banana"] def test_correct_spelling_single_typo(): dictionary = ["apple", "b...
[]
[ 1, 0, 0, 0, 0, 0, 1, 1, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "# We will implement a TrieNode, a Trie, and a function to find the closest word using Levenshtein distance.\n\nclass TrieNode:\n def __init__(self):\n se...
trial_gpt4o_7
{ "original_instruction": "Implement a function to detect and correct spelling mistakes in a given list of words using a Trie data structure. Your function should take a dictionary of correctly spelled words as input to build the Trie and then identify and suggest corrections for words in the list that are not in the...
0.549672
Evol_626
C
[ "levenshtein_distance", "correct_spelling" ]
2
[ [ "correct_spelling", "levenshtein_distance" ] ]
1
[]
false
[ "TrieNode", "Trie" ]
true
pytest
true
[]
true
6726c88fceabacb5b87b8d82ee7dfcdfcb079e50
c9c431388a350c5648f8ced6babde615d3d07c35
v1.0
complete
Evol
Evol_1004_C
import csv from datetime import datetime def parse_csv(file_path): """ Reads a CSV file and returns its contents as a list of dictionaries. """ pass def analyze_weather_data(file_path): """ Analyzes weather data from a CSV file. Output: 1. Average temperature and wind speed for th...
import csv from datetime import datetime def parse_csv(file_path): """ Reads a CSV file and returns its contents as a list of dictionaries. """ try: with open(file_path, 'r') as file: reader = csv.DictReader(file) data = [row for row in reader] return data ex...
import pytest from solution import analyze_weather_data def test_analyze_weather_data(): file_path = 'test_weather_data.csv' with open(file_path, 'w') as file: file.write("Date,Temperature,Wind Speed,Precipitation\n") file.write("2023-01-01,30.0,5.0,0.2\n") file.write("2023-01-02,25.0,6...
[ { "docstring": "Reads a CSV file and returns its contents as a list of dictionaries.", "function_declaration": "def parse_csv(file_path):", "function_name": "parse_csv", "parameter_list": "(file_path)" }, { "docstring": "Analyzes weather data from a CSV file.\n\nOutput:\n1. Average temperatu...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import csv\n\ndef analyze_weather_data(file_path):\n total_temperature = 0.0\n total_wind_speed = 0.0\n highest_temperature = float('-inf')\n highest_t...
trial_gpt4o_8
{ "original_instruction": "Write a Python function that reads a CSV file containing data on daily weather observations. Each row represents an observation with columns for 'Date', 'Temperature', 'Wind Speed', and 'Precipitation'. The function should compute and display: \n1. The average temperature and wind speed for...
0.670612
Evol_1004
C
[ "parse_csv", "analyze_weather_data" ]
2
[ [ "analyze_weather_data", "parse_csv" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c3e81b0838bc6351ef3fb0990113cfc7cd44daf
c31bd28392d4c8d66b9926af9abc48cb09d9ffba
v1.0
complete
Evol
Evol_1599_C
import numpy as np def initialize_centroids(X, K): """ Initializes K centroids randomly selected from the data points. """ pass def closest_centroids(X, centroids): """ Assigns each data point to the closest centroid. """ pass def update_centroids(X, labels, K): """ Updates th...
import numpy as np def initialize_centroids(X, K): """ Initializes K centroids randomly selected from the data points. """ indices = np.random.choice(np.arange(len(X)), size=K, replace=False) return X[indices] def closest_centroids(X, centroids): """ Assigns each data point to the closest ...
import numpy as np from solution import initialize_centroids, closest_centroids, update_centroids, kmeans def test_initialize_centroids(): X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]]) centroids = initialize_centroids(X, 2) assert centroids.shape == (2, 2) assert len(set(tuple(point) for point in cent...
[ { "docstring": "Initializes K centroids randomly selected from the data points.", "function_declaration": "def initialize_centroids(X, K):", "function_name": "initialize_centroids", "parameter_list": "(X, K)" }, { "docstring": "Assigns each data point to the closest centroid.", "function...
[ 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef initialize_centroids(points, k):\n \"\"\"\n Randomly initialize `k` centroids from the `points`.\n \"\"\"\n return points[np....
trial_gpt4o_7
{ "original_instruction": "Implement the K-means clustering algorithm from scratch to partition a dataset into K clusters. The dataset consists of points in a 2D space. Your implementation should include steps for initializing centroids, assigning points to the nearest centroid, and updating centroids based on the as...
0.831628
Evol_1599
C
[ "initialize_centroids", "closest_centroids", "update_centroids", "kmeans" ]
4
[ [ "kmeans", "closest_centroids" ], [ "kmeans", "initialize_centroids" ], [ "kmeans", "update_centroids" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy" ]
false
3ffd9e34ee611489b5746bdcb5635e0266a5c39c
a1bb3cd811f38188effd71bef053b3181ae3df32
v1.0
complete
Evol
Evol_1577_C
from typing import List, Tuple def merge_sort(arr: List[int]) -> List[int]: """ Sort an array of integers using the merge sort algorithm. >>> merge_sort([]) == [] >>> merge_sort([1]) == [1] >>> merge_sort([3, 1, 4, 1, 5, 9, 2]) == [1, 1, 2, 3, 4, 5, 9] """ def count_inversions(arr: List[int]) ...
def merge_sort(arr): if len(arr) < 2: return arr mid = len(arr) // 2 left_half = merge_sort(arr[:mid]) right_half = merge_sort(arr[mid:]) return merge(left_half, right_half) def merge(left, right): result = [] i = j = 0 while i < len(left) and j < len(right): if left[i] ...
from solution import merge_sort, count_inversions def test_merge_sort_empty_array(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_sorted_array(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_unsorted_arra...
[ { "docstring": null, "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" }, { "docst...
[ 1, 1, 1, 0, 1, 1, 1, 0, 0, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Returns a sorted array using the merge sort algorithm.\n \"\"\"\n if len(arr) <= 1:\n return arr\n\n mid = le...
trial_gpt4o_6
{ "original_instruction": "Create a function to sort an array of integers using the merge sort algorithm. Your implementation should divide the array into two halves, recursively sort each half, and then merge the sorted halves back together. The function should also handle edge cases such as an empty array or an arr...
0.649362
Evol_1577
C
[ "merge_sort", "merge", "count_inversions", "merge_sort_and_count", "merge_and_count" ]
5
[ [ "count_inversions", "merge_sort_and_count" ], [ "merge_sort", "merge" ], [ "merge_sort_and_count", "merge_and_count" ] ]
3
[]
false
[]
false
pytest
true
[]
true
a7507780e857a8ff60955ddb21f26fc62b6920c1
a1b555c00f10a97fb686cb615c0b49f8ad82ca5f
v1.0
complete
Evol
Evol_1615_C
def sum_of_primes(lst: List[int]) -> int: """Returns the sum of all prime numbers in the list. If no prime numbers are found, returns 0. >>> sum_of_primes([4, 6, 9, 11, 20, 23]) 34 >>> sum_of_primes([4, 6, 8, 10, 20]) 0 >>> sum_of_primes([2, 3, 5, 7, 11]) 28 >>> sum_of_primes([0, 1,...
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 sum_of_primes def test_sum_of_primes_with_primes(): assert sum_of_primes([4, 6, 9, 11, 20, 23]) == 34 def test_sum_of_primes_without_primes(): assert sum_of_primes([4, 6, 8, 10, 20]) == 0 def test_sum_of_primes_all_primes(): assert sum_of_primes([2, 3, 5, 7, 11]) == 28 def test_sum_...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers in the list.\nIf no prime numbers are found, returns 0.", "functio...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 ...
trial_gpt4o_2
{ "original_instruction": "Write a program that takes a list of integers and returns the sum of all prime numbers in the list. If no prime numbers are found, return 0.\n\nExample:\nInput: [4, 6, 9, 11, 20, 23]\nOutput: 34\n\nExplanation:\nPrime numbers in the list are 11 and 23, their sum is 34.", "prompt_id": "000...
0.68816
Evol_1615
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e06df5f5731a0713b6bed4464fc74a31ed3ef446
6c039a1fac5d6c033a0507bb6a72f9ea3bfd83d9
v1.0
complete
Evol
Evol_931_C
def binary_search_desc(arr, target): """ Performs a binary search on a descendingly sorted list of integers. Returns the index of target if found, otherwise returns -1. """ pass def linear_search(arr, target): """ Performs a linear search on a list of integers. Returns the index of targ...
def binary_search_desc(arr, target): """ Performs a binary search on a descendingly sorted list of integers. Returns the index of target if found, otherwise returns -1. """ left, right = 0, len(arr) - 1 while left <= right: mid = (left + right) // 2 if arr[mid] == target: ...
from solution import binary_search_desc, linear_search def test_binary_search_found(): arr = [15, 10, 5, 3, 1] target = 10 assert binary_search_desc(arr, target) == 1 def test_binary_search_not_found(): arr = [20, 17, 15, 12, 10, 8, 6, 4, 2] target = 7 assert binary_search_desc(arr, target) ==...
[ { "docstring": "Performs a binary search on a descendingly sorted list of integers.\nReturns the index of target if found, otherwise returns -1.", "function_declaration": "def binary_search_desc(arr, target):", "function_name": "binary_search_desc", "parameter_list": "(arr, target)" }, { "do...
[ 0, 1, 1, 1, 1, 0, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def binary_search_desc(arr, target):\n \"\"\"\n Performs binary search on a descendingly sorted list.\n \n :param arr: List[int], a list of integers so...
trial_gpt4o_9
{ "original_instruction": "Design and implement a Binary Search algorithm that operates on a descendingly sorted list of integers. The function should take a list and a target integer as inputs and return the index of the target integer if found, or -1 if not found. Assess the performance of your Binary Search algori...
0.604972
Evol_931
C
[ "binary_search_desc", "linear_search", "performance_test" ]
3
[ [ "performance_test", "binary_search_desc" ], [ "performance_test", "linear_search" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7f82485094e2d36ab77adaf1c1f021f0e12f8c7c
91e7793204f2a83798a5d8f74d51bd22ca607b63
v1.0
complete
Evol
Evol_1368_C
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) == True >>> is_prime(4) == False >>> is_prime(17) == True """ # Complete the function here def sort_primes_and_composites(numbers: List[int]) -> List[int]: """ Takes a list of integers...
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 sort_primes_and_composites(numbers): """ Takes a list of integers and retur...
from solution import sort_primes_and_composites, 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(13) == True assert is_prime(1) == False assert is_prim...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Takes a list of integers and returns a list with all prime numbers at the beginning in ascending order,\nfo...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ret...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of integers and returns a list of the same integers but with all prime numbers at the beginning in ascending order, followed by all composite numbers in descending order. Example input: [7, 8, 4, 13, 18, 15, 3], example output: [3, 7, 13, 18, 15, 8, 4]\n\...
0.755132
Evol_1368
C
[ "is_prime", "sort_primes_and_composites" ]
2
[ [ "sort_primes_and_composites", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63c47330ba8ef43cc63624b7cc1143f6533c2ea4
5adcee1931d6a151020bfe5cb241bc901c9d50e9
v1.0
complete
Evol
Evol_1696_C
def filter_primes(numbers): """ Returns a new list containing only the prime numbers from the original list. >>> filter_primes([2, 4, 6, 7, 9, 11, 13]) [2, 7, 11, 13] >>> filter_primes([4, 6, 8, 9, 10]) [] >>> filter_primes([]) [] >>> filter_primes([2, 3, 5, 7, 11]) [2, 3, 5, 7, 11] ...
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 filter_primes(numbers): """ Returns a list containing only the prime numbers from the original list. """ return [num for num in numbers if is_...
from solution import filter_primes def test_filter_primes_with_primes(): assert filter_primes([2, 4, 6, 7, 9, 11, 13]) == [2, 7, 11, 13] def test_filter_primes_with_no_primes(): assert filter_primes([4, 6, 8, 9, 10]) == [] def test_filter_primes_with_empty_list(): assert filter_primes([]) == [] def test...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the original list.", "function_declaration": "def filter_primes(numbers):", "function_name": ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is prime.\n Returns True if n is prime, False otherwise.\n \"\"\"\n if n <= 1:\...
trial_gpt4o_8
{ "original_instruction": "Create a function in Python that takes a list of integers and returns a new list containing only the prime numbers from the original list. Ensure that the function handles an empty list input as well and returns an empty list in that case. An example of the function call and its expected ou...
0.678732
Evol_1696
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8b49d01ba8d0752923a67ab46190a254eab17d2
18e4184a2ca51a827a97244703c49030876d42ee
v1.0
complete
Evol
Evol_1656_C
from typing import List def factorial(n: int) -> int: """ Helper function to calculate the factorial of a number. >>> factorial(0) 1 >>> factorial(1) 1 >>> factorial(2) 2 >>> factorial(3) 6 >>> factorial(4) 24 >>> factorial(5) 120 """ def list_factorial(lst:...
def factorial(n): """ Helper function to calculate the factorial of a number. """ if n == 0: return 1 result = 1 for i in range(1, n + 1): result *= i return result def list_factorial(lst): """ Returns a list where each element is the factorial of the corresponding e...
from solution import list_factorial, factorial def test_factorial_zero(): assert factorial(0) == 1 def test_factorial_positive_numbers(): assert factorial(1) == 1 assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 assert factorial(5) == 120 def test_list_factorial(): ...
[ { "docstring": "Helper function to calculate the factorial of a number.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Returns a list where each element is the factorial of the corresponding element in the input list.",...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def factorial(n):\n \"\"\"\n Returns the factorial of a given number n.\n \"\"\"\n if n == 0:\n return 1\n result = 1\n for i in range(1, ...
trial_gpt4o_9
{ "original_instruction": "Create a Python function that takes a list of integers, and returns a new list where each element is the factorial of the corresponding element in the input list. The function should not use any external libraries like `math`. Demonstrate your function with the list [3, 4, 5].", "prompt_i...
0.741178
Evol_1656
C
[ "factorial", "list_factorial" ]
2
[ [ "list_factorial", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9fb908334e063c1fb5c1f4eb54148b2de428d5ca
f224a146f17ad1973fdf6469e07380e55c58a547
v1.0
complete
Evol
Evol_1503_C
def roman_to_int(roman: str) -> int: """ Converts a Roman numeral to an integer. If the Roman numeral is invalid, returns an error message. >>> roman_to_int("III") == 3 >>> roman_to_int("IV") == 4 >>> roman_to_int("IX") == 9 >>> roman_to_int("LVIII") == 58 >>> roman_to_int("MCMXCIV") == 1994 ...
def roman_to_int(roman): """ Converts a Roman numeral to an integer. Returns an integer if the Roman numeral is valid, otherwise returns an error message. """ roman_values = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} # Validate the Roman numeral for ch in roman: ...
from solution import roman_to_int def test_valid_roman_numerals(): assert roman_to_int("III") == 3 assert roman_to_int("IV") == 4 assert roman_to_int("IX") == 9 assert roman_to_int("LVIII") == 58 assert roman_to_int("MCMXCIV") == 1994 def test_invalid_roman_numerals(): assert roman_to_int("III...
[ { "docstring": "Converts a Roman numeral to an integer.\nReturns an integer if the Roman numeral is valid, otherwise returns an error message.", "function_declaration": "def roman_to_int(roman):", "function_name": "roman_to_int", "parameter_list": "(roman)" }, { "docstring": "Converts an int...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def roman_to_int(s):\n \"\"\"\n Converts a roman numeral to an integer.\n If the input is invalid, returns an error message.\n \"\"\"\n roman_to_int...
trial_gpt4o_9
{ "original_instruction": "Develop a program that takes a Roman numeral as input and converts it to its equivalent integer value. Ensure that the program handles invalid Roman numeral inputs by returning an appropriate error message.", "prompt_id": "00001503", "row_id": 1503, "seed_ids": "[42136]" }
0.771471
Evol_1503
C
[ "roman_to_int", "int_to_roman" ]
2
[ [ "roman_to_int", "int_to_roman" ] ]
1
[]
false
[]
false
pytest
true
[]
true
012d6d3ab21dc6b1f660ddf40c00e4aa4ae398ff
7c511785c64ac77c62a12a47c82316f958e650e9
v1.0
complete
Evol
Evol_1478_C
from typing import List def is_prime(num: int) -> bool: """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False >>> is_prime(19) True >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-5...
def is_prime(num): """ Checks 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 get_primes_in_desce...
from solution import is_prime, get_primes_in_descending_order def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Takes a list of integers and returns a new list containing only the prime numbers\nfrom the original list, in descending orde...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 <= 3:\n return True\n if n % 2...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of integers as input and returns a new list containing only the prime numbers from the original list, but the order of the prime numbers should be in descending order. For assistance, you can refer to this link: https://www.geeksforgeeks.org/python-...
0.794093
Evol_1478
C
[ "is_prime", "get_primes_in_descending_order" ]
2
[ [ "get_primes_in_descending_order", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b02ef374fc2070c2d6984fa1b8eddd52d8e3302f
3d278a3bc50a2fc5fb54a998119bf8a893c766ec
v1.0
complete
Evol
Evol_1534_C
from typing import List def is_prime(num: int) -> bool: """ Determine if a given number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(0) False >>> is_prime(-3) False """ def filter_primes(numbers: List[int]) -> List[int]: """ Given a...
from math import isqrt def is_prime(num): """ Helper function to determine if a number is prime. """ if num < 2: return False for i in range(2, isqrt(num) + 1): if num % i == 0: return False return True def filter_primes(numbers): """ Returns a list of prime...
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(5) == True assert is_prime(10) == False assert is_prime(11) == True assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.", "function_declaration": "def fil...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n...
trial_gpt4o_9
{ "original_instruction": "Implement a function in Python that takes a list of integers as input and returns a new list with only the prime numbers from the original list. Utilize a helper function to determine if a number is prime. It's important that the main function has a time complexity no worse than O(n * sqrt(...
0.755337
Evol_1534
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d98f9868433da48f1f32512bee1e82cd11d50f0f
7401b7833f2f16740aa8f36d85eb2a2d246fa7f0
v1.0
complete
Evol
Evol_1214_C
import multiprocessing import re from typing import List, Tuple def word_lengths(sentence: str) -> Tuple[int, int]: """Determine the lengths of the shortest and longest words in a sentence. Args: sentence (str): A sentence containing words possibly separated by punctuation. Returns: Tuple...
import multiprocessing import re def word_lengths(sentence): words = re.findall(r'\b\w+\b', sentence) if not words: return (0, 0) else: lengths = [len(word) for word in words] return (min(lengths), max(lengths)) def process_sentences(sentences_list): with multiprocessing.Pool(p...
from solution import word_lengths, process_sentences def test_word_lengths(): # Test for a sentence with varied word lengths assert word_lengths("The quick brown fox jumps over the lazy dog") == (3, 5) # Test for a sentence with punctuation assert word_lengths("To be, or not to be, that is the question...
[ { "docstring": null, "function_declaration": "def word_lengths(sentence):", "function_name": "word_lengths", "parameter_list": "(sentence)" }, { "docstring": null, "function_declaration": "def process_sentences(sentences_list):", "function_name": "process_sentences", "parameter_l...
[ 1, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import re\nfrom multiprocessing import Pool\n\ndef word_lengths(sentence):\n \"\"\"\n Function to calculate the length of shortest and longest words in the g...
trial_gpt4o_6
{ "original_instruction": "Write a Python function that accepts a list of sentences and returns a list of the lengths of the shortest and longest words in each sentence. Use multiprocessing to handle multiple sentences concurrently to optimize performance. The function should handle punctuation and special characters...
0.651727
Evol_1214
C
[ "word_lengths", "process_sentences" ]
2
[ [ "process_sentences", "word_lengths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
72413644ab4ede20d3ea073603e8b2f96804d690
525d903b24be513c8281d9bf90ad8268b38b8ec6
v1.0
complete
Evol
Evol_1823_C
def is_prime(n: int) -> bool: """ Returns True if the number n is prime, otherwise False. >>> is_prime(2) True >>> is_prime(4) False """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a list of prime numbers from the list of integers provided. >>> filter_pri...
def is_prime(n): """ Returns True if the number n is prime, 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 filt...
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(18) == False assert is_prime(29) == True def test_filter_primes_with_no_primes(): assert filter_pr...
[ { "docstring": "Returns True if the number n is prime, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the list of integers provided.", "function_declaration": "def...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_7
{ "original_instruction": "Write a function that accepts a list of integers and returns a new list containing only the prime numbers from the original list. Implement a helper function to check if a number is prime.", "prompt_id": "00001823", "row_id": 1823, "seed_ids": "[47075]" }
0.765318
Evol_1823
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c89309f841adc19756abbf66f4098b0cd4c3b5b2
2655fcfba226d7400de64fa0d3e039cdcf341c1b
v1.0
complete
Evol
Evol_1032_C
import numpy as np from scipy.optimize import minimize def distance(point1, point2): """ Compute the Euclidean distance between two 2D points. """ pass def time_to_reach(convergence_point, starting_point, speed): """ Compute the time it takes for a drone to reach the convergence point from its...
import numpy as np from scipy.optimize import minimize def distance(point1, point2): """ Compute the Euclidean distance between two 2D points. """ return np.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) def time_to_reach(convergence_point, starting_point, speed): """ Compute th...
from solution import distance, time_to_reach, total_time, optimal_convergence def test_distance(): assert np.isclose(distance((0, 0), (3, 4)), 5.0) assert np.isclose(distance((1, 1), (4, 5)), 5.0) def test_time_to_reach(): assert np.isclose(time_to_reach((3, 4), (0, 0), 1.0), 5.0) assert np.isclose(ti...
[ { "docstring": "Compute the Euclidean distance between two 2D points.", "function_declaration": "def distance(point1, point2):", "function_name": "distance", "parameter_list": "(point1, point2)" }, { "docstring": "Compute the time it takes for a drone to reach the convergence point from its ...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom scipy.optimize import minimize\n\ndef euclidean_distance(p1, p2):\n \"\"\"\n Returns the Euclidean distance between two points p1 an...
trial_gpt4o_4
{ "original_instruction": "Write a program that determines the optimal point of convergence for three randomly positioned drones in a 2D space, represented as points with floating-point coordinates (x, y). Each drone travels at a constant speed, but potentially different from one another.\n\nYour task is to calculate...
0.578294
Evol_1032
C
[ "distance", "time_to_reach", "total_time", "optimal_convergence" ]
4
[ [ "optimal_convergence", "total_time" ], [ "time_to_reach", "distance" ], [ "total_time", "time_to_reach" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy", "scipy" ]
false
b226742261d068e445bcba26f44eda11671bef3b
35394d7ed171c2ae650dcf1c910cac50735122e2
v1.0
complete
Evol
Evol_1277_C
from typing import List def filter_primes(arr: List[int]) -> List[int]: """ Create a function that receives an array of integers and returns a new array containing only the prime numbers from the original array. >>> filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) [2, 3, 5, 7] >>> filter_primes([10, 23, 4, ...
def is_prime(num): """ Returns True if the number is prime, otherwise 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...
from solution import filter_primes def test_filter_primes_with_primes(): assert filter_primes([2, 3, 5, 7]) == [2, 3, 5, 7] def test_filter_primes_with_mixed_numbers(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_with_small_array(): assert filter_primes([10, ...
[ { "docstring": "Returns True if the number is prime, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers from the given array.", "function_declaration": "def filter_prim...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_8
{ "original_instruction": "Create a function that receives an array of integers and returns a new array containing only the prime numbers from the original array. Each element in the returned array should be a prime number, and the order should follow their original occurrence.\n\n### Input\n- An array of integers, e...
0.74362
Evol_1277
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e096396d3167441cdb993ce7ba93e729995ed383
8b05d1d1acf67d9ae8bbc70a32dcab8baa445829
v1.0
complete
Evol
Evol_1744_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) == True True >>> is_prime(3) == True True >>> is_prime(4) == False False >>> is_prime(17) == True True >>> is_prime(18) == False False >>> is_prime(1) == False False """ pas...
def is_prime(n): """ Check if a number is a prime number. """ 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 is_prime, pairs_with_prime_product 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 def test_pairs_with_prime_product(): # Test wi...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of tuples, where each tuple contains a pair of numbers\nfrom the input list whose product is a prime numbe...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef 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...
trial_gpt4o_6
{ "original_instruction": "Create a function in Python that accepts a list of integers and returns a list of tuples, where each tuple contains a pair of numbers from the input list whose product is a prime number. If no such pairs exist, return an empty list. Ensure your solution properly handles edge cases such as i...
0.781758
Evol_1744
C
[ "is_prime", "pairs_with_prime_product" ]
2
[ [ "pairs_with_prime_product", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
753c9b9665614015a3db510de70f0e4308c38d0a
95423313d85771695290c0ba2ac444eb86d7b2ef
v1.0
complete
Evol
Evol_1733_C
def merge_sort(arr): """ Sorts an array of integers using the Merge Sort algorithm. >>> merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] >>> merge_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] >>> merge_sort([3, 1, 4, 5, 2]) == [1, 2, 3, 4, 5] >>> merge_sort([3, 3, 1, 4, 4, 2, 2]) == [1, 2, 2, 3, ...
def merge_sort(arr): """ Sorts an array of integers using the Merge Sort algorithm. """ if len(arr) <= 1: return arr # Splitting the array into two halves mid = len(arr) // 2 left_half = merge_sort(arr[:mid]) right_half = merge_sort(arr[mid:]) # Merging the sorted h...
from solution import merge_sort def test_merge_sort_already_sorted(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_sorted(): assert merge_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5] def test_merge_sort_random_order(): assert merge_sort([3, 1, 4, 5, 2]) == [1, 2, 3, 4, 5]...
[ { "docstring": "Sorts an array of integers using the Merge Sort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted arrays into one sorted array.", "function_declaration": "def merge(le...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts an array using Merge Sort technique.\n \n Parameters:\n arr (list): The unsorted array of integers.\n \n ...
trial_gpt4o_9
{ "original_instruction": "You are given an unsorted array of integers. Design and implement an algorithm to sort the array using the Merge Sort technique. Additionally, analyze the algorithm's time and space complexity. Discuss the scenarios where Merge Sort would be preferred over other sorting algorithms like Quic...
0.66895
Evol_1733
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0fdd6a7e6ce2d7b6f68170321a3a679878ff60a6
947a8ab89cd8fd2becce648fff683ab8b18119e6
v1.0
complete
Evol
Evol_1175_C
import os def read_numbers_from_file(file_path): """ Reads a list of numbers from a specified file. The file should contain one number per line. Returns the list of numbers. """ pass def calculate_median(numbers): """ Calculates the median of a list of numbers. """ pass def fi...
import os def read_numbers_from_file(file_path): """ Reads a list of numbers from a specified file. The file should contain one number per line. Returns the list of numbers. """ if not os.path.isfile(file_path): raise FileNotFoundError("The specified file does not exist.") numbers ...
import pytest from solution import read_numbers_from_file, calculate_median, find_median_from_file def test_read_numbers_from_file_valid(): with open('test_valid.txt', 'w') as f: f.write('1\n2\n3\n4\n5\n6\n7\n8\n9\n10') assert read_numbers_from_file('test_valid.txt') == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ...
[ { "docstring": "Reads a list of numbers from a specified file.\nThe file should contain one number per line.\nReturns the list of numbers.", "function_declaration": "def read_numbers_from_file(file_path):", "function_name": "read_numbers_from_file", "parameter_list": "(file_path)" }, { "docs...
[ 1, 0, 1, 0, 1, 1, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import os\n\ndef read_numbers_from_file(filename):\n \"\"\"\n Reads a list of numbers from a specified file.\n \n Returns a list of numbers or raises a...
trial_gpt4o_9
{ "original_instruction": "Build a Python application that reads a text file containing a list of numbers (one number per line) and calculates the median of these numbers. If the list has an odd number of elements, the median is the middle element. If it has an even number of elements, the median is the average of th...
0.660168
Evol_1175
C
[ "read_numbers_from_file", "calculate_median", "find_median_from_file" ]
3
[ [ "find_median_from_file", "calculate_median" ], [ "find_median_from_file", "read_numbers_from_file" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4ef0b36e771ab96ea55588dfc0740f9223d869fb
a3140558a02d201cd24ed26bc712acce7bf88524
v1.0
complete
Evol
Evol_1865_C
from typing import List def filter_and_reverse_primes(nums: List[int]) -> List[int]: """ Returns a list containing only the prime numbers from the original list, but reversed in order. >>> filter_and_reverse_primes([3, 6, 10, 29, 18, 19]) == [19, 29, 3] >>> filter_and_reverse_primes([4, 6, 8, 10, ...
from typing import List def is_prime(n: int) -> bool: """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 filter_and_reverse_primes(nums: List[int]) -> List[int]: ""...
from solution import filter_and_reverse_primes def test_filter_and_reverse_primes_with_primes(): assert filter_and_reverse_primes([3, 6, 10, 29, 18, 19]) == [19, 29, 3] def test_filter_and_reverse_primes_with_no_primes(): assert filter_and_reverse_primes([4, 6, 8, 10, 12]) == [] def test_filter_and_reverse_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 a list of prime numbers from the input list, in reverse order.", "function_declaration": "def filte...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n ...
trial_gpt4o_9
{ "original_instruction": "Write a function that accepts a list of integers and returns a list containing only the prime numbers from the original list, but reversed in order. If the input list is empty or contains no prime numbers, return an empty list.\n\nFunction signature:\n```python\ndef filter_and_reverse_prime...
0.651872
Evol_1865
C
[ "is_prime", "filter_and_reverse_primes" ]
2
[ [ "filter_and_reverse_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5d130815f3e551832e081c6479e54311a5500e40
eb0f5d263ebdc7c403a45a5cd71daa3f8a80d582
v1.0
complete
Evol
Evol_1250_C
import pandas as pd from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split, cross_val_score from sklearn.preprocessing import StandardScaler from sklearn.metrics import confusion_matrix from sklearn.impute import SimpleImputer def preprocess_data(df): """ Prepr...
import pandas as pd from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split, cross_val_score from sklearn.preprocessing import StandardScaler from sklearn.metrics import confusion_matrix from sklearn.impute import SimpleImputer def preprocess_data(df): # Handling mi...
import pandas as pd import numpy as np from solution import preprocess_data, train_random_forest, evaluate_model from sklearn.datasets import make_classification def generate_dummy_data(): # Generate a dummy dataset for testing X, y = make_classification(n_samples=1000, n_features=20, n_classes=2, random_state...
[ { "docstring": null, "function_declaration": "def preprocess_data(df):", "function_name": "preprocess_data", "parameter_list": "(df)" }, { "docstring": null, "function_declaration": "def train_random_forest(df, target):", "function_name": "train_random_forest", "parameter_list": ...
[ 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import pandas as pd\nfrom sklearn.model_selection import train_test_split, cross_val_score\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.prepr...
trial_gpt4o_7
{ "original_instruction": "Given the frequency of fraudulent activities in credit card transactions, developing a reliable detection system is crucial. Implement a Python script using Scikit-learn to build a binary classification model based on the random forest algorithm to detect fraudulent transactions. The datase...
0.809915
Evol_1250
C
[ "preprocess_data", "train_random_forest", "evaluate_model" ]
3
[ [ "evaluate_model", "preprocess_data" ], [ "train_random_forest", "preprocess_data" ] ]
2
[]
false
[]
false
pytest
true
[ "numpy", "pandas", "sklearn" ]
false
bf26e925f579e0bee02f307f6f437e653711f75c
347fb2945546ca91346b73bbc19fa7763011f6de
v1.0
complete
Evol
Evol_1523_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise returns False. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a ...
import math def is_prime(n): """ Returns True if n is a prime number, otherwise returns 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: ...
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(5) == True assert is_prime(17) == True assert is_prime(18) == False assert is_prime(-1) == False assert is_prime(0) == Fals...
[ { "docstring": "Returns True if n is a prime number, otherwise returns False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list 'numbers'.", "function_declaration": "de...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n :param n: Integer to check\n :return: True if n is prime, else False\...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. Implement a helper function to check for prime numbers, ensuring optimal performance by using the square root method for divisibility checks.", "...
0.770054
Evol_1523
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2768b09117718a05c1d26ce2f7b929cd54663cd3
eb7fcb85fc26d724e6af1c09dd61053cebd2235c
v1.0
complete
Evol
Evol_1925_C
def nested_frequency(nested_list): """ Returns a new nested list where each integer is replaced with its frequency within the entire nested list. >>> nested_frequency([[1, 2], [1, [2, [3, 4], 3]], 4]) [[2, 2], [2, [2, [2, 2], 2]], 2] >>> nested_frequency([[5]]) [[1]] >>> nested_frequency([1, 1, [1, ...
def flatten_and_count(nested_list): """ Flattens a nested list of integers and returns a dictionary with the frequency count of each integer. """ def flatten(lst): for item in lst: if isinstance(item, int): yield item elif isinstance(item, list): ...
from solution import nested_frequency def test_nested_frequency_simple(): input_list = [[1, 2], [1, [2, [3, 4], 3]], 4] expected_output = [[2, 2], [2, [2, [2, 2], 2]], 2] assert nested_frequency(input_list) == expected_output def test_nested_frequency_single_element(): input_list = [[5]] expected_...
[ { "docstring": "Flattens a nested list of integers and returns a dictionary with the frequency count of each integer.", "function_declaration": "def flatten_and_count(nested_list):", "function_name": "flatten_and_count", "parameter_list": "(nested_list)" }, { "docstring": "Replaces each inte...
[ 1, 1, 1, 1, 0, 1, 1, 1, 1, 0 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from collections import Counter\nfrom typing import Union, List\n\ndef flatten_and_count(nested_list: List[Union[int, List]]) -> Counter:\n \"\"\"\n Flattens...
trial_gpt4o_8
{ "original_instruction": "Write a function in Python that takes a nested list of integers as input and returns a new list where each integer is replaced with its frequency within the nested list. Be sure to handle any depth of nesting. For example, given the input `[[1, 2], [1, [2, [3, 4], 3]], 4]`, the function sho...
0.665065
Evol_1925
C
[ "flatten_and_count", "replace_with_frequency", "nested_frequency" ]
3
[ [ "nested_frequency", "flatten_and_count" ], [ "nested_frequency", "replace_with_frequency" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7097b673e853647f13453cc430c6f6ccbceddcdf
51527eb6d69f6ee56e1e1066c163d5fedba9921e
v1.0
complete
Evol
Evol_841_C
from typing import List def is_prime(n: int) -> bool: """ Helper function to determine if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(13) True """ pass def next_prime(n: int) -> int: """ Helper function to find...
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 next_prim...
from solution import replace_with_next_prime, is_prime, next_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(17) == True assert is_prime(18) == False def test_next_prime(): assert next_...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to find the next prime number greater than n.", "function_declaration": "def next_prime...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_5
{ "original_instruction": "Write a function that accepts a list of integers and returns a list of the same integers but with all prime numbers replaced by their immediate next higher prime number. This task requires a good understanding of both prime number validation and list manipulation:\n\ndef replace_with_next_p...
0.690208
Evol_841
C
[ "is_prime", "next_prime", "replace_with_next_prime" ]
3
[ [ "next_prime", "is_prime" ], [ "replace_with_next_prime", "is_prime" ], [ "replace_with_next_prime", "next_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
266b30ea36f86cece56c8759d55f5cc52dd7547a
f747db1d025c6d9a5455a8548a26022994b346f3
v1.0
complete
Evol
Evol_1746_C
def is_prime(n: int) -> bool: """ Helper function to determine if a number is prime. Returns True if prime, otherwise False. """ def get_prime_numbers(lst: List[int]) -> List[int]: """ Accepts a list of integers and returns a new list containing only the prime numbers. Raises TypeError if a...
def is_prime(n): """ Helper function to determine if a number is prime. Returns True if prime, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i...
import pytest from solution import get_prime_numbers def test_get_prime_numbers_basic(): assert get_prime_numbers([2, 3, 5, 10, 15, 17, 23]) == [2, 3, 5, 17, 23] def test_get_prime_numbers_empty(): assert get_prime_numbers([]) == [] def test_get_prime_numbers_no_primes(): assert get_prime_numbers([4, 6, ...
[ { "docstring": "Helper function to determine if a number is prime.\nReturns True if prime, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Accepts a list of integers and returns a new list containing only ...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_9
{ "original_instruction": "Create a function in Python that accepts a list of integers and returns a new list that contains only the prime numbers from the original list. Additionally, if a non-integer or a negative number is encountered within the list, raise an appropriate exception with a meaningful error message....
0.828199
Evol_1746
C
[ "is_prime", "get_prime_numbers" ]
2
[ [ "get_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d2f472d463a84d2b4623654f84551efece1c0afc
9e295ab9171fbb209f8766a17ac5818e7b87af74
v1.0
complete
Evol
Evol_2028_C
from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(5) True >>> is_prime(4) False >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-3) False """ def find_primes(numbers: List[int]) ->...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def find_primes(numbers)...
from solution import find_primes, is_prime def test_find_primes_with_mixed(): assert find_primes([15, 3, 7, 10, 24]) == [3, 7] def test_find_primes_with_no_primes(): assert find_primes([8, 10, 20]) == [] def test_find_primes_with_all_primes(): assert find_primes([11, 2, 5, 3, 7]) == [2, 3, 5, 7, 11] def...
[ { "docstring": "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 input list in ascending order.", "function_declaration": "def find_primes(numbers...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n return True\n ...
trial_gpt4o_5
{ "original_instruction": "Create a function that takes a list of integers and returns a list of the prime numbers from the input list in ascending order. If no prime numbers are found, return an empty list. Optimize the function for efficient computation.\n\nExample:\n\nInput: [15, 3, 7, 10, 24]\nOutput: [3, 7]\n\nI...
0.820138
Evol_2028
C
[ "is_prime", "find_primes" ]
2
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
492ae471ab32f6469940d4227dc258907e076675
9b37f70ad693e023e3ebf571597c8b63eccf9d5f
v1.0
complete
Evol
Evol_1819_C
def is_subsequence(word, string): """ Check if word is a subsequence of string """ it = iter(string) return all(char in it for char in word) def longest_word(words, string): """ Finds the longest word from the list that can be constructed by deleting some characters of the string "stri...
def is_subsequence(word, string): """ Check if word is a subsequence of string """ it = iter(string) return all(char in it for char in word) def longest_word(words, string): """ Finds the longest word from the list that can be constructed by deleting some characters of the string "stri...
from solution import longest_word def test_longest_word(): words = ["algorithm", "binary", "code", "data", "debug", "function", "loop", "program", "syntax", "variable"] string = "programming" assert longest_word(words, string) == "program" def test_longest_word_no_subsequence(): words = ["hello", "wor...
[ { "docstring": "Check if word is a subsequence of string", "function_declaration": "def is_subsequence(word, string):", "function_name": "is_subsequence", "parameter_list": "(word, string)" }, { "docstring": "Finds the longest word from the list that can be constructed by deleting some \ncha...
[ 1, 0, 1, 0, 0, 0, 1, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def longest_word_by_deleting_chars(words, string):\n \"\"\"\n Finds the longest word from the list 'words' that can be constructed by deleting some character...
trial_gpt4o_9
{ "original_instruction": "<p>&lt;code&gt; words = [\"algorithm\", \"binary\", \"code\", \"data\", \"debug\", \"function\", \"loop\", \"program\", \"syntax\", \"variable\"] &lt;/code&gt;&lt;p&gt; Given the list of words above, write a function that finds the longest word that can be constructed by deleting some chara...
0.749654
Evol_1819
C
[ "is_subsequence", "longest_word" ]
2
[ [ "longest_word", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5131a89259ec2cc71e91407b0c2343e0bac00eb
29a67b4765eaa1a11fd358e66f72996c39bb179c
v1.0
complete
Evol
Evol_1877_C
def is_prime(n: int) -> bool: """ Checks if a number n is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(17) True >>> is_prime(18) False """ def sort_primes_...
def is_prime(n): """ Checks if a number n is a prime number. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def sort_primes_first(lst): """ Sort the list such that prime numbers appear before non-prime ...
from solution import is_prime, sort_primes_first def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(17) == True assert is_prime(18) == False def test_sort_primes_firs...
[ { "docstring": "Checks if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sort the list such that prime numbers appear before non-prime numbers,\nmaintaining the relative order from the origin...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_8
{ "original_instruction": "Create a Python function that accepts a list of integers and returns the list sorted in such a way that all prime numbers appear before non-prime numbers, while maintaining the relative order of prime numbers and non-prime numbers as they appear in the original list. Optimize for readabilit...
0.756696
Evol_1877
C
[ "is_prime", "sort_primes_first" ]
2
[ [ "sort_primes_first", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
21695ff8f81105d3824a1726c9269923272b4d30
7bfd427729874522f7629121c8d57001ad1d8a6d
v1.0
complete
Evol
Evol_2199_C
def filter_primes(input_list: List[int]) -> List[int]: """ Given a list of integers, return a new list containing only the prime numbers from the original list. >>> filter_primes([10, 15, 3, 7, 9, 11]) [3, 7, 11] >>> filter_primes([4, 6, 8, 10, 15]) [] >>> filter_primes([2, 3, 5, 7, 11]) [2, 3, 5, ...
def is_prime(n): """ Check if a given number n is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(i...
from solution import filter_primes def test_filter_primes_mixed_list(): assert filter_primes([10, 15, 3, 7, 9, 11]) == [3, 7, 11] def test_filter_primes_all_non_primes(): assert filter_primes([4, 6, 8, 10, 15]) == [] def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5,...
[ { "docstring": "Check if a given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the input list of integers.", "function_declaration": "...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_9
{ "original_instruction": "Given a list of integers, return a new list containing only the prime numbers from the original list.\nexample_list = [10, 15, 3, 7, 9, 11]", "prompt_id": "00002199", "row_id": 2199, "seed_ids": "[39218]" }
0.677666
Evol_2199
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
79635fe5a4183ae55351dd2aa4929f14e0562e38
e2e7e0b28b2a3d20a2f16fb03f7a7529fefca824
v1.0
complete
Evol
Evol_2218_C
def valid_subsequence(subseq: list) -> bool: """ Verify if the given subsequence has all consecutive elements with a difference greater than 2.""" pass def longest_disjoint_subsequence(array: list) -> list: """ Find the longest subsequence from the array where the difference between consecutive elements is...
def valid_subsequence(subseq: list) -> bool: """ Verify if the given subsequence has all consecutive elements with a difference greater than 2.""" for i in range(len(subseq) - 1): if abs(subseq[i + 1] - subseq[i]) <= 2: return False return True def longest_disjoint_subsequence(array: li...
from solution import valid_subsequence, longest_disjoint_subsequence def test_valid_subsequence(): assert valid_subsequence([1, 4, 7, 10]) == True assert valid_subsequence([1, 3, 5, 7, 9]) == False assert valid_subsequence([1, 5, 10]) == True assert valid_subsequence([1, 2, 6, 10]) == False def test_l...
[ { "docstring": "Verify if the given subsequence has all consecutive elements with a difference greater than 2.", "function_declaration": "def valid_subsequence(subseq):", "function_name": "valid_subsequence", "parameter_list": "(subseq)" }, { "docstring": "Find the longest subsequence from t...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def valid_subsequence(subseq):\n \"\"\" Verify if the given subsequence has all consecutive elements with a difference greater than 2.\"\"\"\n for i in range...
trial_gpt4o_9
{ "original_instruction": "Create a function `longest_disjoint_subsequence` that finds the longest subsequence from an array of integers where the difference between consecutive elements is always greater than 2. The function should also include a helper function, `valid_subsequence`, that verifies if a given subsequ...
0.798766
Evol_2218
C
[ "valid_subsequence", "longest_disjoint_subsequence" ]
2
[ [ "longest_disjoint_subsequence", "valid_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
571e84d0e0e40476b7dc00be6fb8407b9d09e201
87d623abc673894294eeee7d50d5685874ff4ca8
v1.0
complete
Evol
Evol_2025_C
def add_to_group(word: str, group_dict: dict) -> None: """ Add a word to the appropriate group in the dictionary based on its starting letter in a case-insensitive manner. >>> group_dict = {} >>> add_to_group('Apple', group_dict) >>> group_dict {'a': ['Apple']} >>> add_to_group('apricot', group_...
def add_to_group(word, group_dict): first_letter = word[0].lower() if first_letter in group_dict: group_dict[first_letter].append(word) else: group_dict[first_letter] = [word] def group_by_starting_letter(words): group_dict = {} for word in words: add_to_group(word, grou...
from solution import add_to_group, group_by_starting_letter def test_add_to_group_new_group(): group_dict = {} add_to_group('Apple', group_dict) assert group_dict == {'a': ['Apple']} def test_add_to_group_existing_group(): group_dict = {'a': ['Apple']} add_to_group('apricot', group_dict) asser...
[ { "docstring": null, "function_declaration": "def add_to_group(word, group_dict):", "function_name": "add_to_group", "parameter_list": "(word, group_dict)" }, { "docstring": null, "function_declaration": "def group_by_starting_letter(words):", "function_name": "group_by_starting_lett...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def add_to_group(word, group_dict):\n first_letter = word[0].lower()\n if first_letter in group_dict:\n group_dict[first_letter].append(word)\n els...
trial_gpt4o_9
{ "original_instruction": "Given a list of strings, write a function to group them by their starting letter in case-insensitive manner. Specifically, return a dictionary where the keys are the lowercase starting letters and the values are lists of words that start with that particular letter.\n\nAdditionally, you are...
0.67777
Evol_2025
C
[ "add_to_group", "group_by_starting_letter" ]
2
[ [ "group_by_starting_letter", "add_to_group" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e06c0e6d5a518b0e5c7deaa2f081e462a304de11
aabf20f0d2b36c3c2f417acd047d314e5ff0265d
v1.0
complete
Evol
Evol_2110_C
from typing import List def find_subsequences(strings_list: List[str], target_string: str) -> List[str]: """ Write a function that takes a list of strings and a target string as input. The function should return all strings from the list that can be formed by deleting some characters of the target string ...
def is_subsequence(s, target): """ Helper function to determine if `s` is a subsequence of `target`. """ it = iter(target) return all(char in it for char in s) def find_subsequences(strings_list, target_string): """ Returns all strings from `strings_list` that can be formed by deleting...
from solution import find_subsequences def test_find_subsequences_all_valid(): assert find_subsequences(["abc", "ac", "b"], "abc") == ["abc", "ac", "b"] def test_find_subsequences_some_valid(): assert find_subsequences(["a", "d", "e"], "abc") == ["a"] def test_find_subsequences_none_valid(): assert f...
[ { "docstring": "Helper function to determine if `s` is a subsequence of `target`.", "function_declaration": "def is_subsequence(s, target):", "function_name": "is_subsequence", "parameter_list": "(s, target)" }, { "docstring": "Returns all strings from `strings_list` that can be formed by \n...
[ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def find_subsequences(strings_list, target_string):\n \"\"\"\n Returns all strings from strings_list that can be formed by \n deleting some characters of ...
trial_gpt4o_8
{ "original_instruction": "Write a function that takes a list of strings and a target string as input. The function should return all strings from the list that can be formed by deleting some characters of the target string without reordering the remaining characters. Ensure your solution is efficient for large input...
0.695526
Evol_2110
C
[ "is_subsequence", "find_subsequences" ]
2
[ [ "find_subsequences", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
87fb39b457f392b42ca1bbd6d4c037814a250715
ca79a46bcd138e466ce4dfa424694197ea382fff
v1.0
complete
Evol
Evol_2002_C
def fibonacci_iterative(n: int) -> int: """ Returns the nth Fibonacci number using an iterative approach. n: An integer representing the position in the Fibonacci sequence. >>> fibonacci_iterative(1) == 1 >>> fibonacci_iterative(2) == 1 >>> fibonacci_iterative(3) == 2 >>> fibonacci_iterative...
def fibonacci_iterative(n): """ Returns the nth Fibonacci number using an iterative approach. n: An integer representing the position in the Fibonacci sequence. """ if n <= 0: raise ValueError("n must be a positive integer") if n == 1 or n == 2: return 1 a, b = 1...
from solution import fibonacci_iterative, fibonacci_recursive, get_fibonacci_n def test_fibonacci_iterative(): assert fibonacci_iterative(1) == 1 assert fibonacci_iterative(2) == 1 assert fibonacci_iterative(3) == 2 assert fibonacci_iterative(4) == 3 assert fibonacci_iterative(5) == 5 assert fi...
[ { "docstring": "Returns the nth Fibonacci number using an iterative approach.\nn: An integer representing the position in the Fibonacci sequence.", "function_declaration": "def fibonacci_iterative(n):", "function_name": "fibonacci_iterative", "parameter_list": "(n)" }, { "docstring": "Return...
[ 0, 1, 0, 0, 0, 0, 0, 0, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def iterative_fibonacci(n):\n \"\"\"\n Returns the nth Fibonacci number using an iterative approach.\n \"\"\"\n if n < 0:\n raise ValueError(\"n...
trial_gpt4o_8
{ "original_instruction": "Write a Python program that calculates the nth Fibonacci number. The program should prompt the user to enter a positive integer n and should include error handling for invalid inputs such as non-integer or negative values. Implement the function using both iterative and recursive approaches...
0.852545
Evol_2002
C
[ "fibonacci_iterative", "fibonacci_recursive", "get_fibonacci_n" ]
3
[ [ "get_fibonacci_n", "fibonacci_iterative" ], [ "get_fibonacci_n", "fibonacci_recursive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
68d49f69580ab3ee35ddfdaf09a6197a0b425cee
ced859779732fcd72bcb121a09de23ac98f968d9
v1.0
complete
Evol
Evol_1808_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, else False. A prime number is a natural number greater than 1, that has no positive divisors other than 1 and itself. >>> is_prime(-10) False >>> is_prime(0) False >>> is_prime(1) ...
def is_prime(n): """ Returns True if n is a prime number, else False. A prime number is a natural number greater than 1, that has no positive divisors other than 1 and itself. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for ...
from solution import filter_primes, is_prime def test_is_prime(): assert not is_prime(-10) assert not is_prime(0) assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(29) def test_filter_primes_basic(): assert filter_primes([1, 2, 3, 4, 5,...
[ { "docstring": "Returns True if n is a prime number, else False.\nA prime number is a natural number greater than 1, \nthat has no positive divisors other than 1 and itself.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from math import isqrt\n\ndef is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n A number n is prime if it's greater than 1 and has ...
trial_gpt4o_8
{ "original_instruction": "Write a Python function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Ensure that your function handles edge cases such as negative numbers, zero, and one correctly. Include a brief explanation of how your prime-checking logic...
0.779811
Evol_1808
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e3e9f7cab0307cf5669cd4108ebb25c87ff52dfa
670d4494e1f81bae25c523f1f9da09b0a311c108
v1.0
complete
Evol
Evol_1959_C
def sieve_of_eratosthenes(n: int) -> List[int]: """Returns a list of all prime numbers up to n (inclusive) using the Sieve of Eratosthenes algorithm. >>> sieve_of_eratosthenes(10) [2, 3, 5, 7] >>> sieve_of_eratosthenes(30) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] """ pass def extract_prime_numb...
def sieve_of_eratosthenes(n): sieve = [True] * (n + 1) p = 2 while (p * p <= n): if (sieve[p] == True): for i in range(p * p, n + 1, p): sieve[i] = False p += 1 return [p for p in range(2, n + 1) if sieve[p]] def extract_prime_numbers(lst): if not lst: ...
from solution import sieve_of_eratosthenes, extract_prime_numbers def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(30) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] assert sieve_of_eratosthenes(1) == [] def test_extract_prime_numbers(): assert e...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def extract_prime_numbers(lst):", "function_name": "extract_prime_numbers", "parameter_...
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(n):\n \"\"\"Returns a list of prime numbers up to n using the sieve of Eratosthenes.\"\"\"\n is_prime = [True] * (n + 1)\n p = 2...
trial_gpt4o_8
{ "original_instruction": "Write a Python function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Use the Sieve of Eratosthenes algorithm for finding prime numbers.\nThe List = [10, 15, 20, 23, 29, 31, 45, 50]", "prompt_id": "00001959", "row_id": 195...
0.638602
Evol_1959
C
[ "sieve_of_eratosthenes", "extract_prime_numbers" ]
2
[ [ "extract_prime_numbers", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0f75127920ac4b9ebc3bfd139379f761c7f20f39
9243fb8d45a337c11250c8864e28bd34957f48e4
v1.0
complete
Evol
Evol_2298_C
def is_prime(num: int) -> bool: """ Helper function to determine if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def generate_primes(n: int) -> List[int]: """ Returns a list of the first 'n' prime numbers. >>> generate_primes(0) [] >>> gener...
import math def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import generate_primes, is_prime def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(11) assert not is_prime(1) assert not is_prime(0) assert not is_prime(-1) def test_generate_pri...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of the first 'n' prime numbers.", "function_declaration": "def generate_primes(n):",...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def generate_primes(n):\n \"\"\"\n Returns a list of the first n prime numbers.\n \"\"\"\n if n <= 0:\n return []\n \n primes = []\n nu...
trial_gpt4o_1
{ "original_instruction": "Create a Python function `generate_primes` that takes an integer `n` and returns a list of the first `n` prime numbers. You are not allowed to use any libraries that directly provide prime numbers, but you may use standard mathematical libraries. Implement the function as efficiently as pos...
0.801323
Evol_2298
C
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e3a4ca18d96fe3a97ca09b4e5cc3d77943fb46c
194d237dddb63c1139516d98349d38034d9bef1a
v1.0
complete
Evol
Evol_2272_C
import heapq def dijkstra(graph, start): """ Calculate the shortest paths from the start node to all other nodes using Dijkstra's algorithm. Params: graph: dict, the graph where keys are nodes and values are lists of tuples (neighbor, weight) start: the starting node Returns: (dis...
import heapq def dijkstra(graph, start): """ Calculate the shortest paths from the start node to all other nodes using Dijkstra's algorithm. Params: graph: dict, the graph where keys are nodes and values are lists of tuples (neighbor, weight) start: the starting node Returns: (dis...
import pytest from solution import dijkstra, read_graph_from_file, shortest_path def test_dijkstra_example_graph(): graph = { 'a': [('b', 4), ('c', 2)], 'b': [('e', 3)], 'c': [('b', 1), ('d', 4), ('e', 5)], 'd': [('e', 1)], 'e': [] } start = 'a' distances, previo...
[ { "docstring": "Calculate the shortest paths from the start node to all other nodes using Dijkstra's algorithm.\n\nParams:\ngraph: dict, the graph where keys are nodes and values are lists of tuples (neighbor, weight)\nstart: the starting node\n\nReturns:\n(distances, previous): a tuple where distances is a dic...
[ 1, 0, 0, 0, 1, 1, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start):\n \"\"\"\n Dijkstra's algorithm to find the shortest path in a weighted, directed graph.\n \n :param graph:...
trial_gpt4o_7
{ "original_instruction": "Design a Python program that calculates the shortest path in a weighted, directed graph using Dijkstra's algorithm. The program should first read graph data from a text file, where each line represents an edge with a source node, destination node, and weight (formatted as \"source destinati...
0.641644
Evol_2272
C
[ "dijkstra", "read_graph_from_file", "shortest_path" ]
3
[ [ "shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
52012ea56ccb09c4693c97e4b4006b8edbd037dd
ef68c863836b0b1e2923aa29cf20004abb02e908
v1.0
complete
Evol
Evol_2126_C
def sum_of_digits(num): """ Returns the sum of the digits of the given number. >>> sum_of_digits(1) == 1 >>> sum_of_digits(10) == 1 >>> sum_of_digits(123) == 6 >>> sum_of_digits(999) == 27 """ def sequence_term(n): """ Returns the n-th term of the sequence where each term is describ...
def sum_of_digits(num): """ Returns the sum of the digits of the given number. """ return sum(int(digit) for digit in str(num)) def sequence_term(n): """ Returns the n-th term of the sequence where each term is described as the product of its position (1-based) and the sum of its digits. ...
from solution import sum_of_digits, sequence_term, sequence def test_sum_of_digits(): assert sum_of_digits(1) == 1 assert sum_of_digits(10) == 1 assert sum_of_digits(123) == 6 assert sum_of_digits(999) == 27 def test_sequence_term(): assert sequence_term(1) == 1 assert sequence_term(2) == 4 ...
[ { "docstring": "Returns the sum of the digits of the given number.", "function_declaration": "def sum_of_digits(num):", "function_name": "sum_of_digits", "parameter_list": "(num)" }, { "docstring": "Returns the n-th term of the sequence where each term is described as\nthe product of its pos...
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def digit_sum(num):\n \"\"\"\n Returns the sum of the digits of a given number.\n \"\"\"\n return sum(int(digit) for digit in str(num))\n\ndef sequence...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that calculates and returns the first 'n' terms of the sequence where each term is described as the product of its position (1-based) and the sum of its digits. For instance, if 'n' is 5, the sequence would be [1, 4, 9, 16, 25].", "prompt_id": "00002126", "row_id...
0.715049
Evol_2126
C
[ "sum_of_digits", "sequence_term", "sequence" ]
3
[ [ "sequence", "sequence_term" ], [ "sequence_term", "sum_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a4c52fd22f65d147332a4c471abf0bfd0a85f9e2
bc6f9720625b44696315013843df776a523cf872
v1.0
complete
Evol
Evol_1007_C
import numpy as np def initialize_centroids(X, k): """ Randomly initialize centroids from the dataset X. Args: X (np.ndarray): The dataset. k (int): The number of centroids. Returns: np.ndarray: Initialized centroids. """ pass def assign_clusters(X, centroids): """ Assign each dat...
import numpy as np from sklearn.datasets import load_iris from sklearn.preprocessing import StandardScaler def initialize_centroids(X, k): np.random.seed(0) indices = np.random.choice(X.shape[0], k, replace=False) return X[indices] def assign_clusters(X, centroids): distances = np.linalg.norm(X[:, np....
import numpy as np from sklearn.datasets import load_iris from sklearn.preprocessing import StandardScaler from solution import initialize_centroids, assign_clusters, update_centroids, kmeans def test_initialize_centroids(): X = np.array([[1,2], [3,4], [5,6], [7,8]]) np.random.seed(0) centroids = initializ...
[ { "docstring": null, "function_declaration": "def initialize_centroids(X, k):", "function_name": "initialize_centroids", "parameter_list": "(X, k)" }, { "docstring": null, "function_declaration": "def assign_clusters(X, centroids):", "function_name": "assign_clusters", "parameter...
[ 1, 1, 1, 0, 0, 1, 0, 1, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom sklearn.datasets import load_iris\n\nclass KMeans:\n def __init__(self, n_clusters, max_iter=300, tol=1e-4):\n self.n_clusters =...
trial_gpt4o_8
{ "original_instruction": "Generate a Python script to implement a K-means clustering algorithm from scratch. The script should be able to:\n- Initialize centroids randomly\n- Assign data points to the nearest centroid\n- Update centroids based on the mean of assigned data points\n- Repeat the above steps until centr...
0.831
Evol_1007
C
[ "initialize_centroids", "assign_clusters", "update_centroids", "kmeans" ]
4
[ [ "kmeans", "assign_clusters" ], [ "kmeans", "initialize_centroids" ], [ "kmeans", "update_centroids" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy", "sklearn" ]
false
aecbcb0b4df9d460e5e0fb338634e47b33760a6f
d6ae8f41f75084fdbe9132561d53866da7844759
v1.0
complete
Evol
Evol_2285_C
def is_prime(num: int) -> bool: """Check if a number is a prime.""" if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while (i * i) <= num: if num % i == 0 or num % (i + 2) == 0: return False ...
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 canBeSumOfTwoPrimes(n): ...
from solution import canBeSumOfTwoPrimes def test_canBeSumOfTwoPrimes_positive_case(): assert canBeSumOfTwoPrimes(10) == True # 10 = 3 + 7 def test_canBeSumOfTwoPrimes_no_pair(): assert canBeSumOfTwoPrimes(11) == False # There are no two primes that sum up to 11 def test_canBeSumOfTwoPrimes_smallest_sum():...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def canBeSumOfTwoPrimes(n):", "function_name": "canBeSumOfTwoPrimes", "parameter_list": "(n)" } ]
[ 0, 0, 0, 0, 0, 1, 0, 1, 1 ]
3
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def canBeSumOfTwoPrimes(n: int) -> bool:\n \"\"\"\n Returns True if n can be expressed as the sum of two prime numbers, False otherwise.\n \"\"\"\n if ...
trial_gpt4o_9
{ "original_instruction": "In a game, you are given a number and you need to determine if it can be expressed as the sum of two prime numbers. Write a function `canBeSumOfTwoPrimes(n)` that takes an integer `n` and returns `True` if `n` can be expressed as the sum of two prime numbers and `False` otherwise. Keep in m...
0.800426
Evol_2285
C
[ "is_prime", "canBeSumOfTwoPrimes" ]
2
[ [ "canBeSumOfTwoPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
82ada95c0bb48ad9477c922d0f51ea4f6997179c
fc24b84f4839858c4559c886c725d5c385dfb0ac
v1.0
complete
Evol
Evol_2469_C
def find_happy_numbers(n: int) -> list: """ Implement a function `find_happy_numbers(n)` that takes a positive integer `n` and returns a list of the first `n` happy numbers. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of it...
def is_happy_number(num): """ Helper function to determine if a number is a happy number. """ visited = set() while num != 1 and num not in visited: visited.add(num) num = sum(int(digit) ** 2 for digit in str(num)) return num == 1 def find_happy_numbers(n): """ Returns t...
from solution import find_happy_numbers def test_find_happy_numbers_basic(): assert find_happy_numbers(1) == [1] assert find_happy_numbers(3) == [1, 7, 10] assert find_happy_numbers(5) == [1, 7, 10, 13, 19] def test_find_happy_numbers_larger(): assert find_happy_numbers(8) == [1, 7, 10, 13, 19, 23, 28...
[ { "docstring": "Helper function to determine if a number is a happy number.", "function_declaration": "def is_happy_number(num):", "function_name": "is_happy_number", "parameter_list": "(num)" }, { "docstring": "Returns the first n happy numbers.", "function_declaration": "def find_happy...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_happy_number(x):\n \"\"\"Helper function to determine if a number x is happy.\"\"\"\n seen = set()\n while x != 1 and x not in seen:\n seen....
trial_gpt4o_9
{ "original_instruction": "Implement a function `find_happy_numbers(n)` that takes a positive integer `n` and returns a list of the first `n` happy numbers. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat th...
0.574305
Evol_2469
C
[ "is_happy_number", "find_happy_numbers" ]
2
[ [ "find_happy_numbers", "is_happy_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6324ffae441804e2eefdceda63256bbd0a6ac0e1
0baf6453a6df82b58ab568bfaa4ced83e302d684
v1.0
complete
Evol
Evol_2254_C
def get_prime_numbers(lst): """ Returns a list of prime numbers from the input list 'lst'. If 'lst' is empty or contains non-integer elements, returns appropriate error message. >>> get_prime_numbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] >>> get_prime_numbers([]) == [] >>> get_pr...
def is_prime(n): """ Helper function to determine if a number is a 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 get_prime_numbers def test_prime_numbers_in_mixed_list(): assert get_prime_numbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_empty_list(): assert get_prime_numbers([]) == [] def test_list_with_non_integer_elements(): assert get_prime_numbers([2, 3, 'a', 5, 7]) == "Err...
[ { "docstring": "Helper function to determine if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list 'lst'.\nIf 'lst' is empty or contains non-integer ele...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def filter_primes(numbers):\n \"\"\"\n Filters the list and returns only the prime numbers.\n If the list is empty or contains non-integer elements, retur...
trial_gpt4o_8
{ "original_instruction": "Design a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Your function should include an inner helper function to determine the primality of a number and handle cases where the input list is empty or contains non-intege...
0.723293
Evol_2254
C
[ "is_prime", "get_prime_numbers" ]
2
[ [ "get_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
57ed490905a30cfc4d9cc2490ead1b545a020e56
0af14cbd9d7b247b8198fb58c85d41cf1eab6a72
v1.0
complete
Evol
Evol_2527_C
import re from collections import defaultdict from typing import List, Tuple, Dict def is_valid_email(email: str) -> bool: """ Validates if the given email address is valid based on described rules. >>> is_valid_email("user.name@example.com") True >>> is_valid_email("username@com") False ""...
import re from collections import defaultdict def is_valid_email(email): """ Validates if the given email address is valid based on described rules. """ email_regex = re.compile(r'^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$') return bool(email_regex.match(email)) def categorize_emails(email_l...
from solution import is_valid_email, categorize_emails def test_is_valid_email(): # Test valid emails assert is_valid_email("user.name@example.com") assert is_valid_email("user_name@example.com") assert is_valid_email("user-name@example.com") assert is_valid_email("username@example.com") #...
[ { "docstring": "Validates if the given email address is valid based on described rules.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Categorizes valid emails by their domain and counts the number of ...
[ 1, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import re\nfrom collections import defaultdict\n\ndef is_valid_email(email):\n \"\"\"\n This function checks if an email address is valid based on the provid...
trial_gpt4o_5
{ "original_instruction": "Write a program to read a list of email addresses and filter out invalid ones based on the following rules:\n1. An email address must have exactly one '@' symbol.\n2. The local part (before the '@') should not be empty and should only contain alphanumeric characters and the following specia...
0.659059
Evol_2527
C
[ "is_valid_email", "categorize_emails", "user_interface" ]
3
[ [ "categorize_emails", "is_valid_email" ], [ "user_interface", "categorize_emails" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fb145a64580ec1519b5b308e5d15f6806c37b416
8ef0d7b7b289ce6839eb9b1c80fc58892bc12075
v1.0
complete
Evol
Evol_2211_C
import os import json from datetime import datetime TASKS_FILE = 'tasks.json' def load_tasks(): """Load tasks from the task file.""" pass def save_tasks(tasks): """Save tasks to the task file.""" pass def add_task(description, due_date): """ Add a new task with a description and due date. ...
import json import os from datetime import datetime TASKS_FILE = 'tasks.json' def load_tasks(): if os.path.exists(TASKS_FILE): with open(TASKS_FILE, 'r') as file: return json.load(file) return [] def save_tasks(tasks): with open(TASKS_FILE, 'w') as file: json.dump(tasks, file)...
import os import json import pytest from solution import add_task, list_tasks, mark_task_completed, delete_task, TASKS_FILE def setup_function(): if os.path.exists(TASKS_FILE): os.remove(TASKS_FILE) def teardown_function(): if os.path.exists(TASKS_FILE): os.remove(TASKS_FILE) def test_add_tas...
[ { "docstring": null, "function_declaration": "def load_tasks():", "function_name": "load_tasks", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def save_tasks(tasks):", "function_name": "save_tasks", "parameter_list": "(tasks)" }, { "docstring": n...
[ 0, 1, 1, 0, 0, 1, 1, 0, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import json\nimport os\nfrom datetime import datetime\n\nTASK_FILE = 'tasks.json'\n\ndef load_tasks():\n if os.path.exists(TASK_FILE):\n with open(TASK_F...
trial_gpt4o_8
{ "original_instruction": "Create a command-line application in Python that acts as a simple task manager. This application should allow the user to add new tasks with due dates, list all tasks, mark tasks as completed, and delete tasks. Ensure the application stores tasks persistently between runs using a file-based...
0.634104
Evol_2211
C
[ "load_tasks", "save_tasks", "add_task", "list_tasks", "mark_task_completed", "delete_task" ]
6
[ [ "add_task", "load_tasks" ], [ "add_task", "save_tasks" ], [ "delete_task", "load_tasks" ], [ "delete_task", "save_tasks" ], [ "list_tasks", "load_tasks" ], [ "mark_task_completed", "load_tasks" ], [ "mark_task_completed", "save_tasks"...
7
[]
false
[]
false
pytest
true
[]
true
aece47290950330600ee1b34347f5054264efa81
185efbc4082749b9ebff0edb1275514690f44344
v1.0
complete
Evol
Evol_2333_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ # Implement the helper function here def filter_primes(numbers: List[int]) -> List[int]: """ Returns a list of prime numbers from the input list. >...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2 or n == 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return Fals...
from solution import filter_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(13) == True assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list.", "function_declaration": "def filter_primes(numbers):...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_6
{ "original_instruction": "Write a Python function that receives a list of integers and returns a new list containing only the prime numbers from the original list in the same order. Your function should implement a helper function to check for primality, and cannot use any libraries such as `sympy` or similar. Ensur...
0.778101
Evol_2333
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f074516706b93be645f3a29b4dc13e7d2d2bae3f
7acf100d9be9e214f2fbd14b06154c84359c738c
v1.0
complete
Evol
Evol_2320_C
def convert_xml_to_json(xml_string: str) -> str: """ Parses a large XML document, extracts hierarchical data, and transforms it into a structured JSON format while preserving intrinsic relationships and nested structures. >>> xml_string = "<root><child>value</child></root>" >>> expected_json = json...
import xml.etree.ElementTree as ET import json def xml_to_dict(element): """ Converts an XML element and its children into a dictionary. """ def element_to_dict(elem): node = {} children = list(elem) if children: d = {} for child in children: ...
from solution import convert_xml_to_json import xml.etree.ElementTree as ET import json def test_convert_xml_to_json_simple(): xml_string = "<root><child>value</child></root>" expected_json = json.dumps({"root": {"child": "value"}}, indent=4) assert convert_xml_to_json(xml_string) == expected_json def tes...
[ { "docstring": "Converts an XML element and its children into a dictionary.", "function_declaration": "def xml_to_dict(element):", "function_name": "xml_to_dict", "parameter_list": "(element)" }, { "docstring": "Converts an XML string to a JSON string.", "function_declaration": "def conv...
[ 1, 1, 0, 1, 1, 1, 0, 0, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import xml.etree.ElementTree as ET\nimport json\n\ndef xml_to_json(xml_string):\n \"\"\"\n Parses an XML string, extracting hierarchical data and transformin...
trial_gpt4o_9
{ "original_instruction": "Design a sophisticated algorithm capable of parsing and analyzing a large XML document, extracting hierarchical data, and transforming it into a structured JSON format. Emphasize the importance of preserving the intrinsic relationships and nested structures present within the original XML w...
0.770726
Evol_2320
C
[ "xml_to_dict", "convert_xml_to_json" ]
2
[ [ "convert_xml_to_json", "xml_to_dict" ] ]
1
[]
false
[]
false
pytest
true
[]
true
61934e429c22cbf01de31813d262541ca6b087ca
6bcc07c1dfc28785a73bdc46bfdb23f2ee7aa5bf
v1.0
complete
Evol
Evol_1570_C
import os import json import csv from typing import List, Tuple def search_keyword_in_file(filepath: str, keyword: str) -> int: """ Search for a specific keyword in a file and return the count of occurrences. Handles text, JSON, and CSV file formats. Args: - filepath (str): Path to the file. -...
import os import json import csv def search_keyword_in_file(filepath, keyword): count = 0 try: if filepath.endswith('.txt'): with open(filepath, 'r', errors='ignore') as f: content = f.read() count = content.count(keyword) elif filepath.endswith('.jso...
import tempfile import os from solution import search_keyword_in_directory def create_temp_file(directory, filename, content): filepath = os.path.join(directory, filename) with open(filepath, 'w') as f: f.write(content) return filepath def test_search_keyword_in_directory(): with tempfile.Temp...
[ { "docstring": null, "function_declaration": "def search_keyword_in_file(filepath, keyword):", "function_name": "search_keyword_in_file", "parameter_list": "(filepath, keyword)" }, { "docstring": null, "function_declaration": "def search_keyword_in_directory(directory, keyword):", "f...
[ 0, 1, 1, 0, 0, 0, 1, 1, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import os\nimport json\nimport csv\n\ndef search_keyword_in_file(file_path, keyword):\n try:\n if file_path.endswith('.txt'):\n with open(file...
trial_gpt4o_1
{ "original_instruction": "Given a large directory of files, design a program that searches for a specific keyword in each file and lists the filenames that contain the keyword. The program should be able to handle different file formats (text, JSON, CSV, etc.) and should be optimized for performance to effectively h...
0.746605
Evol_1570
C
[ "search_keyword_in_file", "search_keyword_in_directory" ]
2
[ [ "search_keyword_in_directory", "search_keyword_in_file" ] ]
1
[]
false
[]
false
pytest
true
[]
true
082b54d62ef24e35f1ead577f4ae132db47161d7
c200098e7c58090f38d5e0b9ff1bbc302e7780a3
v1.0
complete
Evol
Evol_2761_C
def prime_factors(n: int) -> List[int]: """ Returns a list of prime factors of the given number n. """ def prime_factor_sum(nums: List[int]) -> int: """ Returns the sum of the sum of prime factors for each number in the input list. >>> prime_factor_sum([6, 28, 15]) 24 >>> prime_factor_sum([...
def prime_factors(n): """ Returns a list of prime factors of the given number n. """ i = 2 factors = [] while i * i <= n: while (n % i) == 0: factors.append(i) n //= i i += 1 if n > 1: factors.append(n) return factors def prime_factor_sum(...
from solution import prime_factor_sum def test_prime_factor_sum_example(): nums = [6, 28, 15] assert prime_factor_sum(nums) == 24 def test_prime_factor_sum_single_number(): nums = [6] assert prime_factor_sum(nums) == 5 def test_prime_factor_sum_prime_numbers(): nums = [2, 3, 5, 7, 11] assert ...
[ { "docstring": "Returns a list of prime factors of the given number n.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Returns the sum of the sum of prime factors for each number in the input list.", "functio...
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def sum_of_prime_factors(n):\n \"\"\"\n Returns the sum of prime factors of the given number n.\n If n is prime, it returns n.\n \"\"\"\n def is_pri...
trial_gpt4o_3
{ "original_instruction": "Create a Python function that takes a list of positive integers and returns a new list where each integer is replaced by the sum of its prime factors. The function should then calculate and return the sum of all elements in the new list. Note that if a number itself is prime, its prime fact...
0.782138
Evol_2761
C
[ "prime_factors", "prime_factor_sum" ]
2
[ [ "prime_factor_sum", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5d5064a35eec9a557669e04f1907a561ebdc4b9
1855da743909f6411b351b3e0943284aeaa40316
v1.0
complete
Evol
Evol_2151_C
import json import os from datetime import datetime, timedelta from filelock import FileLock TODO_FILE = 'todo_list.json' LOCK_FILE = 'todo_list.lock' DATE_FORMAT = '%Y-%m-%d' def load_tasks(): if os.path.exists(TODO_FILE): with open(TODO_FILE, 'r') as file: return json.load(file) return [...
import json import os from datetime import datetime, timedelta from filelock import FileLock TODO_FILE = 'todo_list.json' LOCK_FILE = 'todo_list.lock' DATE_FORMAT = '%Y-%m-%d' def load_tasks(): if os.path.exists(TODO_FILE): with open(TODO_FILE, 'r') as file: return json.load(file) return [...
import os import pytest import json from datetime import datetime, timedelta from solution import add_task, list_tasks, mark_task_completed, delete_task, archive_old_tasks, TODO_FILE, DATE_FORMAT def setup_module(module): if os.path.exists(TODO_FILE): os.rename(TODO_FILE, TODO_FILE + '.bak') def teardown...
[ { "docstring": null, "function_declaration": "def load_tasks():", "function_name": "load_tasks", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def save_tasks(tasks):", "function_name": "save_tasks", "parameter_list": "(tasks)" }, { "docstring": n...
[ 0, 0, 1, 0, 0, 0, 0, 0, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import os\nimport json\nimport datetime\nfrom threading import Lock\nfrom contextlib import contextmanager\n\n# Global lock for managing concurrent access\ntask_lo...
trial_gpt4o_8
{ "original_instruction": "Implement a command-line tool in Python that manages a simple to-do list. The tool should support the following operations: adding a new task with a specified deadline, listing all tasks (sorted by deadline), marking a task as completed, and deleting a task. Each task should include a title...
0.6231
Evol_2151
C
[ "load_tasks", "save_tasks", "add_task", "list_tasks", "mark_task_completed", "delete_task", "archive_old_tasks", "manage_to_do_list" ]
8
[ [ "add_task", "load_tasks" ], [ "add_task", "save_tasks" ], [ "archive_old_tasks", "load_tasks" ], [ "archive_old_tasks", "save_tasks" ], [ "delete_task", "load_tasks" ], [ "delete_task", "save_tasks" ], [ "list_tasks", "load_tasks" ]...
14
[]
false
[]
false
pytest
true
[ "filelock" ]
false
d873e68130af6388e1318d2da2b166545b782306
73798ae661551bc9dcb8113f5295f35c94357aba
v1.0
complete
Evol
Evol_2742_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from the original list. >>> filter_p...
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import is_prime, 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(19) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(-5) == Fals...
[ { "docstring": "Check if a number is a prime number.", "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": "def filter_pr...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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 ...
trial_gpt4o_8
{ "original_instruction": "Formulate a Python algorithm that takes in a list of integers and returns a new list containing only the prime numbers from the original list.", "prompt_id": "00002742", "row_id": 2742, "seed_ids": "[32243]" }
0.758858
Evol_2742
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d5671bb4f31a9408c02c5c160c41256e6a671cf4
385b7e60ede0303bac636e71e7067b5a6abdb346
v1.0
complete
Evol
Evol_2602_C
def dictionary_medians(data: Dict[str, List[int]]) -> Dict[str, Union[int, None]]: """ Given a dictionary with lists of integers as values, returns a new dictionary with the same keys but where the values are the median of the respective lists. If a list is empty, the value for that key should be None. ...
from typing import List, Dict, Union def median_of_list(numbers: List[int]) -> Union[int, None]: """ Returns the median of the list numbers. If the list is empty, returns None. """ if not numbers: return None sorted_numbers = sorted(numbers) n = len(sorted_numbers) mid_index = ...
from solution import dictionary_medians def test_dictionary_medians(): assert dictionary_medians({"a": [1, 3, 5], "b": [2, 4, 6, 8], "c": []}) == {"a": 3, "b": 5, "c": None} assert dictionary_medians({"x": [7, 4, 1], "y": [10, 20, 30, 40], "z": [42]}) == {"x": 4, "y": 25, "z": 42} assert dictionary_medians...
[ { "docstring": "Returns the median of the list numbers. If the list is empty, returns None.", "function_declaration": "def median_of_list(numbers):", "function_name": "median_of_list", "parameter_list": "(numbers)" }, { "docstring": "Given a dictionary with lists of integers as values, retur...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from typing import List, Dict, Optional\n\ndef median_of_lists(data: Dict[str, List[int]]) -> Dict[str, Optional[float]]:\n def median(lst: List[int]) -> Option...
trial_gpt4o_9
{ "original_instruction": "Create a function in Python that takes a dictionary as an input, where the keys are strings and the values are lists of integers. The function should return a new dictionary with the same keys, but the values should now be the median of the respective lists. If a list is empty, the function...
0.734917
Evol_2602
C
[ "median_of_list", "dictionary_medians" ]
2
[ [ "dictionary_medians", "median_of_list" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7084e8f64a3cdbf9eafb483307174d92feb3195f
d234dd77895a38ba0a6a5a9764cf98ca49811661
v1.0
complete
Evol
Evol_2245_C
import math from typing import List, Tuple def euclidean_distance(point1: List[float], point2: List[float]) -> float: """ Computes the Euclidean distance between two points in a multi-dimensional space. Args: point1 (List[float]): The coordinates of the first point. point2 (List[float]): The c...
import math def euclidean_distance(point1, point2): """ Computes and returns the Euclidean distance between two points in a multi-dimensional space. """ if len(point1) != len(point2): raise ValueError("Both points must have the same number of dimensions.") distance = math.sqrt(sum((x -...
from solution import euclidean_distance, find_nearest_point def test_euclidean_distance(): assert euclidean_distance([0, 0], [3, 4]) == 5 assert euclidean_distance([1, 2, 3], [4, 5, 6]) == math.sqrt(27) assert euclidean_distance([-1, -2], [-4, -6]) == 5 def test_find_nearest_point(): points = [[1, 2],...
[ { "docstring": "Computes and returns the Euclidean distance between two points in a multi-dimensional space.", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Finds the nearest p...
[ 0, 0, 1, 1, 1, 0, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef euclidean_distance(point1, point2):\n \"\"\"\n Computes the Euclidean distance between two points in a multi-dimensional space.\n \"\"\...
trial_gpt4o_8
{ "original_instruction": "Write a function that computes the Euclidean distance between two points in a multi-dimensional space. The function should accept two lists of equal length, where each list contains the coordinates of a point. Use this function to find the nearest point from a list of points to a given refe...
0.71264
Evol_2245
C
[ "euclidean_distance", "find_nearest_point" ]
2
[ [ "find_nearest_point", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
df29c3b5d56a3e017343e2324c757e1f12f60b7d
92b9369124891461a3c41d0d7577b897b633390c
v1.0
complete
Evol
Evol_2781_C
from typing import List def is_prime(n: int) -> bool: """ Determines if a number is prime. >>> is_prime(0) False >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(9) False >>> is_prime(11) True """ def primes_from_array(arr: List[int]) -> List[int]: """ Returns a new arr...
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 is_prime, primes_from_array def test_is_prime(): assert not is_prime(0) assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(11) assert not is_prime(15) assert is_prime(...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new array containing only the prime numbers from the original array.", "function_declaration": "def primes_from...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_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...
trial_gpt4o_9
{ "original_instruction": "Implement a function that takes an array of integers and returns a new array containing only the prime numbers from the original array. The function should be optimized to handle an array with up to 10,000 integers efficiently. As part of your solution, include a helper function that determ...
0.761279
Evol_2781
C
[ "is_prime", "primes_from_array" ]
2
[ [ "primes_from_array", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
23506c3fd6642b23d1afc48f136def3eb810134c
41166f5abb452ce27da715b5eb8c5afbdc86c296