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_1885_C
from datetime import datetime from typing import List, Tuple, Dict import re def parse_log_entry(log_entry: str) -> Tuple[datetime, str]: """ Parse a log entry to extract the timestamp and other metadata. >>> parse_log_entry("2023-10-01T12:00:00 EventA occurred") (datetime(2023, 10, 1, 12, 0, 0), "EventA o...
import heapq from collections import defaultdict import re from datetime import datetime def parse_log_entry(log_entry): """ Parses a log entry to extract the timestamp and other metadata. The log entry format is assumed to be "timestamp metadata". """ log_parts = log_entry.split(' ', 1) timest...
from datetime import datetime from solution import parse_log_entry, merge_and_sort_logs, detect_anomalies, summarize_anomalies def test_parse_log_entry(): log_entry = "2023-10-01T12:00:00 EventA occurred" timestamp, metadata = parse_log_entry(log_entry) assert timestamp == datetime(2023, 10, 1, 12, 0, 0) ...
[ { "docstring": "Parses a log entry to extract the timestamp and other metadata.\nThe log entry format is assumed to be \"timestamp metadata\".", "function_declaration": "def parse_log_entry(log_entry):", "function_name": "parse_log_entry", "parameter_list": "(log_entry)" }, { "docstring": "M...
[ 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 datetime import datetime\n\nclass LogProcessor:\n def __init__(self):\n self.logs = []\n self.anomalies = []\n\n def add_log(self, server_...
trial_gpt4o_8
{ "original_instruction": "Design an efficient algorithm to process and analyze log files generated by a distributed system. The log files record events with timestamps and other metadata, and they are stored across multiple servers. Your solution should aggregate and sort events from these distributed logs by timest...
0.767934
Evol_1885
C
[ "parse_log_entry", "merge_and_sort_logs", "detect_anomalies", "summarize_anomalies" ]
4
[ [ "merge_and_sort_logs", "parse_log_entry" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3775ee64f9272d3a9dd23c3837fad01096377b5d
510fa9140f58785eda531adb08f4967da4715349
v1.0
complete
Evol
Evol_2765_C
def is_prime(n: int) -> bool: """ Checks if a number n is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(16) False >>> is_prime(17) True """ def count_unique_primes(numbers: List[int]) -> int: """ Returns the count of unique prime numbers in the ...
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return T...
from solution import count_unique_primes, is_prime def test_is_prime(): # Test lower primes assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(7) == True # Test non-primes and larger primes assert is_prime(1) == False assert is_prime(4)...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the count of unique prime numbers in the list numbers.", "function_declaration": "def count_unique_primes(numbers):...
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def count_unique_prime_numbers(nums):\n \"\"\"\n Given a list of integers, this function returns the count of unique prime numbers present in the list.\n ...
trial_gpt4o_9
{ "original_instruction": "Given a list of integers, determine the count of unique prime numbers present in the list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\n```\nlist = [2, 3, 5, 7, 8, 10, 11, 13, 13, 3]\n# Output: 5 (unique prime numbers are 2, 3, ...
0.768597
Evol_2765
C
[ "is_prime", "count_unique_primes" ]
2
[ [ "count_unique_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0cffd08420a4d114c8fd72e32fd493db90595727
2d739b385ba7953a309a6017a807e8f579e53544
v1.0
complete
Evol
Evol_2803_C
def longest_unique_substring(s: str) -> (str, int): """ Find the longest substring without repeating characters from a given string. Returns the substring and its length. >>> longest_unique_substring("abcabcbb") ("abc", 3) >>> longest_unique_substring("bbbbb") ("b", 1) >>> longest_...
def longest_unique_substring(s): """ Returns the longest substring without repeating characters from a given string s, and its length. """ char_index_map = {} longest_substring = "" start = 0 for i, char in enumerate(s): if char in char_index_map and char_index_map[char] >= star...
from solution import longest_unique_substring, longest_unique_substrings def test_longest_unique_substring_single_string(): assert longest_unique_substring("abcabcbb") == ("abc", 3) assert longest_unique_substring("bbbbb") == ("b", 1) assert longest_unique_substring("pwwkew") == ("wke", 3) assert longe...
[ { "docstring": "Returns the longest substring without repeating characters from a given string s,\nand its length.", "function_declaration": "def longest_unique_substring(s):", "function_name": "longest_unique_substring", "parameter_list": "(s)" }, { "docstring": "Returns the longest substri...
[ 1, 0, 1, 1, 0, 1, 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 longest_substring_no_repeats(s):\n \"\"\"\n Finds the longest substring without repeating characters from a given string.\n \n Args:\n s (str): ...
trial_gpt4o_6
{ "original_instruction": "Write a Python function to find the longest substring without repeating characters from a given string. The function should return the substring and its length. Document any assumptions you make, and analyze the time complexity of your solution. Additionally, extend the function to handle a...
0.728807
Evol_2803
C
[ "longest_unique_substring", "longest_unique_substrings" ]
2
[ [ "longest_unique_substrings", "longest_unique_substring" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0a74365d3e7e914732cd242aacd8203e1c8f27e1
57d1257a57e205eafb86ae4bac6df42f5eac03ec
v1.0
complete
Evol
Evol_2653_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(9) == False >>> is_prime(11) == True """ pass def filter_primes(int_list: List[int]) -> List[int]: """ ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import 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(9) == False assert is_prime(11) == True def test_filter_primes(): assert filter_primes([4, 7, 10, 1...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.", "function_declaration": "def...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ...
trial_gpt4o_5
{ "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, in the same order. Ensure that your function is optimized for efficiency. For example, given the list [4, 7, 10, 11, 13, 18, 19], the function should return [7, 1...
0.780954
Evol_2653
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00c5eaf9c45b91dfa3edfca25b44ca9d3b217971
b15424098a5c5d8f74995c723b5b5fb5b5c12b4d
v1.0
complete
Evol
Evol_2913_C
from typing import List def filter_primes(numbers: List[int]) -> List[int]: """Write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list, in the same order. >>> filter_primes([10, 29, 15, 37, -3, 17, 23]) [29, 37, 17, 23] >>> filter_...
from typing import List def is_prime(n: int) -> bool: 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: List[int]) -> List[...
from solution import filter_primes def test_filter_primes_with_primes_and_non_primes(): assert filter_primes([10, 29, 15, 37, -3, 17, 23]) == [29, 37, 17, 23] def test_filter_primes_with_mixed_numbers(): assert filter_primes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 3, 5, 7] def test_filter_primes_with_empty_li...
[ { "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, 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\nimport math\n\ndef is_prime(num: int) -> bool:\n if num <= 1:\n return False\n if num == 2:\n return True\n if num ...
trial_gpt4o_7
{ "original_instruction": "Write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list, in the same order. \n\nFunction Signature: \n```python\ndef filter_primes(numbers: List[int]) -> List[int]:\n pass\n```\n\nInput: \n- A list of integers (0 <= l...
0.671771
Evol_2913
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
82336ac7a7ab5c835d38e9d30e14fba2b32c383d
9d0643aba2edd0f2c8310cba9f9692e98163e3d6
v1.0
complete
Evol
Evol_2821_C
def first_n_primes(n: int) -> List[int]: """ Returns a list containing the first `n` prime numbers. >>> first_n_primes(0) == [] >>> first_n_primes(1) == [2] >>> first_n_primes(5) == [2, 3, 5, 7, 11] >>> first_n_primes(10) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] >>> first_n_primes(20) == [2,...
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True d...
from solution import first_n_primes def test_first_n_primes_zero(): assert first_n_primes(0) == [] 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, 7, 11] def test_first_n_primes_ten(): assert first_n_primes(10) == [...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of the first n prime numbers.", "function_declaration": "def first_n_primes(n):", ...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(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_0
{ "original_instruction": "Write a function in Python that takes an integer `n` and returns a list containing the first `n` prime numbers. Your solution should be efficient and consider the time complexity of the algorithm used to find prime numbers.", "prompt_id": "00002821", "row_id": 2821, "seed_ids": "[3756...
0.780618
Evol_2821
C
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3e6f6beb06168cc5d7a4df1dd68c2ed7a91e5040
f569602d9bddd96d69991d766a0606e4b5693454
v1.0
complete
Evol
Evol_2303_C
def find_closest_pair(points: List[Tuple[int, int]]) -> Tuple[Tuple[int, int], Tuple[int, int]]: """Find the closest pair of points in a given list of points in a 2D plane. Args: points (List[Tuple[int, int]]): A list of points where each point is represented as a tuple (x, y). Returns: Tu...
import math from typing import List, Tuple def euclidean_distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float: return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def find_closest_pair(points: List[Tuple[int, int]]) -> Tuple[Tuple[int, int], Tuple[int, int]]: min_dista...
from solution import find_closest_pair def test_find_closest_pair_general_case(): points = [(1, 2), (4, 6), (7, 8), (2, 1), (3, 4)] assert find_closest_pair(points) in [((1, 2), (2, 1)), ((2, 1), (1, 2))] def test_find_closest_pair_two_points(): points = [(1, 1), (2, 2)] assert find_closest_pair(p...
[ { "docstring": null, "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def find_closest_pair(points):", "function_name": "find_closest_pair", ...
[ 1, 1, 0, 0, 0, 1, 1, 0, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\nfrom math import sqrt\n\ndef euclidean_distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float:\n return sqrt((p1[0] - p2[0]...
trial_gpt4o_9
{ "original_instruction": "You are given a list of points in a 2D plane, where each point is represented as a tuple (x, y). Write a Python function `find_closest_pair(points)` that finds the closest pair of points in the list and returns the pair with the smallest distance between them. If there are multiple pairs wi...
0.714932
Evol_2303
C
[ "euclidean_distance", "find_closest_pair" ]
2
[ [ "find_closest_pair", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8035a0714b9fc97c73a3f5713f052a01851cb8ab
785a67392b07d4bc4a24d5efbe259c39413f0845
v1.0
complete
Evol
Evol_2187_C
import string from typing import Dict def word_histogram(sentence: str) -> Dict[str, int]: """ Create a word frequency histogram from the given input sentence. Ignore punctuation and case differences. Args: sentence (str): A string sentence from which to build the histogram. Returns: ...
import string def word_histogram(sentence): """ Returns a dictionary with words as keys and their frequency as values. Words are considered case-insensitive and punctuation is ignored. """ # Remove punctuation and convert to lower case translator = str.maketrans('', '', string.punctuation) ...
from solution import word_histogram, most_frequent_word def test_word_histogram_basic(): sentence = "Hello world" expected = {"hello": 1, "world": 1} assert word_histogram(sentence) == expected def test_word_histogram_with_punctuation(): sentence = "Hello, world! Hello." expected = {"hello": 2, "w...
[ { "docstring": "Returns a dictionary with words as keys and their frequency as values.\nWords are considered case-insensitive and punctuation is ignored.", "function_declaration": "def word_histogram(sentence):", "function_name": "word_histogram", "parameter_list": "(sentence)" }, { "docstri...
[ 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 string\n\ndef word_histogram(sentence):\n \"\"\"\n Returns a dictionary with words as keys and their frequency as values.\n \"\"\"\n # Remove pu...
trial_gpt4o_7
{ "original_instruction": "Implement a Python function named \"word_histogram\" that takes a string as input and returns a dictionary. The dictionary should have individual words from the input string as keys and the number of times each word appears in the string as values. Assume that the input string is a sentence...
0.777486
Evol_2187
C
[ "word_histogram", "most_frequent_word" ]
2
[ [ "most_frequent_word", "word_histogram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5980e2e5a85e1e815aab0ff17783e567b5eeed33
247d6316342b276a501f4871bfd925a3c3d0e5c3
v1.0
complete
Evol
Evol_2232_C
import numpy as np from scipy.optimize import linear_sum_assignment def read_matrices(filename: str): """ Reads a file containing multiple 5x5 matrices and returns a list of numpy arrays. >>> read_matrices('example.txt') [array([[ 7, 53, 183, 439, 863], [497, 383, 563, 79, 973], [2...
import numpy as np from scipy.optimize import linear_sum_assignment import os def read_matrices(filename): with open(filename, 'r') as file: data = file.read() matrices = [] individual_matrix = [] for line in data.splitlines(): if line.strip(): individual_matrix.append(...
from solution import read_matrices, maximum_sum_assignment, solve_problem import numpy as np def test_read_matrices(): filename = 'test_matrices.txt' data = """7 53 183 439 863 497 383 563 79 973 287 63 343 169 583 627 343 773 959 943 767 473 103 699 303 7 53 183 439 863 497 383 563 79 973 287 63 343 169 583 ...
[ { "docstring": null, "function_declaration": "def read_matrices(filename):", "function_name": "read_matrices", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def maximum_sum_assignment(matrix):", "function_name": "maximum_sum_assignment", "paramet...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def read_matrices_from_file(filepath):\n \"\"\"\n Reads matrices from the given file and returns a list of matrices.\n Each matrix is represented as a lis...
trial_gpt4o_5
{ "original_instruction": "<div class=\"center\"><img src=\"project/images/p345_matrix1.gif\" class=\"dark_img\" alt=\"p345_matrix1.gif\" /></div>\n\n<p>The image above shows a 5x5 matrix with each cell containing an integer. This is just one example of a matrix used in the problem described below.</p>\n\n<p>The text...
0.620449
Evol_2232
C
[ "read_matrices", "maximum_sum_assignment", "solve_problem" ]
3
[ [ "solve_problem", "maximum_sum_assignment" ], [ "solve_problem", "read_matrices" ] ]
2
[]
false
[]
false
pytest
true
[ "numpy", "scipy" ]
false
93c54ada2ffc82ec278074ab1e6d196941519b76
14642e53902bba2954e0e433186f11c6d80d05d9
v1.0
complete
Evol
Evol_2900_C
def extract_primes(input_list): """ Write a Python function that takes a list of integers and returns a new list containing only the prime numbers from the original list. If an input element is not an integer, the function should skip it and continue processing the next element. Optimize the function to h...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import extract_primes def test_extract_primes_with_mixed_inputs(): assert extract_primes([11, 22, "foo", 3, 4.5, 5]) == [11, 3, 5] def test_extract_primes_with_non_primes(): assert extract_primes([6, 8, 10, 15]) == [] def test_extract_primes_with_primes(): assert extract_primes([2, 3, 5, 7,...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the input list of integers.\nSkips non-integer elements."...
[ 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 the given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n...
trial_gpt4o_8
{ "original_instruction": "Write a Python function that takes a list of integers and returns a new list containing only the prime numbers from the original list. If an input element is not an integer, the function should skip it and continue processing the next element. Optimize the function to handle large lists eff...
0.682183
Evol_2900
C
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b85f8461963e87ff51f52d4d72c6a5a578f14499
c7c24b6a30a4ff86cb7639972a9d382800b73842
v1.0
complete
Evol
Evol_2974_C
def is_prime(n): """ Check if the integer n is a prime number. Parameters: - n (int): The integer to check for primality. Returns: - bool: True if n is prime, otherwise False. """ # Your code here def prime_in_range(start, end): """ Find all prime numbers in the range [start,...
def is_prime(n): """ Check if the integer n is a prime number. Parameters: - n (int): The integer to check for primality. Returns: - bool: True if n is prime, otherwise False. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number ...
from solution import is_prime, prime_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False # 1 is not a prime number ...
[ { "docstring": "Check if the integer n is a prime number.\n\nParameters:\n- n (int): The integer to check for primality.\n\nReturns:\n- bool: True if n is prime, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstrin...
[ 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 the integer n is a prime number.\n \n Parameters:\n - n (int): The integer to check for primality.\n \n R...
trial_gpt4o_9
{ "original_instruction": "Write a function `is_prime(n)` that checks whether a given integer `n` is a prime number. Return `True` if `n` is prime, and `False` otherwise. Then, using this helper function, create a function `prime_in_range(start, end)` that returns a list of all prime numbers within the given range `s...
0.773961
Evol_2974
C
[ "is_prime", "prime_in_range" ]
2
[ [ "prime_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4b688cfef70864fbb9a5d4221f59198f82b75c03
28ccef8bffad7df5f917137f71ccc9e2ad05ee9a
v1.0
complete
Evol
Evol_2823_C
import math from typing import List def is_prime(n: int) -> bool: """ Check if a number n is a prime number """ pass def is_t_prime(n: int) -> str: """ Given an integer, determine whether it is a T-prime or not. >>> is_t_prime(49) 'YES' >>> is_t_prime(10) 'NO' >>> is_t_prime(4) ...
import math def is_prime(n): """ Check 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 is_t_prime def test_t_prime(): assert is_t_prime(49) == "YES" assert is_t_prime(10) == "NO" assert is_t_prime(4) == "YES" assert is_t_prime(9) == "YES" assert is_t_prime(25) == "YES" assert is_t_prime(1) == "NO" assert is_t_prime(1000000000000) == "NO" # This is 10^12 a...
[ { "docstring": "Check if a number n is a prime number ", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Check if a number n is a T-prime ", "function_declaration": "def is_t_prime(n):", "function_name": "is_t_prime"...
[ 1, 1, 0, 0, 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": "import math\n\ndef is_prime(n):\n \"\"\" Check if a number n is a prime number \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True...
trial_gpt4o_0
{ "original_instruction": "Given an integer, determine whether it is a T-prime or not. A T-prime is a number that is the square of a prime number. For example, 4 is a T-prime because it is equal to $2^2$, where 2 is a prime number.\n\n### Input\n- A single integer $n$, where $1 \\leq n \\leq 10^{12}$.\n\n### Output\n...
0.765593
Evol_2823
C
[ "is_prime", "is_t_prime" ]
2
[ [ "is_t_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5ed09fd6d1e32952e3f5a7449e3054cf08d2d0f1
6180c00c0a6a1775ea82e3d0ef83c37522fb11fb
v1.0
complete
Evol
Evol_1737_C
def flatten(lst): """ Helper function to flatten a nested list. >>> flatten([1, [2, 3], 4, [5, [6, 7]]]) [1, 2, 3, 4, 5, 6, 7] >>> flatten([1, 2, [3]]) [1, 2, 3] >>> flatten([[1, 2], 3]) [1, 2, 3] >>> flatten([1, [2], 3, [4, [5]]]) [1, 2, 3, 4, 5] """ def merge_sorted_lists(list1, list2): ...
def flatten(lst): """ Helper function to flatten a nested list. """ flattened_list = [] for item in lst: if isinstance(item, list): flattened_list.extend(flatten(item)) else: flattened_list.append(item) return flattened_list def merge_sorted_lists(list1, ...
from solution import flatten, merge_sorted_lists def test_flatten(): assert flatten([1, [2, 3], 4, [5, [6, 7]]]) == [1, 2, 3, 4, 5, 6, 7] assert flatten([1, 2, [3]]) == [1, 2, 3] assert flatten([[1, 2], 3]) == [1, 2, 3] assert flatten([1, [2], 3, [4, [5]]]) == [1, 2, 3, 4, 5] def test_merge_sorted_lis...
[ { "docstring": "Helper function to flatten a nested list.", "function_declaration": "def flatten(lst):", "function_name": "flatten", "parameter_list": "(lst)" }, { "docstring": "Merges two sorted lists into one sorted list, handling nested lists.", "function_declaration": "def merge_sort...
[ 1, 1, 0, 0, 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": "def flatten_and_merge(list1, list2):\n \"\"\"\n This function takes in two sorted lists, possibly containing nested lists,\n flattens them and merges them...
trial_gpt4o_9
{ "original_instruction": "Implement a function `merge_sorted_lists` that takes in two sorted lists and merges them into a single sorted list. You are required to maintain the order of elements, ensuring that the final list is sorted in ascending order. \n\nAdditionally, the function should handle nested lists where ...
0.646758
Evol_1737
C
[ "flatten", "merge_sorted_lists" ]
2
[ [ "merge_sorted_lists", "flatten" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b525010bd02ebaa14cbd0d3cf04d0c70f977eab6
936d6591796cba307d4747b8b34a80e6df30147a
v1.0
complete
Evol
Evol_2615_C
import time import asyncio def synchronous_task(task_name, wait_time): """ Simulate a synchronous task by sleeping for wait_time seconds. """ print(f"Task {task_name} starting") time.sleep(wait_time) print(f"Task {task_name} completed") def run_synchronous_tasks(): """ Run multiple syn...
import time import asyncio def synchronous_task(task_name, wait_time): """ Simulate a synchronous task by sleeping for wait_time seconds. """ print(f"Task {task_name} starting") time.sleep(wait_time) print(f"Task {task_name} completed") def run_synchronous_tasks(): """ Run multiple syn...
import time import asyncio from solution import synchronous_task, run_synchronous_tasks, asynchronous_task, run_asynchronous_tasks def test_synchronous_task(): start_time = time.time() run_synchronous_tasks() elapsed_time = time.time() - start_time assert elapsed_time >= 10, "Synchronous tasks should t...
[ { "docstring": "Simulate a synchronous task by sleeping for wait_time seconds.", "function_declaration": "def synchronous_task(task_name, wait_time):", "function_name": "synchronous_task", "parameter_list": "(task_name, wait_time)" }, { "docstring": "Run multiple synchronous tasks.", "fu...
[ 0, 1, 1, 1, 1, 1, 1, 0, 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 synchronous_task(n):\n \"\"\"\n Performs a synchronous task by sleeping for n seconds\n and then returning a completion message.\n \"\"\"\n from...
trial_gpt4o_9
{ "original_instruction": "Explain the difference between synchronous and asynchronous programming. Provide a Python example that demonstrates the benefits of using asynchronous programming over synchronous programming in handling multiple tasks.", "prompt_id": "00002615", "row_id": 2615, "seed_ids": "[32364]" ...
0.637689
Evol_2615
C
[ "synchronous_task", "run_synchronous_tasks", "asynchronous_task", "run_asynchronous_tasks" ]
4
[ [ "run_asynchronous_tasks", "asynchronous_task" ], [ "run_synchronous_tasks", "synchronous_task" ] ]
2
[]
false
[]
false
pytest
true
[]
true
93cdd425636970e3fc5c0cca1c20090cd13c3d54
abe388ece63a3c26711aec701c7f9d78f0497a6e
v1.0
complete
Evol
Evol_2925_C
from typing import List def filter_primes(numbers: List[int]) -> List[int]: """ Create a Python function that accepts a list of integers and returns a new list containing only the prime numbers from the original list. The function should remove any duplicates and maintain the original order of the first ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes...
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_with_duplicates(): assert filter_primes([17, 23, 23, 4, 2, 5, 4, 29, 5, 17]) == [17, 23, 2, 5, 29] def test_filter_primes_no_primes(): assert filter_pr...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of unique prime numbers maintaining the original order.", "function_declaration": "def filte...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n r...
trial_gpt4o_9
{ "original_instruction": "Create a Python function that accepts a list of integers and returns a new list containing only the prime numbers from the original list. The function should remove any duplicates and maintain the original order of the first occurrence of each prime number.\nnumbers = [17, 23, 23, 4, 2, 5, ...
0.656971
Evol_2925
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4afad26e13a90b218c9c7d7aa1e803754bf6d14e
39f3e37bf3cdd0c1b1ee7e7fae3b84c803112ff9
v1.0
complete
Evol
Evol_2624_C
def is_arithmetic_sequence(sequence: list[int]) -> bool: """ Function to check if a list forms an arithmetic sequence. >>> is_arithmetic_sequence([1, 2, 3, 4, 5]) True >>> is_arithmetic_sequence([2, 4, 6, 8]) True >>> is_arithmetic_sequence([1, 3, 6]) False >>> is_arithmetic_sequence([5, 5, 5, 5]) T...
def is_arithmetic_sequence(sequence): """ Returns True if the given sequence forms an arithmetic sequence, False otherwise. """ if len(sequence) < 2: return True diff = sequence[1] - sequence[0] for i in range(2, len(sequence)): if sequence[i] - sequence[i-1] != diff: ...
from solution import is_arithmetic_sequence, missing_number_in_sequence, restore_arithmetic_sequence def test_is_arithmetic_sequence(): assert is_arithmetic_sequence([1, 2, 3, 4, 5]) == True assert is_arithmetic_sequence([2, 4, 6, 8]) == True assert is_arithmetic_sequence([1, 3, 6]) == False assert is_...
[ { "docstring": "Returns True if the given sequence forms an arithmetic sequence, False otherwise.", "function_declaration": "def is_arithmetic_sequence(sequence):", "function_name": "is_arithmetic_sequence", "parameter_list": "(sequence)" }, { "docstring": "Identifies and returns the single ...
[ 0, 0, 0, 1, 1, 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": "def is_arithmetic_sequence(sequence):\n \"\"\"\n Check if the given list of integers forms an arithmetic sequence.\n \"\"\"\n if len(sequence) < 2:\n ...
trial_gpt4o_4
{ "original_instruction": "Design and provide three related functions `is_arithmetic_sequence`, `missing_number_in_sequence`, and `restore_arithmetic_sequence`. Here are the key requirements for each function:\n\n- `is_arithmetic_sequence`: Create a function to check if a given list of integers forms an arithmetic se...
0.610223
Evol_2624
C
[ "is_arithmetic_sequence", "missing_number_in_sequence", "restore_arithmetic_sequence" ]
3
[ [ "restore_arithmetic_sequence", "is_arithmetic_sequence" ], [ "restore_arithmetic_sequence", "missing_number_in_sequence" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9cc7fe0539156b9683ed9ad2fcdf1c0c2e1dbad2
c6ed77cb660076957e0b381325b5e0198b727bf1
v1.0
complete
Evol
Evol_1948_C
import string from collections import Counter STOP_WORDS = { 'i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're", "you've", "you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself', 'she', "she's", 'her', 'hers', 'herself', 'it', "it's", 'its', ...
import string from collections import Counter STOP_WORDS = { 'i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're", "you've", "you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself', 'she', "she's", 'her', 'hers', 'herself', 'it', "it's", 'its', ...
from solution import get_top_five_words def test_get_top_five_words_empty_file(tmp_path): file = tmp_path / "empty.txt" file.write_text("") assert get_top_five_words(file) == [] def test_get_top_five_words_single_word(tmp_path): file = tmp_path / "single.txt" file.write_text("hello") assert ge...
[ { "docstring": null, "function_declaration": "def preprocess_text(text):", "function_name": "preprocess_text", "parameter_list": "(text)" }, { "docstring": null, "function_declaration": "def get_top_five_words(file_path):", "function_name": "get_top_five_words", "parameter_list":...
[ 0, 0, 0, 0, 0, 1, 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 re\nimport collections\nfrom typing import List, Tuple\n\n# Define common English stop words\nSTOP_WORDS = set([\n \"i\", \"me\", \"my\", \"myself\", \"w...
trial_gpt4o_6
{ "original_instruction": "Formulate a Python function that analyzes a given text file and identifies the top 5 most frequently occurring words. The function should preprocess the text by converting it to lowercase, removing punctuation, and disregarding common stop words. It must return a list of tuples, each contai...
0.926861
Evol_1948
C
[ "preprocess_text", "get_top_five_words" ]
2
[ [ "get_top_five_words", "preprocess_text" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a4b3e0ddb212b78d629eccb80f4cea7a7bbf196b
11733f15be0a04be4625d8bf9bce04d61b1de961
v1.0
complete
Evol
Evol_2893_C
def next_element(n) -> int: """ Returns the next element in the sequence following the "Multiply by 4 and Subtract 3" rule. """ pass def generate_sequence(start: int, length: int) -> List[int]: """ Generates a sequence of given length starting from the given value. """ pass # Test...
def next_element(n): """ Returns the next element in the sequence following the "Multiply by 4 and Subtract 3" rule. """ return (n * 4) - 3 def generate_sequence(start, length): """ Generates a sequence of given length starting from the given value. """ sequence = [start] for _...
from solution import next_element, generate_sequence def test_next_element(): assert next_element(1) == 1 assert next_element(2) == 5 assert next_element(-1) == -7 def test_generate_sequence(): assert generate_sequence(1, 5) == [1, 1, 1, 1, 1] assert generate_sequence(2, 3) == [2, 5, 17] asser...
[ { "docstring": "Returns the next element in the sequence following \nthe \"Multiply by 4 and Subtract 3\" rule.", "function_declaration": "def next_element(n):", "function_name": "next_element", "parameter_list": "(n)" }, { "docstring": "Generates a sequence of given length starting from the...
[ 0, 0, 1, 0, 1, 0, 0, 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 sequence_element(n):\n \"\"\"\n Returns the nth element in the sequence starting with 1,\n and using the \"Multiply by 4 and Subtract 3\" rule.\n \...
trial_gpt4o_7
{ "original_instruction": "Emily is applying the \"Multiply by 4 and Subtract 3\" rule to create her numerical sequence starting with 1. Which of the following statements about the sequence is most accurate?\n\nA) The fifth element in the sequence will be an even number.\nB) There will always be a mix of even and odd...
0.607872
Evol_2893
C
[ "next_element", "generate_sequence" ]
2
[ [ "generate_sequence", "next_element" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9175a507559c69ff73f37670434b48ad239fbf81
7f2a6f2a6b341c4718bffccb5551cecae29fe031
v1.0
complete
Evol
Evol_1623_C
import pandas as pd import matplotlib.pyplot as plt def calculate_ema(data, span): """ Computes the Exponential Moving Average (EMA) for a given data series. Parameters: - data (pandas.Series): The data series to compute the EMA on. - span (int): The span for the EMA calculation. Returns...
import pandas as pd import matplotlib.pyplot as plt def calculate_ema(data, span): """ Computes the Exponential Moving Average (EMA) for a given data series. Parameters: - data (pandas.Series): The data series to compute the EMA on. - span (int): The span for the EMA calculation. Returns:...
import pandas as pd import tempfile import pytest from solution import calculate_ema, process_csv, plot_stock_with_ema def test_calculate_ema(): data = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) span = 2 expected_ema = pd.Series([1.0, 1.6666667, 2.5555556, 3.5185185, 4.5061728, 5.5020577, 6.5006862, 7.5002...
[ { "docstring": "Computes the Exponential Moving Average (EMA) for a given data series.\n\nParameters:\n- data (pandas.Series): The data series to compute the EMA on.\n- span (int): The span for the EMA calculation.\n\nReturns:\n- pandas.Series: The EMA of the input data series.", "function_declaration": "de...
[ 0, 0, 0, 0, 0, 1, 1, 0, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef calculate_ema(df, span):\n \"\"\"\n Calculate the Exponential Moving Average ...
trial_gpt4o_6
{ "original_instruction": "Design a Python program that reads a CSV file containing rows of numerical data representing different stocks' prices over time. Your task is to implement the Exponential Moving Average (EMA) for each stock. The program should allow the user to specify the span for the EMA calculation. Pres...
0.667181
Evol_1623
C
[ "calculate_ema", "process_csv", "plot_stock_with_ema" ]
3
[ [ "plot_stock_with_ema", "calculate_ema" ], [ "process_csv", "calculate_ema" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "pandas" ]
false
8088f020ef71f88f560e3df4152a5018655e31d3
ec35c8840f7fea9a98144cf943f5b71bd1214c6a
v1.0
complete
Evol
Evol_2730_C
def hasZeroPrimaryDiagonal(matrix): """ Check if there are any zeros along the primary diagonal of the matrix. >>> hasZeroPrimaryDiagonal([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == False >>> hasZeroPrimaryDiagonal([[1, 0], [0, 2]]) == False >>> hasZeroPrimaryDiagonal([[1, 2, 3], [4, 0, 6], [7, 8, 9]]) =...
def hasZeroPrimaryDiagonal(matrix): """ Check if there are any zeros along the primary diagonal of the matrix. """ for i in range(min(len(matrix), len(matrix[0]))): if matrix[i][i] == 0: return True return False def hasZeroSecondaryDiagonal(matrix): """ Check if there ar...
from solution import hasZeroPrimaryDiagonal, hasZeroSecondaryDiagonal, checkDiagonals def test_hasZeroPrimaryDiagonal(): matrix1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] matrix2 = [[1, 0], [0, 2]] matrix3 = [[1, 2, 3], [4, 0, 6], [7, 8, 9]] assert hasZeroPrimaryDiagonal(matrix1) == False assert hasZeroP...
[ { "docstring": "Check if there are any zeros along the primary diagonal of the matrix.", "function_declaration": "def hasZeroPrimaryDiagonal(matrix):", "function_name": "hasZeroPrimaryDiagonal", "parameter_list": "(matrix)" }, { "docstring": "Check if there are any zeros along the secondary ...
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def hasZeroPrimaryDiagonal(matrix):\n \"\"\"\n Check if the matrix has any zeroes along the primary diagonal.\n \"\"\"\n rows = len(matrix)\n for i ...
trial_gpt4o_2
{ "original_instruction": "Create a Python function to determine if a matrix contains any zeros along its diagonals. Provide two matrices and write code to identify if they contain any zero values along both the primary and secondary diagonals. Optimize your algorithm for efficient processing. In addition, ensure tha...
0.493163
Evol_2730
C
[ "hasZeroPrimaryDiagonal", "hasZeroSecondaryDiagonal", "checkDiagonals" ]
3
[ [ "checkDiagonals", "hasZeroPrimaryDiagonal" ], [ "checkDiagonals", "hasZeroSecondaryDiagonal" ] ]
2
[]
false
[]
false
pytest
true
[]
true
db2d92514566c7f8ad3035927d38553ac5391233
d2e4cdd6ac2ee2cae9bc04f3a862d17a86f692c6
v1.0
complete
Evol
Evol_2830_C
import os from typing import List, Tuple def read_integers_from_file(file_path: str) -> List[int]: """ Reads a list of integers from the specified file. Each line in the file should contain one integer. Returns a list of integers. Raises ValueError if the file contains non-integer values. >>...
import os def read_integers_from_file(file_path): """ Reads a list of integers from the specified file. Each line in the file should contain one integer. Returns a list of integers. Raises ValueError if the file contains non-integer values. """ integers = [] try: with open(file...
import os import pytest from solution import read_integers_from_file, write_primes_to_file, sum_and_count_primes, is_prime # Helper function for creating test files def create_test_file(file_path, lines): with open(file_path, 'w') as file: file.write('\n'.join(lines)) def test_read_integers_from_file(): ...
[ { "docstring": "Reads a list of integers from the specified file.\nEach line in the file should contain one integer.\n\nReturns a list of integers.\nRaises ValueError if the file contains non-integer values.", "function_declaration": "def read_integers_from_file(file_path):", "function_name": "read_inte...
[ 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if the number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\...
trial_gpt4o_3
{ "original_instruction": "Create a Python program that reads a file containing a list of integers, one per line. Implement a function to identify all prime numbers from the list and write them into a new file. Then, create another function to read this new file, sum all the prime numbers, and return the sum along wi...
0.661596
Evol_2830
C
[ "read_integers_from_file", "is_prime", "write_primes_to_file", "sum_and_count_primes" ]
4
[ [ "write_primes_to_file", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8f26ca716ff18cffbfb85e85a650271896904558
a5012ab2e3b0ad11c793acc28664bba99d7bc886
v1.0
complete
Evol
Evol_2564_C
def is_prime(num): """ Checks if a number is prime. """ pass def categorize_numbers(n, numbers): """ Categorizes the provided list of numbers into odd, even, and prime. Parameters: n (int): The number of elements in the list numbers (list): The list containing `n` random numbers ...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def categorize_numbers(...
from solution import categorize_numbers def test_all_odd_numbers(): assert categorize_numbers(5, [1, 3, 5, 7, 9]) == { "odd": [1, 3, 5, 7, 9], "even": [], "prime": [3, 5, 7] } def test_all_even_numbers(): assert categorize_numbers(4, [2, 4, 6, 8]) == { "odd": [], ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Categorizes the provided list of numbers into odd, even, and prime.\n\nParameters:\nn (int): The number of elements in the li...
[ 1, 1, 0, 0, 0, 1, 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": "def is_prime(num):\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n return False\n for i in range(3...
trial_gpt4o_9
{ "original_instruction": "Write a function in Python that takes an integer `n` and a list of `n` random numbers as input. The function should return a dictionary with three keys: \"odd\", \"even\", and \"prime\". The values corresponding to these keys should be lists containing the odd numbers, even numbers, and pri...
0.749235
Evol_2564
C
[ "is_prime", "categorize_numbers" ]
2
[ [ "categorize_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
768a08439662e60741cdd8d46836a02a50d92c2d
50cb42517e74ea9b41de680884396eb53a177d6d
v1.0
complete
Evol
Evol_3133_C
def filter_primes(input_list: List[int]) -> List[int]: """ Returns a list of prime numbers from the input list. >>> filter_primes([10, 15, 3, 7, 19, 22, 23, 25, 29]) [3, 7, 19, 23, 29] >>> filter_primes([4, 6, 8, 10, 12]) [] >>> filter_primes([2, 5, 7, 11, 13]) [2, 5, 7, 11, 13] >>> filter_prime...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes...
from solution import filter_primes def test_filter_primes(): assert filter_primes([10, 15, 3, 7, 19, 22, 23, 25, 29]) == [3, 7, 19, 23, 29] assert filter_primes([4, 6, 8, 10, 12]) == [] assert filter_primes([2, 5, 7, 11, 13]) == [2, 5, 7, 11, 13] assert filter_primes([1, 2, 3, 4, 5]) == [2, 3, 5] a...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list.", "function_declaration": "def filter_primes(input_lis...
[ 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 <= 3:\n return True\n if n % 2 == 0 or n % ...
trial_gpt4o_9
{ "original_instruction": "Write a function that takes a list of integers as an input and returns a new list that contains only the prime numbers from the original list. To solve this problem, do not use any library functions related to prime number generation or checking. Additionally, optimize the function to minim...
0.680879
Evol_3133
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
90882e60a9e1f0cacdcc04ee68fc4091464dfd16
54470191e4510c4d78fe55487ce2517885ac9e3d
v1.0
complete
Evol
Evol_3072_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def filter_primes(lst: List[int]) -> List[int]: """ Returns a list containing only the prime numbers from the original list. >>> filter_primes([2, 3, ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import is_prime, 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(29) == True assert is_prime(25) == False assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the original list.", "function_declaration": "def fil...
[ 1, 1, 0, 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 Checks if a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return T...
trial_gpt4o_8
{ "original_instruction": "Design an algorithm that receives a list of integers and returns a new list containing only the prime numbers from the original list. Optimize your solution to handle lists containing up to 10,000 integers efficiently. Provide a Python function implementing the algorithm and include necessa...
0.765783
Evol_3072
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4a068265f92d543bb4282afa6e20e19b6f27062b
3c22bb6a4485ccd5d17d7979c1357ebf22d8a3ed
v1.0
complete
Evol
Evol_2261_C
def extract_primes(numbers: List[int]) -> List[int]: """ Returns a list of prime numbers from the given list of integers. :param numbers: A list of integers :return: A list of prime numbers """ # Your code goes here from typing import List def test_extract_primes_with_only_primes(): a...
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 extract_primes(numbers): """ R...
from solution import extract_primes def test_extract_primes_with_only_primes(): assert extract_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_extract_primes_with_no_primes(): assert extract_primes([4, 6, 8, 9, 12]) == [] def test_extract_primes_with_mixed_numbers(): assert extract_primes([2, 4, 5,...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.\n\n:param numbers: A list of integers\n:return: A list of prime 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 :param n: Integer number to check\n :return: True if n is prime, False otherwise\n \"\"\"...
trial_gpt4o_9
{ "original_instruction": "Develop a function in Python that accepts a list of integers and returns a new list containing only the prime numbers from the original list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should be named `extract_primes...
0.669187
Evol_2261
C
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a069a36a6c151fddff3ba4f53127eb4794797382
ababcd09c89272b2528a665185f8292551ddab6f
v1.0
complete
Evol
Evol_2645_C
library_books = {} borrowed_books = {} def add_book(book_title): """ Adds a book to the library's collection. >>> add_book("The Great Gatsby") >>> assert library_books == {"The Great Gatsby": 1} """ pass def borrow_book(book_title, user_name): """ Allows a user to borrow a book from the librar...
library_books = {} borrowed_books = {} def add_book(book_title): library_books[book_title] = library_books.get(book_title, 0) + 1 def borrow_book(book_title, user_name): if book_title in library_books and library_books[book_title] > 0: library_books[book_title] -= 1 borrowed_books[book_title] ...
from solution import add_book, borrow_book, return_book, library_books, borrowed_books def test_add_book(): library_books.clear() add_book("The Great Gatsby") assert library_books == {"The Great Gatsby": 1} def test_borrow_book_success(): library_books.clear() borrowed_books.clear() add_book("...
[ { "docstring": null, "function_declaration": "def add_book(book_title):", "function_name": "add_book", "parameter_list": "(book_title)" }, { "docstring": null, "function_declaration": "def borrow_book(book_title, user_name):", "function_name": "borrow_book", "parameter_list": "(b...
[ 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": "class Library:\n def __init__(self):\n self.library_books = []\n self.borrowed_books = {}\n\n def add_book(self, book_title):\n if book_...
trial_gpt4o_8
{ "original_instruction": "You are to implement a simple library system in Python that manages the borrowing and returning of books. Your task is to write a function that can add books to the library, lend books to users, and return books back to the library. The library system should keep a record of which books are...
0.432466
Evol_2645
C
[ "add_book", "borrow_book", "return_book" ]
3
[ [ "return_book", "add_book" ] ]
1
[]
false
[]
false
pytest
true
[]
true
33004ceac03574d6f481bced9d8c404ab3d5f403
9d9a45d4c857a131a9f702bb30641b03dd17a314
v1.0
complete
Evol
Evol_2950_C
def merge_sort(arr: List[int]) -> List[int]: """ Sorts a list of integers using the Merge Sort algorithm. Parameters: arr (list): List of integers to sort. Returns: list: Sorted list of integers. >>> merge_sort([34, 7, 23, 32, 5, 62]) [5, 7, 23, 32, 34, 62] >>> merge_sort([-12...
def merge_sort(arr): """ Sorts a list of integers using the Merge Sort algorithm. Parameters: arr (list): List of integers to sort. Returns: list: Sorted list of integers. """ # Base case: a list of zero or one elements is already sorted if len(arr) <= 1: return arr ...
from solution import merge_sort def test_merge_sort_with_positive_numbers(): assert merge_sort([34, 7, 23, 32, 5, 62]) == [5, 7, 23, 32, 34, 62] def test_merge_sort_with_negative_numbers(): assert merge_sort([-12, -3, -7, -1, 0, -2]) == [-12, -7, -3, -2, -1, 0] def test_merge_sort_with_mixed_sign_numbers(): ...
[ { "docstring": "Sorts a list of integers using the Merge Sort algorithm.\n\nParameters:\narr (list): List of integers to sort.\n\nReturns:\nlist: Sorted list of integers.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstrin...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def merge_sort(lst):\n \"\"\"\n Sorts a list of integers using the Merge Sort algorithm.\n \"\"\"\n if len(lst) <= 1:\n return lst\n\n # Divi...
trial_gpt4o_9
{ "original_instruction": "Create a function in a programming language that takes a list of integers and sorts it using the Merge Sort algorithm. The function should recursively divide the list into halves until each sublist has one element, then merge the sorted sublists to produce the sorted list. The function must...
0.606368
Evol_2950
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a026868c8733797b7048dc3393d399fd9c26548a
dd4e8bb209a2c9811cde942b8f8fe1146717e8e3
v1.0
complete
Evol
Evol_2444_C
from datetime import datetime from collections import defaultdict from typing import List, Dict, Union def parse_log_entry(log_entry: str, time_format: str) -> Union[datetime, str]: """ Parse a single log entry to extract timestamp and event details. Assumes that each log entry is a string where the first ...
from datetime import datetime from collections import defaultdict def parse_log_entry(log_entry, time_format): """ Parse a single log entry to extract timestamp and event details. Assumes that each log entry is a string where the first part is the timestamp followed by the event details. """ try: ...
from solution import parse_log_entry, filter_log_entries, sort_log_entries, categorize_log_entries, generate_summary_report def test_parse_log_entry_valid(): log_entry = "2023-05-15 10:15:53 ERROR Disk space low" time_format = "%Y-%m-%d %H:%M:%S" timestamp, event_details = parse_log_entry(log_entry, time_f...
[ { "docstring": "Parse a single log entry to extract timestamp and event details.\nAssumes that each log entry is a string where the first part is the timestamp followed by the event details.", "function_declaration": "def parse_log_entry(log_entry, time_format):", "function_name": "parse_log_entry", ...
[ 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": "from datetime import datetime\n\ndef parse_log_entry(log_entry, time_format):\n \"\"\"\n Parse a single log entry and extract timestamp and event details.\n ...
trial_gpt4o_8
{ "original_instruction": "Develop a function to process log entries from a system monitoring tool. Each log entry contains a timestamp and various event details. Your program should be able to:\n\n- Parse log entries to extract timestamps and event details.\n- Filter log entries based on a given time range.\n- Sort ...
0.752004
Evol_2444
C
[ "parse_log_entry", "filter_log_entries", "sort_log_entries", "categorize_log_entries", "generate_summary_report" ]
5
[ [ "categorize_log_entries", "parse_log_entry" ], [ "filter_log_entries", "parse_log_entry" ], [ "generate_summary_report", "categorize_log_entries" ], [ "generate_summary_report", "filter_log_entries" ], [ "sort_log_entries", "parse_log_entry" ] ]
5
[]
false
[]
false
pytest
true
[]
true
aadf2fbc1419c07386614a6d7a0d62a3658e6c39
9fef673f16a913de7de220215fe6917198ed9126
v1.0
complete
Evol
Evol_2962_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(0) == False >>> is_prime(-1) == False ...
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 pair_with_prime_...
from solution import is_prime, pair_with_prime_sum def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False assert is_prime(29) =...
[ { "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": "Takes an array of integers and returns True if there's a pair of indices (i, j) such that i < j\nand the...
[ 1, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Returns True if n is a prime number, False otherwise.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\...
trial_gpt4o_0
{ "original_instruction": "Devise a code that takes an array of integers as input and determines if there exists a pair of indices (i, j) such that i < j and the sum of elements at these indices is a prime number.", "prompt_id": "00002962", "row_id": 2962, "seed_ids": "[20046]" }
0.772056
Evol_2962
C
[ "is_prime", "pair_with_prime_sum" ]
2
[ [ "pair_with_prime_sum", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9d64fc415371cb970422ca88c57dff044df71c03
1f5ab953cf9b54553671594db9c381c840e274b3
v1.0
complete
Evol
Evol_2971_C
def filter_palindromes(words): """ Write a function that accepts an array of strings and returns a new array containing only the strings that are palindromes. A palindrome is a word that reads the same forwards and backwards, case-insensitively. The function should not use any built-in string reversal m...
def is_palindrome(word): """ Helper function to check if a given word is a palindrome. The function is case-insensitive. """ word = word.lower() left, right = 0, len(word) - 1 while left < right: if word[left] != word[right]: return False left += 1 right -...
from solution import filter_palindromes def test_filter_palindromes_basic(): assert filter_palindromes(["Racecar", "hello", "Level", "world", "noon", "Python"]) == ["Racecar", "Level", "noon"] def test_filter_palindromes_no_palindromes(): assert filter_palindromes(["hello", "world", "Python"]) == [] def test...
[ { "docstring": "Helper function to check if a given word is a palindrome.\nThe function is case-insensitive.", "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "docstring": "Returns a new array containing only the palindrom...
[ 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_palindrome(s):\n \"\"\"\n Helper function to check if a given string is a palindrome.\n \"\"\"\n s = s.lower() # Case-insensitive check\n le...
trial_gpt4o_9
{ "original_instruction": "Write a function that accepts an array of strings and returns a new array containing only the strings that are palindromes. A palindrome is a word that reads the same forwards and backwards, case-insensitively. The function should not use any built-in string reversal methods.\n\nExample:\nI...
0.712688
Evol_2971
C
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
47ba3d69063c62f6e63a45111f9a37c870be44da
7d56ec012b0ee544d0f41efd2ac2c7aded3b1386
v1.0
complete
Evol
Evol_3123_C
from typing import List def filter_primes(numbers: List[int]) -> List[int]: """ Implement a 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 handles both positive and negative integers, excluding any negat...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def filter_pr...
from solution import filter_primes def test_filter_primes_with_mixed_numbers(): assert filter_primes([3, 4, -1, 7, 10, 13]) == [3, 7, 13] def test_filter_primes_with_only_primes(): assert filter_primes([2, 3, 5, 7, 11, 13]) == [2, 3, 5, 7, 11, 13] def test_filter_primes_with_no_primes(): assert filter_pr...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the prime numbers from a list of integers.\n\n:param numbers: List of integers\n:return: List of 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 == 2:\n ret...
trial_gpt4o_7
{ "original_instruction": "Implement a function in Python that accepts a list of integers and returns a new list containing only the prime numbers from the original list. Ensure that the function handles both positive and negative integers, excluding any negative numbers from the result.\n\ndef filter_primes(numbers)...
0.669279
Evol_3123
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c07f347853f5963b295794f3a95aa122e369d75
4fb77947c9268adff7782c10d6c5c69763ef9c7e
v1.0
complete
Evol
Evol_3083_C
from typing import List def filter_even_numbers(numbers: List[int]) -> List[int]: """ Returns a list of even numbers from the input list. """ def square_numbers(numbers: List[int]) -> List[int]: """ Returns a list of squared numbers from the input list. """ def process_numbers(numbers: List[i...
def filter_even_numbers(numbers): """ Returns a list of even numbers from the input list. """ return [num for num in numbers if num % 2 == 0] def square_numbers(numbers): """ Returns a list of squared numbers from the input list. """ return [num ** 2 for num in numbers] def process_num...
from solution import filter_even_numbers, square_numbers, process_numbers def test_filter_even_numbers(): assert filter_even_numbers([1, 2, 3, 4, 5]) == [2, 4] assert filter_even_numbers([1, 3, 5]) == [] assert filter_even_numbers([2, 4, 6]) == [2, 4, 6] def test_square_numbers(): assert square_number...
[ { "docstring": "Returns a list of even numbers from the input list.", "function_declaration": "def filter_even_numbers(numbers):", "function_name": "filter_even_numbers", "parameter_list": "(numbers)" }, { "docstring": "Returns a list of squared numbers from the input list.", "function_d...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def filter_even_numbers(numbers):\n \"\"\"\n Filters out the even numbers from a list.\n \"\"\"\n return [num for num in numbers if num % 2 == 0]\n\nde...
trial_gpt4o_9
{ "original_instruction": "Implement a Python function that takes a list of integers and returns a new list with the squares of the original integers, but only for those integers that are even. Each intermediate step, from filtering the even numbers to computing their squares, should be handled within separate helper...
0.664452
Evol_3083
C
[ "filter_even_numbers", "square_numbers", "process_numbers" ]
3
[ [ "process_numbers", "filter_even_numbers" ], [ "process_numbers", "square_numbers" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fb0d3caf955e34ee9a4eb73da12efcbab599df13
0b0fb18c91f48a57ee3ed83b5356bffcae47b4ad
v1.0
complete
Evol
Evol_3282_C
import re from collections import Counter def read_file(file_path): """ Reads the content of a file and returns it as a string. """ def write_file(file_path, content): """ Writes content to a file. """ def count_word_frequencies(text): """ Counts the frequency of each word in the text...
import re from collections import Counter def read_file(file_path): """ Reads the content of a file and returns it as a string. """ with open(file_path, 'r', encoding='utf-8') as file: return file.read() def write_file(file_path, content): """ Writes content to a file. """ with...
import os from solution import generate_frequency_report, read_file, write_file, count_word_frequencies # Helper functions to create and remove test files def create_test_file(file_path, content): with open(file_path, 'w', encoding='utf-8') as file: file.write(content) def remove_test_file(file_path): ...
[ { "docstring": "Reads the content of a file and returns it as a string.", "function_declaration": "def read_file(file_path):", "function_name": "read_file", "parameter_list": "(file_path)" }, { "docstring": "Writes content to a file.", "function_declaration": "def write_file(file_path, c...
[ 1, 0, 0, 0, 0, 0, 0, 0, 1 ]
2
hard
0.222
{ "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 count_word_frequency(input_file, output_file):\n \"\"\"\n Reads a text file, counts the frequency of each w...
trial_gpt4o_9
{ "original_instruction": "Write a program that reads a text file, counts the frequency of each word, and writes the results to a new file in descending order of frequency. Ignore case and punctuation, considering only words that contain alphabetic characters.", "prompt_id": "00003282", "row_id": 3282, "seed_id...
0.738101
Evol_3282
C
[ "read_file", "write_file", "count_word_frequencies", "generate_frequency_report" ]
4
[ [ "generate_frequency_report", "count_word_frequencies" ], [ "generate_frequency_report", "read_file" ], [ "generate_frequency_report", "write_file" ] ]
3
[]
false
[]
false
pytest
true
[]
true
ae475353ab85d02f785f43c38d777b248f931563
6bb1e3ce3c77818a3c58bfa0b2d9eb11f89ef6da
v1.0
complete
Evol
Evol_2385_C
# Simulate a message queue message_queue = [] def user_service_add_user(user_id, user_info): """ Adds a user to the system and notifies other services. """ print(f"User {user_id} added") # Publish user created event message_queue.append(('user_created', user_id, user_info)) def product_service...
# Simplified communication between services using dummy functions and a message queue # Simulate a message queue message_queue = [] def user_service_add_user(user_id, user_info): """ Adds a user to the system and notifies other services. """ print(f"User {user_id} added") # Publish user created ev...
# Tests to verify the communication between services and message queue handling from solution import user_service_add_user, product_service_add_product, order_service_create_order, handle_event def test_user_service_add_user(): message_queue.clear() # Ensure the message_queue is empty before the test user_se...
[ { "docstring": "Adds a user to the system and notifies other services.", "function_declaration": "def user_service_add_user(user_id, user_info):", "function_name": "user_service_add_user", "parameter_list": "(user_id, user_info)" }, { "docstring": "Adds a product to the system.", "functi...
[ 0, 0, 1, 1, 1, 1, 0, 0, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from flask import Flask, request, jsonify\nimport requests\n\napp = Flask(__name__)\n\n# Microservice URLs\nUSER_SERVICE_URL = 'http://user-service'\nPRODUCT_SERVI...
trial_gpt4o_9
{ "original_instruction": "Explain how you would design a microservices architecture for an e-commerce platform, highlighting key services, the communication between these services, and considerations for ensuring scalability and fault tolerance.", "prompt_id": "00002385", "row_id": 2385, "seed_ids": "[35107]" ...
0.443765
Evol_2385
C
[ "user_service_add_user", "product_service_add_product", "order_service_create_order", "payment_service_process_payment", "notification_service_send_email", "handle_event" ]
6
[ [ "handle_event", "notification_service_send_email" ], [ "handle_event", "payment_service_process_payment" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fbc8e32e344b48f6a9101b6dc2f5fd46eab041e1
bc919d52d3fd50207826acfbd46cbc19c1c3723e
v1.0
complete
Evol
Evol_2972_C
from typing import List def is_prime(num: int) -> bool: """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(29) True >>> is_prime(35) False >>> is_prime(1) False """ def filter_primes(numbers...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += ...
from solution import is_prime, 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(35) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == Fal...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list containing only the prime numbers from the input list.", "function_declaration": "def filter_primes(number...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from math import isqrt\n\ndef is_prime(n):\n \"\"\"\n Check if a number is a prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_8
{ "original_instruction": "Write a function that takes in a list of integers and returns a new list containing only the prime numbers from the original list, preserving their order. Implement an efficient algorithm to check for primality to ensure the function can handle large input sizes.", "prompt_id": "00002972"...
0.76136
Evol_2972
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41c3833b5d8bdef689fa4c44c58c02eca7e5251c
344c94274d241fb8fa448593cc0d2a8d670692a8
v1.0
complete
Evol
Evol_3207_C
from typing import List, Tuple def findPeaks(grid: List[List[int]]) -> Tuple[List[Tuple[int, int]], int, int]: """ Find the coordinates of all peaks in a 2D grid of integers. A peak is a cell that is strictly greater than its four neighboring cells (north, east, south, and west). Also, calculate ...
def findPeaks(grid): rows = len(grid) cols = len(grid[0]) peaks = [] for r in range(rows): for c in range(cols): if (r == 0 or grid[r][c] > grid[r-1][c]) and \ (r == rows-1 or grid[r][c] > grid[r+1][c]) and \ (c == 0 or grid[r][c] > grid[r][c-1]) and \ ...
# Since the code above is self-contained, I will test directly with inlining the function definitions. def test_findPeaks_single_peak(): grid = [ [1, 4, 3, 2], [3, 5, 6, 4], [2, 2, 1, 3] ] assert findPeaks(grid) == ([(1, 2)], 6, 6) def test_findPeaks_multiple_peaks(): grid = [ ...
[ { "docstring": null, "function_declaration": "def findPeaks(grid):", "function_name": "findPeaks", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def prod(lst):", "function_name": "prod", "parameter_list": "(lst)" } ]
[ 0, 0, 0, 0, 1, 1, 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": "def findPeaks(grid):\n rows = len(grid)\n cols = len(grid[0])\n peaks = []\n \n for r in range(rows):\n for c in range(cols):\n is...
trial_gpt4o_8
{ "original_instruction": "In a 2D grid of integers, each cell in the grid represents a building with a certain height. A peak is defined as a cell that is strictly greater than its four neighboring cells (north, east, south, and west). Write a function that takes a 2D list representing the heights of buildings in a ...
0.595586
Evol_3207
C
[ "findPeaks", "prod" ]
2
[ [ "findPeaks", "prod" ] ]
1
[]
false
[]
false
pytest
false
[]
true
43105a8ed46ed9d12f87a88371c5195f5c054d01
ad3ce8179456bef9c2d6fe0303ebaa8b29b6b93c
v1.0
complete
Evol
Evol_2105_C
from typing import List def infix_to_postfix(expression: str) -> str: """ Converts an infix expression to postfix notation. >>> infix_to_postfix("3 + 4 * 2 / ( 1 - 5 )") == '3 4 2 * 1 5 - / +' >>> infix_to_postfix("10 + 2 * 6") == '10 2 6 * +' """ pass def evaluate_postfix(expression: str): ...
def infix_to_postfix(expression): """ Converts an infix expression to postfix notation. """ precedence = {'+': 1, '-': 1, '*': 2, '/': 2} stack = [] postfix = [] tokens = expression.split() for token in tokens: if token.isnumeric(): postfix.append(token) ...
from solution import infix_to_postfix, evaluate_postfix, analyze_expressions def test_infix_to_postfix(): assert infix_to_postfix("3 + 4 * 2 / ( 1 - 5 )") == '3 4 2 * 1 5 - / +' assert infix_to_postfix("10 + 2 * 6") == '10 2 6 * +' assert infix_to_postfix("100 * 2 + 12") == '100 2 * 12 +' assert infix_...
[ { "docstring": "Converts an infix expression to postfix notation.", "function_declaration": "def infix_to_postfix(expression):", "function_name": "infix_to_postfix", "parameter_list": "(expression)" }, { "docstring": "Evaluates a postfix expression.", "function_declaration": "def evaluat...
[ 1, 0, 0, 1, 0, 1, 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": "def infix_to_postfix(expression):\n precedence = {'+': 1, '-': 1, '*': 2, '/': 2}\n output = []\n operators = []\n \n def greater_precedence(op1, op...
trial_gpt4o_9
{ "original_instruction": "Design a Python function to analyze and transform a given list of strings where each element represents a mathematical expression in infix notation. The function needs to convert each expression into its respective postfix notation (Reverse Polish Notation) and then evaluate it. The functio...
0.547877
Evol_2105
C
[ "infix_to_postfix", "evaluate_postfix", "analyze_expressions" ]
3
[ [ "analyze_expressions", "evaluate_postfix" ], [ "analyze_expressions", "infix_to_postfix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ababdc26e955e7185d75718f556f7c793654d136
32e1dc734260abd8c8dc9937a873b9979d68aaf2
v1.0
complete
Evol
Evol_2147_C
from typing import List import random def partition(nums: List[int], left: int, right: int, pivot_index: int) -> int: pivot_value = nums[pivot_index] nums[pivot_index], nums[right] = nums[right], nums[pivot_index] # Move pivot to end store_index = left for i in range(left, right): if nums[i] >...
import random def partition(nums, left, right, pivot_index): pivot_value = nums[pivot_index] nums[pivot_index], nums[right] = nums[right], nums[pivot_index] # Move pivot to end store_index = left for i in range(left, right): if nums[i] > pivot_value: nums[store_index], nums[i] = nu...
from solution import find_kth_largest def test_single_element(): assert find_kth_largest([1], 1) == 1 def test_two_elements(): assert find_kth_largest([1, 2], 1) == 2 assert find_kth_largest([1, 2], 2) == 1 def test_multiple_elements(): assert find_kth_largest([3, 2, 1, 5, 6, 4], 2) == 5 assert f...
[ { "docstring": null, "function_declaration": "def partition(nums, left, right, pivot_index):", "function_name": "partition", "parameter_list": "(nums, left, right, pivot_index)" }, { "docstring": null, "function_declaration": "def quickselect(nums, left, right, k):", "function_name":...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def partition(nums, low, high):\n pivot = nums[high]\n i = low - 1\n for j in range(low, high):\n if nums[j] >= pivot:\n i += 1\n ...
trial_gpt4o_9
{ "original_instruction": "Implement a function `find_kth_largest(nums, k)` that accepts a list of integers `nums` and an integer `k`, and returns the k-th largest element in the list. The solution must have an average-case time complexity of O(n) or better. You may assume that `1 <= k <= len(nums)`. Additionally, pr...
0.630727
Evol_2147
C
[ "partition", "quickselect", "find_kth_largest" ]
3
[ [ "find_kth_largest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b42da70984e286f8cb120839ea740e7f2a44eef9
1236854b8160520d089d8d28f0c3ab91d178c659
v1.0
complete
Evol
Evol_3100_C
from typing import List def optimized_sort(nums: List[int]) -> List[int]: """ An efficient sorting algorithm to sort a list of both positive and negative integers. >>> optimized_sort([4, -1, 7, -3, 2, -6, 5]) == [-6, -3, -1, 2, 4, 5, 7] >>> optimized_sort([]) == [] >>> optimized_sort([1]) == [1] >>...
def optimized_sort(nums): """ An efficient sorting algorithm to sort a list of both positive and negative integers. Uses Timsort algorithm which is efficient for large datasets. """ return sorted(nums) def performance_test(size): import random from time import time nums = [random.randi...
from solution import optimized_sort, performance_test def test_small_list(): assert optimized_sort([4, -1, 7, -3, 2, -6, 5]) == [-6, -3, -1, 2, 4, 5, 7] assert optimized_sort([]) == [] assert optimized_sort([1]) == [1] def test_all_positive(): assert optimized_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] ...
[ { "docstring": "An efficient sorting algorithm to sort a list of both positive and negative integers.\nUses Timsort algorithm which is efficient for large datasets.", "function_declaration": "def optimized_sort(nums):", "function_name": "optimized_sort", "parameter_list": "(nums)" }, { "docs...
[ 0, 1, 1, 0, 0, 1, 1, 0, 0, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def radix_sort(nums):\n \"\"\"\n An optimized sorting algorithm using Radix Sort\n that works efficiently for positive and negative numbers.\n \"\"\"\n...
trial_gpt4o_9
{ "original_instruction": "Devise an efficient algorithm to sort a list of integers which consists of both positive and negative numbers. Optimize the algorithm to handle lists with large numbers of elements where a traditional quicksort or mergesort may prove inefficient. Additionally, implement a function to measur...
0.62666
Evol_3100
C
[ "optimized_sort", "performance_test" ]
2
[ [ "performance_test", "optimized_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b89bf7198e07a6bdca0f939d4f0d291b7ac03166
8dcb670a79fe5f3c1276e46a20387670aea7bd4b
v1.0
complete
Evol
Evol_2694_C
def generate_matrix(N: int, M: int) -> list: """Generates a N x M matrix filled with elements based on the rule 3 * i - 2 * j. Params: N (int): Number of rows M (int): Number of columns Raises: ValueError: If N or M is not a positive integer Returns: list: The generated m...
import copy def generate_matrix(N, M): """Generates a N x M matrix filled with elements based on the rule 3 * i - 2 * j.""" if N <= 0 or M <= 0: raise ValueError("N and M must be positive integers") return [[3 * i - 2 * j for j in range(M)] for i in range(N)] def transpose_matrix(matrix): """T...
from solution import generate_matrix, transpose_matrix, rotate_matrix_90_clockwise, matrix_manipulation def test_generate_matrix(): matrix = generate_matrix(3, 3) expected = [ [0, -2, -4], [3, 1, -1], [6, 4, 2] ] assert matrix == expected def test_transpose_matrix(): matrix...
[ { "docstring": "Generates a N x M matrix filled with elements based on the rule 3 * i - 2 * j.", "function_declaration": "def generate_matrix(N, M):", "function_name": "generate_matrix", "parameter_list": "(N, M)" }, { "docstring": "Transposes the given matrix.", "function_declaration": ...
[ 1, 1, 0, 1, 1, 0, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def generate_matrix(N, M):\n if not (isinstance(N, int) and isinstance(M, int) and N > 0 and M > 0):\n raise ValueError(\"N and M must be positive intege...
trial_gpt4o_8
{ "original_instruction": "Write a Python function `matrix_manipulation` that generates an N x M matrix filled with elements. The elements of the matrix follow a specific pattern: the value at position (i, j) is calculated as \\(3 * i - 2 * j\\). \n\nYour function should have the following features:\n1. Accept two in...
0.553512
Evol_2694
C
[ "generate_matrix", "transpose_matrix", "rotate_matrix_90_clockwise", "matrix_manipulation" ]
4
[ [ "matrix_manipulation", "generate_matrix" ], [ "matrix_manipulation", "rotate_matrix_90_clockwise" ], [ "matrix_manipulation", "transpose_matrix" ], [ "rotate_matrix_90_clockwise", "transpose_matrix" ] ]
4
[]
false
[]
false
pytest
true
[]
true
348c1bb2b8f27d0698588589ee8e034c793993f1
ab8844fa8c137bed469810a3812d1b9763a037b6
v1.0
complete
Evol
Evol_3344_C
def get_prime_factors_list(nums: List[int]) -> List[int]: """ Returns a list of unique prime factors from the input list of integers in ascending order. >>> get_prime_factors_list([28]) [2, 7] >>> get_prime_factors_list([12, 15, 21]) [2, 3, 5, 7] >>> get_prime_factors_list([7, 13, 19]) [7, 13, 19] >...
def prime_factors(n): """Returns the list of prime factors of the given number n.""" factors = set() i = 2 while i * i <= n: while (n % i) == 0: factors.add(i) n //= i i += 1 if n > 1: factors.add(n) return list(factors) def get_prime_factors_list...
from solution import get_prime_factors_list def test_single_number(): assert get_prime_factors_list([28]) == [2, 7] def test_multiple_numbers(): assert get_prime_factors_list([12, 15, 21]) == [2, 3, 5, 7] def test_prime_numbers(): assert get_prime_factors_list([7, 13, 19]) == [7, 13, 19] def test_with_1...
[ { "docstring": "Returns the list of prime factors of the given number n.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Returns a list of unique prime factors from the input list of integers.", "function_dec...
[ 0, 1, 0, 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": "def prime_factors(numbers):\n \"\"\"\n Returns a list of prime factors of given list of numbers.\n The result list will contain each prime factor only onc...
trial_gpt4o_7
{ "original_instruction": "Write a function that takes a list of integers as input and returns another list consisting of the prime factors of each number in the input list. The result should present prime factors in ascending order, and each number should only appear once in the output list, even if it is a factor o...
0.837781
Evol_3344
C
[ "prime_factors", "get_prime_factors_list" ]
2
[ [ "get_prime_factors_list", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b45298cce63aa2008ee41f6450727da5566bc96d
4c33a18ea72b48751b32fa7c42fc65acedfcabbc
v1.0
complete
Evol
Evol_2933_C
def fibonacci(n, memo={}): """ Calculate the nth Fibonacci number using memoization. Args: n (int): The position in the Fibonacci sequence. memo (dict): Dictionary to store previously calculated Fibonacci numbers. Returns: int: The nth Fibonacci number. """ pass def non_me...
def fibonacci(n, memo={}): """ Calculate the nth Fibonacci number using memoization. Args: n (int): The position in the Fibonacci sequence. memo (dict): Dictionary to store previously calculated Fibonacci numbers. Returns: int: The nth Fibonacci number. """ if n in memo: ...
import time from solution import fibonacci, non_memoized_fibonacci, time_complexity, test_memoization def test_fibonacci(): assert fibonacci(0) == 0 assert fibonacci(1) == 1 assert fibonacci(10) == 55 assert fibonacci(20) == 6765 assert fibonacci(30) == 832040 assert fibonacci(50) == 1258626902...
[ { "docstring": "Calculate the nth Fibonacci number using memoization.\n\nArgs:\nn (int): The position in the Fibonacci sequence.\nmemo (dict): Dictionary to store previously calculated Fibonacci numbers.\n\nReturns:\nint: The nth Fibonacci number.", "function_declaration": "def fibonacci(n, memo={}):", ...
[ 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def fibonacci(n, memo={}):\n \"\"\"\n Calculate the nth Fibonacci number using memoization.\n \n Args:\n n (int): The position in the Fibonacci sequ...
trial_gpt4o_0
{ "original_instruction": "Write a function in Python to calculate the nth Fibonacci number, but with the added constraint that every number in the sequence is generated using memoization to optimize performance. Your function should handle large inputs efficiently (e.g., n = 1000). Additionally, write a function to ...
0.80514
Evol_2933
C
[ "fibonacci", "non_memoized_fibonacci", "time_complexity", "test_memoization" ]
4
[ [ "test_memoization", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
473a5060af2dfd88f1030acddab319239d611f75
0bc439bc78135e7394938905b57e0d3e65d5588f
v1.0
complete
Evol
Evol_3030_C
def compute_lps(pattern: str) -> List[int]: """ Compute the Longest Prefix Suffix (LPS) array for the given pattern. >>> compute_lps("AABAACAABAA") [0, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5] >>> compute_lps("ABCDE") [0, 0, 0, 0, 0] """ def kmp_search(text: str, pattern: str) -> List[int]: """ Pe...
def compute_lps(pattern): length = 0 lps = [0] * len(pattern) i = 1 while i < len(pattern): if pattern[i] == pattern[length]: length += 1 lps[i] = length i += 1 else: if length != 0: length = lps[length - 1] els...
from solution import kmp_search, compute_lps def test_compute_lps(): assert compute_lps("AABAACAABAA") == [0, 1, 0, 1, 2, 0, 1, 2, 3, 4, 5] assert compute_lps("ABCDE") == [0, 0, 0, 0, 0] assert compute_lps("AAACAAAA") == [0, 1, 2, 0, 1, 2, 3, 3] assert compute_lps("ABABCABAB") == [0, 0, 1, 2, 0, 1, 2, ...
[ { "docstring": null, "function_declaration": "def compute_lps(pattern):", "function_name": "compute_lps", "parameter_list": "(pattern)" }, { "docstring": null, "function_declaration": "def kmp_search(text, pattern):", "function_name": "kmp_search", "parameter_list": "(text, patte...
[ 1, 0, 0, 0, 1, 1, 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 compute_lps(pattern):\n \"\"\"\n Compute the longest prefix which is also suffix (LPS) array for the pattern.\n \"\"\"\n lps = [0] * len(pattern)\n...
trial_gpt4o_6
{ "original_instruction": "Explain how the Knuth-Morris-Pratt (KMP) algorithm improves pattern searching within a text. Illustrate the concept with an example, detailing the preprocessing step and the search step. Highlight the advantages of using KMP over the naive string matching algorithm.", "prompt_id": "000030...
0.579871
Evol_3030
C
[ "compute_lps", "kmp_search" ]
2
[ [ "kmp_search", "compute_lps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f8c60ca10061d0e3260163262f6169eaa9ec426e
37f0921bf9332940f1c2844b38c52fec6ed8219d
v1.0
complete
Evol
Evol_3234_C
def find_max(arr): """ Given an array of numbers, identify and correct any logical errors that exist. Refactor this function to improve its efficiency in terms of time complexity. >>> find_max([1, 2, 3, 4, 5]) 5 >>> find_max([5, 4, 3, 2, 1]) 5 >>> find_max([-1, -2, -3, -4, -5]) -1 >>> find_max(...
def find_max(arr): if not arr: return None max_num = arr[0] for num in arr: if num > max_num: max_num = num return max_num def find_max_refactored(arr): if not arr: return None return max(arr) import time def compare_execution_time(arr): start_time_orig...
from solution import find_max, find_max_refactored, compare_execution_time def test_find_max(): assert find_max([1, 2, 3, 4, 5]) == 5 assert find_max([5, 4, 3, 2, 1]) == 5 assert find_max([-1, -2, -3, -4, -5]) == -1 assert find_max([]) == None assert find_max([0]) == 0 def test_find_max_refactored...
[ { "docstring": null, "function_declaration": "def find_max(arr):", "function_name": "find_max", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def find_max_refactored(arr):", "function_name": "find_max_refactored", "parameter_list": "(arr)" }, { ...
[ 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 find_max(arr):\n \"\"\"\n Returns the maximum value in the array arr.\n \"\"\"\n if not arr:\n raise ValueError(\"The input array cannot be ...
trial_gpt4o_9
{ "original_instruction": "Given the following Python code, identify and correct any logical errors that exist. Once you have a logically correct version of the code, refactor it to improve its efficiency in terms of time complexity. Additionally, write a function to measure and compare the execution time of the orig...
0.605023
Evol_3234
C
[ "find_max", "find_max_refactored", "compare_execution_time" ]
3
[ [ "compare_execution_time", "find_max" ], [ "compare_execution_time", "find_max_refactored" ] ]
2
[]
false
[]
false
pytest
true
[]
true
89d62bbb077fbac5144f6e6231b546c0e956228f
97c04c1ab7fbd97c6b6e7fe58c6e90259c219abe
v1.0
complete
Evol
Evol_3394_C
def gini_impurity(dataset): """ Calculate the Gini Impurity for a given dataset. Args: dataset (list): List of classes. Returns: float: Gini Impurity """ pass def split_and_calculate_gini(dataset, thresholds): """ Calculate the Gini Impurity for the dataset before and ...
from collections import Counter def gini_impurity(dataset): """ Calculate the Gini Impurity for a given dataset. Args: dataset (list): List of classes. Returns: float: Gini Impurity """ total = len(dataset) if total == 0: return 0 class_counts = Counter(da...
from solution import gini_impurity, split_and_calculate_gini def test_gini_impurity(): assert gini_impurity([1, 1, 1]) == 0 assert gini_impurity([1, 1, 2, 2]) == 1 - 0.5*0.5 - 0.5*0.5 assert gini_impurity([1, 2, 2, 3]) == 1 - (1/4)**2 - (2/4)**2 - (1/4)**2 def test_split_and_calculate_gini(): dataset ...
[ { "docstring": "Calculate the Gini Impurity for a given dataset.\n\nArgs:\ndataset (list): List of classes.\n\nReturns:\nfloat: Gini Impurity", "function_declaration": "def gini_impurity(dataset):", "function_name": "gini_impurity", "parameter_list": "(dataset)" }, { "docstring": "Calculate ...
[ 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 gini_impurity(classes):\n \"\"\"\n Computes the Gini Impurity for a given dataset.\n Gini Impurity = 1 - sum of (probability of each class)^2\n :pa...
trial_gpt4o_8
{ "original_instruction": "**Develop a function to compute the Gini Impurity for a given dataset. The dataset is provided as a list of classes. Explain how the Gini Impurity helps in the process of splitting nodes in a decision tree classifier. Given the dataset below, calculate the Gini Impurity before and after spl...
0.461384
Evol_3394
C
[ "gini_impurity", "split_and_calculate_gini" ]
2
[ [ "split_and_calculate_gini", "gini_impurity" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d98d126ae421c5d396edb2f017e3a8bbe6cba4b6
d0597500d411dc6c4735ed66cf342204faa113cf
v1.0
complete
Evol
Evol_3362_C
def is_prime(num: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ def generate_prime_numbers(n: int) -> List[int]: """ Generate a list of the first n prime numbers. >>> generate_prime_numbers(0) [] >>> generate_prime_numbers(5...
def is_prime(num): """ Check if a number is prime. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def generate_prime_numbers(n): """ Generate a list of the first n prime numbers. """ prim...
from solution import ( is_prime, generate_prime_numbers, is_palindrome, prime_palindromes ) 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(25) == False def test_generate_prime_number...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generate a list of the first n prime numbers.", "function_declaration": "def generate_prime_numbers(n):", "function_na...
[ 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 Check if a number is prime.\n :param num: Integer, the number to check.\n :return: Boolean, True if the number is prime, ...
trial_gpt4o_8
{ "original_instruction": "Formulate a Python script module that defines a function `is_prime(num)` to check if a number is prime and a function `generate_prime_numbers(n)` to generate a list of the first `n` prime numbers. Additionally, implement a function `is_palindrome(number)` to verify if a given number is a pa...
0.688072
Evol_3362
C
[ "is_prime", "generate_prime_numbers", "is_palindrome", "prime_palindromes" ]
4
[ [ "generate_prime_numbers", "is_prime" ], [ "prime_palindromes", "is_palindrome" ], [ "prime_palindromes", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
4e27e8fb626757a0c138dcb414f00be01ab8f642
c4b1c81be9f54f88d242a6bfaff4af0956be1be0
v1.0
complete
Evol
Evol_2445_C
import csv from typing import List, Dict def read_employees(csv_file_path: str) -> List[Dict[str, str]]: """Read employees from a CSV file and return a list of employees. """ ... def list_employees_by_department(employees: List[Dict[str, str]], department: str) -> List[Dict[str, str]]: """List all emp...
import csv from collections import defaultdict def read_employees(csv_file_path): employees = [] with open(csv_file_path, newline='') as csvfile: reader = csv.DictReader(csvfile) for row in reader: row['salary'] = float(row['salary']) employees.append(row) return emp...
import pytest from solution import read_employees, list_employees_by_department, calculate_average_salary, find_highest_and_lowest_salary def test_read_employees(tmp_path): csv_file = tmp_path / "employees.csv" csv_file.write_text("employee_id,name,department,salary\n1,John Doe,Engineering,70000\n2,Jane Smith,...
[ { "docstring": null, "function_declaration": "def read_employees(csv_file_path):", "function_name": "read_employees", "parameter_list": "(csv_file_path)" }, { "docstring": null, "function_declaration": "def list_employees_by_department(employees, department):", "function_name": "list...
[ 1, 0, 1, 1, 1, 0, 1, 0, 1, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import csv\nfrom collections import defaultdict\n\ndef read_csv(file_path):\n employees = []\n try:\n with open(file_path, mode='r') as file:\n ...
trial_gpt4o_8
{ "original_instruction": "Implement a Python program that reads in a CSV file containing information about employees, such as employee ID, name, department, and salary. The program should provide functionality to:\n1. List all employees in a specific department.\n2. Calculate the average salary for a specific depart...
0.652721
Evol_2445
C
[ "read_employees", "list_employees_by_department", "calculate_average_salary", "find_highest_and_lowest_salary" ]
4
[ [ "calculate_average_salary", "list_employees_by_department" ] ]
1
[]
false
[]
false
pytest
true
[]
true
457be96b19757bc483978ef7aeb69d2dc715da23
19064d82f9386e2e9a50db562517ec616b5a7dae
v1.0
complete
Evol
Evol_3403_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(0) False """ def remove_primes(lst: List[int]) -> List[int]: """ Returns a new list with all prime numbers removed. >>> remove_primes([2, 3, 4, 5, 6...
def is_prime(n): if n < 2: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for divisor in range(3, max_divisor, 2): if n % divisor == 0: return False return True def remo...
from solution import remove_primes def test_remove_primes_with_mixed_numbers(): assert remove_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [4, 6, 8, 9, 10] def test_remove_primes_with_all_primes(): assert remove_primes([2, 3, 5, 7, 11, 13]) == [] def test_remove_primes_with_no_primes(): assert remove_primes([...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list with all prime numbers removed.\n\nParameters:\nlst (list): List of integers.\n\nReturns:\nlist: New list with all prime numbers removed...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n...
trial_gpt4o_7
{ "original_instruction": "Write a function that takes a list of integers and returns a new list with all the prime numbers removed. The order of the elements should be preserved. Provide an efficient solution considering the computational complexity of checking for prime numbers.", "prompt_id": "00003403", "row_...
0.716266
Evol_3403
C
[ "is_prime", "remove_primes" ]
2
[ [ "remove_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
845ea8a8b1474daf7d26fa4e290fd50e15c27535
e43e0edf881e82bc2c898939857f2338fc857ef8
v1.0
complete
Evol
Evol_3372_C
def segregate_and_sort(input_list): """ Segregates a mixed list into integers and strings and returns a dictionary with two sorted lists in ascending order, without using built-in sorting functions. >>> segregate_and_sort([3, "apple", 1, "banana", 2, "cherry"]) {'integers': [1, 2, 3], 'strings': ...
def insertion_sort(arr): """ Sorts an array using the insertion sort algorithm. """ for i in range(1, len(arr)): key = arr[i] j = i - 1 while j >= 0 and key < arr[j]: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key return arr def segregate_and_sor...
from solution import segregate_and_sort def test_segregate_and_sort_mixed_list(): input_list = [3, "apple", 1, "banana", 2, "cherry"] expected_output = { "integers": [1, 2, 3], "strings": ["apple", "banana", "cherry"] } assert segregate_and_sort(input_list) == expected_output def test_...
[ { "docstring": "Sorts an array using the insertion sort algorithm.", "function_declaration": "def insertion_sort(arr):", "function_name": "insertion_sort", "parameter_list": "(arr)" }, { "docstring": "Segregates a mixed list into integers and strings,\nand returns a dictionary with two sorte...
[ 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 mixed_type_sort(my_list):\n \"\"\"\n Takes a list of mixed data types (integers and strings) and returns a dictionary \n with sorted lists of integers...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of mixed data types (integers and strings) and returns a dictionary with two keys: 'integers' and 'strings'. The value for each key should be a sorted list (in ascending order) containing only the integers or strings from the input list. Do not use built-...
0.661399
Evol_3372
C
[ "insertion_sort", "segregate_and_sort" ]
2
[ [ "segregate_and_sort", "insertion_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cbd9835c44db182aae0dbbfb28158821e7ab7253
9a6eeffba2e0efd6598d837bca19640de9286735
v1.0
complete
Evol
Evol_3309_C
from typing import List def is_prime(n: int) -> bool: """ Checks if the given number n is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(10) == False >>> is_prime(17) == True >>> is_prime(-3) == False >>> is_prime...
def is_prime(n): """ Checks if the given number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(arr): ...
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(17) == True assert is_prime(-3) == False assert is_prime(1) == Fals...
[ { "docstring": "Checks if the given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new array containing only the prime numbers from the original array.", "function_declaration": "def filte...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n r...
trial_gpt4o_6
{ "original_instruction": "Write a function that takes an integer array as input and returns a new array containing only the prime numbers from the original array, in the same order they appeared. A prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself.", "p...
0.758254
Evol_3309
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a020a35f5a259b573648aa2fec48dfb12206795e
3e2c4adc4b97877008ec0b5a9d7827d5891732ce
v1.0
complete
Evol
Evol_3350_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(9) == False >>> is_prime(11) == True >>> is_prime(1) == False >>> is_prime(0) == False >>> is_prime(-7) ...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): # Check only odd numbers if n % i == 0: retur...
from solution import is_prime, product_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False assert is_prime(11) == True assert is_prime(1) == False assert is_prime(0) == Fa...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the product of all prime numbers in the list.\nIf there are no prime numbers or the list is empty,\nreturns a message indi...
[ 1, 1, 1, 1, 1, 0, 0, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_7
{ "original_instruction": "Write a program that accepts a list of integers and returns the product of all prime numbers in the list. Your code should include a function to check for prime numbers and handle edge cases, such as an empty list or a list with no prime numbers. If no prime numbers are found, the program s...
0.813443
Evol_3350
C
[ "is_prime", "product_of_primes" ]
2
[ [ "product_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dd1bae0cc7d37d46b89973470da02b3d1476c30b
07398d307ee4f5865a0bab7814baccbc674f7109
v1.0
complete
Evol
Evol_3431_C
from typing import List def find_common_subsequences(str1: str, str2: str) -> List[str]: """ Given two strings, finds all common subsequences between the two strings. A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elem...
from itertools import combinations def generate_subsequences(s): """ Generate all possible subsequences of a given string. """ subsequences = set() for i in range(1, len(s) + 1): for comb in combinations(s, i): subsequences.add(''.join(comb)) return subsequences def find_co...
from solution import find_common_subsequences def test_identical_strings(): assert find_common_subsequences("abc", "abc") == ["abc", "ab", "ac", "bc", "a", "b", "c"] def test_no_common_subsequences(): assert find_common_subsequences("abc", "def") == [] def test_empty_string(): assert find_common_subseque...
[ { "docstring": "Generate all possible subsequences of a given string.", "function_declaration": "def generate_subsequences(s):", "function_name": "generate_subsequences", "parameter_list": "(s)" }, { "docstring": "Finds all common subsequences between two strings and returns them sorted by l...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def find_common_subsequences(str1, str2):\n from itertools import combinations\n \n def all_subsequences(string):\n subs = set()\n for i in ...
trial_gpt4o_9
{ "original_instruction": "Given two strings, write a function called `find_common_subsequences` that finds all common subsequences between the two strings. A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. Your functi...
0.66643
Evol_3431
C
[ "generate_subsequences", "find_common_subsequences" ]
2
[ [ "find_common_subsequences", "generate_subsequences" ] ]
1
[]
false
[]
false
pytest
true
[]
true
70edd97c280fb87a581b4a15435402c592f34f47
8352c1778dc6910bb261e50b1f9fa9c52b7e00c7
v1.0
complete
Evol
Evol_3452_C
def merge_sort(arr): """ Sorts the list of integers in non-decreasing order using the Merge Sort algorithm. Includes error handling for cases where the input is not a list or the list contains non-integer elements. >>> merge_sort([1, 2, 3, 4, 5]) # [1, 2, 3, 4, 5] >>> merge_sort([3, 1, 4, 5, 2]...
def merge_sort(arr): """ Sorts the list of integers in non-decreasing order using the Merge Sort algorithm. Includes error handling for cases where the input is not a list or the list contains non-integer elements. """ if not isinstance(arr, list): raise TypeError("Input should be of type li...
from solution import merge_sort def test_merge_sort_with_sorted_positive_numbers(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_with_unsorted_positive_numbers(): assert merge_sort([3, 1, 4, 5, 2]) == [1, 2, 3, 4, 5] def test_merge_sort_with_negative_numbers(): assert merge_s...
[ { "docstring": "Sorts the list of integers in non-decreasing order using the Merge Sort algorithm.\nIncludes error handling for cases where the input is not a list or the list contains non-integer elements.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_l...
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def merge_sort(nums):\n \"\"\"\n Sorts a list of integers in non-decreasing order using the Merge Sort algorithm.\n Raises TypeError if nums is not a list...
trial_gpt4o_9
{ "original_instruction": "Write a function that takes a list of integers and returns the list sorted in non-decreasing order using the Merge Sort algorithm. Demonstrate how the function works with a test list. Include error handling for cases where the input is not a list or the list contains non-integer elements.",...
0.630676
Evol_3452
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e3e366fb9de700fae70e95da7327356f89ca4a62
3e2cfd923556a2d9467e21d6d707e2c4cde1b578
v1.0
complete
Evol
Evol_3510_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. Returns True if n is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(4) False """ def filter_primes(numbers: List[int]) -> List[int]: """ Takes a list of integers and returns a new list containin...
def is_prime(n): """ Helper function to check if a number is prime. Returns True if n is a prime number, otherwise False. """ if n <= 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def filter_primes(numbers): """...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(11) == True assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Helper function to check if a number is prime.\nReturns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a new list containi...
[ 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 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_9
{ "original_instruction": "Design a function in Python that takes a list of integers and returns a new list containing only the prime numbers from the original list. The function should implement a nested loop to check for the primality of each number. Define the structure of the function, and provide an example usag...
0.754326
Evol_3510
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4b10058cbd0c2f4d9a376e3e4a7093a6a1f582e8
3c15a8f5bf4b581b7791db10620e4a4e95aebf86
v1.0
complete
Evol
Evol_3165_C
def transpose(matrix): """ Transposes the given matrix. >>> transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) [[1, 4, 7], [2, 5, 8], [3, 6, 9]] """ def rotate_90_clockwise(matrix): """ Rotates the given matrix 90 degrees clockwise. >>> rotate_90_clockwise([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) [[7, ...
def transpose(matrix): """Transposes the given matrix.""" rows, cols = len(matrix), len(matrix[0]) return [[matrix[j][i] for j in range(rows)] for i in range(cols)] def rotate_90_clockwise(matrix): """Rotates the given matrix 90 degrees clockwise.""" return [list(reversed(col)) for col in zip(*matr...
from solution import transpose, rotate_90_clockwise, rotate_90_counterclockwise, apply_operation def test_transpose(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] result = transpose(matrix) expected = [ [1, 4, 7], [2, 5, 8], [3, 6, 9] ] assert re...
[ { "docstring": "Transposes the given matrix.", "function_declaration": "def transpose(matrix):", "function_name": "transpose", "parameter_list": "(matrix)" }, { "docstring": "Rotates the given matrix 90 degrees clockwise.", "function_declaration": "def rotate_90_clockwise(matrix):", ...
[ 0, 0, 1, 1, 0, 1, 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": "def transpose_matrix(matrix):\n \"\"\"\n Transpose the given matrix.\n \n :param matrix: List[List[int]] - a 2D list representing the matrix\n :retu...
trial_gpt4o_5
{ "original_instruction": "Implement a matrix manipulation program that performs the following operations based on user input:\n\n1. Transpose the Matrix\n2. Rotate the Matrix 90 degrees clockwise\n3. Rotate the Matrix 90 degrees counterclockwise\n\nThe program should initially accept a matrix of integers and display...
0.505193
Evol_3165
C
[ "transpose", "rotate_90_clockwise", "rotate_90_counterclockwise", "apply_operation" ]
4
[ [ "apply_operation", "rotate_90_clockwise" ], [ "apply_operation", "rotate_90_counterclockwise" ], [ "apply_operation", "transpose" ] ]
3
[]
false
[]
false
pytest
true
[]
true
ea188e5f2d899b798893f39559d7bf17ca7cfdb9
6410f64da3a4a37e0e30ee88315e49da12fb2a17
v1.0
complete
Evol
Evol_3499_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(11) True >>> is_prime(1) False """ def square_primes(lst: List[int]) -> List[int]: """ Returns a new l...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def square_primes(lst): """ Returns a new list with each element squared if the ...
from solution import square_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(0) assert not is_prime(1) assert not is_prime(15) assert is_prime(13) ...
[ { "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 with each element squared if the element is a prime number.\nElements that are not pr...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n 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_7
{ "original_instruction": "Write a function that takes in a list of integers and returns a new list with each element squared, but only if the original element is a prime number. If the element is not a prime number, it should be excluded from the new list. For example, given the input list [4, 7, 10, 11, 13, 16], th...
0.718785
Evol_3499
C
[ "is_prime", "square_primes" ]
2
[ [ "square_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cac0b8468459241f14104ff020695d674e2b785a
d03aaad51c1235bdf9b5573b7dca83d7d3130f55
v1.0
complete
Evol
Evol_3355_C
import re from typing import List def is_palindrome(s: str) -> str: """ Determines if a given string is a palindrome. Spaces, punctuation, and casing are ignored. Parameters: s (str): The string to check. Returns: str: 'yes' if the string is a palindrome, 'no' otherwise. >>> is_palin...
import re def is_palindrome(s): """ Determines if a given string is a palindrome. Spaces, punctuation, and casing are ignored. Parameters: s (str): The string to check. Returns: str: 'yes' if the string is a palindrome, 'no' otherwise. """ if not isinstance(s, str): raise ...
from solution import is_palindrome, check_palindromes import pytest def test_is_palindrome(): assert is_palindrome("A man, a plan, a canal, Panama") == 'yes' assert is_palindrome("racecar") == 'yes' assert is_palindrome("Hello, World!") == 'no' assert is_palindrome("") == 'yes' assert is_palindrome...
[ { "docstring": "Determines if a given string is a palindrome.\nSpaces, punctuation, and casing are ignored.\n\nParameters:\ns (str): The string to check.\n\nReturns:\nstr: 'yes' if the string is a palindrome, 'no' otherwise.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindr...
[ 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 re\n\ndef is_palindrome(s):\n \"\"\"\n Checks if the given string s is a palindrome.\n Handles spaces, punctuation, and mixed casing.\n \n Ar...
trial_gpt4o_9
{ "original_instruction": "You are tasked with designing a system in a programming language of your choice to determine if a given string is a valid palindrome. Your software should be capable of handling multiple strings simultaneously and return a response for each string indicating whether it is a palindrome (\"ye...
0.838048
Evol_3355
C
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
12e7edc4c185152a1c3a2b6f47efbddb32fb29c1
29299fe9fbcd61f09e9c7612509f8af80a32ac47
v1.0
complete
Evol
Evol_3378_C
def is_prime(num): """ Check if a number is a prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def extract_primes(numbers): """ Return a list of prime numbers from the given list of integers. >>> extract_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) [2, 3, 5, 7] >>> extr...
def is_prime(num): if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def extract_primes(numbers): primes = [] for num in numbers: if is_prime(num): primes.append(num) return primes
from solution import is_prime, extract_primes def test_is_prime_with_prime_numbers(): assert is_prime(2) is True assert is_prime(3) is True assert is_prime(5) is True assert is_prime(7) is True def test_is_prime_with_non_prime_numbers(): assert is_prime(0) is False assert is_prime(1) is False ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def extract_primes(numbers):", "function_name": "extract_primes", "parameter_list": "(numbers)" } ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Determine if a number is prime.\n :param num: An integer.\n :return: True if the integer is a prime number, else False.\n...
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. If the input list is empty or has no prime numbers, return an empty list.\n\nAdditionally, handle and fix the error in the given code snippet:\n\n```python\...
0.691113
Evol_3378
C
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a8b82aa1c5ee7dd8d2d3dfab83f4ec60595aae5
a13bbb8f030bf63546d3ad4eede84e01a16515ff
v1.0
complete
Evol
Evol_3543_C
def is_prime(num: int) -> bool: """ Check if a number is prime. Parameters: num (int): The number to check. Returns: bool: True if the number is prime, else False. """ pass def filter_primes(nums: List[int]) -> List[int]: """ Filters the prime numbers from the given ar...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def filter_primes(nums):...
from solution import filter_primes def test_empty_array(): assert filter_primes([]) == [] def test_no_primes(): assert filter_primes([0, 1, -2, -3, 4, 6, 8, 10]) == [] def test_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_mixed_elements(): assert filter_primes([1...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Filters the prime numbers from the given array.\n\nParameters:\nnums (list of int): The input array of integers.\n\nReturns:\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 Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ret...
trial_gpt4o_8
{ "original_instruction": "Write a function in Python that receives an array of integers and returns an array containing only the prime numbers from the input, in the same order they appeared. If the input array contains no prime numbers, the function should return an empty array. Consider edge cases such as when the...
0.74043
Evol_3543
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3176e61431bf706be141e3fe5a82c1be9ba72b4e
9b13e56a92df6d661c87e2df0e779f0166429573
v1.0
complete
Evol
Evol_3674_C
def prime_product(numbers: list) -> int: """ This function takes a list of integers and returns the product of all prime numbers in the list. If there are no prime numbers in the list, it should return an error message. If the input is not a list of integers, the function should return an appropriate error ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def prime_product(numbers: list) -> int: """ This function takes a list of integers and returns the...
from solution import prime_product def test_prime_product_with_primes(): assert prime_product([2, 3, 4, 5, 6]) == 30 assert prime_product([11, 13, 17]) == 2431 def test_prime_product_no_primes(): assert prime_product([4, 6, 8, 10]) == 'Error: No prime numbers in the list.' def test_prime_product_empty_li...
[ { "docstring": "Helper function to check if a number is prime. ", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "This function takes a list of integers and returns the product of all prime numbers in the list.\nIf there are...
[ 1, 0, 1, 1, 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 check if a number is prime. \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n...
trial_gpt4o_0
{ "original_instruction": "Implement a function that calculates the product of all the prime numbers in a given list of integers. Include error handling for non-integer inputs and return an appropriate error message when the input list is empty or contains no prime numbers.\n\n```python\ndef prime_product(numbers: li...
0.704666
Evol_3674
C
[ "is_prime", "prime_product" ]
2
[ [ "prime_product", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e1386b917c7ce1a50644ed56ed5d5fa289742561
681cbf229c767483e1f40c0032c3da83a5a9ac0c
v1.0
complete
Evol
Evol_3402_C
import requests from concurrent.futures import ThreadPoolExecutor def fetch_status(url): """ Fetches the HTTP status code for a given URL. Handles exceptions for unreachable URLs. """ try: response = requests.get(url) return (url, response.status_code) except requests.RequestExc...
import requests from concurrent.futures import ThreadPoolExecutor def fetch_status(url): """ Fetches the HTTP status code for a given URL. Handles exceptions for unreachable URLs. """ try: response = requests.get(url) return (url, response.status_code) except requests.RequestExc...
from solution import fetch_status_codes def test_fetch_status_codes_all_success(): urls = ["https://httpbin.org/status/200", "https://httpbin.org/status/204"] results = fetch_status_codes(urls) assert results == [ ("https://httpbin.org/status/200", 200), ("https://httpbin.org/status/204", 2...
[ { "docstring": "Fetches the HTTP status code for a given URL.\nHandles exceptions for unreachable URLs.", "function_declaration": "def fetch_status(url):", "function_name": "fetch_status", "parameter_list": "(url)" }, { "docstring": "Fetches HTTP status codes for a list of URLs concurrently....
[ 1, 1, 0, 1, 1, 1, 0, 1, 1 ]
7
easy
0.778
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import concurrent.futures\nimport requests\n\ndef fetch_status_code(url):\n \"\"\"\n Fetches the HTTP status code for a given URL.\n \n :param url: The...
trial_gpt4o_9
{ "original_instruction": "Develop a program that takes a list of URLs and fetches their HTTP status codes. Your program should be able to handle cases where URLs are unreachable and should accurately report failures alongside successful responses. Additionally, ensure the program is optimized to handle a large list ...
0.642281
Evol_3402
C
[ "fetch_status", "fetch_status_codes" ]
2
[ [ "fetch_status_codes", "fetch_status" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
3cbc04d3ec216be5dfd7e8e4b2c5eae69eae38c7
cef5934aba0315ebcf6241836227ed8a00be8737
v1.0
complete
Evol
Evol_3579_C
from typing import List, Dict def prime_factorials(numbers: List[int]) -> Dict[int, int]: """ Write a function that receives a list of integers and performs the following operations: 1. Find all the prime numbers in the list. 2. Compute the factorial of each prime number. 3. Return a dictionary wh...
from math import factorial def is_prime(n): if n <= 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def prime_factorials(numbers): primes = [num for num in numbers if is_prime(num)] return {prime: factorial(prime) for prime ...
from solution import prime_factorials def test_prime_factorials_example_case(): assert prime_factorials([2, 3, 4, 5, 6, 7, 8, 9, 10]) == {2: 2, 3: 6, 5: 120, 7: 5040} def test_prime_factorials_no_primes(): assert prime_factorials([4, 6, 8, 9, 10]) == {} def test_prime_factorials_all_primes(): assert prim...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_factorials(numbers):", "function_name": "prime_factorials", "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": "import math\n\ndef is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n for i...
trial_gpt4o_8
{ "original_instruction": "Write a function in Python that receives a list of integers and performs the following operations:\n\n1. Find all the prime numbers in the list.\n2. Compute the factorial of each prime number.\n3. Return a dictionary where the keys are the prime numbers and the values are their respective f...
0.690408
Evol_3579
C
[ "is_prime", "prime_factorials" ]
2
[ [ "prime_factorials", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eecad44aadfb6f8e2158012789c395fb5570b848
cdea65e99de54010d7765392d565c956ce02a273
v1.0
complete
Evol
Evol_3598_C
from typing import List 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(20) == False >>> is_prime(1) == False >>> is_prime(0) == False >>> is_prime(-5) == Fal...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(20) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == Fal...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers between a and b (inclusive).", "function_declaration": "def sum_of_primes(a, b):", "f...
[ 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 is_prime(n):\n \"\"\"\n Determines if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n...
trial_gpt4o_9
{ "original_instruction": "Write a Python function to find the sum of all prime numbers between two given numbers (inclusive). The function should take two integers as input and return the calculated sum. If there are no prime numbers in the given range, the function should return 0.", "prompt_id": "00003598", "r...
0.777719
Evol_3598
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
82c7b34e419aa8ae6b973e90bdceae36e9fa1d23
79bd63948c7cac96ad29026c82d0d24e8f9a1abf
v1.0
complete
Evol
Evol_2949_C
import asyncio import websockets import json async def start_server(): """ Create a program that implements a basic chat server using WebSockets in Python. The server should be capable of handling multiple simultaneous client connections and implement the following features: 1. A way for new users to ...
import asyncio import websockets import json clients = {} usernames = set() async def register_client(websocket): while True: msg = await websocket.recv() msg_data = json.loads(msg) if msg_data["action"] == "register": username = msg_data["username"] if use...
import asyncio import websockets import json import pytest from solution import start_server @pytest.fixture def event_loop(): loop = asyncio.get_event_loop() yield loop loop.close() @pytest.fixture async def server(event_loop): server = await start_server yield server server.close() awai...
[]
[ 0, 1, 1, 0, 0, 0, 1, 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": "import asyncio\nimport websockets\nimport json\n\nclients = {} # Dictionary to store clients and their usernames\n\nasync def broadcast(message):\n \"\"\"Send ...
trial_gpt4o_1
{ "original_instruction": "Create a program that implements a basic chat server using WebSockets in Python. The server should be capable of handling multiple simultaneous client connections. Implement the following features:\n\n1. A way for new users to connect to the chat by providing a unique username.\n2. Broadcas...
0.550921
Evol_2949
C
[ "register_client", "unregister_client", "broadcast", "handler" ]
4
[ [ "handler", "broadcast" ], [ "handler", "register_client" ], [ "handler", "unregister_client" ], [ "register_client", "broadcast" ], [ "unregister_client", "broadcast" ] ]
5
[]
false
[]
false
pytest
true
[ "websockets" ]
false
218e86599195e2bc82c9934e9ea71bb1b1b3de3e
2ca4eabadf87bea0424d229dfe93b72fd5acf233
v1.0
complete
Evol
Evol_3669_C
import math from typing import List, Dict def is_prime(n: int) -> bool: """ Return True if n is a prime number.""" # Implementation required def is_perfect_square(n: int) -> bool: """Return True if n is a perfect square.""" # Implementation required def factorial(n: int) -> int: """Return the fac...
import math def is_prime(n): """ Return True if n is a prime number.""" if n <= 1: return False for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def is_perfect_square(n): """Return True if n is a perfect square.""" if n < 0: ...
from solution import analyze_numbers def test_analyze_numbers(): test_list = [2, 4, 5, -1, 0] result = analyze_numbers(test_list) assert result[2]['is_prime'] == True assert result[2]['is_perfect_square'] == False assert result[2]['factorial'] == 2 assert result[4]['is_prime'] == False ...
[ { "docstring": "Return True if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return True if n is a perfect square.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of integers and returns a dictionary with the following properties for each number: whether it is a prime, whether it is a perfect square, and its factorial value. The function should handle edge cases where the number might be negative or zero.\n\nList: ...
0.693018
Evol_3669
C
[ "is_prime", "is_perfect_square", "factorial", "analyze_numbers" ]
4
[ [ "analyze_numbers", "factorial" ], [ "analyze_numbers", "is_perfect_square" ], [ "analyze_numbers", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
7ee4fff063a3178d489eb807d252fa384dd01201
0599b1078c8e70875510d3737009c978615ecf2d
v1.0
complete
Evol
Evol_3570_C
def is_prime(n: int) -> bool: """ Check if a number is a 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 """ pass def next_prime(n: int) -> i...
def is_prime(n): """ Check if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def next_prime(n): """ Fin...
from solution import is_prime, next_prime, replace_with_next_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False def te...
[ { "docstring": "Check if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find the next prime greater than or equal to n.", "function_declaration": "def next_prime(n):", "function_name": "next_p...
[ 0, 0, 0, 1, 0, 1, 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": "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 for i in range(3, int(n ...
trial_gpt4o_7
{ "original_instruction": "Write a function that takes in a list of integers and returns a new list containing all the elements of the original list but with each prime number replaced by the nearest prime number that is greater than or equal to it. If the input list is empty, return an empty list. The function shoul...
0.754906
Evol_3570
C
[ "is_prime", "next_prime", "replace_with_next_primes" ]
3
[ [ "next_prime", "is_prime" ], [ "replace_with_next_primes", "next_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5df45b040a7844176fdabf3b6d3671b4d3fb641e
639b6d83280e57af1c418ea2cfbf646fce9464b6
v1.0
complete
Evol
Evol_3835_C
from typing import List def largest_number(nums: List[int]) -> str: """ Takes a list of integers and returns the largest possible number formed by rearranging the list, as a string. >>> largest_number([3, 30, 34, 5, 9]) == "9534330" >>> largest_number([1, 2, 3, 4, 5, 6, 7, 8, 9]) == "987654321" >>...
from functools import cmp_to_key def comparator(a, b): t1 = a + b t2 = b + a return (t1 > t2) - (t1 < t2) # returns 1 if t1 > t2, -1 if t1 < t2, 0 otherwise def largest_number(nums): """ Takes a list of integers and returns the largest possible number formed by rearranging the list, as a string. ...
from solution import largest_number def test_largest_number_basic(): assert largest_number([3, 30, 34, 5, 9]) == "9534330" def test_largest_number_single_digit(): assert largest_number([1, 2, 3, 4, 5, 6, 7, 8, 9]) == "987654321" def test_largest_number_all_zeros(): assert largest_number([0, 0, 0, 0]) == ...
[ { "docstring": null, "function_declaration": "def comparator(a, b):", "function_name": "comparator", "parameter_list": "(a, b)" }, { "docstring": "Takes a list of integers and returns the largest possible number formed by rearranging the list, as a string.", "function_declaration": "def ...
[ 0, 0, 0, 0, 1, 1, 0, 0, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef largest_number(nums):\n \"\"\"\n Returns the largest possible number that can be formed from the list of integers.\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of integers and returns the list with its elements rearranged to form the maximum possible integer. The output should be in the form of a string to avoid issues with large integers.\n\nExample:\nInput: [3, 30, 34, 5, 9]\nOutput: \"9534330\"", "prompt_id...
0.730032
Evol_3835
C
[ "comparator", "largest_number" ]
2
[ [ "largest_number", "comparator" ] ]
1
[]
false
[]
false
pytest
true
[]
true
278f0a8e7168f1f8ee7f8724cfb76ec9d22318a8
86c4043fe427a812f3ad99acd473b31c5d45f0cc
v1.0
complete
Evol
Evol_3785_C
def is_prime(n): """ Helper function to determine 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...
def is_prime(n): """ Helper function to determine 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...
from solution import separate_primes def test_empty_list(): primes, non_primes = separate_primes([]) assert primes == [] assert non_primes == [] def test_only_prime_numbers(): primes, non_primes = separate_primes([2, 3, 5, 7, 11]) assert primes == [2, 3, 5, 7, 11] assert non_primes == [] def ...
[ { "docstring": "Helper function to determine if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns two separate lists:\none with prime numbers and one with non-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 is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of integers as an argument and returns two separate lists: one containing all the prime numbers and the other containing all non-prime numbers from the given list. Ensure that the function handles edge cases such as an empty list or lists with no prime nu...
0.764229
Evol_3785
C
[ "is_prime", "separate_primes" ]
2
[ [ "separate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e4f1f53c9c3860342aa425db9c35cf92739f3828
2953d09bd0190436a2b9c994a6e6832ba8db26f8
v1.0
complete
Evol
Evol_3962_C
import sqlite3 from typing import List, Dict def classify_students(students: List[Dict]) -> List[Dict]: """ Classify students as 'Pass' or 'Fail' based on their average grade. Args: students (list): A list of dictionaries, each containing 'name', 'age', and 'grades'. Returns: list: A...
import sqlite3 def classify_students(students): """ Classify students as 'Pass' or 'Fail' based on their average grade. Args: students (list): A list of dictionaries, each containing 'name', 'age', and 'grades'. Returns: list: A list of dictionaries containing 'name' and 'classificati...
from solution import classify_students, save_to_database import sqlite3 import os DATABASE_PATH = 'students.db' def setup_function(): # Remove database file if exists before each test if os.path.exists(DATABASE_PATH): os.remove(DATABASE_PATH) def teardown_function(): # Remove database file after...
[ { "docstring": "Classify students as 'Pass' or 'Fail' based on their average grade.\n\nArgs:\nstudents (list): A list of dictionaries, each containing 'name', 'age', and 'grades'.\n\nReturns:\nlist: A list of dictionaries containing 'name' and 'classification'.", "function_declaration": "def classify_studen...
[ 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
8
easy
0.889
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import sqlite3\n\ndef classify_students(student_records):\n \"\"\"\n Classifies students as \"Pass\" or \"Fail\" based on their average grade.\n Also stor...
trial_gpt4o_2
{ "original_instruction": "Create a Python function that takes a list of dictionaries representing student records. Each dictionary contains `name`, `age`, and `grades` (a list of integers). The function should calculate the average grade for each student and classify them as \"Pass\" or \"Fail\". A student passes if...
0.609612
Evol_3962
C
[ "classify_students", "save_to_database" ]
2
[ [ "classify_students", "save_to_database" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00609ce839e27b952cbadffd9348c6ba863f4a0d
59a6c99e89aaa297ba0336edcad6e19aa9f36630
v1.0
complete
Evol
Evol_3787_C
from typing import List def is_prime(n: int) -> bool: """ Determine if n is a prime number. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(16) == False >>> is_prime(17) == True >>> is_prime(1) == False >>> is_prime(0...
from typing import List def is_prime(n: int) -> bool: """ Determine if 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: ...
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(16) == False assert is_prime(17) == True assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Determine if 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 filter_primes(lst):...
[ 1, 1, 0, 1, 1, 1, 0, 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": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n ...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of integers as input and returns a new list containing only the prime numbers from the input list. Ensure that your function is optimized for performance, especially for large input lists, and that it properly handles edge cases such as empty lists or lis...
0.815357
Evol_3787
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
391041741ae09b551abe43ae6424ffeab8eca6a5
714f7d1b7f9734a3b03de770eaf847988dcc522d
v1.0
complete
Evol
Evol_3868_C
from typing import List def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. """ # Function implementation here def filter_primes(numbers: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from the original list. >>> filter_...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes...
from solution import filter_primes def test_filter_primes_all_prime_numbers(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_mixed_numbers(): assert filter_primes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_no_primes(): assert filter_prim...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.", "function_declaration": "def...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. If there are no prime numbers, the function should return an empty list. Ensure that your function handles edge cases such as negative numbers and zeros appropria...
0.755434
Evol_3868
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f31db204171f8beb64ba21a3947f0069994a37b3
ccd1a7dcc02a1c49a2cf569221158df95176d99e
v1.0
complete
Evol
Evol_2919_C
import numpy as np from sklearn.datasets import load_iris from sklearn.preprocessing import StandardScaler from typing import Tuple def preprocess_iris_data() -> np.ndarray: """ Preprocess the Iris dataset. The function loads the iris dataset, scales the features and returns the data. """ # Your code h...
import numpy as np from sklearn.datasets import load_iris from sklearn.preprocessing import StandardScaler from sklearn.metrics import silhouette_score def initialize_centroids(X, k): np.random.seed(42) random_indices = np.random.permutation(np.arange(len(X))) centroids = X[random_indices[:k]] return c...
from solution import preprocess_iris_data, kmeans, compute_silhouette_score from sklearn.cluster import KMeans import numpy as np def test_initialize_centroids(): X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]]) centroids = initialize_centroids(X, 2) assert centroids.shape == (2, 2) assert len(np.unique(...
[ { "docstring": null, "function_declaration": "def initialize_centroids(X, k):", "function_name": "initialize_centroids", "parameter_list": "(X, k)" }, { "docstring": null, "function_declaration": "def assign_clusters(X, centroids):", "function_name": "assign_clusters", "parameter...
[ 0, 1, 1, 1, 1, 1, 1, 0, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import numpy as np\nimport pandas as pd\nfrom sklearn.datasets import load_iris\nfrom sklearn.metrics import silhouette_score\nfrom sklearn.preprocessing import St...
trial_gpt4o_9
{ "original_instruction": "Implement a k-means clustering algorithm from scratch and use it to cluster the data from the Iris dataset. After obtaining the clusters, use a silhouette score to evaluate the quality of the clustering. Compare the silhouette score of your implementation with the score obtained using Sciki...
0.700849
Evol_2919
C
[ "initialize_centroids", "assign_clusters", "update_centroids", "kmeans", "preprocess_iris_data", "compute_silhouette_score" ]
6
[ [ "kmeans", "assign_clusters" ], [ "kmeans", "initialize_centroids" ], [ "kmeans", "update_centroids" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy", "sklearn" ]
false
d5c604e21f181520920891d9e05c7611221b9ac7
8dca08126c8898ab4826d4da802381ddf0a38f93
v1.0
complete
Evol
Evol_4223_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, else False. """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from the input list. >>> filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 1...
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 filter_prim...
from solution import filter_primes def test_filter_primes_with_mixed_numbers(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_with_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13, 17]) == [2, 3, 5, 7, 11, 13, 17] def test_filter_primes_with_no_primes...
[ { "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 new list containing only the prime numbers from the input list.", "function_declaration": "def ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a list of integers and returns a new list containing only the elements that are prime numbers. The function should efficiently check for prime numbers and maintain the original order of the elements in the returned list.", "prompt_id": "00004223", "row_id": ...
0.761046
Evol_4223
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ae7aa9b34e94be7f1c32f73e8ee155004ec4a03b
db2c3e70f50e118b41b5e593c69b59c1dafc4cef
v1.0
complete
Evol
Evol_3803_C
def is_unique_string(s: str) -> bool: """ Determines if a string has all unique characters. >>> is_unique_string("hello") == False >>> is_unique_string("world") == True >>> is_unique_string("") == True >>> is_unique_string("abcdefg") == True >>> is_unique_string("aabbcc") == False """ def ar...
def is_unique_string(s): """ Determines if a string has all unique characters. Args: s (str): The string to check. Returns: bool: True if all characters in the string are unique, False otherwise. """ char_set = set() for char in s: if char in char_set: r...
from solution import is_unique_string, are_strings_unique def test_is_unique_string(): assert is_unique_string("hello") == False assert is_unique_string("world") == True assert is_unique_string("") == True assert is_unique_string("abcdefg") == True assert is_unique_string("aabbcc") == False def te...
[ { "docstring": "Determines if a string has all unique characters.\n\nArgs:\ns (str): The string to check.\n\nReturns:\nbool: True if all characters in the string are unique, False otherwise.", "function_declaration": "def is_unique_string(s):", "function_name": "is_unique_string", "parameter_list": ...
[ 1, 1, 0, 0, 1, 0, 1, 1, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def has_all_unique_chars(s):\n \"\"\"\n Returns True if the string `s` has all unique characters, otherwise False.\n \"\"\"\n char_set = set()\n for...
trial_gpt4o_9
{ "original_instruction": "Write a function to determine if a string has all unique characters. For example, \"hello\" has duplicate characters, while \"world\" does not. Your solution should first implement a function that checks uniqueness for a given string. Then, extend it to handle inputs of a list of strings an...
0.764656
Evol_3803
C
[ "is_unique_string", "are_strings_unique" ]
2
[ [ "are_strings_unique", "is_unique_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6fc46ed4a1e94a408ce0d00474270560649c7b8d
123d30acfbd86558f53f443c1b6661ccf846b76a
v1.0
complete
Evol
Evol_4054_C
import random def simulate_robot() -> int: """ Simulate the robot's movement on an 8x8 grid. The robot starts at (1, 1) and collects energy units in a specified area. Returns the number of steps taken for the robot to collect 10 energy units and then reach the teleporter at (8, 8). """ pass def expect...
import random def simulate_robot(): grid_size = 8 start = (1, 1) teleporter = (8, 8) energy_area = {(i, j) for i in range(3, 7) for j in range(3, 7)} position = start energy_units = 0 steps = 0 while energy_units < 10 or position != teleporter: # Random move x,...
from solution import expected_steps, simulate_robot def test_simulate_robot(): """ Test simulate_robot to ensure it does not run infinitely and collects 10 energy units before ending. """ result = simulate_robot() assert result > 0 def test_expected_steps(): """ Test expected_steps produce...
[ { "docstring": null, "function_declaration": "def simulate_robot():", "function_name": "simulate_robot", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def expected_steps(num_simulations=10000):", "function_name": "expected_steps", "parameter_list": "(num...
[ 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 random\n\ndef simulate_robot_steps():\n # Initial position\n position = (1, 1)\n # Number of energy units collected\n energy_units = 0\n # St...
trial_gpt4o_1
{ "original_instruction": "A robot is placed on an $8 \\times 8$ grid. The robot's initial position is at the bottom-left corner (1, 1). The robot can move one step up, down, left, or right, but cannot move outside the grid. A teleporter is located at the top-right corner (8, 8). When the robot reaches the teleporter...
0.610901
Evol_4054
C
[ "simulate_robot", "expected_steps" ]
2
[ [ "expected_steps", "simulate_robot" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fe7c56e03031045a8d2c49b6ffcc07a050d91a5b
2c6ca850a90ab6edc11128f390cc3a1328a5a2ce
v1.0
complete
Evol
Evol_4194_C
import math from typing import List def is_perfect_square(x: int) -> bool: """ Check if x is a perfect square. >>> is_perfect_square(4) True >>> is_perfect_square(5) False """ s = int(math.sqrt(x)) return s * s == x def a(k: int) -> int: """ Returns the k-th term of the sequence a(...
import math def is_perfect_square(x): """ Check if x is a perfect square. """ s = int(math.sqrt(x)) return s * s == x def a(k): """ Returns the k-th term of the sequence a(n). """ if k == 1: return 1 sequence = [1] while len(sequence) < k: previous = se...
from solution import a def test_a_first_term(): assert a(1) == 1 def test_a_second_term(): assert a(2) == 3 def test_a_third_term(): assert a(3) == 6 def test_a_fourth_term(): assert a(4) == 10 def test_a_fifth_term(): assert a(5) == 15 def test_a_larger_terms(): assert a(6) == 21 # 15 + ...
[ { "docstring": "Check if x is a perfect square.", "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": "Returns the k-th term of the sequence a(n).", "function_declaration": "def a(k):", "function_name": ...
[ 0, 1, 0, 0, 0, 1, 1, 0, 0 ]
3
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(x):\n \"\"\"Check if x is a perfect square.\"\"\"\n s = int(math.sqrt(x))\n return s * s == x\n\ndef sequence_a(k):\n...
trial_gpt4o_6
{ "original_instruction": "Define a sequence of integers where each term in the sequence is denoted by $a(n)$. The first term of this sequence is $a(1) = 1$. For any $n>1$, $a(n)$ is defined as the smallest positive integer greater than $a(n-1)$ such that $a(n) + a(n-1)$ is a perfect square.\n\nFor example, the first...
0.670786
Evol_4194
C
[ "is_perfect_square", "a" ]
2
[ [ "a", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aa3fc75a0a8420becb774687624462fb65350237
d81c6266ab6aa3bb893d0d46613b67542b5b4122
v1.0
complete
Evol
Evol_3859_C
from typing import List def extract_primes(numbers: List[int]) -> List[int]: """ Given a list of integers, returns a new list containing only the prime numbers. Optimizations include trial division by numbers up to the square root of the target number, skipping even numbers and multiples of 3 bey...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import extract_primes def test_extract_primes_with_mixed_list(): assert extract_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_extract_primes_with_all_primes(): assert extract_primes([11, 13, 17, 19, 23]) == [11, 13, 17, 19, 23] def test_extract_primes_with_no_primes(): asser...
[ { "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": "Given a list of integers, returns a new list containing only the prime numbers.\nOptimizations include t...
[ 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 Check if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_8
{ "original_instruction": "Implement a Python function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Optimize your function for performance with large input lists. Provide a brief explanation of your optimization approach.", "prompt_id": "00003859", ...
0.800059
Evol_3859
C
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0da1345a42dea72b2a412dfd9cb66139a52ad08f
f078aa7ee595fe60344a79a1a07f24dd38f90107
v1.0
complete
Evol
Evol_3661_C
import os from typing import Dict, Tuple def read_and_count_words(file_path: str, keyword: str) -> Tuple[Dict[str, int], int, bool]: """Read the file at file_path, count occurrences of each word, and check for keyword. Args: file_path (str): Path to the file. keyword (str): Keyword to search ...
def read_and_count_words(file_path, keyword): try: with open(file_path, 'r') as f: content = f.read() word_list = content.split() word_count = {} for word in word_list: word_count[word] = word_count.get(word, 0) + 1 keyword_count = ...
import pytest from solution import read_and_count_words, process_files def test_read_and_count_words_valid_file(): # Create a temporary text file for testing with open('temp_test_file.txt', 'w') as f: f.write("hello world hello") word_count, keyword_count, keyword_found = read_and_count_words('tem...
[ { "docstring": null, "function_declaration": "def read_and_count_words(file_path, keyword):", "function_name": "read_and_count_words", "parameter_list": "(file_path, keyword)" }, { "docstring": null, "function_declaration": "def process_files(file_paths, keyword):", "function_name": ...
[ 1, 1, 1, 0, 0, 1, 0, 0, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def read_and_count_words(file_path, keyword):\n try:\n with open(file_path, 'r') as f:\n content = f.read()\n word_list = content.s...
trial_gpt4o_8
{ "original_instruction": "Design a **Coding Assessment Question**.\n\n## Objective\nAnalyze the provided sample questions and create an additional question that aligns with the existing set in terms of style, complexity, and scope.\n\n## Guidelines\n\n### Question Style\n- Carefully examine the format and presentati...
0.702458
Evol_3661
C
[ "read_and_count_words", "process_files" ]
2
[ [ "process_files", "read_and_count_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9a8cd43670f9a9e43f1d08e02ebb7dd8136e7829
de8dd3450465cc6842a9f924728e74226e7564f2
v1.0
complete
Evol
Evol_4205_C
def validate_numbers(lst): """Ensure each item in the list is either int or float. Raises: ValueError: If any item is not a number. """ pass def flatten_list(lst): """Flatten a nested list into a single list of numbers. Returns: list: A flattened list of numbers. "...
def validate_numbers(lst): """Ensure each item in the list is either int or float. Raises: ValueError: If any item is not a number. """ for item in lst: if isinstance(item, list): validate_numbers(item) # Recursive check for nested lists elif not isinstance(item...
from solution import calculate_average, flatten_list, validate_numbers def test_validate_numbers_all_int(): validate_numbers([1, 2, 3]) # Should not raise any exception def test_validate_numbers_all_float(): validate_numbers([1.0, 2.0, 3.0]) # Should not raise any exception def test_validate_numbers_mixed_...
[ { "docstring": "Ensure each item in the list is either int or float.\n\nRaises:\n ValueError: If any item is not a number.", "function_declaration": "def validate_numbers(lst):", "function_name": "validate_numbers", "parameter_list": "(lst)" }, { "docstring": "Flatten a nested list into a...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def validate_numbers(lst):\n \"\"\"Ensure each item in the list is either int or float.\n \n Raises:\n ValueError: If any item is not a number.\n ...
trial_gpt4o_9
{ "original_instruction": "Design a Python function, `calculate_average`, that computes the average value of an array of numbers. The function should also handle lists of lists (nested lists) by calculating the average of all the numbers contained within. For this purpose, you should implement two helper functions: `...
0.633472
Evol_4205
C
[ "validate_numbers", "flatten_list", "calculate_average" ]
3
[ [ "calculate_average", "flatten_list" ], [ "calculate_average", "validate_numbers" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b32591b437e625a754bcb7d321adb4ebbb52ff2c
6b10ddfda4861ab349e5ba95937c54a94f6ca42d
v1.0
complete
Evol
Evol_4188_C
def sequence_value(n: int) -> int: """ Given a position 'n', calculate the number based on its position, the position immediately before it, and the position immediately after it. >>> sequence_value(1) == 1 >>> sequence_value(2) == 6 >>> sequence_value(3) == 24 >>> sequence_value(4) == 60 >>...
def sequence_value(n): if n == 1: return 1 return n * (n-1) * (n+1) def get_6th_number(): return sequence_value(6)
from solution import sequence_value, get_6th_number def test_sequence_value(): assert sequence_value(1) == 1 assert sequence_value(2) == 2 * 1 * 3 == 6 assert sequence_value(3) == 3 * 2 * 4 == 24 assert sequence_value(4) == 4 * 3 * 5 == 60 assert sequence_value(5) == 5 * 4 * 6 == 120 assert seq...
[ { "docstring": null, "function_declaration": "def sequence_value(n):", "function_name": "sequence_value", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def get_6th_number():", "function_name": "get_6th_number", "parameter_list": "()" } ]
[ 1, 0, 0, 1, 1, 1, 0, 1, 0 ]
5
medium
0.556
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def sequence_product(n):\n \"\"\"\n Computes the product of the sequence number.\n \"\"\"\n if n == 1:\n return 1 * 1 * 2\n else:\n re...
trial_gpt4o_7
{ "original_instruction": "In a sequence where each number is the product of its position (starting from 1) and the position immediately before and after it, determine the 6th number in the sequence. Interpret the position before 1 as 1 and after the end position (n) as n. What would be the 6th number if the options ...
0.625902
Evol_4188
C
[ "sequence_value", "get_6th_number" ]
2
[ [ "get_6th_number", "sequence_value" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b601c19c93741be0bc8a4ce9aa30880ad8ae01cb
c4347805eacda9942ff5bba3bee8a607dc2b3935
v1.0
complete
Evol
Evol_3375_C
from typing import List, Tuple def longest_increasing_subsequence(arr: List[int]) -> Tuple[List[int], int]: """Finds the longest increasing subsequence in a list of integers. Returns the subsequence and its length as a tuple. >>> longest_increasing_subsequence([10, 9, 2, 5, 3, 7, 101, 18]) ([2, 3, 7, 1...
def longest_increasing_subsequence(arr): """ Finds the longest increasing subsequence in a list of integers. Returns the subsequence and its length as a tuple. """ from bisect import bisect_left if not arr: return [], 0 n = len(arr) # Will store the indices of the small...
from solution import longest_increasing_subsequence, process_multiple_requests def test_single_request(): arr = [10, 9, 2, 5, 3, 7, 101, 18] expected_subsequence = [2, 3, 7, 18] expected_length = 4 subsequence, length = longest_increasing_subsequence(arr) assert subsequence == expected_subsequence ...
[ { "docstring": "Finds the longest increasing subsequence in a list of integers.\nReturns the subsequence and its length as a tuple.", "function_declaration": "def longest_increasing_subsequence(arr):", "function_name": "longest_increasing_subsequence", "parameter_list": "(arr)" }, { "docstri...
[ 0, 1, 0, 0, 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": "from bisect import bisect_left\n\ndef longest_increasing_subsequence(nums):\n \"\"\"\n Finds the longest increasing subsequence (LIS) in the given list of in...
trial_gpt4o_1
{ "original_instruction": "Write a Python function that identifies the longest increasing subsequence within a given list of integers. The function must efficiently handle lists that may include negative integers and have a size up to 10^5 elements without exceeding time and space complexity constraints.\n\nThe retur...
0.665732
Evol_3375
C
[ "longest_increasing_subsequence", "process_multiple_requests" ]
2
[ [ "process_multiple_requests", "longest_increasing_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f4cdf500048bdc5da3bf7e963a8cae5645d5ab5c
596b726e7aae110b24b51ebe8d6dc394429a444f
v1.0
complete
Evol
Evol_4199_C
def find_primes_in_range(start: int, end: int) -> List[int]: """ Identify all prime numbers within a given range, inclusive of the start and end points. >>> find_primes_in_range(10, 20) [11, 13, 17, 19] >>> find_primes_in_range(50, 100) [53, 59, 61, 67, 71, 73, 79, 83, 89, 97] >>> find_primes_in_range(2...
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def find_prim...
from solution import find_primes_in_range def test_small_range(): assert find_primes_in_range(10, 20) == [11, 13, 17, 19] def test_large_range(): assert find_primes_in_range(50, 100) == [53, 59, 61, 67, 71, 73, 79, 83, 89, 97] def test_single_prime_range(): assert find_primes_in_range(29, 29) == [29] de...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find all prime numbers in the given range [start, end].", "function_declaration": "def find_primes_in_r...
[ 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 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": "Utilizing the Python programming language, devise a function to identify all prime numbers within a given range, inclusive of the start and end points. The function should take two parameters representing the start and end values and return a list of prime numbers within that range. Ensure ...
0.669886
Evol_4199
C
[ "is_prime", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0e845fa6d6d5f9f9e25803c0a5a8d4cdef6f24cd
61555668ae6bf6eeb5178043d8c9285d61d96731
v1.0
complete
Evol
Evol_3824_C
import math from typing import List, Optional def is_prime(n: int) -> bool: """ Helper function to check if a given number n is prime. """ if n <= 1: return False if n == 2: return True for i in range(2, math.isqrt(n) + 1): if n % i == 0: return False re...
import math def is_prime(n): """ Helper function to check if a given number n is prime. """ if n <= 1: return False if n == 2: return True for i in range(2, math.isqrt(n) + 1): if n % i == 0: return False return True def filter_primes(lst): """ R...
from solution import filter_primes, highest_prime, sum_of_primes def test_filter_primes(): assert filter_primes([10, 15, 3, 7, 11, 2, 20, 13, 5]) == [3, 7, 11, 2, 13, 5] assert filter_primes([1, 4, 6, 8, 9, 10]) == [] assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_highest_prime(): ...
[ { "docstring": "Helper function to check if a given number n 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 lst.", "function_declaration": "def filter_prim...
[ 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 a prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**...
trial_gpt4o_8
{ "original_instruction": "Write a program that takes a list of integers and returns a new list that contains only the prime numbers from the original list. Additionally, the program should include a function to find the highest prime number in the list and another function to calculate the sum of all prime numbers. ...
0.714751
Evol_3824
C
[ "is_prime", "filter_primes", "highest_prime", "sum_of_primes" ]
4
[ [ "filter_primes", "is_prime" ], [ "highest_prime", "filter_primes" ], [ "sum_of_primes", "filter_primes" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5fe96b3c90b9c7f7bbd4fd993463eeec349df80e
414e76100956509db906ec71fba25bb6c8ef75ed
v1.0
complete
Evol
Evol_4123_C
from typing import List, Tuple def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. """ # Implementation of is_prime function pass def prime_numbers_and_count(nums: List[int]) -> Tuple[List[int], int]: """ Returns a list containing only the prime numbers from t...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2 or n == 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import prime_numbers_and_count def test_prime_numbers_and_count(): assert prime_numbers_and_count([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == ([2, 3, 5, 7], 4) assert prime_numbers_and_count([11, 13, 17, 19, 23]) == ([11, 13, 17, 19, 23], 5) assert prime_numbers_and_count([0, 1, 4, 6, 8, 10, 12]) == ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the original input list,\nand the count of these prime nu...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_9
{ "original_instruction": "Write a function in Python that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. Additionally, the function should return the count of these prime numbers in the new list. Provide any necessary helper functions and ensure you...
0.799012
Evol_4123
C
[ "is_prime", "prime_numbers_and_count" ]
2
[ [ "prime_numbers_and_count", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b855b24937b21d7160d18b2ca800317583866665
eef4ae34d333581d476b6beadd5c47cfdcc1d05e
v1.0
complete
Evol
Evol_3683_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def inorder_traversal(root): """ Perform an inorder traversal of the BST and collect values in a list. """ pass def sorted_list_to_bst(nums): """...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def inorder_traversal(root): """ Perform an inorder traversal of the BST and collect values in a list. """ if root is None: return [] return inord...
from solution import TreeNode, balance_bst, print_inorder, merge_two_bsts def test_inorder_traversal(): # Construct a sample BST root = TreeNode(3) root.left = TreeNode(1) root.right = TreeNode(4) root.left.right = TreeNode(2) # Expected inorder traversal: [1, 2, 3, 4] assert inorder_t...
[]
[ 0, 0, 0, 0, 1, 0, 1, 1, 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": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef inorder...
trial_gpt4o_9
{ "original_instruction": "Design a function to balance a binary search tree (BST) which may contain duplicate values. Given an unbalanced BST with n nodes (1 <= n <= 10^5), your task is to write a function that transforms it into a balanced BST while retaining its properties.\n\nYour solution should perform the foll...
0.58418
Evol_3683
C
[ "inorder_traversal", "sorted_list_to_bst", "balance_bst", "print_inorder", "merge_two_bsts" ]
5
[ [ "balance_bst", "inorder_traversal" ], [ "balance_bst", "sorted_list_to_bst" ], [ "merge_two_bsts", "inorder_traversal" ], [ "merge_two_bsts", "sorted_list_to_bst" ], [ "print_inorder", "inorder_traversal" ] ]
5
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
d24834ff08781016ffc816e0c82476bebc9ea02b
cbfa1bd04f3bea4db008d4a2f04bdc3a52b541e9
v1.0
complete
Evol
Evol_3827_C
from typing import List, Union def sum_of_digits(n: int) -> int: """ Returns the sum of the digits of an integer n. >>> sum_of_digits(21) 3 >>> sum_of_digits(123) 6 """ pass def create_sum_list(int_list: List[int]) -> List[int]: """ Given a list of integers, returns a new list...
def sum_of_digits(n): """ Returns the sum of the digits of an integer n. """ return sum(int(digit) for digit in str(n)) def create_sum_list(int_list): """ Given a list of integers, returns a new list where each integer is replaced by the sum of its digits. """ return [sum_of_digits(x) f...
from solution import sum_of_digits, create_sum_list, create_digit_sum_dict, highest_digit_sum_in_list def test_sum_of_digits(): assert sum_of_digits(7) == 7 assert sum_of_digits(21) == 3 assert sum_of_digits(123) == 6 def test_create_sum_list(): assert create_sum_list([7, 21, 123]) == [7, 3, 6] as...
[ { "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": "Given a list of integers, returns a new list where each integer is replaced by the sum of its digits....
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def sum_of_digits(n):\n return sum(int(digit) for digit in str(n))\n\ndef create_digit_sums_list(integers):\n return [sum_of_digits(n) for n in integers]\n\n...
trial_gpt4o_3
{ "original_instruction": "Given a list of integers, perform the following tasks in Python:\n\nOriginal list: [7, 2, 9, 21, 4, 6, 1, 3]\n\n1. Create a new list where each integer is replaced by the sum of its digits.\n2. Use the new list to create a dictionary where each key is the original integer from the list and ...
0.644194
Evol_3827
C
[ "sum_of_digits", "create_sum_list", "create_digit_sum_dict", "highest_digit_sum_in_list" ]
4
[ [ "create_digit_sum_dict", "sum_of_digits" ], [ "create_sum_list", "sum_of_digits" ], [ "highest_digit_sum_in_list", "create_digit_sum_dict" ] ]
3
[]
false
[]
false
pytest
true
[]
true
40d7ce5f2d984ba5737860b2e5c56ad606552a6e
c846e8752e447a86cf0911a3aa7779b0e01dea15
v1.0
complete
Evol
Evol_4239_C
from typing import List def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ pass def filter_primes(lst: List[int]) -> List[int]: """ Returns a list containing only the prime numbers from the input list. >>> filter_primes([4, 7, 12, 17, 23]) [7, 17, 23] ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import filter_primes def test_filter_primes_all_prime(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_mixed(): assert filter_primes([4, 7, 12, 17, 23]) == [7, 17, 23] def test_filter_primes_no_prime(): assert filter_primes([4, 6, 8, 10]) == [] def test_...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list containing only the prime numbers from the input list.", "function_declaration": "def fi...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_8
{ "original_instruction": "Create a function that processes an input list of integers and returns a new list containing only the elements that are prime numbers. For instance, given the input list [4, 7, 12, 17, 23], the function should output [7, 17, 23]. Ensure the solution handles edge cases and has an efficient a...
0.743373
Evol_4239
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3e224f485e9938bba5dc5820b1e1e0f6b7e03589
001dd8521c2134beab2886c21d3477d3ea6f28db
v1.0
complete
Evol
Evol_4212_C
def find_anagrams(word: str, candidates: list) -> list: """ Identifies all distinct anagrams of the given word within the nested candidate list. Only includes nested structures in the result and skips non-string elements. >>> word = "listen" >>> candidates = ["enlists", "google", "inlets", "banana", ["...
import re def sanitize_string(s): """ Removes all non-alphabetic characters from the string and converts it to lowercase """ return re.sub(r'[^a-z]', '', s.lower()) def is_anagram(word1, word2): """ Checks if word1 and word2 are anagrams, ignoring case and non-alphabetic characters. """ ...
from solution import find_anagrams def test_find_anagrams(): word = "listen" candidates = ["enlists", "google", "inlets", "banana", ["Silent", "LISTEN"], "tinsel", [None, "Listen"]] expected = ["inlets", ["silent", "listen"], "tinsel", ["listen"]] assert find_anagrams(word, candidates) == expected def...
[ { "docstring": "Removes all non-alphabetic characters from the string and converts it to lowercase", "function_declaration": "def sanitize_string(s):", "function_name": "sanitize_string", "parameter_list": "(s)" }, { "docstring": "Checks if word1 and word2 are anagrams, ignoring case and non...
[ 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import string\n\ndef normalize_string(s):\n return ''.join(sorted(s.lower().translate(str.maketrans('', '', string.punctuation + string.whitespace))))\n\ndef fi...
trial_gpt4o_8
{ "original_instruction": "Construct a function that identifies and returns all the distinct anagrams of a given word within a list of possible candidates. The function should handle case insensitivity and ignore spaces and punctuation in the input word and the candidate words.\n\nThe function should also be able to ...
0.576781
Evol_4212
C
[ "sanitize_string", "is_anagram", "find_anagrams" ]
3
[ [ "find_anagrams", "is_anagram" ], [ "find_anagrams", "sanitize_string" ], [ "is_anagram", "sanitize_string" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5ad34e32e3bb499a8d387680c520456cb8d202ca
ceee715922fc119708cac6ccb2fde7f2cf82c016
v1.0
complete
Evol
Evol_3040_C
def is_prime(n: int) -> bool: """ Determines if a given number n is prime. Args: - n (int): The number to check for primality. Returns: - bool: True if n is prime, False otherwise. """ pass def prime_dict(numbers: list) -> dict: """ Returns a dictionary with unique integers fr...
def is_prime(n): """ Determines if a given number n is prime. Args: - n (int): The number to check for primality. Returns: - bool: True if n is prime, False otherwise. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2...
from solution import prime_dict, is_prime def test_prime_dict_with_mixed_elements(): numbers = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'a', 15] expected_output = { 2: True, 3: True, 4: False, 5: True, 6: False, 7: True, 8: False, 9: False, 10...
[ { "docstring": "Determines if a given number n is prime.\n\nArgs:\n- n (int): The number to check for primality.\n\nReturns:\n- bool: True if n is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Ret...
[ 1, 1, 1, 1, 1, 0, 1, 0, 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 if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n*...
trial_gpt4o_9
{ "original_instruction": "Create a function in a language of your choice that takes a list of integers and returns a dictionary where the keys are the unique integers and the values are Booleans indicating whether the integer is prime. \n\nThe function should handle error scenarios such as when the input list contai...
0.742158
Evol_3040
C
[ "is_prime", "prime_dict" ]
2
[ [ "prime_dict", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
729fd5c14ed93525116f8ea17a634903ff343c69
e9b507521dfab71229b346fa97d0c486b6ea22ae
v1.0
complete
Evol
Evol_4353_C
from typing import List def merge_sort(arr: List[int]) -> List[int]: """ Complete the merge_sort function to implement the Merge Sort algorithm. Given an unsorted list of integers, the function should return the sorted list in ascending order using the Merge Sort algorithm. >>> merge_sort([38, 27, 43,...
from typing import List def merge_sort(arr: List[int]) -> List[int]: if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = merge_sort(arr[:mid]) right_half = merge_sort(arr[mid:]) return merge(left_half, right_half) def merge(left: List[int], right: List[int]) -> List[int]...
from solution import merge_sort def test_merge_sort_with_positive_numbers(): assert merge_sort([38, 27, 43, 3, 9, 82, 10]) == [3, 9, 10, 27, 38, 43, 82] def test_merge_sort_with_negative_and_positive_numbers(): assert merge_sort([-1, 6, 3, -5, 9, 0, 2]) == [-5, -1, 0, 2, 3, 6, 9] def test_merge_sort_with_dup...
[ { "docstring": null, "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" } ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Perform a Merge Sort on a given list of integers.\n\n Parameters:\n arr (List[int]): A list of integers to sort.\n\n ...
trial_gpt4o_9
{ "original_instruction": "Complete the `merge_sort` function to implement the Merge Sort algorithm. Given an unsorted list of integers, the function should return the sorted list in ascending order using the Merge Sort algorithm. \n\n## Function Signature\n```python\ndef merge_sort(arr: List[int]) -> List[int]:\n```...
0.647864
Evol_4353
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
24c5a83bc39613b2bb8d32519c03fe772fc1a7fe
b6c6e75661c99d945e66e437e85e59c25a205e86
v1.0
complete
Evol
Evol_4211_C
import numpy as np import matplotlib.pyplot as plt from typing import List, Tuple def normalize_ratios(ratios: List[float]) -> List[float]: """ Normalize a list of ratios so that they sum to 1. """ def blend_colors(primary_colors: List[Tuple[int, int, int]], blending_ratios: List[List[float]]) -> Lis...
import numpy as np import matplotlib.pyplot as plt def normalize_ratios(ratios): """ Normalize a list of ratios so that they sum to 1. """ total = sum(ratios) if total == 0 or any(r < 0 for r in ratios): raise ValueError("Invalid blending ratio") return [r / total for r in ratios] def ...
from solution import blend_colors, visualize_colors def test_blend_colors_normal_input(): primary_colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255)] ratios = [[1/3, 1/3, 1/3], [1, 0, 0], [0, 1, 0], [0, 0, 1]] expected = [(85, 85, 85), (255, 0, 0), (0, 255, 0), (0, 0, 255)] assert blend_colors(primary_col...
[ { "docstring": "Normalize a list of ratios so that they sum to 1.", "function_declaration": "def normalize_ratios(ratios):", "function_name": "normalize_ratios", "parameter_list": "(ratios)" }, { "docstring": "Blend the primary colors based on the blending ratios.", "function_declaration...
[ 1, 1, 1, 0, 1, 1, 0, 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": "from typing import List, Tuple\nimport numpy as np\n\ndef blend_colors(primary_colors: List[Tuple[int, int, int]], blending_ratios: List[List[float]], visualize: b...
trial_gpt4o_5
{ "original_instruction": "Develop a program that synthesizes RGB color palettes based on specific inputs and constraints. The program should take a set of primary RGB colors (each defined by R, G, and B values between 0 and 255) and generate a range of new colors by blending these primary colors according to given r...
0.54988
Evol_4211
C
[ "normalize_ratios", "blend_colors", "visualize_colors" ]
3
[ [ "blend_colors", "normalize_ratios" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
2a44b161618855026d90ecee00c7f7e0359ee919
96d817033d5bac46f493ad48c0ea054f8b8f0f4e
v1.0
complete
Evol
Evol_3707_C
from typing import List, Dict from collections import Counter from datetime import datetime import pandas as pd from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer from sklearn.decomposition import LatentDirichletAllocation def preprocess_text(text: str) -> str: """ Preprocess the inp...
import re from collections import Counter from datetime import datetime import pandas as pd from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer from sklearn.decomposition import LatentDirichletAllocation def preprocess_text(text): """ Preprocess the input text by removing special char...
from solution import preprocess_text, extract_hashtags, analyze_trends from datetime import datetime def test_preprocess_text(): assert preprocess_text("Check this out! http://example.com") == "check this out" assert preprocess_text("Amazing! #test @user") == "amazing test user" assert preprocess_text("123...
[ { "docstring": "Preprocess the input text by removing special characters, links, and converting to lowercase.", "function_declaration": "def preprocess_text(text):", "function_name": "preprocess_text", "parameter_list": "(text)" }, { "docstring": "Extract hashtags from the text.", "funct...
[ 0, 1, 0, 0, 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 re\nimport string\nfrom collections import Counter\nfrom datetime import datetime, timedelta\nimport pandas as pd\nfrom sklearn.feature_extraction.text impo...
trial_gpt4o_1
{ "original_instruction": "Develop a sophisticated algorithm capable of dissecting multi-faceted social media data to automatically categorize and predict trending topics. Your solution should harness natural language processing techniques and advanced statistical modeling to analyze user engagement, hashtag prolifer...
0.668561
Evol_3707
C
[ "preprocess_text", "extract_hashtags", "analyze_trends" ]
3
[ [ "analyze_trends", "extract_hashtags" ], [ "analyze_trends", "preprocess_text" ] ]
2
[]
false
[]
false
pytest
true
[ "pandas", "sklearn" ]
false
9fa962448213d3b3ac99a992a7bbe3b653f05c64
f7c659817b8bb925c70cb3c8258ad7055ec5c416
v1.0
complete
Evol
Evol_4501_C
def length_of_longest_substring(s: str) -> int: """Returns the length of the longest substring without repeating characters. >>> length_of_longest_substring('aaaaaaa') == 1 >>> length_of_longest_substring('abcdef') == 6 >>> length_of_longest_substring('abcabcbb') == 3 >>> length_of_longest_substring...
def length_of_longest_substring(s): """ Returns the length of the longest substring without repeating characters. """ n = len(s) max_length = 0 start = 0 char_index_map = {} for end in range(n): if s[end] in char_index_map: start = max(start, char_index_map[s[end]] +...
from solution import length_of_longest_substring, longest_substrings def test_length_of_longest_substring_single_char(): assert length_of_longest_substring('aaaaaaa') == 1 def test_length_of_longest_substring_no_repeats(): assert length_of_longest_substring('abcdef') == 6 def test_length_of_longest_substring...
[ { "docstring": "Returns the length of the longest substring without repeating characters.", "function_declaration": "def length_of_longest_substring(s):", "function_name": "length_of_longest_substring", "parameter_list": "(s)" }, { "docstring": "Returns all distinct substrings of maximum len...
[ 0, 0, 0, 1, 0, 1, 1, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def length_of_longest_substring(s):\n \"\"\"\n Returns the length of the longest substring without repeating characters.\n \"\"\"\n n = len(s)\n cha...
trial_gpt4o_6
{ "original_instruction": "Implement a function that takes a string as an input and returns the length of the longest substring without repeating characters. Additionally, write a function to display all distinct substrings of the input string that are of this maximum length. Ensure your solution efficiently handles ...
0.752617
Evol_4501
C
[ "length_of_longest_substring", "longest_substrings" ]
2
[ [ "longest_substrings", "length_of_longest_substring" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3dc3207832bba37f68073f1514d090b4bad52b6e
e8e704e8d1b1bd8c80532ad5ad5002c8c86a836b
v1.0
complete
Evol
Evol_4088_C
def reverse_string(s: str) -> str: """ Returns a new string with the characters in reverse order. >>> reverse_string("hello") "olleh" >>> reverse_string("") "" >>> reverse_string("a") "a" >>> reverse_string("abc") "cba" >>> reverse_string("Madam") "madaM" """ pas...
def reverse_string(s): """ Returns a new string with the characters in reverse order. """ reversed_str = "" for char in s: reversed_str = char + reversed_str return reversed_str def is_palindrome(s): """ Checks if the input string is a palindrome, ignoring case and non-alphanume...
from solution import reverse_string, is_palindrome def test_reverse_string(): assert reverse_string("hello") == "olleh" assert reverse_string("") == "" assert reverse_string("a") == "a" assert reverse_string("abc") == "cba" assert reverse_string("Madam") == "madaM" def test_is_palindrome(): as...
[ { "docstring": "Returns a new string with the characters in reverse order.", "function_declaration": "def reverse_string(s):", "function_name": "reverse_string", "parameter_list": "(s)" }, { "docstring": "Checks if the input string is a palindrome, ignoring case and non-alphanumeric characte...
[ 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 reverse_string(s):\n \"\"\"\n Returns a new string with the characters in reverse order.\n \"\"\"\n reversed_s = ''\n for char in s:\n re...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a string and returns a new string with the characters in reverse order, without using Python's built-in reverse methods. Additionally, write a function to check if the reversed string is a palindrome, ignoring case and non-alphanumeric characters.", "pro...
0.820032
Evol_4088
C
[ "reverse_string", "is_palindrome" ]
2
[ [ "is_palindrome", "reverse_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9804f7f503a5e1da19f57e442c7e29bb1639b680
2ae8bbce97079b1dab335175d00b86fe336b9528
v1.0
complete
Evol
Evol_3589_C
class Hub: def __init__(self, identifier): """ Initialize a Hub with an identifier and an empty list of neighbors. Parameters: identifier (str): The unique identifier for the hub. """ self.identifier = identifier self.neighbors = [] def add_neighbor(self...
class Hub: def __init__(self, identifier): self.identifier = identifier self.neighbors = [] def add_neighbor(self, neighbor): self.neighbors.append(neighbor) class Package: def __init__(self, tracking_id, sender_address, recipient_address, route): self.tracking_id = trackin...
def test_hub(): hub = Hub("A") assert hub.identifier == "A" assert hub.neighbors == [] def test_hub_add_neighbor(): hub_a = Hub("A") hub_b = Hub("B") hub_a.add_neighbor(hub_b) assert hub_b in hub_a.neighbors def test_package(): route = ["A", "B", "C"] package = Package("123", "Send...
[]
[ 1, 1, 0, 1, 1, 1, 1, 0, 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": "class Hub:\n def __init__(self, identifier):\n self.identifier = identifier\n self.neighbors = []\n \n def add_neighbor(self, neighbor_hub):...
trial_gpt4o_9
{ "original_instruction": "Develop a program to simulate a basic package delivery system. In this system, packages are delivered to users through a series of delivery hubs. The path from the central hub (warehouse) to the end-user's address involves multiple intermediate hubs based on a defined route. Each package ha...
0.397447
Evol_3589
C
[ "initialize_hubs", "add_package", "move_packages", "simulate_delivery" ]
4
[ [ "simulate_delivery", "move_packages" ] ]
1
[]
false
[ "Hub", "Package" ]
true
pytest
false
[]
true
edc22de02c5272506da22fca5ec20b17049532d1
8e3f108df3652b162374f9e8837937f5be7837d2
v1.0
complete
Evol
Evol_4503_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(-3) False >>> is_prime(17) True """ pass def filter_primes(numbers: List[int]) -> List[int]: """ ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for i in range(3, max_divisor, 2): if n % i == 0: return False ...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) assert not is_prime(4) assert is_prime(5) assert not is_prime(0) assert not is_prime(1) assert not is_prime(-3) assert is_prime(17) def test_filter_primes(): assert filter_primes([11, 14, 17, 19, 21]) ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list.", "function_declaration": "def filter_primes(numbers):...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % ...
trial_gpt4o_7
{ "original_instruction": "Write a function that accepts a list of integers and returns a new list that contains only the prime numbers from the original list. Use helper functions to check for prime numbers and to filter the list. If no prime numbers are found, return an empty list.\n\nExample input: [11, 14, 17, 19...
0.778361
Evol_4503
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
84fd5bdfe11abc8726ca62078012635a19a15358
baaf6a6634b3cbc1529224cd10537427df8edee6
v1.0
complete
Evol
Evol_4496_C
class TreeNode: def __init__(self, key): self.left = None self.right = None self.key = key def balance_bst(root): """ This function takes an unbalanced BST and returns a balanced BST which maintains the properties of a binary search tree. The algorithm runs in O(n) time complex...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.key = key def store_inorder(node, inorder_list): """ Helper function to store the inorder traversal of a tree. """ if node is None: return # Store nodes in the left subtree stor...
from solution import TreeNode, balance_bst def bst_to_list(root): """ Helper function to convert BST to a sorted list which can be used in tests for comparison. """ result = [] def inorder(node): if not node: return inorder(node.left) result.append(node.key) ...
[]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef inorder...
trial_gpt4o_9
{ "original_instruction": "Design an algorithm to balance a binary search tree (BST). Given an unbalanced BST, the task is to convert it into a balanced BST that maintains the properties of a BST where the left subtree of a node contains only nodes with keys lesser than the node’s key, and the right subtree only node...
0.677385
Evol_4496
C
[ "store_inorder", "sorted_array_to_bst", "balance_bst" ]
3
[ [ "balance_bst", "sorted_array_to_bst" ], [ "balance_bst", "store_inorder" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
4d9ccea2ff685847f2669045eb9d44cdf39472ac
c471b32c36d99fe88e574199cafcdd87df3e6b77
v1.0
complete
Evol
Evol_4703_C
from typing import List, Tuple def factorial(n: int) -> int: """ Returns the factorial of the given integer n. >>> factorial(0) 1 >>> factorial(1) 1 >>> factorial(5) 120 """ def list_factorials(numbers: List[int]) -> List[Tuple[int, int]]: """ Takes a list of integers and returns a...
from typing import List, Tuple def factorial(n: int) -> int: """ Returns the factorial of the given integer n. """ if n == 0: return 1 result = 1 for i in range(1, n + 1): result *= i return result def list_factorials(numbers: List[int]) -> List[Tuple[int, int]]: """ ...
from solution import factorial, list_factorials def test_factorial_zero(): assert factorial(0) == 1 def test_factorial_one(): assert factorial(1) == 1 def test_factorial_positive_number(): assert factorial(5) == 120 def test_list_factorials_empty(): assert list_factorials([]) == [] def test_list_fa...
[ { "docstring": "Returns the factorial of the given integer n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a list of tuples.\nEach tuple contains an integer from the input list and...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\n\ndef factorial(n: int) -> int:\n \"\"\"\n Returns the factorial of a given integer n.\n \"\"\"\n if n == 0:\n r...
trial_gpt4o_9
{ "original_instruction": "Implement a function in Python that takes a list of integers and returns a list of tuples. Each tuple should contain an integer from the input list and its corresponding factorial. The function should utilize a helper function to calculate the factorial of a given number. Provide type hints...
0.731692
Evol_4703
C
[ "factorial", "list_factorials" ]
2
[ [ "list_factorials", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9b85277ba2b0cfeebc14b017760749dd04c50ec7
6df35e26b1729b29804262d3baca3f5feff5a6cb
v1.0
complete
Evol
Evol_4316_C
def sieve_of_eratosthenes(max_num: int) -> List[int]: """ Return a list of prime numbers up to max_num using the Sieve of Eratosthenes algorithm. """ def filter_primes(numbers: List[int]) -> List[int]: """ Filter and return prime numbers from a list of integers. >>> filter_primes([]) == [] ...
def sieve_of_eratosthenes(max_num): """ Return a list of prime numbers up to max_num using the Sieve of Eratosthenes algorithm. """ sieve = [True] * (max_num + 1) sieve[0] = sieve[1] = False for start in range(2, int(max_num**0.5) + 1): if sieve[start]: for multiple in r...
from solution import filter_primes def test_filter_primes_empty_list(): assert filter_primes([]) == [] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 10, 12]) == [] def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_...
[ { "docstring": "Return a list of prime numbers up to max_num using the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Filter and return prime 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 sieve_of_eratosthenes(max_num):\n \"\"\"\n Generate a list of boolean values, where index represents number\n and boolean value represents whether the...
trial_gpt4o_7
{ "original_instruction": "Write a function that takes a list of integers as input and returns a new list containing only the prime numbers from the input list. The function should be efficient, using a technique such as the Sieve of Eratosthenes for prime number detection. Provide examples and edge cases to illustra...
0.661198
Evol_4316
C
[ "sieve_of_eratosthenes", "filter_primes" ]
2
[ [ "filter_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
58ae559d7bf0ed3f3515cb25d59dabb394941079
d120cb51f1090a82a0d0c03c1ddf656a5db398c3
v1.0
complete
Evol
Evol_4552_C
from typing import List def is_prime(n: int) -> bool: """ Helper function to determine if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(0) False """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Returns a new lis...
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_pr...
from solution import is_prime, filter_primes def test_is_prime(): # Test prime numbers assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(17) == True # Test non-prime numbers assert is_prime(1) == False assert is_prime(4) == False assert...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list consisting of only the prime numbers from the original list.", "function_declaration...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 ...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a list of integers and returns a new list consisting of only the prime numbers from the original list. Ensure that the function is optimally efficient and handles edge cases, such as empty lists or lists with no prime numbers, appropriately. Additionally, implem...
0.757136
Evol_4552
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
30a1c3276d835a1b138003aa8052fc6419b5d241
3457530943fbd36b884c64cb84a30105f033ce2b