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_4451_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_subtree(rootA: TreeNode, rootB: TreeNode) -> bool: """ Determine if one binary tree B is a subtree of another binary tree A. >>> rootA = TreeNode(3) >>> ro...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_same_tree(s, t): if not s and not t: return True if not s or not t: return False if s.val != t.val: return False return is_same...
from solution import TreeNode, is_subtree def test_is_subtree_positive(): # Example Binary Tree A rootA = TreeNode(3) rootA.left = TreeNode(4) rootA.right = TreeNode(5) rootA.left.left = TreeNode(1) rootA.left.right = TreeNode(2) # Example Binary Tree B rootB = TreeNode(4) rootB.le...
[]
[ 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": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef is_subt...
trial_gpt4o_9
{ "original_instruction": "Given a binary tree, where each node contains a value, write a function `is_subtree` that takes in two binary trees (A and B) and returns True if tree B is a subtree of tree A, and False otherwise.\n\n### Input\n- `A`: The root node of Binary Tree A.\n- `B`: The root node of Binary Tree B.\...
0.613399
Evol_4451
C
[ "is_same_tree", "is_subtree" ]
2
[ [ "is_subtree", "is_same_tree" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
2a06707d14e8d0b2574159b30b74d72694ce09fe
0f0347e149132228a5a0a680558e2506131aa87c
v1.0
complete
Evol
Evol_4487_C
from typing import List def sieve_of_eratosthenes(max_num: int) -> List[bool]: """ Returns a list of boolean values where True indicates that the index is a prime number. Uses the Sieve of Eratosthenes algorithm. """ sieve = [True] * (max_num + 1) sieve[0] = sieve[1] = False # 0 and 1 are not ...
from typing import List def sieve_of_eratosthenes(max_num: int) -> List[bool]: """ Returns a list of boolean values where True indicates that the index is a prime number. Uses the Sieve of Eratosthenes algorithm. """ sieve = [True] * (max_num + 1) sieve[0] = sieve[1] = False # 0 and 1 are not ...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 9, 10]) == [] def test_filter_primes_mixed_numbers(): assert filter_primes([2, 3, 5, 7, 8, 10, 13, 15]) == ...
[ { "docstring": "Returns a list of boolean values where True indicates that the index is a prime number.\nUses the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "do...
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ]
9
easy
0.9
{ "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 filter_primes(numbers: List[int]) -> List[int]:\n \"\"\"\n Returns a list containing only the prime numbers from the original ...
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. Use the Sieve of Eratosthenes algorithm to identify the prime numbers. Provide the function signature as `def filter_primes(numbers: List[int]) -> List[int]...
0.656396
Evol_4487
C
[ "sieve_of_eratosthenes", "filter_primes" ]
2
[ [ "filter_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e150b893544e6c6133ee929d6bb20402b83b4e74
e458e0af853d66a5dce4b7c65a0291451b0ad091
v1.0
complete
Evol
Evol_4185_C
from typing import List, Union def palindromic_primes(n: Union[int, List[int]], count=False) -> Union[List[int], List[List[int]], int, List[Union[List[int], str]]]: """ Generates a list of palindromic primes less than a given number `n`. A palindromic prime is a prime number that remains the same when its...
def is_prime(num): if num < 2: 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 is_palindrome(num): return str(num) == str(num)[::-1] def palind...
from solution import palindromic_primes def test_single_positive_integer(): assert palindromic_primes(10) == [2, 3, 5, 7] assert palindromic_primes(20) == [2, 3, 5, 7, 11] def test_single_positive_integer_count(): assert palindromic_primes(10, count=True) == 4 assert palindromic_primes(20, count=True)...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 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 is_prime(num):\n \"\"\"\n Returns True if the number is prime, else False.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n ...
trial_gpt4o_8
{ "original_instruction": "Write a Python function that generates a list of palindromic primes less than a given number `n`. A palindromic prime is a prime number that remains the same when its digits are reversed. The function should include input validation to ensure `n` is a positive integer greater than 2. If `n`...
0.698417
Evol_4185
C
[ "is_prime", "is_palindrome", "palindromic_primes" ]
3
[ [ "palindromic_primes", "is_palindrome" ], [ "palindromic_primes", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
800b2c7d9f02805b6deac5406e39e2fb689a0ef7
486d1b1fe2ee9229d9c73ec8a3a6834fde9f4db3
v1.0
complete
Evol
Evol_4883_C
from typing import List def is_prime(n: int) -> bool: """ Determines if a given number n is prime. """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Filters the list of numbers and returns a new list containing only the prime numbers. >>> filter_primes([1, 4, 6, 8, 10]) [] >...
def is_prime(n): """ Determines if a given number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6...
from solution import filter_primes def test_filter_primes_with_no_primes(): assert filter_primes([1, 4, 6, 8, 10]) == [] def test_filter_primes_with_all_primes(): assert filter_primes([2, 3, 5, 7]) == [2, 3, 5, 7] def test_filter_primes_with_mixed_numbers(): assert filter_primes([10, 11, 12, 13, 14, 15])...
[ { "docstring": "Determines if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the list of numbers and returns a new list containing only the prime numbers.", "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": "from math import isqrt\n\ndef is_prime(n):\n \"\"\"\n Checks if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= ...
trial_gpt4o_8
{ "original_instruction": "Create a program that takes a list of integers and returns a new list that contains only the prime numbers from the original list. Ensure the program performs efficiently even for large lists and correctly identifies prime numbers.", "prompt_id": "00004883", "row_id": 4883, "seed_ids"...
0.757511
Evol_4883
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9932c3f1031f17bef31f05d68af2d15e9018864a
89af8f0c3478854adda320b16e81ba97a117d9b2
v1.0
complete
Evol
Evol_4622_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, False otherwise. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(1) == False >>> is_prime(29) == True >>> is_prime(30) == Fals...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def sum_of_primes(arr): """ Returns the sum of all elements in the given list tha...
from solution import sum_of_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(29) == True assert is_prime(30) == False def test_sum_of_primes(): ...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all elements in the given list that are prime numbers.", "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 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_5
{ "original_instruction": "Compute the sum of all elements in the given list that are prime numbers.\nArray: [3, 5, 8, 13, 20, 23, 28]", "prompt_id": "00004622", "row_id": 4622, "seed_ids": "[4235]" }
0.786215
Evol_4622
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b760a1d5a2b409ac55104f72b997a78e111824a2
e4099198d954fa67370d383338bfa5a52b6b4489
v1.0
complete
Evol
Evol_4850_C
import numpy as np import random def initialize_population(pop_size, chromosome_length): """ Initialize the population with random chromosomes. Each chromosome is binary encoded. """ pass def decode_chromosome(chromosome): """ Decode the binary chromosome to a float value in the range [0, ...
import numpy as np import random def initialize_population(pop_size, chromosome_length): """ Initialize the population with random chromosomes. Each chromosome is binary encoded. """ return np.random.randint(2, size=(pop_size, chromosome_length)) def decode_chromosome(chromosome): """ Deco...
def test_initialize_population(): pop_size = 10 chromosome_length = 8 population = initialize_population(pop_size, chromosome_length) assert population.shape == (pop_size, chromosome_length) assert set(np.unique(population).tolist()).issubset({0, 1}) # Only binary values def test_decode_chromosome...
[ { "docstring": "Initialize the population with random chromosomes.\nEach chromosome is binary encoded.", "function_declaration": "def initialize_population(pop_size, chromosome_length):", "function_name": "initialize_population", "parameter_list": "(pop_size, chromosome_length)" }, { "docstr...
[ 1, 1, 0, 0, 1, 1, 0, 0, 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 numpy as np\nfrom math import sin, pi\n\ndef initialize_population(pop_size, gene_length):\n \"\"\"\n Initialize a population with random genes.\n ...
trial_gpt4o_5
{ "original_instruction": "Implement a genetic algorithm from scratch in Python to solve a simple optimization problem. Your task is to maximize the function `f(x) = x * sin(10 * pi * x) + 1`, where `x` ranges from 0 to 1. The algorithm should include the following elements: population initialization, fitness evaluat...
0.430081
Evol_4850
C
[ "initialize_population", "decode_chromosome", "fitness_function", "evaluate_population", "select_parents", "crossover", "mutate", "genetic_algorithm" ]
8
[ [ "evaluate_population", "decode_chromosome" ], [ "evaluate_population", "fitness_function" ], [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "decode_chromosome" ], [ "genetic_algorithm", "evaluate_population" ], [ "genetic_algorithm", ...
8
[]
false
[]
false
pytest
false
[ "numpy" ]
false
839d663327fb50e1bd559fa9259f9dae4bf4f7aa
05d4940f52873ec214225307a370b271ec87a897
v1.0
complete
Evol
Evol_5078_C
from typing import List def is_prime(n: int) -> bool: """ Determines if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(11) True >>> is_prime(1) False >>> is_prime(75) False """ def sum_excluding_primes(lst: Li...
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 sum_excluding_primes(lst): """ Returns the sum of the elements in lst excluding any integers that...
from solution import is_prime, sum_excluding_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(75) == False def test_sum_excluding_primes_no_primes(): assert ...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of the elements in lst excluding any integers that are prime numbers.", "function_declaration": "def sum_...
[ 1, 1, 1, 0, 1, 0, 1, 0, 0, 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 is_prime(n):\n \"\"\"\n Determines if an integer n is a prime number.\n A prime number is greater than 1 and has no divisors other than 1 and itself.\...
trial_gpt4o_4
{ "original_instruction": "Write a function that takes a list of integers and returns the sum of its elements excluding any integers that are prime numbers. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself. In your solution, implement a helper function to dete...
0.747595
Evol_5078
C
[ "is_prime", "sum_excluding_primes" ]
2
[ [ "sum_excluding_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
75bf7b6bbf7596319faf968cd7e554e6b466a216
e6c459585da170fba8c1c78c9eb6104c90a45b20
v1.0
complete
Evol
Evol_4569_C
import math from typing import List def factorial(n: int) -> int: """ Compute the factorial of n. >>> factorial(0) == 1 >>> factorial(1) == 1 >>> factorial(5) == 120 >>> factorial(10) == 3628800 >>> factorial(-5) Traceback (most recent call last): ... ValueError: Factorial is no...
import math def factorial(n): """ Compute the factorial of n. """ if n < 0: raise ValueError("Factorial is not defined for negative numbers.") if n == 0: return 1 return math.factorial(n) def binomial_coefficient(i, j): """ Compute binomial coefficient C(i, j) which is ...
import pytest from solution import generate_matrix, binomial_coefficient, factorial def test_factorial(): assert factorial(0) == 1 assert factorial(1) == 1 assert factorial(5) == 120 assert factorial(10) == 3628800 with pytest.raises(ValueError): factorial(-5) def test_binomial_coefficient...
[ { "docstring": "Compute the factorial of n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Compute binomial coefficient C(i, j) which is given by (i+j)! / (i! * j!)", "function_declaration": "def binomial_coefficien...
[ 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 factorial(n):\n \"\"\"\n Computes the factorial of a given number n.\n \"\"\"\n if n < 0:\n raise ValueError(\"Factorial is n...
trial_gpt4o_9
{ "original_instruction": "Generate a matrix (2-dimensional array) where the number of rows (m) and columns (n) are given as input. Populate the matrix such that each element A[i][j] is populated using the formula:\n\nA[i][j] = (i+j)! / (i! * j!)\n\nwhere \"!\" denotes factorial. The result should be a matrix where e...
0.610199
Evol_4569
C
[ "factorial", "binomial_coefficient", "generate_matrix" ]
3
[ [ "binomial_coefficient", "factorial" ], [ "generate_matrix", "binomial_coefficient" ] ]
2
[]
false
[]
false
pytest
true
[]
true
04490e1afd9d3a1e517a94477ff01a01b5a97b3a
ee3cc31dfc8d7da383285585b0a97a4fc6faa1fb
v1.0
complete
Evol
Evol_5016_C
def parse_query(user_input: str) -> str: """ Parses the user input and returns an appropriate response based on predefined rules. >>> parse_query("Hello") "Hello! How can I assist you today?" >>> parse_query("When do you close?") "Our operating hours are from 9 AM to 5 PM, Monday to Friday....
import re def parse_query(user_input): """ Parses the user input and returns an appropriate response based on predefined rules. """ user_input = user_input.lower().strip() # Define predefined rules and responses greetings = ["hello", "hi", "hey", "good morning", "good afternoon", "good eve...
from solution import parse_query def test_greeting_responses(): assert parse_query("Hello") == "Hello! How can I assist you today?" assert parse_query("Hi there") == "Hello! How can I assist you today?" assert parse_query("good morning") == "Hello! How can I assist you today?" def test_operating_hours_que...
[ { "docstring": "Parses the user input and returns an appropriate response based on predefined rules.", "function_declaration": "def parse_query(user_input):", "function_name": "parse_query", "parameter_list": "(user_input)" }, { "docstring": "A simple interface function to interact with the ...
[ 0, 1, 1, 0, 0, 0, 0, 0, 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 re\n\ndef respond_to_greeting():\n return \"Hello! How can I assist you today?\"\n\ndef respond_to_hours():\n return \"Our operating hours are from 9 ...
trial_gpt4o_1
{ "original_instruction": "Develop a chatbot that uses natural language processing to parse user queries and provide appropriate responses based on a predefined set of rules. The chatbot should be able to handle different types of input, including greetings, questions about operating hours, and requests for product i...
0.496732
Evol_5016
C
[ "parse_query", "chatbot_interface" ]
2
[ [ "chatbot_interface", "parse_query" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b41b637879aa57ccf98ed35748531d9e3d597066
02fd6324f21539540b2e2ccb7c51a59d767b32b2
v1.0
complete
Evol
Evol_4769_C
def is_prime(n: int) -> bool: """ Checks if a number is prime. """ # Implement this helper function to check if a number is prime. def extract_prime_numbers(lst: List[int]) -> List[int]: """ Create a function that takes an unsorted list of integers and returns a new list containing onl...
def is_prime(n): """ Checks if n is a prime number. """ 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 extract_prime_numbers(lst...
from solution import extract_prime_numbers def test_extract_prime_numbers_mixed_list(): assert extract_prime_numbers([10, 2, 3, 4, 5, 6, 11, 13, 17, 19, 22, 23, 29]) == [2, 3, 5, 11, 13, 17, 19, 23, 29] def test_extract_prime_numbers_no_primes(): assert extract_prime_numbers([4, 6, 8, 10, 12, 14, 15, 16, 20])...
[ { "docstring": "Checks if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list.", "function_declaration": "def extract_prime_numbers(lst):", "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(n):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ret...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes an unsorted list of integers and returns a new list containing only the prime numbers from the original list. Each prime number in the returned list should be in the same order as they appeared in the input list.", "prompt_id": "00004769", "row_id": 4769, ...
0.796721
Evol_4769
C
[ "is_prime", "extract_prime_numbers" ]
2
[ [ "extract_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
532fb356885aef17cf40d1f426490893a28f88df
5561f9bfad0b29ca1129c80d75dcc59103c44b82
v1.0
complete
Evol
Evol_4892_C
from typing import List def merge_intervals(intervals: List[List[int]]) -> List[List[int]]: """ Given a list of intervals representing lines on a 2D plane, merge all overlapping intervals and return the resulting list of non-overlapping intervals. >>> merge_intervals([[1, 3], [2, 4], [5, 7]]) == [[1, 4], [...
def merge_intervals(intervals): """ Merges the overlapping intervals. """ if not intervals: return [] intervals.sort(key=lambda x: x[0]) merged = [intervals[0]] for current in intervals[1:]: last_merged = merged[-1] if current[0] <= last_merged[1]: ...
from solution import merge_intervals, add_interval, remove_interval def test_merge_intervals(): assert merge_intervals([[1, 3], [2, 4], [5, 7]]) == [[1, 4], [5, 7]] assert merge_intervals([[1, 5], [6, 9]]) == [[1, 5], [6, 9]] assert merge_intervals([[1, 4], [4, 5], [5, 8], [9, 12]]) == [[1, 8], [9, 12]] ...
[ { "docstring": "Merges the overlapping intervals.", "function_declaration": "def merge_intervals(intervals):", "function_name": "merge_intervals", "parameter_list": "(intervals)" }, { "docstring": "Adds a new interval and merges if there are overlapping intervals.", "function_declaration...
[ 0, 1, 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": "def merge_intervals(intervals):\n \"\"\"\n Merges overlapping intervals and returns a list of non-overlapping intervals.\n \"\"\"\n if not intervals:\n...
trial_gpt4o_9
{ "original_instruction": "Given a list of intervals representing lines on a 2D plane, merge all overlapping intervals and return the resulting list of non-overlapping intervals. Each interval is represented as a list of two integers [start, end], where start represents the starting point and end represents the endin...
0.655346
Evol_4892
C
[ "merge_intervals", "add_interval", "remove_interval" ]
3
[ [ "add_interval", "merge_intervals" ], [ "remove_interval", "merge_intervals" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ec34c811c8cc9d3c91135b7b23696d3619dab2c4
080ba9e207a364d74d094a6f6ec2e437589052cd
v1.0
complete
Evol
Evol_5126_C
def min_square_tiles(rectangle: dict) -> tuple: """ Create a function that takes a rectangle (defined as a dictionary with the keys 'length' and 'width') and determines the minimum number of identical square tiles required to cover the entire area of the rectangle. The function should return the side le...
import math def gcd(a, b): """ Calculate the Greatest Common Divisor of a and b. """ while b: a, b = b, a % b return a def min_square_tiles(rectangle): """ Determines the side length of the square tiles and the minimum number of square tiles required to cover the entire area o...
from solution import min_square_tiles def test_min_square_tiles_case_1(): rectangle = {'length': 20, 'width': 15} assert min_square_tiles(rectangle) == (5, 12) def test_min_square_tiles_case_2(): rectangle = {'length': 10, 'width': 10} assert min_square_tiles(rectangle) == (10, 1) def test_min_square...
[ { "docstring": "Calculate the Greatest Common Divisor of a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Determines the side length of the square tiles and \nthe minimum number of square tiles required to cover the en...
[ 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": "import math\n\ndef min_square_tiles(rectangle):\n \"\"\"\n Returns the side length of the largest possible square tile and the number of such tiles required\...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a rectangle (defined as a dictionary with the keys 'length' and 'width') and determines the minimum number of identical square tiles required to cover the entire area of the rectangle without any overlap. The function should return the side length of the square ...
0.635325
Evol_5126
C
[ "gcd", "min_square_tiles" ]
2
[ [ "min_square_tiles", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4ba10d996cfc68cbed36a712370bc8a27bfd533d
53b925ccd0f0a706c61b498bf9418308a6b60846
v1.0
complete
Evol
Evol_2845_C
import pandas as pd import matplotlib.pyplot as plt def load_transactions(file_path): """ Load the transaction data into a pandas DataFrame. """ return pd.read_csv(file_path) def unique_customers(df): """ Determine the total number of unique customers. """ return df['customer_id'].nuni...
import pandas as pd import matplotlib.pyplot as plt import numpy as np def load_transactions(file_path): """ Load the transaction data into a pandas DataFrame. """ return pd.read_csv(file_path) def unique_customers(df): """ Determine the total number of unique customers. """ return df[...
import pandas as pd import numpy as np from solution import load_transactions, unique_customers, total_transaction_amount_by_category, top_5_customers_by_spending, peak_hour_per_day, remove_outliers def test_unique_customers(): data = { 'transaction_id': [1, 2, 3, 4, 5], 'timestamp': ['2023-01-01 1...
[ { "docstring": "Load the transaction data into a pandas DataFrame.", "function_declaration": "def load_transactions(file_path):", "function_name": "load_transactions", "parameter_list": "(file_path)" }, { "docstring": "Determine the total number of unique customers.", "function_declarati...
[ 0, 0, 1, 1, 0, 0, 0, 0, 0 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport matplotlib.pyplot as plt\n\ndef load_data(file_path):\n return pd.read_csv(file_path)\n\ndef get_unique_customers(data):\n return...
trial_gpt4o_2
{ "original_instruction": "Create a Python script that reads the file 'transactions.csv', which contains transaction records with the fields: `transaction_id`, `timestamp`, `customer_id`, `amount`, and `category`. Write a function to load the data into a pandas DataFrame. Then perform the following tasks:\n\n1. Write...
0.723586
Evol_2845
C
[ "load_transactions", "unique_customers", "total_transaction_amount_by_category", "top_5_customers_by_spending", "peak_hour_per_day", "visualize_data", "remove_outliers" ]
7
[ [ "visualize_data", "top_5_customers_by_spending" ], [ "visualize_data", "total_transaction_amount_by_category" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy", "pandas" ]
false
8dc64f86f6a3222af22f47d66901fc7c996ccc4d
a11a8602f738e754e691a60fee2bdfcddfb687c8
v1.0
complete
Evol
Evol_4998_C
from typing import List, Dict def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ def classify_numbers(nums: List[int]) -> Dict[str, List[int]]: """ Classifies a list of numbers into 'prime', 'even', and 'odd' categories. ...
from math import isqrt def is_prime(n): """ Check if a number is prime """ if n <= 1: return False for i in range(2, isqrt(n) + 1): if n % i == 0: return False return True def classify_numbers(nums): """ Classifies a list of numbers into 'prime', 'even', and...
from solution import classify_numbers, 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(1) assert not is_prime(0) assert not is_prime(-7) assert is_prime(17) def test_classify_numbers(): result = class...
[ { "docstring": "Check if a number is prime", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Classifies a list of numbers into 'prime', 'even', and 'odd' categories.\n\nReturns:\n dict: A dictionary with keys 'prime', 'ev...
[ 0, 0, 1, 1, 1, 1, 1, 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": "def classify_numbers(nums):\n def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0...
trial_gpt4o_6
{ "original_instruction": "Create a function that classifies a list of numbers into three different categories and returns a dictionary with these categories as keys.\n\nHere's the list of numbers:\n\nnums = [17, 23, 42, 56, 67, 89, 90, 100, 123]\n\nThe requirements are:\n\n1. The dictionary should have the following...
0.623846
Evol_4998
C
[ "is_prime", "classify_numbers" ]
2
[ [ "classify_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
05e378dad0f37380f98feacf029f058931da43f2
36598953f73e54082ab12bc42f8166e3ee28b0a3
v1.0
complete
Evol
Evol_4378_C
def is_prime(n: int) -> bool: """ Checks if a number is prime. >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(4) False """ def sort_primes_to_front(lst: List[int]) -> List[int]: """ Returns a new list with prime numbers moved to the front, retaining the relative order of non-prime ...
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 for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def sort_primes_to_front(lst): ...
from solution import is_prime, sort_primes_to_front 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) def test_sort_primes_to_front_basic(): assert sort_primes_to_front([4, 3, 5, 7, 6, 2, 8]) =...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list with prime numbers moved to the front, retaining the relative\norder of non-prime numbers.", "function_dec...
[ 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_1
{ "original_instruction": "Given a list of integers, write a function that returns a new list of the same integers sorted in ascending order, but with all prime numbers moved to the front of the list. Non-prime numbers should retain their relative order from the original list. For example, given the input [4, 3, 5, 7...
0.732276
Evol_4378
C
[ "is_prime", "sort_primes_to_front" ]
2
[ [ "sort_primes_to_front", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5967b63608e27e8ff27d43bf40738d2aa2cea8db
1513149104bc85485014f41ed9c43cba3f212c1b
v1.0
complete
Evol
Evol_5284_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(10) False """ def filter_primes(arr: List[int]) -> List[int]: """ Takes an array of integ...
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 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": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes an array of integers and returns a new array containing only the prime numbers from the original a...
[ 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 isPrime(n):\n \"\"\"\n Checks if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ...
trial_gpt4o_9
{ "original_instruction": "Design a function that takes an array of integers as input and returns a new array containing only the prime numbers from the original array. Write a function `isPrime(n)` that checks if a number is prime, and use it within your main function. Ensure your function handles edge cases such as...
0.757075
Evol_5284
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
88565c169a48c5f718af51e095b65098e87fb28a
c4bece7c89eace95a00c731b258f3696bfb24160
v1.0
complete
Evol
Evol_5192_C
def is_prime(n: int) -> bool: """ Helper function to determine if a number is prime. """ pass def filter_primes(arr: List[int]) -> List[int]: """ Takes an array of integers as input and returns a new array containing only the prime numbers. >>> filter_primes([]) == [] >>> filter_primes...
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import filter_primes def test_filter_primes_empty_array(): assert filter_primes([]) == [] def test_filter_primes_no_primes(): assert filter_primes([1, 4, 6, 8, 10, 12]) == [] def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13]) == [2, 3, 5, 7, 11, 13] def test_fi...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes an array of integers as input and returns a new array containing only the prime numbers.", "funct...
[ 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 a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_8
{ "original_instruction": "In JavaScript, write a function that takes an array of integers as input and returns a new array containing only the prime numbers from the original array. Ensure that the solution efficiently identifies prime numbers from the input array using suitable algorithms and in reasonable time com...
0.812672
Evol_5192
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
37c6570732718bab29a65d553c79937131ee9373
ac4ca287672f205a17128a052366beda3ba71ae1
v1.0
complete
Evol
Evol_5396_C
def is_prime(n: int) -> bool: """ Determines if an integer n is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(-3) False >>> is_prime(17) True """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers...
def is_prime(n): """ Determines if an integer n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return Tru...
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(29) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(-5) == False assert is_prime(17) == Tru...
[ { "docstring": "Determines if an integer n 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.", "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 Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ret...
trial_gpt4o_9
{ "original_instruction": "Implement 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. In your response, demonstrate the use of fundamental principles and describe the steps taken to determine the primality of each number.", "pro...
0.770214
Evol_5396
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a4010fe92df197d40aad3f3bda308986ab482d67
48700c911c723f39f8497f4b3640945bba2b53aa
v1.0
complete
Evol
Evol_4635_C
from typing import List, Tuple, Union def validate_and_round_input(n: Union[int, float]) -> int: """ Validate and round the input to the nearest integer. Raises ValueError for invalid types or negative numbers. >>> validate_and_round_input(3.7) 4 >>> validate_and_round_input(0) 0 """ def t...
import math from concurrent.futures import ThreadPoolExecutor def validate_and_round_input(n): # Validate and round the input to nearest integer if not isinstance(n, (int, float)): raise ValueError("Input must be an integer or a float") if n < 0: raise ValueError("Input must be a non-negati...
from solution import ( validate_and_round_input, triangular_number_iterative, triangular_number_recursive, generate_series_and_aggregate, process_input_array, parallel_processing, flawed_triangular_number ) import pytest def test_validate_and_round_input(): assert validate_and_round_in...
[ { "docstring": null, "function_declaration": "def validate_and_round_input(n):", "function_name": "validate_and_round_input", "parameter_list": "(n)" }, { "docstring": "Generate the nth triangular number iteratively.", "function_declaration": "def triangular_number_iterative(n):", "f...
[ 0, 0, 0, 0, 0, 1, 1, 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 math\nfrom concurrent.futures import ThreadPoolExecutor\n\ndef nth_triangular(n):\n \"\"\"\n Computes the nth triangular number using the formula T(n)...
trial_gpt4o_6
{ "original_instruction": "Design an efficient algorithm to solve the task of generating the nth term in the series of triangular numbers. The triangular number for a given n is defined by the formula T(n) = n*(n+1)/2. The solution should integrate both iterative and recursive approaches and should highlight the trad...
0.6174
Evol_4635
C
[ "validate_and_round_input", "triangular_number_iterative", "triangular_number_recursive", "generate_series_and_aggregate", "process_input_array", "parallel_processing", "flawed_triangular_number" ]
7
[ [ "generate_series_and_aggregate", "triangular_number_iterative" ], [ "generate_series_and_aggregate", "validate_and_round_input" ], [ "parallel_processing", "generate_series_and_aggregate" ], [ "process_input_array", "generate_series_and_aggregate" ], [ "triangul...
6
[]
false
[]
false
pytest
true
[]
true
7e7869725436b0474d71cdd52a8d7e798f57c144
70238dd4d98689e07dfcf741070a32a91116638b
v1.0
complete
Evol
Evol_4588_C
def digital_root(n: int) -> int: """ Helper function to calculate the digital root of a number `n`. >>> digital_root(9875) == 2 >>> digital_root(29) == 2 >>> digital_root(99) == 9 >>> digital_root(-9875) == 2 >>> digital_root(-29) == 2 >>> digital_root(-99) == 9 >>> digital_root(5) =...
def digital_root(n): """ Helper function to calculate the digital root of a number `n`. """ while n >= 10 or n <= -10: n = sum(int(digit) for digit in str(abs(n))) return n if n >= 0 else -n def list_with_digital_roots(numbers): """ For a given list of integers `numbers`, returns a ...
from solution import digital_root, list_with_digital_roots def test_digital_root_single_digit(): assert digital_root(0) == 0 assert digital_root(5) == 5 assert digital_root(-5) == 5 def test_digital_root_multiple_digits(): assert digital_root(9875) == 2 assert digital_root(29) == 2 assert digi...
[ { "docstring": "Helper function to calculate the digital root of a number `n`.", "function_declaration": "def digital_root(n):", "function_name": "digital_root", "parameter_list": "(n)" }, { "docstring": "For a given list of integers `numbers`, returns a list of tuples \nwhere each tuple con...
[ 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": "def digital_root(n):\n \"\"\"\n Helper function to compute the digital root of a non-negative integer.\n \"\"\"\n while n > 9:\n n = sum(int(dig...
trial_gpt4o_9
{ "original_instruction": "Design a function that takes a list of integers and returns a list of tuples. Each tuple should contain a number from the list and its digital root. The digital root is obtained by iteratively summing the digits of a number until a single-digit number is obtained. For example, the digital r...
0.626534
Evol_4588
C
[ "digital_root", "list_with_digital_roots" ]
2
[ [ "list_with_digital_roots", "digital_root" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b30a01ce5495cb705e2ab2af51c2d109d300d7cc
4d39b908d4ecf6bc530fa96a2355d9fba92b4257
v1.0
complete
Evol
Evol_5183_C
def sieve_of_eratosthenes(n): """ Returns a list of prime numbers up to the given integer n using the Sieve of Eratosthenes algorithm. """ pass def product_of_primes(n): """ Returns the product of all prime numbers up to the given integer n. If there are no prime numbers in the range, r...
def sieve_of_eratosthenes(n): """ Returns a list of prime numbers up to the given integer n using the Sieve of Eratosthenes algorithm. """ if n <= 1: return [] primes = [True] * (n+1) p = 2 while p ** 2 <= n: if primes[p]: for i in range(p * p, n+1, p): ...
from solution import sieve_of_eratosthenes, product_of_primes def test_sieve_of_eratosthenes_basic_cases(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(2) == [2] assert sieve_of_eratosthenes(1) == [] assert sieve_of_eratosthenes(0) == [] def test_sieve_of_eratosthenes...
[ { "docstring": "Returns a list of prime numbers up to the given integer n using\nthe Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns the product of all pri...
[ 1, 1, 1, 1, 1, 0, 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 sieve_of_eratosthenes(n):\n if n <= 1:\n return []\n primes = [True] * (n + 1)\n p = 2\n while p ** 2 <= n:\n if primes[p]:\n ...
trial_gpt4o_6
{ "original_instruction": "Develop a Python function that identifies all the prime numbers up to a given integer `n` through the Sieve of Eratosthenes algorithm. Then, calculate the product of these prime numbers.\n\nAdditionally, validate the function to handle different edge cases by writing comprehensive test case...
0.61586
Evol_5183
C
[ "sieve_of_eratosthenes", "product_of_primes" ]
2
[ [ "product_of_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
15231ef26cad96f1bce383b72665e476c335fd45
8b9519335d8a9acb8d14a0266f2deb38c8c82165
v1.0
complete
Evol
Evol_5106_C
def simulate_ant_movement(n): """Simulates the movement of an ant on a 2D grid for n steps. Returns the final position of the ant as a tuple (x, y). """ pass def average_distance_from_origin(n, simulations=1000): """Simulates the ant movement `simulations` times, each with `n` steps. Returns th...
import random import math def simulate_ant_movement(n): """ Simulates the movement of an ant on a 2D grid for n steps. Returns the final position of the ant as a tuple (x, y). """ directions = ['UP', 'DOWN', 'LEFT', 'RIGHT'] x, y = 0, 0 for _ in range(n): move = random.choice(d...
from solution import simulate_ant_movement, average_distance_from_origin def test_simulate_ant_movement(): final_position = simulate_ant_movement(0) assert final_position == (0, 0), "Ant should be at the origin if no steps are taken." final_position = simulate_ant_movement(10) assert isinstance(fi...
[ { "docstring": "Simulates the movement of an ant on a 2D grid for n steps.\nReturns the final position of the ant as a tuple (x, y).", "function_declaration": "def simulate_ant_movement(n):", "function_name": "simulate_ant_movement", "parameter_list": "(n)" }, { "docstring": "Simulates the a...
[ 0, 1, 1, 0, 0, 0, 1, 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 random\nimport math\n\ndef move_ant(n):\n \"\"\"\n Simulates the movement of an ant on a 2D grid starting from (0, 0).\n \n Args:\n n (int): ...
trial_gpt4o_8
{ "original_instruction": "Write a Python program to simulate an ant moving on a 2D grid. The ant starts at position (0, 0) and moves in random directions, one of `['UP', 'DOWN', 'LEFT', 'RIGHT']`, with each step covering a distance of 1 unit. Implement a function that takes an integer `n` as input and returns the fi...
0.607201
Evol_5106
C
[ "simulate_ant_movement", "average_distance_from_origin" ]
2
[ [ "average_distance_from_origin", "simulate_ant_movement" ] ]
1
[]
false
[]
false
pytest
true
[]
true
653905a349560e7bca8f45341eac20fadcbe279d
dc56b3153377b4f600ae1815700ba4e7632d32c1
v1.0
complete
Evol
Evol_4619_C
def is_prime(n: int) -> bool: """ Determine if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(29) True >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-5) False """ def filter_primes(numbers: List[...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def filter_primes(numbers): primes = [] ...
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(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_filter_primes(): ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def filter_primes(numbers):", "function_name": "filter_primes", "parameter_list": "(numbers)" } ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
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 given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Additionally, optimize the function to handle large inputs efficiently. Then, correct the errors in the provided code so the function works as intended.\n\nSample...
0.782524
Evol_4619
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a5b42be4039165ad27f8a074113ed0426129e195
a748daffe05972f78984adefd256d8206800fa22
v1.0
complete
Evol
Evol_5566_C
def longest_palindrome(s: str) -> str: """ Returns the longest palindromic substring in the input string s. >>> longest_palindrome('babad') in ['bab', 'aba'] >>> longest_palindrome('cbbd') == 'bb' """ pass def expandFromCenter(s: str, left: int, right: int) -> int: """ Expands around the center...
def longest_palindrome(s): """ Returns the longest palindromic substring in the input string s. """ if not s: return "" start = 0 end = 0 for i in range(len(s)): l1 = expandFromCenter(s, i, i) l2 = expandFromCenter(s, i, i + 1) l = max(l1, l2) if l >...
def test_longest_palindrome(): assert longest_palindrome('babad') in ['bab', 'aba'] assert longest_palindrome('cbbd') == 'bb' assert longest_palindrome('a') == 'a' assert longest_palindrome('ac') in ['a', 'c'] assert longest_palindrome('racecar') == 'racecar' assert longest_palindrome('banana') ...
[ { "docstring": "Returns the longest palindromic substring in the input string s.", "function_declaration": "def longest_palindrome(s):", "function_name": "longest_palindrome", "parameter_list": "(s)" }, { "docstring": "Expands around the center and returns the length of the palindromic subst...
[ 1, 0, 1, 0, 1, 0, 1, 0, 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": "def longest_palindrome(s):\n \"\"\"\n Returns the longest palindromic substring in the given input string s.\n \"\"\"\n start, end = 0, 0\n\n for i ...
trial_gpt4o_6
{ "original_instruction": "You are given a function that finds the longest palindrome in a given string. There are errors in the implementation. Your task is to correct the given Python function.\n\n```python\ndef longest_palindrom(s):\n start = 0\n end = 0\n\n for i in range(len(str)):\n l1 = expandF...
0.757425
Evol_5566
C
[ "longest_palindrome", "expandFromCenter" ]
2
[ [ "longest_palindrome", "expandFromCenter" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a68a2ca25ade8f7d7ded6b6f36c60b8a23af7c22
fcbe33c45c49b33371e35d271ba66f9ee1ac63f3
v1.0
complete
Evol
Evol_5155_C
def matrix_analysis(matrix): ''' Given an m x n matrix containing integers, perform the following tasks based on the matrix elements: 1. Find and return the sum of all prime numbers in the matrix. 2. If the sum of all prime numbers is zero, return -1. 3. Count the frequency of each unique integer in...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_div = int(n ** 0.5) + 1 for i in range(3, max_div, 2): if n % i == 0: return False return True def matrix_analysis(matrix): prime_sum = 0 freq_dict...
from solution import matrix_analysis def test_prime_sum_and_frequency(): assert matrix_analysis([[2, 3, 4], [5, 6, 7], [8, 9, 10]]) == (17, {2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1}) def test_no_primes(): assert matrix_analysis([[1, 4, 6], [8, 9, 10], [12, 14, 15]]) == (-1, {1: 1, 4: 1, 6: 1, 8:...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def matrix_analysis(matrix):", "function_name": "matrix_analysis", "parameter_list": "(matrix)" } ]
[ 1, 0, 1, 1, 1, 0, 1, 1, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n max_div = int(n ** 0.5) ...
trial_gpt4o_8
{ "original_instruction": "Implement a function that analyzes the given matrix and categorizes its elements:\n\ndef matrix_analysis(matrix):\n '''\n Given an m x n matrix containing integers, perform the following tasks based on the matrix elements:\n 1. Find and return the sum of all prime numbers in the ma...
0.61931
Evol_5155
C
[ "is_prime", "matrix_analysis" ]
2
[ [ "matrix_analysis", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eb0604e586360c4af326851c9ae91d1fecf60afb
8a3cf19ae1eedd94f1df688a16711d1cc6405b1c
v1.0
complete
Evol
Evol_5282_C
def celsius_to_fahrenheit(celsius: float) -> float: """ Convert Celsius to Fahrenheit. >>> celsius_to_fahrenheit(0) 32.0 >>> celsius_to_fahrenheit(100) 212.0 >>> celsius_to_fahrenheit(-40) -40.0 >>> celsius_to_fahrenheit(37) 98.6 """ pass def process_temperatures(temperature...
def celsius_to_fahrenheit(celsius): return (celsius * 9/5) + 32 def process_temperatures(temperatures): if not temperatures: raise ValueError("No temperatures provided") fahrenheit_temps = [celsius_to_fahrenheit(temp) for temp in temperatures] highest_temp = max(fahrenheit_temps) ...
from solution import celsius_to_fahrenheit, process_temperatures def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 assert celsius_to_fahrenheit(37) == 98.6 def test_process_temperatures_single_input...
[ { "docstring": null, "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": null, "function_declaration": "def process_temperatures(temperatures):", "function_name": "process_temperature...
[ 0, 0, 1, 1, 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": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts Celsius to Fahrenheit.\n \"\"\"\n return (celsius * 9/5) + 32\n\ndef process_temperatures(celsi...
trial_gpt4o_9
{ "original_instruction": "Design a program that reads a series of temperatures (in Celsius) provided as input from the user, converts each temperature to Fahrenheit, and then determines and prints three things: the highest temperature in Fahrenheit, the lowest temperature in Fahrenheit, and the average temperature i...
0.554354
Evol_5282
C
[ "celsius_to_fahrenheit", "process_temperatures" ]
2
[ [ "process_temperatures", "celsius_to_fahrenheit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dca49336bcea2cff9d013dbae1e25ad62f362d06
6be671d240fa770cdd20a27ba192b00cecfee39c
v1.0
complete
Evol
Evol_4647_C
import random def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ pass def remove_duplicates(lst): """ Removes duplicates from lst while maintaining order. """ pass def sum_primes(lst): """ Returns the sum of all prime numbers in lst. """ ...
import random def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def remove_duplicates(lst): """ Removes duplicates fr...
from solution import is_prime, remove_duplicates, sum_primes, process_numbers 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(20) == False def test_remove_duplicates()...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Removes duplicates from lst while maintaining order.", "function_declaration": "def remove_dup...
[ 1, 1, 1, 0, 1, 1, 1, 0, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import random\n\ndef is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "Write a Python program that performs the following:\n\n1. Reads an integer `N` from the user input.\n2. Generates a list of `N` random integers between 1 and 100 inclusive.\n3. Removes any duplicates from the list while keeping the order of the remaining elements.\n4. Computes the sum of al...
0.653877
Evol_4647
C
[ "is_prime", "remove_duplicates", "sum_primes", "process_numbers" ]
4
[ [ "process_numbers", "remove_duplicates" ], [ "process_numbers", "sum_primes" ], [ "sum_primes", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
36225106e4c955da606604a957b92d034a5e17db
7464592e8abc930e87f2e8f9c505187603df000d
v1.0
complete
Evol
Evol_2418_C
import numpy as np def pearson_correlation(user_ratings, user1, user2): """ Calculate the Pearson correlation coefficient between two users' ratings. """ common_movies = [movie for movie in user_ratings[user1] if movie in user_ratings[user2]] n = len(common_movies) if n == 0: retur...
import numpy as np def pearson_correlation(user_ratings, user1, user2): """ Calculate the Pearson correlation coefficient between two users' ratings. """ common_movies = [movie for movie in user_ratings[user1] if movie in user_ratings[user2]] n = len(common_movies) if n == 0: retur...
from solution import recommend_movies def test_recommend_movies_user_not_found(): ratings = { 'User1': {'MovieA': 4.5, 'MovieB': 3.0, 'MovieC': 5.0}, 'User2': {'MovieA': 2.0, 'MovieB': 3.5, 'MovieD': 4.0}, 'User3': {'MovieC': 4.0, 'MovieD': 2.5, 'MovieE': 4.5}, 'User4': {'MovieB': 2...
[ { "docstring": "Calculate the Pearson correlation coefficient between two users' ratings.", "function_declaration": "def pearson_correlation(user_ratings, user1, user2):", "function_name": "pearson_correlation", "parameter_list": "(user_ratings, user1, user2)" }, { "docstring": "Recommend mo...
[ 1, 0, 1, 0, 0, 0, 1, 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 pearson_correlation(user_ratings, user1, user2):\n \"\"\"\n Calculate the Pearson correlation coefficient between two users' rating...
trial_gpt4o_0
{ "original_instruction": "Build a recommendation system using collaborative filtering in Python. The goal of the system is to recommend movies to users based on their movie ratings. You are given a dictionary of users and the movies they have rated, along with the ratings they have given. The structure of the dictio...
0.673689
Evol_2418
C
[ "pearson_correlation", "recommend_movies" ]
2
[ [ "recommend_movies", "pearson_correlation" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
17270a1e31c249bbab2f3aa378b9c5feb32aaa73
b156a75c7bffb3d0faf3ec9e22af9e671748f6ab
v1.0
complete
Evol
Evol_5538_C
from typing import List def is_prime(n: int) -> bool: """ Helper function that checks if a number n is prime. >>> is_prime(2) True >>> is_prime(4) False """ def filter_and_sort_primes(nums: List[int]) -> List[int]: """ Returns a new list with all the prime numbers from the original list sorted...
def is_prime(n): """ Helper function that checks if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def filter...
from solution import filter_and_sort_primes def test_filter_and_sort_primes_regular_case(): assert filter_and_sort_primes([3, 5, 7, 8, 10, 11, 4]) == [11, 7, 5, 3] def test_filter_and_sort_primes_with_no_primes(): assert filter_and_sort_primes([4, 6, 8, 10, 12]) == [] def test_filter_and_sort_primes_with_all...
[ { "docstring": "Helper function that checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list with all the prime numbers from the original list sorted in descending order.", "fu...
[ 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 for i in range(2, int(n ** ...
trial_gpt4o_3
{ "original_instruction": "Develop a Python function that takes a list of integers as input and returns a new list with all the prime numbers from the original list sorted in descending order. Ensure that your function handles edge cases, such as an empty list or a list with no prime numbers, appropriately.", "prom...
0.713629
Evol_5538
C
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
828a997c464c17b35c7a41f879f26a5f37637688
c0ba1f7bb214fc156b6147f23ea52ba2b72f9632
v1.0
complete
Evol
Evol_5612_C
def reverse_palindromes(lst: List[str]) -> List[str]: """ Reverse the elements of the list if they are palindromes. Keep them unchanged if they are not palindromes. A palindrome is a word, phrase, or sequence of characters that reads the same backward as forward. Args: lst (List[str]): List of str...
def is_palindrome(s): s = s.lower() left, right = 0, len(s) - 1 while left < right: if s[left] != s[right]: return False left += 1 right -= 1 return True def reverse_string(s): reversed_s = '' for char in s: reversed_s = char + reversed_s return r...
from solution import reverse_palindromes def test_reverse_palindromes_all_palindromes(): assert reverse_palindromes(['level', 'radar', 'deified']) == ['level', 'radar', 'deified'] def test_reverse_palindromes_mixed(): assert reverse_palindromes(['hello', 'Level', 'world', 'civic']) == ['hello', 'leveL', 'worl...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def reverse_string(s):", "function_name": "reverse_string", "parameter_list": "(s)" }, { "docst...
[ 0, 1, 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": "def is_palindrome(s):\n \"\"\"\n Helper function to check if the given string is a palindrome.\n \"\"\"\n s = s.lower()\n n = len(s)\n for i in r...
trial_gpt4o_7
{ "original_instruction": "A palindrome is a word, phrase, or sequence of characters that reads the same backward as forward. Develop a Python function that takes a list of strings as input and returns a list with the same elements but reversed, only if they are palindromes. If the original string is not a palindrome...
0.810568
Evol_5612
C
[ "is_palindrome", "reverse_string", "reverse_palindromes" ]
3
[ [ "reverse_palindromes", "is_palindrome" ], [ "reverse_palindromes", "reverse_string" ] ]
2
[]
false
[]
false
pytest
true
[]
true
02fee0c9767ff008842466e7b2daacfa6e403d03
903f9c9c2e8c2de48ecb5f308c0417fba684660d
v1.0
complete
Evol
Evol_4993_C
from typing import List def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def remove_primes(lst: List[int]) -> List[int]: """ Design a Python function that receives an unsorted list of integers and returns a new list, preserv...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def remove_primes(lst): """ Returns a ...
from solution import remove_primes def test_remove_primes_with_primes(): assert remove_primes([6, 17, 4, 7, 12, 19, 24]) == [6, 4, 12, 24] def test_remove_primes_no_primes(): assert remove_primes([6, 4, 12, 24]) == [6, 4, 12, 24] def test_remove_primes_all_primes(): assert remove_primes([2, 3, 5, 7, 11])...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list with all primes removed from the input list, preserving the original order.", "function_declaration": "def remove_primes(lst):", "fu...
[ 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_8
{ "original_instruction": "Design a Python function that receives an unsorted list of integers and returns a new list, preserving the original order, but with all prime numbers removed. Ensure the function performs efficiently even with large input lists. \n\nFor example, given the input list [6, 17, 4, 7, 12, 19, 24...
0.696821
Evol_4993
C
[ "is_prime", "remove_primes" ]
2
[ [ "remove_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d73e8023a77d0a2647924a105775ef9ff014700c
cf3c76be5e156995a934c9bda9d7bd37f71bf020
v1.0
complete
Evol
Evol_4118_C
from typing import List, Tuple # Define constants EMPTY = 0 PREY = 1 PREDATOR = 2 class Animal: def __init__(self, breed_steps): self.steps_since_last_breed = 0 self.breed_steps = breed_steps class Prey(Animal): def __init__(self, breed_steps): super().__init__(breed_steps) d...
import random # Define constants EMPTY = 0 PREY = 1 PREDATOR = 2 # Directions for movement DIRECTIONS = [(0, 1), (1, 0), (0, -1), (-1, 0)] class Animal: def __init__(self, breed_steps): self.steps_since_last_breed = 0 self.breed_steps = breed_steps class Prey(Animal): def __init__(self, bree...
from solution import EMPTY, PREY, PREDATOR, Prey, Predator, create_grid, place_animals, run_simulation def test_create_grid(): grid = create_grid(5, 5) assert grid == [[EMPTY for _ in range(5)] for _ in range(5)] def test_place_animals(): grid = create_grid(5, 5) initial_prey = [((1, 1), Prey(breed_st...
[]
[ 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": "import random\n\nclass Animal:\n def __init__(self, reproduction_rate):\n self.reproduction_rate = reproduction_rate\n self.steps_since_reproducti...
trial_gpt4o_5
{ "original_instruction": "Create a program that simulates a simplified ecosystem of predator and prey animals. The simulation should take place on a 2D grid where each cell can either be empty, contain a prey animal, or contain a predator animal. The program should allow the user to define the initial population and...
0.569234
Evol_4118
C
[ "create_grid", "place_animals", "print_grid", "run_simulation" ]
4
[ [ "run_simulation", "create_grid" ], [ "run_simulation", "place_animals" ], [ "run_simulation", "print_grid" ] ]
3
[]
false
[ "Animal", "Prey", "Predator" ]
true
pytest
true
[]
true
661f63a98774278c5d660a548ae0412acfe3e5be
f2f5fc875a4a9f3ae358621514935d77dc17ca48
v1.0
complete
Evol
Evol_5657_C
from typing import List def is_prime(n: int) -> bool: """ Checks if a number n is a prime number. """ pass def primes_from_list(numbers: List[int]) -> List[int]: """ Takes an unsorted list of integers and returns a new list containing only the prime numbers from the original list, sorted in ascending...
def is_prime(n): """ Checks if a number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import primes_from_list def test_single_digit_numbers(): assert primes_from_list([1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 3, 5, 7] def test_mixed_numbers(): assert primes_from_list([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [11, 13, 17, 19] def test_all_non_prime(): assert primes_from_list...
[ { "docstring": "Checks if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes an unsorted list of integers and returns a new list containing only \nthe prime numbers from the original 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 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": "Write a function that takes an unsorted list of integers and returns a new list containing only the prime numbers from the original list, sorted in ascending order. Ensure that the solution has an optimal time complexity for verification of primality and sorting the numbers.", "prompt_id"...
0.800197
Evol_5657
C
[ "is_prime", "primes_from_list" ]
2
[ [ "primes_from_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4635fe74aabda571bbc5217b8ba207a308adf63a
7209847dc20e6bfa440b5fa2f557c8c641ac4db0
v1.0
complete
Evol
Evol_5704_C
def is_happy_number(n: int) -> bool: """ Helper function to determine if a number 'n' is a happy number. >>> is_happy_number(1) True >>> is_happy_number(19) True >>> is_happy_number(2) False """ def happy_numbers_in_range(start: int, end: int) -> List[int]: """ Returns a...
def is_happy_number(n): """ Helper function to determine if a number n is a happy number. """ seen = set() while n != 1 and n not in seen: seen.add(n) n = sum(int(x) ** 2 for x in str(n)) return n == 1 def happy_numbers_in_range(start, end): """ Returns a list of happy n...
from solution import happy_numbers_in_range, is_happy_number def test_is_happy_number(): assert is_happy_number(1) == True assert is_happy_number(19) == True assert is_happy_number(2) == False def test_happy_numbers_in_range_single_number(): assert happy_numbers_in_range(19, 19) == [19] def test_happ...
[ { "docstring": "Helper function to determine if a number n is a happy number.", "function_declaration": "def is_happy_number(n):", "function_name": "is_happy_number", "parameter_list": "(n)" }, { "docstring": "Returns a list of happy numbers in the given range [start, end] inclusive.", "...
[ 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": "def is_happy_number(n):\n \"\"\"\n Helper function to determine if a number is a happy number.\n \"\"\"\n seen = set()\n while n != 1 and n not in s...
trial_gpt4o_7
{ "original_instruction": "Write a Python function that identifies and retrieves the \"Happy Number\" from a given range. A happy number is defined as a number which eventually reaches 1 when replaced by the sum of the square of each digit. If it loops endlessly in a cycle that does not include 1, then it is not a ha...
0.632606
Evol_5704
C
[ "is_happy_number", "happy_numbers_in_range" ]
2
[ [ "happy_numbers_in_range", "is_happy_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
557134ff08ec205be28aae3ac8963eb4596b9e50
78495136cfa4f2dac082bd4145aa1eb9c65d9885
v1.0
complete
Evol
Evol_4829_C
import random def F(x): """ Example fitness function F(x) = -(x-3)**2 + 9 """ return -(x - 3)**2 + 9 def initialize_population(pop_size, x_min, x_max): """ Initialize a population of random x values within the specified range. """ return [random.uniform(x_min, x_max) for _ in range(pop...
import random def F(x): """ Example fitness function F(x) = -(x-3)**2 + 9 """ return -(x - 3)**2 + 9 def initialize_population(pop_size, x_min, x_max): """ Initialize a population of random x values within the specified range. """ return [random.uniform(x_min, x_max) for _ in range(pop...
import pytest from solution import F, initialize_population, compute_fitness, roulette_wheel_selection, crossover, mutate, genetic_algorithm def test_F(): assert F(3) == 9 assert F(0) == 0 assert F(6) == 0 def test_initialize_population(): population = initialize_population(10, 0, 10) assert l...
[ { "docstring": "Example fitness function F(x) = -(x-3)**2 + 9", "function_declaration": "def F(x):", "function_name": "F", "parameter_list": "(x)" }, { "docstring": "Initialize a population of random x values within the specified range.", "function_declaration": "def initialize_populatio...
[ 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": "import random\n\ndef genetic_algorithm(F, x_range, pop_size=50, generations=100, crossover_prob=0.7, mutation_prob=0.01):\n \"\"\"\n Simulates a genetic algo...
trial_gpt4o_3
{ "original_instruction": "Create a Python function that simulates a simplified version of a genetic algorithm to solve a basic optimization problem. The problem involves finding the maximum value of a given mathematical function, F(x), within a predefined range of x values. The function should include the following ...
0.472516
Evol_4829
C
[ "F", "initialize_population", "compute_fitness", "roulette_wheel_selection", "crossover", "mutate", "genetic_algorithm" ]
7
[ [ "compute_fitness", "F" ], [ "genetic_algorithm", "compute_fitness" ], [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "initialize_population" ], [ "genetic_algorithm", "mutate" ], [ "genetic_algorithm", "roulette_wheel_selection" ]...
6
[]
false
[]
false
pytest
true
[]
true
b04748db7cf41a362a209bcb4e503c3c7cd939e1
c4297f5a2817ff8f34106d917240d2c9bfd958f0
v1.0
complete
Evol
Evol_4913_C
from typing import List def is_prime(n: int) -> bool: """ Determine if a given number n is a prime number. """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Returns a list containing only the prime numbers from the input list. >>> filter_primes([2, 3, 4, 5, 6, 7, 8, 9, ...
from typing import List def is_prime(n: int) -> bool: """ Determine 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 ...
from solution import filter_primes def test_filter_primes_with_primes_and_non_primes(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_all_non_primes(): assert filter...
[ { "docstring": "Determine 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.", "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": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n ...
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 `is_prime(n)` to determine if a given number is prime. The function signature should be `filter_primes(numbers: List[in...
0.780342
Evol_4913
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d29e0f17dcb022410d9a9fa56afb3d7edf5076b0
79d998745afc5b869f295002613c6ebd77c3f130
v1.0
complete
Evol
Evol_4885_C
def largest_connected_component(social_graph): """ Returns the largest connected component in the social graph. >>> largest_connected_component({1: []}) == [1] >>> largest_connected_component({1: [2], 2: [1]}) == [1, 2] >>> largest_connected_component({1: [], 2: [], 3: []}) == [1] >>> large...
def bfs(graph, start_node): """ Breadth-First Search to explore all nodes in the connected component from the start_node. """ visited = set() queue = [start_node] while queue: node = queue.pop(0) if node not in visited: visited.add(node) queue.extend(...
from solution import largest_connected_component def test_single_node(): graph = { 1: [] } assert largest_connected_component(graph) == [1] def test_two_connected_nodes(): graph = { 1: [2], 2: [1] } assert sorted(largest_connected_component(graph)) == [1, 2] def test_d...
[ { "docstring": "Breadth-First Search to explore all nodes in the connected component from the start_node.", "function_declaration": "def bfs(graph, start_node):", "function_name": "bfs", "parameter_list": "(graph, start_node)" }, { "docstring": "Returns the largest connected component in the...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def dfs(node, graph, visited):\n \"\"\"\n Perform depth-first search to visit all nodes in the connected component.\n \"\"\"\n stack = [node]\n conn...
trial_gpt4o_8
{ "original_instruction": "In a social network graph, users are represented as nodes and their friendships as undirected edges. Write a Python function to determine the largest connected component in such a graph. A connected component is a subset of nodes where there is a path between any pair of nodes within this s...
0.500522
Evol_4885
C
[ "bfs", "largest_connected_component" ]
2
[ [ "largest_connected_component", "bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a7cbbd7a456d5bf9ca70c280d5085aa793c1b89f
11dff8e4d085c3168dd9ef5039f12396575daeba
v1.0
complete
Evol
Evol_5738_C
def input_and_validate_matrices(matrix1, matrix2): """ Validates and multiplies two input matrices. >>> matrix1 = [[1, 2], [3, 4]] >>> matrix2 = [[2, 0], [1, 2]] >>> input_and_validate_matrices(matrix1, matrix2) [[4, 4], [10, 8]] >>> matrix1 = [[1, 2, 3], [4, 5, 6]] >>> matri...
def matrix_multiply(matrix1, matrix2): """ Multiplies two matrices if they can be multiplied. Returns the resulting matrix or raises a ValueError if they cannot be multiplied. """ # Check if matrix1 and matrix2 can be multiplied if len(matrix1[0]) != len(matrix2): raise ValueError("The m...
import pytest from solution import input_and_validate_matrices def test_matrix_multiplication_valid(): matrix1 = [[1, 2], [3, 4]] matrix2 = [[2, 0], [1, 2]] result = input_and_validate_matrices(matrix1, matrix2) assert result == [[4, 4], [10, 8]] def...
[ { "docstring": "Multiplies two matrices if they can be multiplied.\nReturns the resulting matrix or raises a ValueError if they cannot be multiplied.", "function_declaration": "def matrix_multiply(matrix1, matrix2):", "function_name": "matrix_multiply", "parameter_list": "(matrix1, matrix2)" }, ...
[ 1, 0, 0, 1, 0, 1, 0, 0, 1, 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 matrix_multiply(A, B):\n \"\"\"\n Multiplies two matrices A and B if they can be multiplied.\n \n Args:\n A (list of lists of int/float): The fi...
trial_gpt4o_9
{ "original_instruction": "Design a program that performs matrix multiplication for two matrices input by the user. The program should check if the matrices can be multiplied based on their dimensions and handle cases where they cannot be multiplied by displaying an appropriate error message. Additionally, the progra...
0.542038
Evol_5738
C
[ "matrix_multiply", "validate_matrix", "input_and_validate_matrices" ]
3
[ [ "input_and_validate_matrices", "matrix_multiply" ], [ "input_and_validate_matrices", "validate_matrix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0e015a1832a8d30e72d9ddb2919ee8e5fd884abc
c59734357881c3b8cb8a1a54169a82dd2bde8976
v1.0
complete
Evol
Evol_4665_C
def is_prime(n: int) -> bool: """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(9) False >>> is_prime(11) True >>> is_prime(17) True >>> is_prime(-7) False >>> is_prime(0) False >>> is_pri...
def is_prime(n): """ Checks 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 Tru...
from solution import is_prime, filter_primes def test_is_prime(): # Test small primes assert is_prime(2) == True assert is_prime(3) == True # Test non-primes assert is_prime(4) == False assert is_prime(9) == False # Test larger primes assert is_prime(11) == True assert is_prime(17) ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list.", "function_declaration": "def filter_primes(numbers):", "function_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(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": "Develop a Python function that accepts a list of integers and returns a new list containing only the prime numbers from the original list. Ensure that the function is optimized for handling large lists efficiently.", "prompt_id": "00004665", "row_id": 4665, "seed_ids": "[240]" }
0.763117
Evol_4665
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1cdeb1ea66c5e134c17af33f52dcac44a0354097
e2f87ee889ff21eee7b2d05a045e1daa2e314f81
v1.0
complete
Evol
Evol_5827_C
def is_prime(n): """ Returns True if n is a prime number, else False. """ return False def get_primes(numbers): """ Returns a list of prime numbers from the input list. """ return [] # Unit tests def test_get_primes_empty_list(): assert get_primes([]) == [] def test_get_primes...
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def get_primes(...
from solution import get_primes def test_get_primes_empty_list(): assert get_primes([]) == [] def test_get_primes_no_primes(): assert get_primes([1, 4, 6, 8, 10]) == [] def test_get_primes_all_primes(): assert get_primes([2, 3, 5, 7]) == [2, 3, 5, 7] def test_get_primes_mixed(): assert get_primes([2...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list.", "function_declaration": "def get_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, else False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n ...
trial_gpt4o_6
{ "original_instruction": "Rewrite the following Python function to improve its performance and readability. The function takes a list of integers and returns a new list containing only the prime numbers from the original list.\n\"\"\"\ndef get_primes(numbers):\n primes = []\n for number in numbers:\n is...
0.753316
Evol_5827
C
[ "is_prime", "get_primes" ]
2
[ [ "get_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3ba858874056565ec80203b024ef02bfed6e75ce
539aeaaa3b083fd2b919fb4cafc943277bd5432d
v1.0
complete
Evol
Evol_5767_C
import pandas as pd import numpy as np from sklearn.ensemble import RandomForestRegressor def load_data(): """ Load the dataset from the given URL. >>> data = load_data() >>> isinstance(data, pd.DataFrame) True >>> not data.empty True >>> 'median_house_value' in data.columns True ""...
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler, OneHotEncoder from sklearn.compose import ColumnTransformer from sklearn.impute import SimpleImputer from sklearn.pipeline import Pipeline from sklearn.ensemble import RandomForestRegressor from sk...
import pandas as pd import numpy as np from sklearn.ensemble import RandomForestRegressor from solution import load_data, preprocess_data, train_model def test_load_data(): data = load_data() assert isinstance(data, pd.DataFrame) assert not data.empty assert 'median_house_value' in data.columns def te...
[ { "docstring": null, "function_declaration": "def load_data():", "function_name": "load_data", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def preprocess_data(data):", "function_name": "preprocess_data", "parameter_list": "(data)" }, { "docstri...
[ 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": "import pandas as pd\nimport numpy as np\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler, OneHotEncoder\nfro...
trial_gpt4o_3
{ "original_instruction": "Given a dataset of house prices from https://raw.githubusercontent.com/ageron/handson-ml/master/datasets/housing/housing.csv, construct a machine learning model to predict house prices based on the features provided in the dataset. Additionally, discuss and provide the code for at least thr...
0.671102
Evol_5767
C
[ "load_data", "preprocess_data", "train_model" ]
3
[ [ "train_model", "load_data" ], [ "train_model", "preprocess_data" ] ]
2
[]
false
[]
false
pytest
true
[ "numpy", "pandas", "sklearn" ]
false
df2736546f809155e4a5e67107a7b8d97320f7d1
d6aec763f09f26c1a453b37eec5c1551014f2e5e
v1.0
complete
Evol
Evol_5454_C
import re def is_valid_email(email: str) -> bool: """ Validates if the given email follows the correct email format. """ # Define the regular expression for a valid email. local_part = r"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*" domain_part = r"([a-zA-Z0-9](?:[-a-zA-Z...
import re def is_valid_email(email): """ Validates if the given email follows the correct email format. """ # Define the regular expression for a valid email. local_part = r"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*" domain_part = r"([a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0...
from solution import is_valid_email, filter_emails import os def test_is_valid_email(): # Valid emails assert is_valid_email("test@example.com") assert is_valid_email("first.last@iana.org") assert is_valid_email("test.email+alex@leetcode.com") # Invalid emails assert not is_valid_email("pl...
[ { "docstring": "Validates if the given email follows the correct email format.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Reads emails from the input file, filters out the invalid ones, and writes ...
[ 0, 0, 0, 0, 0, 0, 1, 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 re\n\ndef is_valid_email(email):\n \"\"\"\n Check if the given email is valid based on the specified pattern.\n \"\"\"\n email_regex = re.compil...
trial_gpt4o_8
{ "original_instruction": "Write a Python program that reads a list of email addresses from a text file and filters out the invalid email addresses. The valid email addresses should then be saved to a new text file. An email is considered valid if it follows this pattern: it must consist of a local part and a domain ...
0.716338
Evol_5454
C
[ "is_valid_email", "filter_emails" ]
2
[ [ "filter_emails", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9bf76abb93acbfad8231c33a694aa3430e1a12f3
7ffde37937c623980511f56df3b91ed6d9c3c3c5
v1.0
complete
Evol
Evol_5044_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-3) False """ def sum_primes(numbers: List[int]...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True for i in range(2, n): if n % i == 0: return False return True def sum_primes(numbers): """ Returns the sum of all prime numbers in the list. ""...
from solution import sum_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(1) == False assert is_prime(0) == False assert is_prime(-3) == False ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the list.", "function_declaration": "def sum_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 Returns True if n is a prime number, otherwise False.\n \n A prime number is a natural number greater than 1 that has no po...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of integers and returns the sum of all integers that are prime numbers. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself. Avoid using built-in mathematical functions to check for prime number...
0.815672
Evol_5044
C
[ "is_prime", "sum_primes" ]
2
[ [ "sum_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2bb11ee7771cc7c7165a8786eef09bba4a081548
8ebf3ce68352deb185469e57a90e9801bd690700
v1.0
complete
Evol
Evol_6038_C
import math from typing import List def is_prime(n: int) -> bool: """ 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(math.sqrt(n)) + 1, 2): if n % i == 0: return Fal...
import math 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(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True def filter_primes...
from solution import filter_primes def test_filter_primes_with_mixed_numbers(): assert filter_primes([10, 17, 23, 33, 42, -5, 3]) == [17, 23, 3] def test_filter_primes_with_primes_only(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_with_no_primes(): assert filter_pri...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return a list containing only the prime numbers from the original 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": "import math\n\ndef is_prime(num):\n if num <= 1:\n return False\n\n for i in range(2, int(math.sqrt(num)) + 1):\n if num % i == 0:\n ...
trial_gpt4o_7
{ "original_instruction": "Write a function that takes a list of integers and returns a list containing only the prime numbers from the original list. The function should be optimized having a time complexity of O(n * sqrt(m)), where n is the number of integers in the list and m is the largest integer in the list. Al...
0.753092
Evol_6038
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
88d3531fe1047670bf7a12c2660a6f03b160e81e
133e7ee573d60b2463d86fd9ff09934693da2800
v1.0
complete
Evol
Evol_6134_C
import re def clean_string(s: str) -> str: """ Removes all non-alphanumeric characters from the string and converts it to lowercase. >>> clean_string("Was it a car or a cat I saw?") 'wasitacaroracatisaw' >>> clean_string("Hello, World!") 'helloworld' >>> clean_string("") '' >>> clean_string("!...
import re def clean_string(s): """ Removes all non-alphanumeric characters from the string and converts it to lowercase. """ return re.sub(r'[^a-zA-Z0-9]', '', s).lower() def is_palindrome(s): """ Checks whether a given string is a palindrome ignoring spaces, punctuation, and capitalization. ...
from solution import clean_string, is_palindrome def test_clean_string(): assert clean_string("Was it a car or a cat I saw?") == "wasitacaroracatisaw" assert clean_string("Hello, World!") == "helloworld" assert clean_string("") == "" assert clean_string("!!!!") == "" def test_is_palindrome(): asse...
[ { "docstring": "Removes all non-alphanumeric characters from the string and converts it to lowercase.", "function_declaration": "def clean_string(s):", "function_name": "clean_string", "parameter_list": "(s)" }, { "docstring": "Checks whether a given string is a palindrome ignoring spaces, p...
[ 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 remove_non_alphanumeric(s):\n \"\"\"\n Removes all non-alphanumeric characters from the string.\n \"\"\"\n return ''.join(char for char in s if cha...
trial_gpt4o_9
{ "original_instruction": "Implement a Python function that checks whether a given string is a palindrome, ignoring spaces, punctuation, and capitalization. Additionally, write a short helper function that removes all non-alphanumeric characters from the string. Ensure your solution handles potential edge cases such ...
0.829257
Evol_6134
C
[ "clean_string", "is_palindrome" ]
2
[ [ "is_palindrome", "clean_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4ba113dbc57fcf1626aed786a1be762eceac4c2b
6772131f3c54f8d130ad4b6960e65d4401915473
v1.0
complete
Evol
Evol_5045_C
from typing import List def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(1) == False >>> is_prime(4) == False >>> is_prime(7) == True >>> is_prime(10) == False >>> is_prime(13) == True >>> is_prime(17) == True >>> is_prime(22) == False >>> is_prime...
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(arr): ...
from solution import is_prime, filter_primes def test_is_prime(): assert not is_prime(1) assert not is_prime(4) assert is_prime(7) assert not is_prime(10) assert is_prime(13) assert is_prime(17) assert not is_prime(22) assert is_prime(2) assert is_prime(3) assert not is_prime(9)...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns an array containing only the prime numbers from the original array.", "function_declaration": "def filter_pri...
[ 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 \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even prim...
trial_gpt4o_9
{ "original_instruction": "Write a function that takes an array of integers and returns a new array containing only the prime numbers from the original array, in the same order. Prime numbers are integers greater than 1 that are only divisible by 1 and themselves. For instance, if the input array is `[4, 7, 10, 13, 1...
0.766472
Evol_5045
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
014649a0c3603ecf77b21ee7d7769495cb956001
810eb4e0487b08e66461306ab324fdc71067a3a3
v1.0
complete
Evol
Evol_5407_C
def is_valid_year(year): # Implement year validation pass def is_valid_date(date_str): # Implement date validation pass def add_book(library, book): """ Adds a new book to the library after validating its fields. Raises ValueError with relevant message if validation fails. Args: libra...
import datetime def is_valid_year(year): current_year = datetime.datetime.now().year return isinstance(year, int) and 1500 <= year <= current_year def is_valid_date(date_str): try: datetime.datetime.strptime(date_str, '%Y-%m-%d') return True except ValueError: return False def...
import pytest from solution import add_book, reserve_book, cancel_reservation, check_availability def test_add_book_success(): library = [] book = { 'title': 'The Great Gatsby', 'author': 'F. Scott Fitzgerald', 'publicationYear': 1925, 'genres': ['Classic', 'Fiction'], '...
[ { "docstring": null, "function_declaration": "def is_valid_year(year):", "function_name": "is_valid_year", "parameter_list": "(year)" }, { "docstring": null, "function_declaration": "def is_valid_date(date_str):", "function_name": "is_valid_date", "parameter_list": "(date_str)" ...
[ 1, 1, 0, 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 datetime\n\ndef add_book(library, book):\n current_year = datetime.datetime.now().year\n \n # Validate the book fields\n if not isinstance(book[...
trial_gpt4o_6
{ "original_instruction": "Write a function to manage a library where each book is represented as an object with the following structure:\n```\nbook = {\n 'title': 'The Great Gatsby',\n 'author': 'F. Scott Fitzgerald',\n 'publicationYear': 1925,\n 'genres': ['Classic', 'Fiction'],\n 'availableCopies': ...
0.546895
Evol_5407
C
[ "is_valid_year", "is_valid_date", "add_book", "reserve_book", "cancel_reservation", "check_availability" ]
6
[ [ "add_book", "is_valid_year" ], [ "reserve_book", "is_valid_date" ] ]
2
[]
false
[]
false
pytest
true
[]
true
181fd32eaf420e30d2d983cbe7ce1876b825d8bc
a7d56029fac5471f01469320e9524f22c5646128
v1.0
complete
Evol
Evol_5565_C
def tic_tac_toe(moves): """ Simulates a game of Tic-Tac-Toe for two players and determines the result after all moves. The function accepts a series of moves as input in the format of tuples (row, column, player), where 'player' is either 'X' or 'O', and validates each move before applying it. Afte...
def check_winner(board): """ Checks the board to determine if there is a winner. Returns "X" if player X wins, "O" if player O wins, and None otherwise. """ # Check rows, columns, and diagonals for a winner win_conditions = ( [(0, 0), (0, 1), (0, 2)], # first row [(1, 0), (1, 1...
from solution import tic_tac_toe def test_tic_tac_toe_x_wins(): moves = [ (0, 0, 'X'), (1, 0, 'O'), (0, 1, 'X'), (1, 1, 'O'), (0, 2, 'X') ] assert tic_tac_toe(moves) == "X wins" def test_tic_tac_toe_o_wins(): moves = [ (0, 0, 'O'), (1, 0, 'X'), ...
[ { "docstring": "Checks the board to determine if there is a winner.\nReturns \"X\" if player X wins, \"O\" if player O wins, and None otherwise.", "function_declaration": "def check_winner(board):", "function_name": "check_winner", "parameter_list": "(board)" }, { "docstring": "Checks if the...
[ 1, 0, 1, 1, 1, 0, 0, 0, 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": "def tic_tac_toe(moves):\n \"\"\"\n Simulates a game of Tic-Tac-Toe for two players based on a series of moves.\n Returns the final state of the board and ...
trial_gpt4o_4
{ "original_instruction": "Implement a function that simulates a game of Tic-Tac-Toe for two players. The function should accept a series of moves as input and determine the result of the game. Ensure that the function handles invalid moves (e.g., out-of-bounds or already occupied cells). The function should print th...
0.570106
Evol_5565
C
[ "check_winner", "is_full", "tic_tac_toe", "print_board" ]
4
[ [ "tic_tac_toe", "check_winner" ], [ "tic_tac_toe", "is_full" ], [ "tic_tac_toe", "print_board" ] ]
3
[]
false
[]
false
pytest
true
[]
true
fad7b0215810c6a799e323510daa4930017d753c
b1e78cfe5c9d224cb982d9dbe9618c3d45e17486
v1.0
complete
Evol
Evol_6050_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. """ pass def remove_primes(numbers: List[int]) -> List[int]: """ Take a list of integers and return a new list with all the prime numbers removed. >>> remove_primes([12, 25, 17, 9, 23, 44, 31, 68]) [12, 25, 9, ...
def is_prime(n): """ Checks 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 primes for i in range(3, int(n**0.5) + 1, 2): if n % i ==...
from solution import remove_primes def test_remove_primes_with_primes(): assert remove_primes([12, 25, 17, 9, 23, 44, 31, 68]) == [12, 25, 9, 44, 68] def test_remove_primes_with_non_primes(): assert remove_primes([4, 6, 8, 10]) == [4, 6, 8, 10] def test_remove_primes_with_all_primes(): assert remove_...
[ { "docstring": "Checks if a number is a prime number.", "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 all the prime numbers removed.", "function_declaration": "def r...
[ 1, 1, 1, 1, 1, 1, 1, 0, 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 for i in range(2, int(n**0....
trial_gpt4o_9
{ "original_instruction": "Write a program that takes a list of integers and returns a new list with all the prime numbers removed. If the input list is empty or contains no prime numbers, the output should be an empty list.\n[12, 25, 17, 9, 23, 44, 31, 68]", "prompt_id": "00006050", "row_id": 6050, "seed_ids":...
0.765877
Evol_6050
C
[ "is_prime", "remove_primes" ]
2
[ [ "remove_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
04f039358fd427e81a0562b09ae7ca22b7a30bee
f62116245cf4008e93dad2d8c47e47da5c72128b
v1.0
complete
Evol
Evol_5955_C
def count_vowels(s: str) -> dict: """ Count the number of each vowel in the string s (case-insensitive). Parameters: s (str): The input string. Returns: dict: A dictionary with vowels as keys and their counts as values. >>> count_vowels("aeiou") {'a': 1, 'e': 1, 'i': 1, 'o...
def count_vowels(s): """ Count the number of each vowel in the string s (case-insensitive). Parameters: s (str): The input string. Returns: dict: A dictionary with vowels as keys and their counts as values. """ s = s.lower() vowels = 'aeiou' counts = {vowel: 0 for vowel...
from solution import count_vowels, most_frequent_vowel def test_count_vowels_all_vowels(): assert count_vowels("aeiou") == {'a': 1, 'e': 1, 'i': 1, 'o': 1, 'u': 1} def test_count_vowels_repeated_vowels(): assert count_vowels("aaaeeeiiiooouuu") == {'a': 3, 'e': 3, 'i': 3, 'o': 3, 'u': 3} def test_count_vowels...
[ { "docstring": "Count the number of each vowel in the string s (case-insensitive).\n\nParameters:\ns (str): The input string.\n\nReturns:\ndict: A dictionary with vowels as keys and their counts as values.", "function_declaration": "def count_vowels(s):", "function_name": "count_vowels", "parameter_...
[ 0, 0, 1, 1, 1, 0, 0, 0, 1, 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 count_vowels(s):\n \"\"\"\n Returns a dictionary with the count of each vowel (a, e, i, o, u) in the given string.\n \"\"\"\n vowels = 'aeiou'\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function in Python that takes a string and returns the count of each vowel (a, e, i, o, u) present in the string. The function should be case-insensitive and must return a dictionary with vowels as keys and their counts as values. Additionally, the function should have a time compl...
0.852804
Evol_5955
C
[ "count_vowels", "most_frequent_vowel" ]
2
[ [ "most_frequent_vowel", "count_vowels" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3d3d2b77c759906609796826ee2d6a69ebae29f9
a801f5f7fab09dcdcb9ff7018c33157c2ca52010
v1.0
complete
Evol
Evol_5628_C
def factorial_recursion(n, memo=None): """ Calculates the factorial of n using recursion. Optionally uses memoization if a memo dictionary is provided. """ pass def factorial_iterative(n): """ Calculates the factorial of n using an iterative approach. """ pass def factorial_dict(nu...
def factorial_recursion(n, memo=None): """ Calculates the factorial of n using recursion. Optionally uses memoization if a memo dictionary is provided. """ if n < 0: return None if n == 0 or n == 1: return 1 if memo is not None and n in memo: return memo[n] r...
from solution import factorial_dict, factorial_recursion, factorial_iterative def test_factorial_dict_with_recursion_no_memoization(): assert factorial_dict([5, 3, -1], use_recursion=True, use_memoization=False) == {5: 120, 3: 6} assert factorial_dict([], use_recursion=True, use_memoization=False) == {} as...
[ { "docstring": "Calculates the factorial of n using recursion.\nOptionally uses memoization if a memo dictionary is provided.", "function_declaration": "def factorial_recursion(n, memo=None):", "function_name": "factorial_recursion", "parameter_list": "(n, memo=None)" }, { "docstring": "Calc...
[ 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": "from typing import List, Dict\n\ndef factorial_recursive(n: int, memo: Dict[int, int] = None) -> int:\n \"\"\"\n Calculate the factorial of a number recursiv...
trial_gpt4o_7
{ "original_instruction": "Write a Python function that takes a list of integers and returns a dictionary where the keys are the integers from the list and the values are the factorial of each key. Provide two different implementations: one using recursion to calculate the factorial and another using an iterative app...
0.647915
Evol_5628
C
[ "factorial_recursion", "factorial_iterative", "factorial_dict" ]
3
[ [ "factorial_dict", "factorial_iterative" ], [ "factorial_dict", "factorial_recursion" ] ]
2
[]
false
[]
false
pytest
true
[]
true
72665726915b77fd9adbb0f7a49b766eb1ac9934
cdd500628906f536af7ce943cab729e1b98a2757
v1.0
complete
Evol
Evol_6018_C
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.naive_bayes import MultinomialNB from sklearn.svm import SVC from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score, precision_score, ...
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.naive_bayes import MultinomialNB from sklearn.svm import SVC from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score, precision_score, ...
import pytest from solution import preprocess_text, text_classification_pipeline def test_preprocess_text(): text = "Hello, World!" processed_text = preprocess_text(text) assert processed_text == "hello world" def test_text_classification_pipeline(): data = pd.DataFrame({ 'message': ['This is ...
[ { "docstring": null, "function_declaration": "def preprocess_text(text):", "function_name": "preprocess_text", "parameter_list": "(text)" }, { "docstring": null, "function_declaration": "def text_classification_pipeline(data):", "function_name": "text_classification_pipeline", "p...
[ 0, 1, 0, 1, 1, 1, 0, 1, 0, 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 pandas as pd\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.naive_bayes im...
trial_gpt4o_7
{ "original_instruction": "You are given a collection of short messages obtained from various social media platforms. Implement a text classification pipeline using Python and the scikit-learn library to classify these messages into predefined categories such as spam, advertisement, personal, and news. Your task incl...
0.687213
Evol_6018
C
[ "preprocess_text", "text_classification_pipeline", "evaluate_model" ]
3
[ [ "text_classification_pipeline", "evaluate_model" ], [ "text_classification_pipeline", "preprocess_text" ] ]
2
[]
false
[]
false
pytest
true
[ "pandas", "sklearn" ]
false
23a48ba42a001a6e5e20cc5458eecf9b960fb2cd
8a7d866b4c8516229c6b1c07bcf24f4a5636a30a
v1.0
complete
Evol
Evol_6208_C
def is_prime(n: int) -> bool: """ Helper function to determine if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(0) False >>> is_prime(-3) False """ def prime_numbers(lst: List[int]) -> List[int]: """ Accepts a list of intege...
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 max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False ...
from solution import is_prime, prime_numbers def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(0) == False assert is_prime(1) == False assert is_prime(-3) == False assert is_prime(17) == True def test_prime_numbers(): ...
[ { "docstring": "Helper function to determine if a number is prime.", "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 the prime numbers.", "function_declar...
[ 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 == 2 or n == 3:\n return True...
trial_gpt4o_8
{ "original_instruction": "Write a program in Python that accepts a list of integers as input and returns a new list containing only the prime numbers from the original list. The program should include a helper function to determine if a number is prime. Additionally, ensure that your code can handle negative numbers...
0.821122
Evol_6208
C
[ "is_prime", "prime_numbers" ]
2
[ [ "prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ee554939cfa63ea259b65c6a2022639d137241e2
8621fece8a99bb1b21101dfa73a48045e6b5c248
v1.0
complete
Evol
Evol_6219_C
def extract_primes(nums: list) -> list: """ Extracts all prime numbers from the given list of numbers. Args: nums (list): A list of integers. Returns: list: A list containing all prime numbers from the input list. Raises: ValueError: If the input list is empty. TypeErr...
def is_prime(n): 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: return False return True def extract_p...
from solution import extract_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_extract_prime...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Extracts all prime numbers from the given list of numbers.\n\nArgs:\nnums (list): A list of integers.\n\nReturns:\nlist: A list containing all prime number...
[ 1, 1, 1, 0, 1, 1, 1, 1, 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": "def is_prime(n):\n \"\"\"Helper function to determine if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ...
trial_gpt4o_7
{ "original_instruction": "Design a function that takes a list of integers and returns a new list that contains only the prime numbers from the input list. If the input list is empty, contains non-integer values, or no prime numbers are found, the function should handle these scenarios appropriately by returning spec...
0.734311
Evol_6219
C
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7037eb4352a43bcd1253a29f0f346b2f8b85765e
c8a20bb9e09ada3ca396efbd16ce0bb1a63fde9c
v1.0
complete
Evol
Evol_6151_C
import re from collections import defaultdict def is_valid_ip(ip: str) -> bool: """ Validate if the given IP address is valid. >>> is_valid_ip("192.168.0.1") True >>> is_valid_ip("255.255.255.255") True >>> is_valid_ip("256.256.256.256") False >>> is_valid_ip("192.168.0") False >>> is_valid...
import re from collections import defaultdict def is_valid_ip(ip): """ Validate if the given IP address is valid. """ pattern = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$') if pattern.match(ip): parts = ip.split('.') return all(0 <= int(part) <= 255 for part in parts) ret...
from solution import is_valid_ip, count_ip_addresses def test_is_valid_ip(): assert is_valid_ip("192.168.0.1") == True assert is_valid_ip("255.255.255.255") == True assert is_valid_ip("256.256.256.256") == False assert is_valid_ip("192.168.0") == False assert is_valid_ip("abc.def.ghi.jkl") == False...
[ { "docstring": "Validate if the given IP address is valid.", "function_declaration": "def is_valid_ip(ip):", "function_name": "is_valid_ip", "parameter_list": "(ip)" }, { "docstring": "Parses the log file to extract and count the frequency of distinct valid IP addresses.\nThe results are wri...
[ 0, 0, 1, 1, 1, 0, 1, 1, 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 re\nfrom collections import defaultdict\n\ndef is_valid_ip(ip):\n \"\"\"\n Validates an IP address.\n \"\"\"\n pattern = re.compile(r'^(\\d{1,3}...
trial_gpt4o_4
{ "original_instruction": "Design a Python function that parses a log file to extract and count the frequency of distinct IP addresses. The function should handle large files efficiently, avoid loading the entire file into memory at once, and store the results in a dictionary. Additionally, implement a feature to fil...
0.736639
Evol_6151
C
[ "is_valid_ip", "count_ip_addresses" ]
2
[ [ "count_ip_addresses", "is_valid_ip" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3d902d2e97caba28c28328b92c14e5ca8f01b992
bf205f88bb6b6e4e16b9b9b504e930a1c70a60ed
v1.0
complete
Evol
Evol_5209_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Filter the list to contain only prime numbers. >>> filter_primes([1,...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False # All other even numbers are not primes max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor,...
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(16) == False assert is_prime(17) == True assert is_prime(-1) == False assert is_prime(0) == Fals...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filter the list to contain only prime numbers.", "function_declaration": "def filter_primes(numbers):", "function_name": "...
[ 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": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if...
trial_gpt4o_9
{ "original_instruction": "Write a Python program that takes a list of integers and returns a new list containing only the prime numbers from the original list. The algorithm should efficiently check for prime numbers.", "prompt_id": "00005209", "row_id": 5209, "seed_ids": "[41154]" }
0.779688
Evol_5209
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
907313d0133c2f08e0ec4cf86fbc3b2d0e21fce0
0ad1f8cb65a261345246931afa4663534e459b66
v1.0
complete
Evol
Evol_6367_C
def shift_character(char, n): """ Shifts a character by n positions in the alphabet, wrapping around if necessary. :param char: Single lowercase character to be shifted :param n: Number of positions to shift :return: Shifted character """ pass def shift_string(input_string, shift_amoun...
def shift_character(char, n): """ Shifts a character by n positions in the alphabet, wrapping around if necessary. :param char: Single lowercase character to be shifted :param n: Number of positions to shift :return: Shifted character """ new_position = (ord(char) - ord('a') + n) % 26 ...
from solution import shift_string def test_shift_string_positive_shift(): assert shift_string('abc', 1) == 'bcd' assert shift_string('xyz', 2) == 'zab' def test_shift_string_negative_shift(): assert shift_string('bcd', -1) == 'abc' assert shift_string('zab', -2) == 'xyz' def test_shift_string_zero_sh...
[ { "docstring": "Shifts a character by n positions in the alphabet, wrapping around if necessary.\n\n:param char: Single lowercase character to be shifted\n:param n: Number of positions to shift\n:return: Shifted character", "function_declaration": "def shift_character(char, n):", "function_name": "shift...
[ 0, 1, 1, 1, 1, 0, 1, 0, 0, 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 shift_char(c, n):\n \"\"\"\n Shifts a character c by n positions in the alphabet. Supports both positive\n and negative shifts. Wraps around if the sh...
trial_gpt4o_6
{ "original_instruction": "Write a function that takes a string of lowercase alphabets and returns a new string where each character is replaced by the character occurring `n` positions after it in the alphabet. If a shift moves past 'z', it should wrap around to 'a'. For instance, shifting 'z' by 1 would result in '...
0.708261
Evol_6367
C
[ "shift_character", "shift_string" ]
2
[ [ "shift_string", "shift_character" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d5e4c0c676bf0e69269e4206c403f3e1da51756e
46f543b86be07fc81e3fed6099d6fc099e6dfcea
v1.0
complete
Evol
Evol_6146_C
def is_prime(n: int) -> bool: """ Determines if the given integer n is prime. >>> is_prime(0) False >>> 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(11) True ...
def is_prime(n): """ Determines if the given integer n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6...
from solution import is_prime, sort_primes def test_is_prime_basic_cases(): 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) def test_is_prime_large_prime(): asse...
[ { "docstring": "Determines if the given integer n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given an unsorted list of integers, returns a list of prime numbers sorted in ascending order.", "function_dec...
[ 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": "from math import isqrt\n\ndef is_prime(n):\n \"\"\"\n Returns True if the given number n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n ...
trial_gpt4o_9
{ "original_instruction": "Construct a function that receives an unsorted list of integers and returns a new list containing the integers in ascending order, but only those integers that are prime numbers. Implement this function using Python, and ensure it efficiently handles lists with a size of up to 10,000 elemen...
0.827334
Evol_6146
C
[ "is_prime", "sort_primes" ]
2
[ [ "sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2250b23a60ac0be41d011cc0f413a3b547a116cd
7191d20897e8b349ee8c39aa1920f3a5d97ab001
v1.0
complete
Evol
Evol_6302_C
from typing import List def is_prime(n: int) -> bool: """ Check if the number n is a prime number. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(29) == True >>> is_prime(1) == False >>> is_prime(0) == False >>> is_prime(-5) == False """ ...
def is_prime(n): """ Check if the 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 extract_primes(arr)...
from solution import is_prime, extract_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_extract_primes(): ...
[ { "docstring": "Check if the number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Accepts an integer array as input and returns an array containing only the prime numbers,\nwithout duplicates and in ...
[ 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 for i in range(2, int(n**0....
trial_gpt4o_7
{ "original_instruction": "Write a program that accepts an integer array as input and returns an array containing only the prime numbers from the input array. Additionally, the program should remove any duplicate prime numbers in the output array and return them in ascending order.\n\nFor example, if the input array ...
0.785517
Evol_6302
C
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
188c1dfe08cf4d3b0156378fb1f75bca221c03d9
05e7ad32c3417a88af83e2db1c7582951f00f265
v1.0
complete
Evol
Evol_6708_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, False otherwise. >>> is_prime(2) True >>> is_prime(4) False """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from the original list. >>> filter_primes([...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter...
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(-1) == False assert is_prime(0) == False assert is_prime(1) == False assert is_prime(17) == True...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.", "function_declaration...
[ 0, 0, 1, 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 \"\"\"\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": "Create a program that takes a list of integers and returns a new list containing only the prime numbers from the original list, in the same order they appeared. Ensure that your implementation efficiently checks for prime numbers and handles edge cases such as negative numbers and non-integ...
0.747981
Evol_6708
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
214a04c9eb79d249518052385e4491ffdd569ad4
cad3404ec14b026ea13eda56bb57fdfd12d87994
v1.0
complete
Evol
Evol_6065_C
import random def generate_server_data(num_servers): """ Generates random latency (ms) and bandwidth (Mbps) values for a number of servers. Parameters: num_servers (int): The number of servers to generate data for. Returns: list of dict: A list of dictionaries containing latency and bandwidth...
import random def generate_server_data(num_servers): """ Generates random latency (ms) and bandwidth (Mbps) values for a number of servers. Parameters: num_servers (int): The number of servers to generate data for. Returns: list of dict: A list of dictionaries containing latency and bandwidth...
from solution import generate_server_data, analyze_servers, simulate_network_test def test_generate_server_data(): servers = generate_server_data(5) assert len(servers) == 5 for server in servers: assert 1 <= server["latency"] <= 1500 assert 0.5 <= server["bandwidth"] <= 20.0 def test_anal...
[ { "docstring": "Generates random latency (ms) and bandwidth (Mbps) values for a number of servers.\n\nParameters:\nnum_servers (int): The number of servers to generate data for.\n\nReturns:\nlist of dict: A list of dictionaries containing latency and bandwidth values.", "function_declaration": "def generate...
[ 1, 0, 1, 1, 1, 0, 1, 1, 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": "import random\n\ndef generate_server_data(num_servers):\n servers = {}\n for i in range(1, num_servers + 1):\n latency = random.randint(10, 1500)\n ...
trial_gpt4o_7
{ "original_instruction": "Develop a program that simulates a simple network latency and bandwidth tester for multiple servers. Your program should randomly generate latency (in milliseconds) and bandwidth (in Mbps) values for each server and then summarize the results. Additionally, the program should identify and h...
0.549679
Evol_6065
C
[ "generate_server_data", "analyze_servers", "simulate_network_test" ]
3
[ [ "simulate_network_test", "analyze_servers" ], [ "simulate_network_test", "generate_server_data" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0b577d8740c714932b8a0fb0514a3021b301b752
ce2d51ba5a67fb697f80d85f882cc960bfe01500
v1.0
complete
Evol
Evol_6641_C
def filter_and_sort_primes(numbers: List[int]) -> List[int]: """ This function takes a list of integers and returns a list with only the prime numbers sorted in ascending order. :param numbers: List of integers. :return: List of sorted prime numbers. >>> filter_and_sort_primes([]) == [] >>>...
def is_prime(n): """ Helper function to check 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 filter_and_sort_primes(numbers): """ This function takes a list of int...
import pytest from solution import filter_and_sort_primes def test_filter_and_sort_primes_empty_list(): assert filter_and_sort_primes([]) == [] def test_filter_and_sort_primes_no_primes(): assert filter_and_sort_primes([1, 4, 6, 8, 10, 12]) == [] def test_filter_and_sort_primes_with_primes(): assert filt...
[ { "docstring": "Helper function to check if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "This function takes a list of integers and returns a list with only the prime\nnumbers sorted in asc...
[ 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 for i in range(2, int(n...
trial_gpt4o_9
{ "original_instruction": "Create a function in Python that takes a list of integers and returns another list containing only the prime numbers from the input list. Additionally, the function should also sort the prime numbers in ascending order before returning the list. Ensure the function handles edge cases, such ...
0.69416
Evol_6641
C
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b78441f7486d707089ad0db6cca0ec03ed7696fc
2c8dbf3d59031accc7482f0063b723e58739d192
v1.0
complete
Evol
Evol_6512_C
def sum_of_digits(n: int) -> int: """ Returns the sum of the digits of an integer n. """ def list_with_sum_of_digits(lst: List[int]) -> List[Tuple[int, int]]: """ Returns a list of tuples where each tuple contains an integer from the original list and the sum of its digits. >>> list_with_s...
def sum_of_digits(n): """ Returns the sum of the digits of an integer n. """ return sum(int(digit) for digit in str(abs(n))) def list_with_sum_of_digits(lst): """ Returns a list of tuples with each integer and the sum of its digits. """ return [(num, sum_of_digits(num)) for num in lst]
from solution import list_with_sum_of_digits def test_list_with_sum_of_digits_empty(): assert list_with_sum_of_digits([]) == [] def test_list_with_sum_of_digits_single_element(): assert list_with_sum_of_digits([123]) == [(123, 6)] assert list_with_sum_of_digits([0]) == [(0, 0)] assert list_with_sum_of...
[ { "docstring": "Returns the sum of the digits of an integer n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns a list of tuples with each integer and the sum of its digits.", "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 sum_of_digits(n):\n \"\"\"\n Returns the sum of the digits of an integer n.\n \"\"\"\n return sum(int(digit) for digit in str(abs(n)))\n\ndef list_...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of integers and returns a list of tuples. Each tuple should contain two elements: an integer from the original list and the sum of its digits. Ensure the function maintains the original order of the integers in the returned list.", "prompt_id": "0...
0.706317
Evol_6512
C
[ "sum_of_digits", "list_with_sum_of_digits" ]
2
[ [ "list_with_sum_of_digits", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
33feada57ca02a588f69e9e5951d0ffde562a4f8
9e22a68b63d9bcc2b4d68a4061d4d7aa172d81bc
v1.0
complete
Evol
Evol_5265_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(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(10) == False >>> is_prime(13) == True """ pass def filte...
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 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 def test_filter_primes_with_primes_and_non_primes(): asser...
[ { "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 new list containing only the prime numbers from the original list.", "function_declaration...
[ 1, 1, 0, 1, 0, 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 \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n retur...
trial_gpt4o_9
{ "original_instruction": "Implement a function that receives a list of integers and returns a new list containing only the prime numbers from the original list. Make sure your solution is efficient and can handle large lists.\n\ndef filter_primes(int_list):\n ???\n\n# Example:\n# input: [10, 15, 3, 7, 9, 11, 13]\...
0.731203
Evol_5265
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
39712ddd458fa7b09e66623d8942ede6064bea53
6233f9bee473042b6694a29455cf62caffb70e17
v1.0
complete
Evol
Evol_5608_C
import re import numpy as np from collections import Counter, defaultdict from sklearn.model_selection import train_test_split, StratifiedKFold from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score def preprocess_text(text): """Preprocess text by tokenizing, lowercasing, and removing ...
import re import numpy as np from collections import Counter, defaultdict from sklearn.model_selection import train_test_split, StratifiedKFold from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score # Data Preprocessing def preprocess_text(text): # Tokenization, lowercasing, and removi...
import pytest from solution import preprocess_text, build_vocabulary, text_to_bow, NaiveBayesClassifier def test_preprocess_text(): text = "The quick brown fox jumps over the lazy dog. 123!" expected = ["the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"] assert preprocess_text(text) == e...
[]
[ 0, 1, 0, 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 numpy as np\nimport pandas as pd\nfrom collections import defaultdict\nimport re\nfrom sklearn.model_selection import train_test_split, StratifiedKFold\nfro...
trial_gpt4o_7
{ "original_instruction": "Create and implement a sentiment analysis pipeline for a movie review dataset using a custom-built Naive Bayes classifier. The project should be able to classify reviews as positive or negative based on their content.\n\nYour implementation should include the following steps:\n\n1. **Data P...
0.699037
Evol_5608
C
[ "preprocess_text", "build_vocabulary", "text_to_bow", "evaluate_model", "cross_validation" ]
5
[ [ "build_vocabulary", "preprocess_text" ], [ "cross_validation", "evaluate_model" ], [ "text_to_bow", "preprocess_text" ] ]
3
[]
false
[ "NaiveBayesClassifier" ]
true
pytest
true
[ "numpy", "sklearn" ]
false
72f6a8cecb7a7a67fe3e3c7fd81864214f391041
3a928df5435072934995122376cdf1821fef71e4
v1.0
complete
Evol
Evol_6885_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(0) False >>> 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(11) True """ def divisible_by_3_and_prime() -> li...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def divisible_by_3_and_prime(): ...
from solution import is_prime, divisible_by_3_and_prime 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) def test_divisible_by_3_and_prime(): ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Iterates through numbers from 1 to 50 and prints numbers that are both divisible by 3 and primes.", "function_declaration": "d...
[ 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 is_prime(n):\n \"\"\"\n Check if a number is a prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % ...
trial_gpt4o_9
{ "original_instruction": "Write a Python program that iterates through all numbers from 1 to 50, and prints the numbers that are both divisible by 3 and are prime numbers. Use a while loop for iteration and ensure that the program only prints numbers meeting both criteria. Avoid using any built-in Python functions l...
0.819452
Evol_6885
C
[ "is_prime", "divisible_by_3_and_prime" ]
2
[ [ "divisible_by_3_and_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2098f211179c4b74ce234e11a4ac0f9a40b36e54
e2ddd3fc6f1804310b3b5dd6422964edfd112dc9
v1.0
complete
Evol
Evol_6311_C
def preprocess_string(s: str) -> str: """ Converts the string to lower case and removes all non-alphanumeric characters. >>> preprocess_string("A man, a plan, a canal: Panama") 'amanaplanacanalpanama' >>> preprocess_string("No 'x' in Nixon") 'noxinnixon' >>> preprocess_string("") '' >>>...
def preprocess_string(s): """ Converts the string to lower case and removes all non-alphanumeric characters. """ return ''.join(c.lower() for c in s if c.isalnum()) def longest_palindromic_substring(s): """ Returns the longest palindromic substring in the given document. Ignoring spaces, pu...
from solution import preprocess_string, longest_palindromic_substring def test_preprocess_string(): assert preprocess_string("A man, a plan, a canal: Panama") == "amanaplanacanalpanama" assert preprocess_string("No 'x' in Nixon") == "noxinnixon" assert preprocess_string("") == "" assert preprocess_stri...
[ { "docstring": "Converts the string to lower case and removes all non-alphanumeric characters.", "function_declaration": "def preprocess_string(s):", "function_name": "preprocess_string", "parameter_list": "(s)" }, { "docstring": "Returns the longest palindromic substring in the given docume...
[ 0, 1, 0, 1, 0, 0, 0, 0, 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 re\n\ndef longest_palindromic_substring(text):\n \"\"\"\n Returns the longest palindromic substring from the provided text while ignoring spaces,\n ...
trial_gpt4o_1
{ "original_instruction": "Given a large text corpus, write a function to identify the longest palindromic substring within the document. The function should be efficient to handle texts with lengths up to a few million characters. Additionally, the algorithm should ignore spaces, punctuation, and case variations whe...
0.751891
Evol_6311
C
[ "preprocess_string", "longest_palindromic_substring" ]
2
[ [ "longest_palindromic_substring", "preprocess_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3485b783dc74ecc1c3cd5586b7ed2e7e71308713
65b31d3327ef32d45e69e411e02b3224ae6295d8
v1.0
complete
Evol
Evol_6803_C
import re from collections import defaultdict def normalize_word(word: str) -> str: """ Normalize the word by converting it to lowercase and removing any punctuation. >>> normalize_word("Hello!") "hello" >>> normalize_word("ApPlE") "apple" >>> normalize_word("Fruits,") "fruits" """ pass def so...
import re from collections import defaultdict def normalize_word(word): """ Normalize the word by converting it to lowercase and removing any punctuation. """ return re.sub(r'[^\w\s]', '', word).lower() def sorted_word_frequencies(word_freq_dict): """ Accepts a dictionary of word-frequenc...
import pytest from solution import sorted_word_frequencies, normalize_word def test_normalize_word(): assert normalize_word("Hello!") == "hello" assert normalize_word("ApPlE") == "apple" assert normalize_word("Fruits,") == "fruits" def test_sorted_word_frequencies_simple(): word_freq_dict = { ...
[ { "docstring": "Normalize the word by converting it to lowercase and \nremoving any punctuation.", "function_declaration": "def normalize_word(word):", "function_name": "normalize_word", "parameter_list": "(word)" }, { "docstring": "Accepts a dictionary of word-frequency pairs and returns a ...
[ 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": "import re\n\ndef normalize_word(word):\n \"\"\"\n Normalize the word by making it lowercase and removing punctuation.\n \"\"\"\n return re.sub(r'\\W+',...
trial_gpt4o_9
{ "original_instruction": "Write a function in Python that accepts a dictionary of word-frequency pairs and returns a dictionary with the words sorted alphabetically and their frequencies. The function should take care of case-insensitivity, considering 'Apple' and 'apple' as the same word. Additionally, the function...
0.6824
Evol_6803
C
[ "normalize_word", "sorted_word_frequencies", "example" ]
3
[ [ "example", "sorted_word_frequencies" ], [ "sorted_word_frequencies", "normalize_word" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c6c5dea22499857a306c8d7767b9320953fdb6f7
c2e0ab3c75e09343679d62bf46dbe4f426d156de
v1.0
complete
Evol
Evol_6860_C
from typing import List, Tuple def clean_text(text: str) -> str: """ Remove punctuation and convert text to lowercase. """ pass def count_word_frequencies(file_path: str) -> List[Tuple[str, int]]: """ Count the frequency of each word in the given text file. Returns the ten most common word...
import re from collections import Counter import string # Define the set of common stop words STOP_WORDS = set([ "the", "and", "in", "of", "to", "a", "is", "it", "that", "for", "on", "with", "as", "at", "this", "by", "an", "are", "be", "from", "which", "or", "we", "can", "not", "all", "one", "have", "has...
from solution import count_word_frequencies, query_word_frequency def test_count_word_frequencies(): # Set up a mock text file content mock_text = """This is a test. This test is an example of text processing. The aim of this test is to test the counting frequency.""" ...
[ { "docstring": "Remove punctuation and convert text to lowercase.", "function_declaration": "def clean_text(text):", "function_name": "clean_text", "parameter_list": "(text)" }, { "docstring": "Count the frequency of each word in the given text file.\nReturns the ten most common words along ...
[ 0, 1, 0, 0, 0, 0, 1, 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 re\nfrom collections import Counter\n\ndef preprocess_text(text):\n \"\"\"\n Preprocess the text by removing punctuation and common stop words, and co...
trial_gpt4o_9
{ "original_instruction": "Design a program in Python that reads a large text file (e.g., a book) and identifies the frequency of each word. The program should output the ten most common words along with their frequencies. Your solution should efficiently handle memory usage and consider the removal of punctuation an...
0.687258
Evol_6860
C
[ "clean_text", "count_word_frequencies", "query_word_frequency" ]
3
[ [ "count_word_frequencies", "clean_text" ], [ "query_word_frequency", "clean_text" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9fc3a76e090692a0c5438b5b035c1857d7e6faad
91714eccc2953af4e1c98269e3f5bdc875b84136
v1.0
complete
Evol
Evol_6984_C
def sum_dictionary_values(input_dict: dict) -> dict: """ Write a Python function that accepts a dictionary where the keys are strings and the values are integers or lists of integers (which can also contain nested lists up to two levels). The function should return a new dictionary where each key maps t...
def sum_nested_elements(nested_list): """ Helper function to sum all integers in a nested list structure. It can contain nested lists up to two levels. """ total_sum = 0 for element in nested_list: if isinstance(element, int): total_sum += element elif isinstance(elem...
from solution import sum_dictionary_values def test_single_integers(): assert sum_dictionary_values({'a': 5, 'd': 7}) == {'a': 5, 'd': 7} def test_nested_lists(): assert sum_dictionary_values({'b': [3, 4, [1, 2]], 'c': [2, [3, 4]]}) == {'b': 10, 'c': 9} def test_mixed_values(): assert sum_dictionary_valu...
[ { "docstring": "Helper function to sum all integers in a nested list structure.\nIt can contain nested lists up to two levels.", "function_declaration": "def sum_nested_elements(nested_list):", "function_name": "sum_nested_elements", "parameter_list": "(nested_list)" }, { "docstring": "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": "def sum_nested_integers(input_dict):\n \"\"\"\n Given a dictionary where the keys are strings and the values are integers or lists of integers \n (which c...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that accepts a dictionary where the keys are strings and the values are integers or lists of integers (which can also contain nested lists up to two levels). The function should return a new dictionary where each key maps to the sum of all integers (including nested ...
0.649417
Evol_6984
C
[ "sum_nested_elements", "sum_dictionary_values" ]
2
[ [ "sum_dictionary_values", "sum_nested_elements" ] ]
1
[]
false
[]
false
pytest
true
[]
true
92adb08f9cab448fdac1afefff82e8d45eb9ad36
599fb1cab511d229a6ff0a2b7e327e6978fb0003
v1.0
complete
Evol
Evol_6925_C
import re def clean_string(s: str) -> str: """ Removes non-alphanumeric characters and converts the string to lowercase. >>> clean_string("A man, a plan, a canal, Panama!") 'amanaplanacanalpanama' >>> clean_string("Was it a car or a cat I saw?") 'wasitacaroracatisaw' """ pass def is_pa...
import re def clean_string(s): """ Removes non-alphanumeric characters and converts the string to lowercase. """ cleaned = re.sub(r'[^a-zA-Z0-9]', '', s) return cleaned.lower() def is_palindrome(s): """ Returns True if the processed string is a palindrome, False otherwise. """ clea...
from solution import clean_string, is_palindrome, is_palindrome_substrings def test_clean_string(): assert clean_string("A man, a plan, a canal, Panama!") == "amanaplanacanalpanama" assert clean_string("Was it a car or a cat I saw?") == "wasitacaroracatisaw" def test_is_palindrome(): assert is_palindrome(...
[ { "docstring": "Removes non-alphanumeric characters and converts the string to lowercase.", "function_declaration": "def clean_string(s):", "function_name": "clean_string", "parameter_list": "(s)" }, { "docstring": "Returns True if the processed string is a palindrome, False otherwise.", ...
[ 1, 1, 0, 1, 0, 1, 0, 0, 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 re\n\ndef clean_string(s):\n \"\"\"\n Removes non-alphanumeric characters from the string and converts it to lowercase.\n \"\"\"\n return re.sub...
trial_gpt4o_5
{ "original_instruction": "Develop a Python program that determines if a given string is a palindrome. A palindrome is a sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). For instance, the strings \"A man, a plan, a canal, Panama!\" and \"Was it a car ...
0.77664
Evol_6925
C
[ "clean_string", "is_palindrome", "is_palindrome_substrings" ]
3
[ [ "is_palindrome", "clean_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c6baf93ef1a07b78b69b7d4242ac1cf72c55dabf
61632f2cb4116d1cddb59d01603aec2ba3ef0511
v1.0
complete
Evol
Evol_6906_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False """ def filter_and_sort_primes(input_list: list) -> list: """ Filters the prime numbers from the input list and returns them sorted in descending order. Parameters:...
def is_prime(n): """ Check if a number 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 filter_and_sort_primes(input_list): """ Filters the prime numbers from the input list and ret...
from solution import filter_and_sort_primes def test_filter_and_sort_primes_with_primes(): assert filter_and_sort_primes([10, 3, 5, 7, 9, 11, 2]) == [11, 7, 5, 3, 2] def test_filter_and_sort_primes_mixed_numbers(): assert filter_and_sort_primes([10, 4, 16, 20, 25, 33, 18]) == [] def test_filter_and_sort_prim...
[ { "docstring": "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 input list and returns them sorted in descending order.\n\nParameters:\ninput_list (li...
[ 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 n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n ...
trial_gpt4o_2
{ "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 input list. Additionally, the function should sort these prime numbers in descending order. Provide a piece of erroneous code as a reference and ask for its corre...
0.723962
Evol_6906
C
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4891cd2ba44dba1524bb59310a494c1b184d4cbf
3fee9ec9365418aa3ba4b10d0bfaffa1cd2d7e9d
v1.0
complete
Evol
Evol_6266_C
from typing import List def extract_primes(nums: List[int]) -> List[int]: """ Write a function in Python that takes a list of integers as an input and returns a list containing only the prime numbers found in the input list. >>> extract_primes([10, 15, 3, 7, 11, 20]) [3, 7, 11] >>> extract_primes([4, 6...
def is_prime(num): """ Helper function that returns True if the number is prime, otherwise False. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2...
from solution import extract_primes def test_extract_primes_example_1(): assert extract_primes([10, 15, 3, 7, 11, 20]) == [3, 7, 11] def test_extract_primes_example_2(): assert extract_primes([4, 6, 8, 9, 10]) == [] def test_extract_primes_single_prime(): assert extract_primes([2]) == [2] def test_extra...
[ { "docstring": "Helper function that returns True if the number is prime, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function that takes a list of integers and returns a list of prime numbers foun...
[ 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 Helper function to check if number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_9
{ "original_instruction": "Write a function in Python that takes a list of integers as an input and returns a list containing only the prime numbers found in the input list. \n\n### Constraints:\n1. The input list will have at least one integer and no more than 1000 integers.\n2. Each integer in the input list will b...
0.699764
Evol_6266
C
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ad94ba5a0742725b8b93c125dfe1ec20cd753f7d
16d209213f50155263ba8a62fdd6e498fd8ad994
v1.0
complete
Evol
Evol_7056_C
from typing import List def is_prime(n: int) -> bool: """ Determines if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a list of prime numbers from the given list `numb...
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 i = 3 while i * i <= n: if n % i == 0: return False i += 2 return True def fi...
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": "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 Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ...
trial_gpt4o_7
{ "original_instruction": "Implement a function in Python that takes a list of integers and returns a new list containing only the prime numbers from the original list. Do not use any built-in functions that directly check for prime numbers. Instead, write your own logic to determine if a number is prime. \n\n### Exa...
0.753735
Evol_7056
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aeaa37a194a1e721de09f4014d9828dba34222e8
0898f822939817b6d52906b08e999df3384fe13c
v1.0
complete
Evol
Evol_7213_C
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]: """Filter and return a list of prime numbers from the given list. >>> filter_primes([3, 4, 7, 10, 17]) [3, 7, 17] ...
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(numbers...
from solution import is_prime, filter_primes # Tests for is_prime function def test_is_prime_with_prime_numbers(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(17) == True def test_is_prime_with_non_prime_numbers(): assert is_prime(1) == False ...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filter and return a list of prime numbers from the given 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, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_6
{ "original_instruction": "Implement a function in Python that takes a list of integers and returns a new list containing only the prime numbers from the original list. Your function should efficiently check for primes and should preserve the order of the numbers from the initial list.\n\nExample:\n```python\nInput: ...
0.748314
Evol_7213
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ccc34bf440093f93896edf79cef5b67dc858b127
0d852cde3ec9af868af0fead5ff40066f8d996cb
v1.0
complete
Evol
Evol_6811_C
import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.impute import SimpleImputer from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score d...
import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.impute import SimpleImputer from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score d...
from solution import download_and_preprocess_data, train_and_evaluate_model def test_preprocess_data(): url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data' X_train, X_test, y_train, y_test = download_and_preprocess_data(url) # Check if shapes are correct assert X_train...
[ { "docstring": null, "function_declaration": "def download_and_preprocess_data(url):", "function_name": "download_and_preprocess_data", "parameter_list": "(url)" }, { "docstring": null, "function_declaration": "def train_and_evaluate_model():", "function_name": "train_and_evaluate_mo...
[ 0, 0, 1, 1, 1, 1, 0, 1, 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 pandas as pd\nimport numpy as np\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.imput...
trial_gpt4o_8
{ "original_instruction": "Using the following URL: https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data, download and preprocess the dataset to classify wines into one of three categories according to their origin. Utilize the scikit-learn library to build and evaluate a classification model. Ens...
0.725236
Evol_6811
C
[ "download_and_preprocess_data", "train_and_evaluate_model" ]
2
[ [ "train_and_evaluate_model", "download_and_preprocess_data" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy", "pandas", "sklearn" ]
false
c14de9cfe895275f5cffdfe6548c01c00a7bb525
8c41bc7972c158bb2060b954c7c39f7a6fe66a63
v1.0
complete
Evol
Evol_6618_C
import time from typing import List def binary_search(arr: List[int], target: int) -> int: """ Performs binary search on a sorted list to find the index of the target element. Returns the index of the target if found, otherwise returns -1. :param arr: List of sorted elements :param target: Ele...
import time def binary_search(arr, target): """ Performs binary search on a sorted list to find the index of the target element. Returns the index of the target if found, otherwise returns -1. :param arr: List of sorted elements :param target: Element to search for :return: Index of target...
from solution import binary_search def test_binary_search_found(): assert binary_search([1, 2, 3, 4, 5], 3) == 2 assert binary_search([10, 20, 30, 40, 50], 40) == 3 assert binary_search([100, 200, 300, 400, 500], 100) == 0 def test_binary_search_not_found(): assert binary_search([1, 2, 3, 4, 5], 6) ==...
[ { "docstring": "Performs binary search on a sorted list to find the index of the target element.\nReturns the index of the target if found, otherwise returns -1.\n\n:param arr: List of sorted elements\n:param target: Element to search for\n:return: Index of target if found, -1 otherwise", "function_declarat...
[ 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 time\n\ndef binary_search(arr, target):\n \"\"\"\n Binary search algorithm to find the target in the sorted list arr.\n If target is found, return ...
trial_gpt4o_9
{ "original_instruction": "Create a function that implements the Binary Search algorithm in Python and use it to search for an element in a sorted list. Additionally, use the `time` module to measure the performance (execution time) of your function for different input sizes. Discuss how the input size affects the pe...
0.597567
Evol_6618
C
[ "binary_search", "measure_performance" ]
2
[ [ "measure_performance", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
482ec393f362ff4bb031d1767997b240a9ad5e60
bec8c2c703e4882a0d4034443f2badd3a52c7f9d
v1.0
complete
Evol
Evol_7313_C
from typing import List def perfect_squares(lst: List[int]) -> List[int]: """ Create a function that takes a list of integers and returns a new list containing only the integers that are perfect squares, sorted in ascending order. Additionally, the function should count the number of perfect squares i...
import math def is_perfect_square(n): if n < 0: return False root = int(math.sqrt(n)) return root * root == n def perfect_squares(lst): """ Returns a new list that contains only the perfect squares from the input list, sorted in ascending order, and appends the count of perfect squares...
from solution import perfect_squares def test_perfect_squares(): assert perfect_squares([16, 10, 25, 7, 1, 30, 4]) == [1, 4, 16, 25, 4] assert perfect_squares([49, 50, 51, 52, 9, 3, 2]) == [9, 49, 2] assert perfect_squares([0, 1, 2, 3, 4, 5]) == [0, 1, 4, 3] assert perfect_squares([-1, -4, -9, 8, 26, 6...
[ { "docstring": null, "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Returns a new list that contains only the perfect squares from the input list,\nsorted in ascending order, and appends the count of perfe...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
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_perfect_square(n):\n \"\"\"\n Check if a number is a perfect square.\n \"\"\"\n if n < 0:\n return False\n root = int(n**0.5)\n ret...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a list of integers and returns a new list containing only the integers that are perfect squares, sorted in ascending order. Additionally, your function should count the number of perfect squares identified and append this count as the last element of the returne...
0.731204
Evol_7313
C
[ "is_perfect_square", "perfect_squares" ]
2
[ [ "perfect_squares", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b3e28fec9f10821599f9fce4e0fe476ff3f5582
f1a1c7719dcb79cb973f5b2484df01c2fa6816b3
v1.0
complete
Evol
Evol_7169_C
from typing import List def filter_primes(numbers: List[int]) -> List[int]: """Develop a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. >>> filter_primes([]) [] >>> filter_primes([0, 1, -1, -2, 4, 6, 8, 9, 10]) [] >>>...
def is_prime(num): if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def filter_primes(numbers): return [num for num in numbers if is_prime(num)]
from solution import filter_primes def test_empty_list(): assert filter_primes([]) == [] def test_no_primes(): assert filter_primes([0, 1, -1, -2, 4, 6, 8, 9, 10]) == [] def test_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13, 17]) == [2, 3, 5, 7, 11, 13, 17] def test_mixed_numbers(): assert...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def filter_primes(numbers):", "function_name": "filter_primes", "parameter_list": "(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": "from math import isqrt\n\ndef is_prime(num):\n \"\"\"\n Checks if a number is a prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\...
trial_gpt4o_7
{ "original_instruction": "Develop a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Implement the function in Python and ensure it is optimized for performance. Test your function with a variety of inputs, including edge cases such as empty list...
0.724739
Evol_7169
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3904d1e2714692bfd7a1ec2f8d006534815629ed
3ac1b269dba6b03cb3a1325715602245e4c6fe43
v1.0
complete
Evol
Evol_7382_C
import csv import re from datetime import datetime def is_valid_email(email): """ Validates the email address using a regex pattern. """ pattern = r'^\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b' return re.match(pattern, email) is not None def process_csv(input_file: str, output_file: str) ...
import csv import re from datetime import datetime def is_valid_email(email): """ Validates the email address using a regex pattern. """ regex = r'^\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b' return re.match(regex, email) is not None def process_csv(input_file, output_file): """ P...
import pytest import os from solution import process_csv, is_valid_email def test_is_valid_email(): assert is_valid_email('test@example.com') assert not is_valid_email('invalid-email') assert is_valid_email('user.name+tag+sorting@example.com') assert not is_valid_email('user.name@.com') def test_proce...
[ { "docstring": "Validates the email address using a regex pattern.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Processes the CSV file to retrieve the top 5 most recent signups,\nvalidates emails, an...
[ 1, 0, 1, 0, 1, 0, 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 csv\nimport re\nfrom datetime import datetime\n\ndef process_csv(input_file, output_file):\n \"\"\"\n Processes the CSV file to retrieve the top 5 mos...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that processes a CSV file containing user data with columns such as \"UserID,\" \"Name,\" \"Email,\" and \"SignupDate.\" Your function should parse the CSV file and retrieve the top 5 most recent signups. Ensure your function also validates email addresses using a re...
0.682628
Evol_7382
C
[ "is_valid_email", "process_csv" ]
2
[ [ "process_csv", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8c656349ba77c01b116222039ba67ba20c23fd73
edfd517808c47388d4b464f7463510dc8edbe976
v1.0
complete
Evol
Evol_7289_C
def sort_by_common_chars(strings, target): """ Sort a list of strings by the number of characters they have in common with the target string. Only consider common characters once (even if they occur multiple times in both strings). If two strings have the same number of common characters, they should retai...
def count_common_chars(s, target_set): """ Counts the number of unique characters in s that are also in the target_set. """ return len(set(s) & target_set) def sort_by_common_chars(strings, target): """ Sorts a list of strings based on the number of unique characters they have in common with th...
from solution import sort_by_common_chars def test_sort_by_common_chars_example_case(): assert sort_by_common_chars(['apple', 'banana', 'pear', 'peach'], 'pale') == ['apple', 'pear', 'peach', 'banana'] def test_sort_by_common_chars_empty_list(): assert sort_by_common_chars([], 'pale') == [] def test_sort_by_...
[ { "docstring": "Counts the number of unique characters in s that are also in the target_set.", "function_declaration": "def count_common_chars(s, target_set):", "function_name": "count_common_chars", "parameter_list": "(s, target_set)" }, { "docstring": "Sorts a list of strings based on the ...
[ 0, 0, 0, 0, 0, 0, 0, 1, 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 sort_by_common_chars(strings, target):\n def common_chars_count(s1, s2):\n count = 0\n s1_set = set(s1)\n s2_set = set(s2)\n cou...
trial_gpt4o_7
{ "original_instruction": "Write a function in Python that takes a list of strings and a target string, and returns the list of strings sorted by the number of characters they have in common with the target string. Only consider common characters once (even if they occur multiple times in both strings). If two string...
0.630824
Evol_7289
C
[ "count_common_chars", "sort_by_common_chars" ]
2
[ [ "sort_by_common_chars", "count_common_chars" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b9a68a8c494421798840c853f48369bde4ab126d
a53afeba0f6b087ea5a02707f879a19efeb86635
v1.0
complete
Evol
Evol_7141_C
import threading import os import time import pickle import math from typing import List def load_cache(): # Function to load cache from persistent storage file pass def save_cache(cache): # Function to save cache to persistent storage file pass def factorial_with_caching(n: int) -> int: """ ...
import functools import math import pickle from typing import List import threading import os import time CACHE_FILE = 'factorial_cache.pkl' CACHE_EXPIRATION = 3600 # 1 hour in seconds # Create a lock for thread-safe operations lock = threading.Lock() # Load cache from file if it exists and not expired def load_cac...
from solution import factorial_with_caching, factorial_multiple_queries import pytest def test_factorial_with_caching(): assert factorial_with_caching(0) == 1 assert factorial_with_caching(1) == 1 assert factorial_with_caching(5) == 120 assert factorial_with_caching(10) == 3628800 def test_factorial_w...
[ { "docstring": null, "function_declaration": "def load_cache():", "function_name": "load_cache", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def save_cache(cache):", "function_name": "save_cache", "parameter_list": "(cache)" }, { "docstring": n...
[ 1, 1, 0, 0, 1, 0, 0, 0, 0, 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 functools\nimport os\nimport pickle\nimport time\nfrom typing import List\n\nCACHE_FILE = \"factorial_cache.pkl\"\nCACHE_TIMEOUT = 3600 # seconds\n\n\nclas...
trial_gpt4o_9
{ "original_instruction": "Design a software module that implements a caching mechanism for the factorial of large numbers. The module should be capable of computing and storing factorized results of numbers up to 100,000! to prevent redundant calculations. Ensure your implementation is optimized for both time and sp...
0.575863
Evol_7141
C
[ "load_cache", "save_cache", "factorial_with_caching", "factorial_multiple_queries" ]
4
[ [ "factorial_multiple_queries", "factorial_with_caching" ], [ "factorial_with_caching", "save_cache" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1ea85732384294ccea9f538492e22dcf3eb20f32
14e83a0d5a8dbe59c1170515e7df1ca423a01464
v1.0
complete
Evol
Evol_5308_C
import random def shuffle_and_deal(): """ Shuffles the deck and deals the initial two cards for player and dealer. Returns: deck (list): Remaining cards in the deck. player_hand (list): Cards in player's hand. dealer_hand (list): Cards in dealer's hand. """ deck = ['2', '3',...
import random # Function to shuffle and deal cards def shuffle_and_deal(): """ Shuffles the deck and deals the initial two cards for player and dealer. Returns: deck (list): Remaining cards in the deck. player_hand (list): Cards in player's hand. dealer_hand (list): Cards in dealer'...
from solution import shuffle_and_deal, calculate_hand_value # Unit test for shuffle_and_deal function def test_shuffle_and_deal(): deck, player_hand, dealer_hand = shuffle_and_deal() assert len(deck) == 48 assert len(player_hand) == 2 assert len(dealer_hand) == 2 # Unit test for calculate_hand_value f...
[ { "docstring": "Shuffles the deck and deals the initial two cards for player and dealer.\nReturns:\n deck (list): Remaining cards in the deck.\n player_hand (list): Cards in player's hand.\n dealer_hand (list): Cards in dealer's hand.", "function_declaration": "def shuffle_and_deal():", "functi...
[ 1, 1, 0, 0, 1, 1, 1, 0, 0 ]
5
medium
0.556
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import random\n\n# Define the card deck and values\ndeck = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11] * 4\n\n# Function to shuffle and deal cards\ndef shuffle_de...
trial_gpt4o_6
{ "original_instruction": "Design an algorithm to simulate a simplified version of a basic blackjack game using Python. In this game, the player and the dealer each receive two cards initially. The player can choose to \"hit\" to receive another card or \"stand\" to keep their current hand. The goal is to have the hi...
0.644341
Evol_5308
C
[ "shuffle_and_deal", "calculate_hand_value", "blackjack" ]
3
[ [ "blackjack", "calculate_hand_value" ], [ "blackjack", "shuffle_and_deal" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a648a3a0ee7c2a9b758be87d3815a11f1533583d
8f6f46f6d0d171095b8d3944ae2456a3e6438af0
v1.0
complete
Evol
Evol_6746_C
[Completion Task in Python] import csv from collections import defaultdict import matplotlib.pyplot as plt from datetime import datetime def parse_csv(file_path): """Parse the CSV file and store the data in an appropriate data structure. You should handle errors such as missing or malformed data appropria...
import csv from collections import defaultdict import matplotlib.pyplot as plt from datetime import datetime def parse_csv(file_path): sales_data = defaultdict(lambda: defaultdict(int)) try: with open(file_path, newline='') as csvfile: reader = csv.DictReader(csvfile) for row in...
import pytest from solution import parse_csv, calculate_total_sales, product_with_highest_sales, analyze_sales def setup_module(module): # Create a sample CSV file for testing purposes csv_content = """Product,Date,Quantity,Price ProductA,2023-01-15,10,20 ProductB,2023-01-17,5,30 ProductA,2023-02-03,8,20 Produ...
[ { "docstring": null, "function_declaration": "def parse_csv(file_path):", "function_name": "parse_csv", "parameter_list": "(file_path)" }, { "docstring": null, "function_declaration": "def calculate_total_sales(sales_data):", "function_name": "calculate_total_sales", "parameter_l...
[ 1, 0, 1, 0, 0, 0, 0, 0, 1, 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 csv\nfrom collections import defaultdict\nimport matplotlib.pyplot as plt\nfrom datetime import datetime\n\ndef parse_csv(file_path):\n \"\"\"\n Parse...
trial_gpt4o_8
{ "original_instruction": "Write a Python program that will take a CSV file containing product sales data and analyze the data to identify sales patterns. The program should be able to perform the following tasks:\n\n1. Parse the CSV file and store the data in an appropriate data structure.\n2. Calculate and display ...
0.716743
Evol_6746
C
[ "parse_csv", "calculate_total_sales", "product_with_highest_sales", "plot_monthly_sales_trend", "analyze_sales" ]
5
[ [ "analyze_sales", "calculate_total_sales" ], [ "analyze_sales", "parse_csv" ], [ "analyze_sales", "plot_monthly_sales_trend" ], [ "analyze_sales", "product_with_highest_sales" ] ]
4
[]
false
[]
false
pytest
true
[ "matplotlib" ]
false
6e8497807bd682676969c33783a1c42f505b78b0
bab88b407439c63e2be3c0de09ae60fba647dd3e
v1.0
complete
Evol
Evol_7247_C
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: return False...
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: return False...
from solution import first_n_primes def test_first_n_primes_zero(): assert first_n_primes(0) == [] def test_first_n_primes_negative(): assert first_n_primes(-5) == [] def test_first_n_primes_one(): assert first_n_primes(1) == [2] def test_first_n_primes_five(): assert first_n_primes(5) == [2, 3, 5, ...
[ { "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.\n\nParameters:\nn (int): The number of prime numbers to ge...
[ 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 determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n ...
trial_gpt4o_2
{ "original_instruction": "Write a Python function that takes a single integer input `n` and returns a list of the first `n` prime numbers. Prime numbers are integers greater than 1 that have no positive divisors other than 1 and themselves. Make sure the function handles edge cases appropriately, such as when `n` is...
0.815359
Evol_7247
C
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
654b662f01e891ae2bd8304ded84bd73bfeda008
82c018eeeb0dfe7855d4092910ccecd6e6dcc722
v1.0
complete
Evol
Evol_7078_C
from typing import List def is_prime(n: int) -> bool: """ Check if a number is a prime number. Prime numbers must be greater than 1, and have no positive divisors other than 1 and itself. Args: n (int): The number to be checked. Returns: bool: True if n is a prime number, otherwise Fa...
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 filter_primes(numbers): """ Returns a list...
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(0) == False assert is_prime(-3) == False assert is_prime(-11) == False def test_filter_primes(): ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.", "function_declaration": "def filter_primes(numbers):", "function_name": "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 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 as input and returns a list containing only the prime numbers from the input list. The function should handle both positive and negative numbers, and zero. For example, for the input [-3, 2, 4, 5, 8, -11, 13, 0], the output should be [2, 5, 13]...
0.763947
Evol_7078
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
183e5136bdd515f7b356f07ce5e546fda3a2ca62
f130da216edd2031fa3849630d29729b1af04179
v1.0
complete
Evol
Evol_6720_C
import datetime from typing import List, Tuple def read_pairs(file_path: str) -> List[Tuple[str, int]]: """ Reads pairs of names and ages from the given file. Returns a list of tuples (name, age). Logs any errors encountered to 'error_log.txt'. """ pass def sort_pairs(pairs: List[Tuple[str, in...
import datetime def read_pairs(file_path): """ Reads pairs of names and ages from the given file. Returns a list of tuples (name, age). Logs any errors encountered to 'error_log.txt'. """ pairs = [] with open(file_path, 'r') as file: for line in file: try: ...
from solution import read_pairs, sort_pairs, write_pairs, sort_names_by_age, log_error import os def test_read_pairs(): input_file = 'test_input.txt' with open(input_file, 'w') as file: file.write("Alice 30\nBob 25\nCharlie 25\nEve 22\nInvalidLine\nJohn 30\nJane\n") pairs = read_pairs(input_fi...
[ { "docstring": "Reads pairs of names and ages from the given file.\nReturns a list of tuples (name, age).\nLogs any errors encountered to 'error_log.txt'.", "function_declaration": "def read_pairs(file_path):", "function_name": "read_pairs", "parameter_list": "(file_path)" }, { "docstring": ...
[ 0, 0, 1, 1, 1, 0, 1, 1, 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 logging\nfrom datetime import datetime\n\ndef read_and_sort(file_path, output_path, error_log_path):\n \"\"\"\n Reads a file with pairs of names and a...
trial_gpt4o_9
{ "original_instruction": "Write a program that reads a text file containing pairs of names and their corresponding ages. Sort these pairs based on age in ascending order. If two people have the same age, sort them alphabetically by their names. After sorting, save the output to a new text file in the same format. Ad...
0.567199
Evol_6720
C
[ "read_pairs", "sort_pairs", "write_pairs", "log_error", "sort_names_by_age" ]
5
[ [ "read_pairs", "log_error" ], [ "sort_names_by_age", "read_pairs" ], [ "sort_names_by_age", "sort_pairs" ], [ "sort_names_by_age", "write_pairs" ] ]
4
[]
false
[]
false
pytest
true
[]
true
105798de419f38c6ee725b1e776b163ad2ae58ff
41cb49420c8c069874a3a39e37ffaf1a956bbf5c
v1.0
complete
Evol
Evol_6973_C
import pytest from typing import List def is_valid_input(numbers: List[int], K: int) -> bool: """ Validates the input to check if `numbers` is a list of integers and `K` is an integer within the range 1 to 100. """ # Implementation is required def filter_divisible(numbers: List[int], K: int) -> List[i...
def is_valid_input(numbers, K): """ Validates the input to check if `numbers` is a list of integers and `K` is an integer within the range 1 to 100. """ if not isinstance(numbers, list): return False if not all(isinstance(num, int) for num in numbers): return False if not isinsta...
import pytest from solution import filter_divisible def test_filter_divisible_valid_input(): assert filter_divisible([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6] assert filter_divisible([10, 15, 20, 25, 30], 5) == [10, 15, 20, 25, 30] assert filter_divisible([], 3) == [] def test_filter_divisible_with_no_multiples...
[ { "docstring": "Validates the input to check if `numbers` is a list of integers and `K` is an integer within the range 1 to 100.", "function_declaration": "def is_valid_input(numbers, K):", "function_name": "is_valid_input", "parameter_list": "(numbers, K)" }, { "docstring": "Returns a new l...
[ 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 filter_divisible(nums, K):\n \"\"\"\n Returns a new list containing only those integers from the nums list that are divisible by K.\n \"\"\"\n # Ca...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that receives a list of integers and a key integer K (1 ≤ K ≤ 100) as input, and returns a new list that contains only those integers from the original list that are divisible by K. Your function should also create an input validation function that checks if the prov...
0.621744
Evol_6973
C
[ "is_valid_input", "filter_divisible" ]
2
[ [ "filter_divisible", "is_valid_input" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b3b844147208e223ff0ed7c8a081b575e014e42a
12f43f963d00d945e05f1db256ad2a471d7e2453
v1.0
complete
Evol
Evol_5694_C
def prime_factors(n: int) -> List[Tuple[int, int]]: """ Returns the prime factorization of n as a list of tuples containing each prime factor and its exponent. """ # Implement function here def prime_factorization_list(lst: List[int]) -> List[List[Tuple[int, int]]]: """ Returns a list of pr...
def prime_factors(n): """ Returns the prime factorization of n as a list of tuples containing each prime factor and its exponent. """ i = 2 factors = [] while i * i <= n: count = 0 while (n % i) == 0: n //= i count += 1 if count > 0: ...
from solution import prime_factors, prime_factorization_list, verify_prime_factorizations def test_prime_factors(): assert prime_factors(28) == [(2, 2), (7, 1)] assert prime_factors(30) == [(2, 1), (3, 1), (5, 1)] assert prime_factors(1) == [] assert prime_factors(100) == [(2, 2), (5, 2)] assert pr...
[ { "docstring": "Returns the prime factorization of n as a list of tuples containing\neach prime factor and its exponent.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime factorization for e...
[ 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": "from collections import Counter\n\ndef prime_factors(n):\n \"\"\"\n Helper function to return the prime factors of a number n as a list of (prime, exponent) ...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that accepts a list of integers and returns a list of tuples representing the prime factorization of each integer. Each tuple within the list should contain a prime factor and its exponent in order of smallest to largest prime factor. For example, the prime factoriza...
0.823265
Evol_5694
C
[ "prime_factors", "prime_factorization_list", "verify_prime_factorizations" ]
3
[ [ "prime_factorization_list", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0e5df9a654e874028f2f0582d300d36cb18607ed
50ad4166a3130fab76ee56aea931c8baf40ef4d7
v1.0
complete
Evol
Evol_7323_C
import re from collections import Counter def clean_text(text): """ Takes a string and returns a cleaned version of the string, where all characters are converted to lowercase, and all punctuation and special characters are removed. >>> clean_text("Hello, World!") 'hello world' >>> clean...
import re from collections import Counter def clean_text(text): """ Takes a string and returns a cleaned version of the string, where all characters are converted to lowercase, and all punctuation and special characters are removed. """ # Convert to lowercase text = text.lower() # Remov...
import pytest from solution import clean_text, get_word_frequencies, top_k_frequent_words def test_clean_text(): assert clean_text("Hello, World!") == "hello world" assert clean_text("Python3.8 is great!") == "python38 is great" assert clean_text("No special@characters!") == "no specialcharacters" def tes...
[ { "docstring": "Takes a string and returns a cleaned version of the string,\nwhere all characters are converted to lowercase,\nand all punctuation and special characters are removed.", "function_declaration": "def clean_text(text):", "function_name": "clean_text", "parameter_list": "(text)" }, {...
[ 1, 1, 1, 0, 0, 0, 0, 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 re\nfrom collections import Counter\n\ndef clean_text(text):\n \"\"\"\n Cleans the input text by converting to lowercase and removing punctuation and ...
trial_gpt4o_7
{ "original_instruction": "Your task is to design an algorithm that can read a text document and identify the k most frequently occurring words. The document may contain punctuation and special characters, which should be ignored in the word count. Words are case-insensitive, meaning \"Word\" and \"word\" should be c...
0.804299
Evol_7323
C
[ "clean_text", "get_word_frequencies", "top_k_frequent_words" ]
3
[ [ "top_k_frequent_words", "clean_text" ], [ "top_k_frequent_words", "get_word_frequencies" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a98d0120d1a9d8ac478a643f618d571e02d16887
7f9b4b8baa22f1239c4df650213fd203de83aac2
v1.0
complete
Evol
Evol_7480_C
import numpy as np from typing import Set, Dict def levenshtein_distance(str1: str, str2: str) -> int: """ Returns the Levenshtein distance between str1 and str2. >>> levenshtein_distance("kitten", "sitting") == 3 >>> levenshtein_distance("flaw", "lawn") == 2 >>> levenshtein_distance("", "") == 0 ...
import numpy as np def levenshtein_distance(str1, str2): """ Returns the Levenshtein distance between str1 and str2. """ n, m = len(str1), len(str2) if n > m: str1, str2 = str2, str1 n, m = m, n current_row = range(n + 1) for i in range(1, m + 1): previous_row, curr...
from solution import levenshtein_distance, spell_checker def test_levenshtein_distance(): assert levenshtein_distance("kitten", "sitting") == 3 assert levenshtein_distance("flaw", "lawn") == 2 assert levenshtein_distance("", "") == 0 assert levenshtein_distance("gumbo", "gambol") == 2 def test_spell_c...
[ { "docstring": "Returns the Levenshtein distance between str1 and str2.", "function_declaration": "def levenshtein_distance(str1, str2):", "function_name": "levenshtein_distance", "parameter_list": "(str1, str2)" }, { "docstring": "Identifies misspelled words in the sentence and suggests cor...
[ 0, 1, 1, 0, 0, 0, 1, 1, 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": "from typing import List, Dict\nimport numpy as np\n\ndef levenshtein_distance(s1: str, s2: str) -> int:\n \"\"\"\n Compute the Levenshtein distance between t...
trial_gpt4o_9
{ "original_instruction": "Implement a spell checker in Python. The spell checker should take a dictionary of correctly spelled words and a sentence as inputs. It should identify the words in the sentence that are not in the dictionary and suggest corrections. If there is more than one possible correction, it should ...
0.633316
Evol_7480
C
[ "levenshtein_distance", "spell_checker" ]
2
[ [ "spell_checker", "levenshtein_distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
3ec617fb73ffaf6921fc90fe52623705495b00c0
69b637e1701e8e5351dceb57a48a3608c447427d
v1.0
complete
Evol
Evol_7259_C
def filter_greater_than_threshold(lst, threshold): """ Returns a list containing only the elements from lst that are greater than threshold. Parameters: lst (list): List of integers threshold (int): The threshold integer Returns: list: New list with elements greater than threshold ...
def filter_greater_than_threshold(lst, threshold): """ Returns a list containing only the elements from lst that are greater than threshold. Parameters: lst (list): List of integers threshold (int): The threshold integer Returns: list: New list with elements greater than threshold ...
from solution import filter_greater_than_threshold, validate_inputs import pytest def test_filter_greater_than_threshold(): assert filter_greater_than_threshold([1, 2, 3, 4, 5], 3) == [4, 5] def test_filter_greater_than_threshold_with_empty_list(): assert filter_greater_than_threshold([], 3) == [] def test_f...
[ { "docstring": "Returns a list containing only the elements from lst that are greater than threshold.\n\nParameters:\nlst (list): List of integers\nthreshold (int): The threshold integer\n\nReturns:\nlist: New list with elements greater than threshold", "function_declaration": "def filter_greater_than_thres...
[ 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_greater_than_threshold(numbers, threshold):\n \"\"\"\n Filters elements in the list greater than the given threshold.\n\n :param numbers: List ...
trial_gpt4o_9
{ "original_instruction": "Write a function in Python that takes a list of integers and an integer threshold as inputs and returns a new list containing only the elements from the original list that are greater than the given threshold. Your function should handle edge cases such as an empty list or a threshold that ...
0.788527
Evol_7259
C
[ "filter_greater_than_threshold", "validate_inputs" ]
2
[ [ "filter_greater_than_threshold", "validate_inputs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e7b9a57ef7d434b696e85a7baefd640878c6d4f6
77f7e70103568c8086877480227fc12e1ae03866
v1.0
complete
Evol
Evol_7545_C
def find_kth_largest(arr: List[int], k: int) -> int: """ Given an unsorted array of integers, find the Kth largest element in the array without using built-in sorting functions. The function should run in O(n) average time complexity. >>> find_kth_largest([3, 2, 1, 5, 6, 4], 2) 5 >>> find_kth_largest([3...
def partition(arr, low, high): pivot = arr[high] i = low - 1 for j in range(low, high): if arr[j] >= pivot: # We use >= to arrange in non-increasing order i += 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[high] = arr[high], arr[i + 1] return i + 1 def quicksele...
from solution import find_kth_largest def test_kth_largest_in_middle(): arr = [3, 2, 1, 5, 6, 4] assert find_kth_largest(arr, 2) == 5 def test_kth_largest_at_end(): arr = [3, 2, 3, 1, 2, 4, 5, 5, 6] assert find_kth_largest(arr, 4) == 4 def test_kth_largest_single_element(): arr = [1] assert f...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quickselect(arr, low, high, k):", "function_name": "quickselect", "parameter_list...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1 ]
8
easy
0.889
{ "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 pivot = arr[high]\n i = low\n \n for j in range(low, high):\n if arr[j] > pivot: # Note: '>' for finding Kth l...
trial_gpt4o_9
{ "original_instruction": "Given an unsorted array of integers, write a function to find the \"Kth\" largest element in the array without using any built-in sorting functions. The function should run in O(n) average time complexity. Discuss the approach and reasoning behind your solution.", "prompt_id": "00007545",...
0.775125
Evol_7545
C
[ "partition", "quickselect", "find_kth_largest" ]
3
[ [ "find_kth_largest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5d3eeba52ce123ece39c47fa6f4c0aaca4f5f9d7
f3eeaa824ad86f01877a4bce4140d662859efdf4
v1.0
complete
Evol
Evol_6396_C
def filter_palindromes(strings: list) -> list: """ Create a function that accepts a list of strings and returns a new list containing only the strings that are palindromes. A palindrome is a string that reads the same forwards and backwards, ignoring case and non-alphanumeric characters. >>> filter_palindr...
import re def is_palindrome(s: str) -> bool: # Remove non-alphanumeric characters and convert to lowercase clean_s = re.sub(r'[^a-zA-Z0-9]', '', s).lower() # Compare the cleaned string with its reverse return clean_s == clean_s[::-1] def filter_palindromes(strings: list) -> list: return [s for s i...
from solution import filter_palindromes, is_palindrome def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("racecar") == True assert is_palindrome("apple") == False assert is_palindrome("Step on no pets") == True assert is_palindrome("Was it a car or a cat I saw") =...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def filter_palindromes(strings):", "function_name": "filter_palindromes", "parameter_list": "(strings)"...
[ 0, 0, 1, 1, 1, 1, 1, 1, 0, 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 re\n\ndef filter_palindromes(strings: list) -> list:\n \"\"\"\n Filters out palindromic strings from the list. \n Ignores case and non-alphanumeric...
trial_gpt4o_9
{ "original_instruction": "Create a function that accepts a list of strings and returns a new list containing only the strings that are palindromes. A palindrome is a string that reads the same forwards and backwards, ignoring case and non-alphanumeric characters.\n\n### Sample Function Signature\n```python\ndef filt...
0.733815
Evol_6396
C
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
57a0c8c5bf7bc1bbbe963d05ca03525ef35d6648
02f9e0984b0192d45a9faef752d3c5f6f6c7825f
v1.0
complete
Evol
Evol_7277_C
from typing import List, Tuple, Union def calculate_factorial(n: int) -> Union[int, None]: """ Manually computes the factorial of a given integer n. If n is negative, returns None as the factorial of a negative number is undefined. >>> calculate_factorial(0) 1 >>> calculate_factorial(5) ...
def calculate_factorial(n): """ Manually computes the factorial of a given integer n. If n is negative, returns None as the factorial of a negative number is undefined. """ if n < 0: return None factorial = 1 for i in range(2, n + 1): factorial *= i return factorial def ...
from solution import calculate_factorial, list_integers_with_factorial def test_calculate_factorial(): assert calculate_factorial(0) == 1 assert calculate_factorial(1) == 1 assert calculate_factorial(5) == 120 assert calculate_factorial(10) == 3628800 assert calculate_factorial(-3) == None def tes...
[ { "docstring": "Manually computes the factorial of a given integer n.\nIf n is negative, returns None as the factorial of a negative number is undefined.", "function_declaration": "def calculate_factorial(n):", "function_name": "calculate_factorial", "parameter_list": "(n)" }, { "docstring":...
[ 1, 1, 1, 1, 1, 1, 0, 1, 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": "def calculate_factorial(n):\n \"\"\"\n Computes the factorial of a non-negative integer n.\n For negative integers, returns None.\n \"\"\"\n if n < ...
trial_gpt4o_9
{ "original_instruction": "Create a Python function that takes a list of integers and returns a list of tuples, where each tuple contains two elements: the original integer and its factorial. You are not allowed to use any Python built-in functions or libraries for the factorial calculation. Additionally, add appropr...
0.710961
Evol_7277
C
[ "calculate_factorial", "list_integers_with_factorial" ]
2
[ [ "list_integers_with_factorial", "calculate_factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
97c64c1c322e364a394bd43ff6630cee25c1b2a1
4484fec19eeca8cf65ca29ccf29d73fa80281ab4
v1.0
complete
Evol
Evol_7396_C
def is_substring(s1: str, s2: str) -> bool: """ Checks if s1 is a substring of s2. :param s1: The substring to search for :param s2: The string to search within :return: True if s1 is found within s2, False otherwise """ def is_rotation(s1: str, s2: str) -> bool: """ Determines if ...
def is_substring(s1: str, s2: str) -> bool: return s1 in s2 def is_rotation(s1: str, s2: str) -> bool: """ Determines if s2 is a rotation of s1. :param s1: Original string :param s2: String to check if it is a rotation of s1 :return: True if s2 is a rotation of s1, False otherwise """ ...
from solution import is_rotation def test_is_rotation_positive_cases(): assert is_rotation("waterbottle", "erbottlewat") assert is_rotation("abcdef", "cdefab") assert is_rotation("rotation", "tationro") def test_is_rotation_negative_cases(): assert not is_rotation("abc", "abd") assert not is_rotat...
[ { "docstring": null, "function_declaration": "def is_substring(s1, s2):", "function_name": "is_substring", "parameter_list": "(s1, s2)" }, { "docstring": "Determines if s2 is a rotation of s1.\n\n:param s1: Original string\n:param s2: String to check if it is a rotation of s1\n:return: True ...
[ 1, 1, 1, 0, 1, 1, 0, 1, 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 is_substring(s1, s2):\n \"\"\"\n Checks if s1 is a substring of s2.\n \"\"\"\n return s1 in s2\n\ndef is_rotation(s1, s2):\n \"\"\"\n Determi...
trial_gpt4o_7
{ "original_instruction": "Design a function to determine if a given string is a rotation of another string. For instance, the string \"waterbottle\" is a rotation of \"erbottlewat\". Implement a function `is_rotation(s1: str, s2: str) -> bool` that returns True if `s1` is a rotation of `s2`, and False otherwise. Ass...
0.780062
Evol_7396
C
[ "is_substring", "is_rotation" ]
2
[ [ "is_rotation", "is_substring" ] ]
1
[]
false
[]
false
pytest
true
[]
true
14854e70231a1950b246363610225c06f8834d0b
2f67d81a8de7d8bb2b6b2fdc6b29aa5e79a4fe22
v1.0
complete
Evol
Evol_6376_C
from datetime import datetime import heapq def parse_time(time_str): """ Parses a string to a datetime object. """ return datetime.strptime(time_str, '%Y-%m-%d %H:%M') def find_cheapest_route(flights, departure_city, destination_city): """ Find the cheapest flight route from a given departure ...
from datetime import datetime import heapq def parse_time(time_str): """ Parses a string to a datetime object. """ return datetime.strptime(time_str, '%Y-%m-%d %H:%M') def find_cheapest_route(flights, departure_city, destination_city): """ Finds the cheapest flight route from departure_city to...
from solution import find_cheapest_route, incorrect_find_cheapest_route import pytest def test_parse_time(): assert parse_time('2023-10-10 10:10') == datetime(2023, 10, 10, 10, 10) def test_cheapest_route_single_flight(): flights = [ ('A', 'B', '2023-10-10 10:00', '2023-10-10 12:00', 100.0, 'Airline1'...
[ { "docstring": "Parses a string to a datetime object.", "function_declaration": "def parse_time(time_str):", "function_name": "parse_time", "parameter_list": "(time_str)" }, { "docstring": "Finds the cheapest flight route from departure_city to destination_city.", "function_declaration":...
[ 0, 0, 0, 0, 1, 0, 1, 0, 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 datetime\n\ndef parse_time(time_str):\n return datetime.datetime.strptime(time_str, \"%Y-%m-%d %H:%M\")\n\ndef find_cheapest_flight_route(flights, depart...
trial_gpt4o_6
{ "original_instruction": "Given a list of tuples where each tuple represents a flight with the following information: (departure_city, destination_city, departure_time, arrival_time, cost, airline), write a function to find the cheapest flight route from a given departure city to a destination city that consists of ...
0.573767
Evol_6376
C
[ "parse_time", "find_cheapest_route", "incorrect_find_cheapest_route" ]
3
[ [ "find_cheapest_route", "parse_time" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0447fe4f640519c045d191be6312e60ac5e228eb
28f7f233fcccd3def21a3b9f33eca09a15ebc829
v1.0
complete
Evol
Evol_6310_C
def is_palindrome(s: str) -> bool: """ Returns True if the string s is a palindrome, False otherwise. >>> is_palindrome("racecar") True >>> is_palindrome("hello") False >>> is_palindrome("a") True >>> is_palindrome("") True """ pass def longest_palindromic_substring(s: str) ...
def is_palindrome(s: str) -> bool: """ Returns True if the string s is a palindrome, False otherwise. """ return s == s[::-1] def longest_palindromic_substring(s: str) -> str: """ Returns the longest palindromic substring in s. """ n = len(s) if n == 0: return "" longes...
from solution import is_palindrome, longest_palindromic_substring, get_palindrome_info def test_is_palindrome(): assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("a") == True assert is_palindrome("") == True def test_longest_palindromic_substring(): ...
[ { "docstring": "Returns True if the string s is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns the longest palindromic substring in s.", "function_declaration": "def lo...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
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_palindrome(s):\n \"\"\"\n Returns True if the string s is a palindrome, False otherwise.\n \"\"\"\n return s == s[::-1]\n\ndef longest_palindrom...
trial_gpt4o_8
{ "original_instruction": "Write a program to determine if a given string is a palindrome and the length of the longest palindromic substring within the given string.\n\nFor the given input string \"babad\", the program should return:\nIs Palindrome: False\nLongest Palindromic Substring: \"bab\"\nLength: 3", "promp...
0.808999
Evol_6310
C
[ "is_palindrome", "longest_palindromic_substring", "get_palindrome_info" ]
3
[ [ "get_palindrome_info", "is_palindrome" ], [ "get_palindrome_info", "longest_palindromic_substring" ] ]
2
[]
false
[]
false
pytest
true
[]
true
138171e9f581da84983d2c60d1cd44248b0c50e2
2103412796998851c92ea563f00d27f8787e0080
v1.0
complete
Evol
Evol_7567_C
from typing import List def is_prime(num: int) -> bool: """ Returns True if the given number is prime, otherwise False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(1) False >>> is_prime(0) False """ def sort_array(array: List[i...
def is_prime(num): """ Returns True if the given number is prime, otherwise False. """ if num <= 1: return False if num == 2: return True # 2 is the only even prime number if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0:...
from solution import is_prime, sort_array, parse_input def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(1) == False assert is_prime(0) == False def test_sort_array(): assert sort_array([3, 4, ...
[ { "docstring": "Returns True if the given number is prime, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Sorts the array such that prime numbers come before non-prime numbers.", "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 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 program to sort an array of integers such that all prime numbers appear before non-prime numbers, while keeping the relative order of the prime and non-prime numbers the same. The input will be a single line containing integers separated by spaces. Ensure to include input validation...
0.7639
Evol_7567
C
[ "is_prime", "sort_array", "parse_input" ]
3
[ [ "sort_array", "is_prime" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
c6bc173e38df8a84e0a2acd9fdbdb2f1c1dceea7
e7872611f202e8cce72680d96ec1ffd97e516a9c
v1.0
complete
Evol
Evol_6711_C
import random import numpy as np def create_route(city_list): """Create a random route from a list of cities.""" pass def initial_population(pop_size, city_list): """Generate an initial population of routes.""" pass def rank_routes(population): """Rank routes based on their fitness.""" pass ...
import random import numpy as np def create_route(city_list): return random.sample(city_list, len(city_list)) def initial_population(pop_size, city_list): population = [] for i in range(pop_size): population.append(create_route(city_list)) return population def rank_routes(population): fi...
from solution import (create_route, initial_population, rank_routes, selection, mating_pool, breed, breed_population, mutate, mutate_population, next_generation, genetic_algorithm) def test_create_route(): city_list = [(0, 0), (1, 1), (2, 2)] route = create_route(c...
[ { "docstring": null, "function_declaration": "def create_route(city_list):", "function_name": "create_route", "parameter_list": "(city_list)" }, { "docstring": null, "function_declaration": "def initial_population(pop_size, city_list):", "function_name": "initial_population", "pa...
[ 0, 0, 0, 0, 1, 1, 0, 0, 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 random\nimport numpy as np\n\ndef initialize_population(problem_size, population_size):\n \"\"\"\n Initializes a population for the TSP with given pro...
trial_gpt4o_5
{ "original_instruction": "Implement a genetic algorithm to solve the traveling salesman problem. Your solution should include mechanisms for selection, crossover, and mutation operations. Ensure that your algorithm maintains diversity in the population and converges efficiently to a near-optimal solution.", "promp...
0.531833
Evol_6711
C
[ "create_route", "initial_population", "rank_routes", "route_fitness", "route_distance", "selection", "mating_pool", "breed", "breed_population", "mutate", "mutate_population", "next_generation", "genetic_algorithm" ]
13
[ [ "breed_population", "breed" ], [ "genetic_algorithm", "initial_population" ], [ "genetic_algorithm", "next_generation" ], [ "genetic_algorithm", "rank_routes" ], [ "initial_population", "create_route" ], [ "mutate_population", "mutate" ], [ ...
13
[]
false
[]
false
pytest
true
[ "numpy" ]
false
f61c28c659a301f130d0897ca16a2f521049e59a
99e83ff1d6c1d943d6ab7df3520e07806fba5c71