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_6402_C
import math from typing import List def is_prime(num: int) -> bool: """ 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(math.sqrt(num)) + 1, 2): if num % i == 0: ...
import math 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(math.sqrt(num)) + 1, 2): if num % i == 0: return False return True def s...
from solution import sum_of_primes def test_empty_list(): assert sum_of_primes([]) == 0 def test_no_primes(): assert sum_of_primes([1, 4, 6, 8, 10]) == 0 def test_all_primes(): assert sum_of_primes([2, 3, 5, 7]) == 17 def test_mix_primes_and_non_primes(): assert sum_of_primes([2, 4, 6, 7, 9]) == 9 ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers in the provided list of positive integers.\nIf the list is empty or contains no prime num...
[ 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 Determines if a given number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return Tr...
trial_gpt4o_1
{ "original_instruction": "Design a function that receives a list of positive integers as input and returns the sum of all prime numbers contained in the list. If the list is empty or contains no prime numbers, the function should return 0.\n\nAdditionally, the function should handle invalid inputs, such as lists con...
0.762612
Evol_6402
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1d0fb37ca9fe827ba75e82b61d8a47b07f98d2ad
7761a136144da163d579e7367c1a7e3d731e5d9a
v1.0
complete
Evol
Evol_7314_C
import csv from collections import defaultdict, Counter from statistics import mean from typing import List, Tuple, Dict, Any def read_csv(file_path: str) -> List[Dict[str, Any]]: """Read a CSV file and return a list of movie dictionaries.""" # Implementation goes here def calculate_average_rating(movies: Lis...
import csv from collections import defaultdict, Counter from statistics import mean def read_csv(file_path): movies = [] with open(file_path, newline='') as csvfile: reader = csv.DictReader(csvfile) for row in reader: try: movie = { 'MovieID': int...
import pytest from solution import (read_csv, calculate_average_rating, get_top_10_highest_rated_movies, count_movies_per_year, find_most_common_genres, process_movie_data) def test_calculate_average_rating(): movies = [{'Rating': 5.0}, {'Rating': 4.0}, {'Rating': 3.0}] assert calculate_...
[ { "docstring": null, "function_declaration": "def read_csv(file_path):", "function_name": "read_csv", "parameter_list": "(file_path)" }, { "docstring": null, "function_declaration": "def calculate_average_rating(movies):", "function_name": "calculate_average_rating", "parameter_l...
[ 1, 0, 0, 1, 1, 1, 0, 0, 0 ]
4
medium
0.444
{ "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, Counter\nfrom statistics import mean\n\ndef read_csv(file_path):\n movies = []\n with open(file_path, newlin...
trial_gpt4o_0
{ "original_instruction": "Write a Python program that reads a CSV file containing movie data and performs the following tasks:\n- Calculate the average rating of all the movies.\n- List the top 10 highest rated movies with their respective ratings.\n- Find and list the number of movies released each year.\n- Identif...
0.711952
Evol_7314
C
[ "read_csv", "calculate_average_rating", "get_top_10_highest_rated_movies", "count_movies_per_year", "find_most_common_genres", "process_movie_data" ]
6
[ [ "process_movie_data", "calculate_average_rating" ], [ "process_movie_data", "count_movies_per_year" ], [ "process_movie_data", "find_most_common_genres" ], [ "process_movie_data", "get_top_10_highest_rated_movies" ], [ "process_movie_data", "read_csv" ] ]
5
[]
false
[]
false
pytest
true
[]
true
e00dc5fb453adf7662e7d709ba0597eb893bd88c
801867eeed4609976f161a9e8e4d31d4feb40a13
v1.0
complete
Evol
Evol_7254_C
import pandas as pd import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.cluster import KMeans import matplotlib.pyplot as plt def preprocess_data(data): """Preprocess the data by removing missing values and normalizing the features. """ pass def determine_optimal_clusters(data...
import pandas as pd from sklearn.cluster import KMeans from sklearn.preprocessing import StandardScaler import matplotlib.pyplot as plt import numpy as np def preprocess_data(data): """ Preprocess the data by removing missing values and normalizing the features. """ # Remove missing values data_cle...
from solution import preprocess_data, determine_optimal_clusters, apply_kmeans, visualize_clusters, kmeans_customer_segmentation import pandas as pd import numpy as np def test_preprocess_data(): data = pd.DataFrame({ 'Annual Income (k$)': [15, 16, 17, np.nan, 20], 'Spending Score (1-100)': [39, 81...
[ { "docstring": "Preprocess the data by removing missing values and normalizing the features.", "function_declaration": "def preprocess_data(data):", "function_name": "preprocess_data", "parameter_list": "(data)" }, { "docstring": "Determine the optimal number of clusters using the elbow meth...
[ 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport numpy as np\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.cluster import KMeans\nimport matplotlib.pyplot as plt\nfro...
trial_gpt4o_7
{ "original_instruction": "Develop a K-means clustering model using Scikit-Learn to segment customers based on their annual income and spending scores. Ensure to preprocess the data by removing any missing values and normalizing the features before applying the clustering algorithm. Determine the optimal number of cl...
0.758095
Evol_7254
C
[ "preprocess_data", "determine_optimal_clusters", "apply_kmeans", "visualize_clusters", "kmeans_customer_segmentation" ]
5
[ [ "kmeans_customer_segmentation", "apply_kmeans" ], [ "kmeans_customer_segmentation", "determine_optimal_clusters" ], [ "kmeans_customer_segmentation", "preprocess_data" ], [ "kmeans_customer_segmentation", "visualize_clusters" ] ]
4
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy", "pandas", "sklearn" ]
false
1a294faabd6c27add67928c7c2dbc181e1418061
7665c5ab79698e3fb86388540a5a6c2bd149d81b
v1.0
complete
Evol
Evol_7738_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-1) False >>> is_prime(17) True >>> is_prime(18) False >>> is_prime(29) True ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False...
from solution import is_prime, prime_counts # Unit tests for the is_prime function def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False assert is_prime(17) ...
[ { "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 dictionary where the keys are the prime integers from the list, \nand the values are the number of ti...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_6
{ "original_instruction": "Write a Python function that takes a list of integers as input and returns a dictionary where the keys are the prime integers from the list, and the values are the number of times each prime integer appears in the list. Your function should include a helper function to check if a number is ...
0.819534
Evol_7738
C
[ "is_prime", "prime_counts" ]
2
[ [ "prime_counts", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0f421739778c361e52457e31e233b5dbd1a0f327
75320208ebfb0c5ca3abacadc01c8251737ac48f
v1.0
complete
Evol
Evol_6662_C
from typing import List def validate_emails(email_list: List[str]) -> List[bool]: """ Validates a list of email addresses. Args: email_list (list): List of email addresses to validate. Returns: list: A list of boolean values corresponding to whether each email address is valid o...
import re def is_valid_email(email): """ Checks if the provided email address is valid based on specified conditions. """ email_regex = r'^[a-zA-Z0-9](?:[a-zA-Z0-9._-]{0,63}[a-zA-Z0-9])?@[a-zA-Z0-9](?:[a-zA-Z0-9.-]{0,253}[a-zA-Z0-9])?\.[a-zA-Z]{2,}$' return bool(re.match(email_regex, email)) def v...
from solution import validate_emails def test_valid_emails(): valid_emails = ["john.doe@example.com", "jane_doe@company.co"] result = validate_emails(valid_emails) assert result == [True, True] def test_invalid_email_double_at(): invalid_emails = ["invalid-email@domain@domain.com"] result = valida...
[ { "docstring": "Checks if the provided email address is valid based on specified conditions.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Validates a list of email addresses.\n\nArgs:\nemail_list (li...
[ 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 re\n\ndef is_valid_email(email):\n \"\"\"\n Check if the email address is valid based on given conditions.\n \"\"\"\n # Regular expression for a...
trial_gpt4o_1
{ "original_instruction": "A company requires a system to organize and verify all its employees' email addresses. Create an algorithm that takes a list of email addresses as input and verifies if each email address is valid according to the following conditions:\n1. It should contain exactly one \"@\" symbol.\n2. The...
0.58163
Evol_6662
C
[ "is_valid_email", "validate_emails" ]
2
[ [ "validate_emails", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec041253f3886961f8518e18367f41526edef007
1bc95ead17999dfa8b990cf87aa4b73a8aa9b7e8
v1.0
complete
Evol
Evol_8049_C
from typing import List def filter_primes(input_list: List[int]) -> List[int]: """ Returns a sorted list of prime numbers from the input list. If the input list is empty, or contains non-integer elements, an appropriate error should be raised. >>> filter_primes([29, 15, 3, 8, 23, 76, 5]) [3, 5, 23,...
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 filter_primes def test_filter_primes_normal_case(): assert filter_primes([29, 15, 3, 8, 23, 76, 5]) == [3, 5, 23, 29] def test_filter_primes_with_non_primes(): assert filter_primes([4, 6, 8, 10]) == [] def test_filter_primes_empty_list(): assert filter_primes([]) == [] def test_filt...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a sorted list of prime numbers from the input list.", "function_declaration": "def filter_primes(input_list):", "f...
[ 1, 1, 1, 1, 0, 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": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n retur...
trial_gpt4o_5
{ "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 ascending order. Include error handling to manage cases where the input list is empty or contains non-integer elements. Also, ensure your function is efficient f...
0.680126
Evol_8049
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
568cceb51764f64436ecdef72c97aa5dd7622d58
8cd34f1e9c06560ae183384710c6f5e2d07a1ac8
v1.0
complete
Evol
Evol_7726_C
from collections import deque from typing import List def is_one_letter_different(word1: str, word2: str) -> bool: """ Returns True if word1 and word2 differ by exactly one letter. """ if len(word1) != len(word2): return False diff_count = 0 for c1, c2 in zip(word1, word2): ...
from collections import deque def is_one_letter_different(word1, word2): """ Returns True if word1 and word2 differ by exactly one letter. """ if len(word1) != len(word2): return False diff_count = 0 for c1, c2 in zip(word1, word2): if c1 != c2: diff_count += 1 ...
from solution import find_shortest_transformation def test_simple_case(): assert find_shortest_transformation(["cat", "bat", "hat", "bad", "had", "dad"], "cat") == ["cat", "bat", "bad", "dad"] def test_no_transformation_possible(): assert find_shortest_transformation(["bat", "hat", "bad", "had", "dad"], "xyz"...
[ { "docstring": "Returns True if word1 and word2 differ by exactly one letter.", "function_declaration": "def is_one_letter_different(word1, word2):", "function_name": "is_one_letter_different", "parameter_list": "(word1, word2)" }, { "docstring": "Finds the shortest transformation sequence f...
[ 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": "from collections import deque\n\ndef shortest_transformation_sequence(word_list, target_word):\n \"\"\"\n Finds the shortest sequence of transformations from...
trial_gpt4o_3
{ "original_instruction": "You have been given a list of words and a target word. Your task is to write a function in Python or JavaScript that finds and returns the shortest sequence of transformations from the given word list that converts the target word to another word in the list. Each transformation must change...
0.692513
Evol_7726
C
[ "is_one_letter_different", "find_shortest_transformation" ]
2
[ [ "find_shortest_transformation", "is_one_letter_different" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b93bbca3a4c6676a7cc255ade6152fe2ffc4fd2
609a57ce2daf52d8bd0acabb2db77e03d9ba93b5
v1.0
complete
Evol
Evol_6673_C
import csv from datetime import datetime from collections import defaultdict import numpy as np def read_temperature_data(file_path): """Reads the temperature data from the file and returns a dictionary with dates as keys and lists of (timestamp, temperature) tuples as values. Args: file_path (str...
import csv from datetime import datetime from collections import defaultdict import numpy as np def read_temperature_data(file_path): data = defaultdict(list) with open(file_path, 'r') as f: reader = csv.reader(f) for row in reader: timestamp = datetime.strptime(row[0], '%Y-%m-%d %H...
import pytest from datetime import datetime import os from solution import generate_temperature_report, read_temperature_data, calculate_daily_statistics def test_read_temperature_data(tmp_path): temp_file = tmp_path / "temperature_data.txt" temp_file.write_text("2021-08-01 00:00:00,22.5\n2021-08-01 01:00:00,...
[ { "docstring": null, "function_declaration": "def read_temperature_data(file_path):", "function_name": "read_temperature_data", "parameter_list": "(file_path)" }, { "docstring": null, "function_declaration": "def calculate_daily_statistics(data):", "function_name": "calculate_daily_s...
[ 0, 1, 0, 0, 1, 0, 0, 0, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import csv\nfrom datetime import datetime\nimport statistics\n\ndef read_temperature_data(file_path):\n with open(file_path, 'r') as f:\n reader = csv.re...
trial_gpt4o_9
{ "original_instruction": "Create a program that reads temperature data recorded every hour from a file called \"temperature_data.txt\". The file contains two columns: the first column is the timestamp (formatted as 'YYYY-MM-DD HH:MM:SS'), and the second column is the temperature reading (in degrees Celsius). Your ta...
0.73196
Evol_6673
C
[ "read_temperature_data", "calculate_daily_statistics", "write_summary_to_csv", "generate_temperature_report" ]
4
[ [ "generate_temperature_report", "calculate_daily_statistics" ], [ "generate_temperature_report", "read_temperature_data" ], [ "generate_temperature_report", "write_summary_to_csv" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy" ]
false
a2e19d31ef989757e62551c3e4d932922fea72cc
0250a88f7503ae5479aaa28985b657b40040b35d
v1.0
complete
Evol
Evol_8106_C
def apples_kept_by_sarah(total_apples, num_friends): """ Returns the number of apples Sarah keeps for herself after sharing the apples among her friends. Sarah keeps 2 more apples than each friend. >>> apples_kept_by_sarah(60, 4) 14 >>> apples_kept_by_sarah(60, 0) 62 >>> a...
def apples_kept_by_sarah(total_apples, num_friends): """ Returns the number of apples Sarah keeps for herself after sharing the apples among her friends. Sarah keeps 2 more apples than each friend. """ apples_per_friend = total_apples // (num_friends + 1) # Sarah is considered as one additi...
from solution import sarahs_apples, apples_kept_by_sarah def test_case_given(): assert sarahs_apples() == 14 def test_no_friends(): assert apples_kept_by_sarah(60, 0) == 62 def test_one_friend(): assert apples_kept_by_sarah(60, 1) == 32 def test_even_distribution(): assert apples_kept_by_sarah(50, 4...
[ { "docstring": "Returns the number of apples Sarah keeps for herself after sharing\nthe apples among her friends.\n\nSarah keeps 2 more apples than each friend.", "function_declaration": "def apples_kept_by_sarah(total_apples, num_friends):", "function_name": "apples_kept_by_sarah", "parameter_list"...
[ 1, 1, 1, 1, 0, 0, 0, 1, 0, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def apples_for_sarah(total_apples, friends, extra_apples):\n \"\"\"\n Returns the number of apples Sarah keeps for herself.\n \n :param total_apples: T...
trial_gpt4o_7
{ "original_instruction": "Sarah decided to share her collection of 60 apples equally among her 4 friends. However, she also wants to keep a certain number of apples for herself, which is exactly 2 more than the number of apples each friend gets. Can you determine how many apples Sarah keeps for herself?", "prompt_...
0.64377
Evol_8106
C
[ "apples_kept_by_sarah", "sarahs_apples" ]
2
[ [ "sarahs_apples", "apples_kept_by_sarah" ] ]
1
[]
false
[]
false
pytest
true
[]
true
815401f9814951366d827515316addeab207affb
5f2572d3bedaaa1b034ad4ae10f4f6411d46e1c7
v1.0
complete
Evol
Evol_7126_C
def longest_concatenated_word(words: List[str]) -> str: """ Implement a function in Python that receives a list of words and returns the longest word that can be constructed by concatenating other words from the list. If no such word can be formed, return an empty string. You are permitted to use each...
def can_construct(word, word_set): if word in word_set: return True for i in range(1, len(word)): prefix = word[:i] suffix = word[i:] if prefix in word_set and can_construct(suffix, word_set): return True return False def longest_concatenated_word(words): ...
from solution import longest_concatenated_word def test_example_case(): words = ["cat", "banana", "dog", "nana", "walk", "walker", "dogwalker"] assert longest_concatenated_word(words) == "dogwalker" def test_no_concatenated_word(): words = ["cat", "banana", "dog", "walk"] assert longest_concatenated_w...
[ { "docstring": null, "function_declaration": "def can_construct(word, word_set):", "function_name": "can_construct", "parameter_list": "(word, word_set)" }, { "docstring": null, "function_declaration": "def longest_concatenated_word(words):", "function_name": "longest_concatenated_wo...
[ 1, 1, 1, 0, 1, 1, 1, 0, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def can_form_word(word, word_set):\n if word in word_set:\n return True\n for i in range(1, len(word)):\n prefix = word[:i]\n suffix = w...
trial_gpt4o_6
{ "original_instruction": "Implement a function in Python that receives a list of words and returns the longest word that can be constructed by concatenating other words from the list. If no such word can be formed, return an empty string. You are permitted to use each word from the list multiple times if necessary. ...
0.753617
Evol_7126
C
[ "can_construct", "longest_concatenated_word" ]
2
[ [ "longest_concatenated_word", "can_construct" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9dc584be908aea39f70c7b7e31fd4294e14304f1
8087bb474262bf8192fb94f7044aa8ac1983f5d1
v1.0
complete
Evol
Evol_7036_C
from typing import List def is_prime(n: int) -> bool: """ Checks if a number is a prime number. """ # Function implementation goes here pass def filter_unique_primes(nums: List[int]) -> List[int]: """ Returns a list of unique prime numbers from the given list of integers. >>> filt...
def is_prime(n): """ Checks if a number is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def filter_unique_prim...
from solution import is_prime, filter_unique_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 def test_filter_unique_primes(): assert filter_unique_primes([11, 4, 5, 17, 11, 18...
[ { "docstring": "Checks if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of unique prime numbers from the given list of integers.", "function_declaration": "def filter_unique...
[ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, in...
trial_gpt4o_7
{ "original_instruction": "Create a function that, given a list of integers, returns a new list containing only the elements that are prime numbers and removes any duplicate prime numbers that might exist in the original list.\nExample input: [11, 4, 5, 17, 11, 18, 5, 23]\nExample output: [11, 5, 17, 23]", "prompt_...
0.744893
Evol_7036
C
[ "is_prime", "filter_unique_primes" ]
2
[ [ "filter_unique_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d4000f864075b7d31559eb62868c4f4d5443cd4d
6761efa89961b897879cbd46474e8d6e97311917
v1.0
complete
Evol
Evol_6892_C
def is_prime(n: int) -> bool: """Returns True if n is a prime number, else False. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(10) == False >>> is_prime(13) == True >>> is_prime(1) == False >>> is_prime(0) == False ...
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i...
from solution import is_prime, count_primes_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(13) == True assert is_prime(1) == False assert is_prime(0) ...
[ { "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": "Counts the number of prime numbers between a and b, inclusive.", "function_declaration": "def count_prime...
[ 1, 1, 0, 0, 0, 0, 1, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef 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 ...
trial_gpt4o_8
{ "original_instruction": "Develop a program in Python to detect and count the number of prime numbers within a given range [a, b]. The program should take two integers, a and b, as input and return the count of prime numbers between them, inclusive. Make sure to implement an efficient algorithm to handle large range...
0.776772
Evol_6892
C
[ "is_prime", "count_primes_in_range" ]
2
[ [ "count_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f5994b5f27b0d818fe82f16939fd3376fa90441
69c17f915cc7d10a8faf22e208254da77340c7c8
v1.0
complete
Evol
Evol_8204_C
def find_anagrams(words: List[str], target: str) -> List[str]: """ Create a function that takes a list of strings and a target string, and returns a list of all strings from the input list that are anagrams of the target string. It should handle case sensitivity, spaces, and punctuation. >>>...
import re from collections import Counter def clean_string(s): """ Cleans the input string by removing spaces, punctuation, and converting to lowercase. """ return ''.join(re.findall(r'\w', s)).lower() def find_anagrams(words, target): """ Returns a list of all strings from the input list that...
from solution import find_anagrams def test_find_anagrams_simple_case(): words = ['listen', 'enlist', 'google', 'inlets', 'banana'] target = 'silent' assert find_anagrams(words, target) == ['listen', 'enlist', 'inlets'] def test_find_anagrams_with_punctuation_and_spaces(): words = ['Listen!', 'enlist....
[ { "docstring": "Cleans the input string by removing spaces, punctuation, and converting to lowercase.", "function_declaration": "def clean_string(s):", "function_name": "clean_string", "parameter_list": "(s)" }, { "docstring": "Returns a list of all strings from the input list that are anagr...
[ 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import re\nfrom collections import Counter\n\ndef clean_string(s):\n \"\"\"\n Removes spaces and punctuation from the string and converts it to lowercase.\n ...
trial_gpt4o_3
{ "original_instruction": "Create a Python function called 'find_anagrams' that takes two arguments: a list of strings and a target string. The function should return a list of all strings from the input list that are anagrams of the target string. If there are no anagrams, the function should return an empty list. E...
0.604084
Evol_8204
C
[ "clean_string", "find_anagrams" ]
2
[ [ "find_anagrams", "clean_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c0915d1bfda52deaa8ec483bfc38fa6d4442fb86
f994943209327dfa3dbd5fdb65e5f97eb88f43b0
v1.0
complete
Evol
Evol_7454_C
def rotate_list(nums, k): """ Rotates the elements of the list 'nums' in place to the right by 'k' steps. :param nums: List of integers. :param k: Number of steps to rotate the list. >>> rotate_list([1, 2, 3, 4, 5, 6, 7], 3) [5, 6, 7, 1, 2, 3, 4] >>> rotate_list([-1, -100, 3, 99], ...
def rotate_list(nums, k): """ Rotates the elements of the list 'nums' in place to the right by 'k' steps. :param nums: List of integers. :param k: Number of steps to rotate the list. """ n = len(nums) if n == 0: return nums k = k % n # In case k is larger than the leng...
from solution import rotate_list def test_rotate_list_example1(): assert rotate_list([1, 2, 3, 4, 5, 6, 7], 3) == [5, 6, 7, 1, 2, 3, 4] def test_rotate_list_example2(): assert rotate_list([-1, -100, 3, 99], 2) == [3, 99, -1, -100] def test_rotate_list_empty(): assert rotate_list([], 1) == [] def test_ro...
[ { "docstring": "Rotates the elements of the list 'nums' in place to the right by 'k' steps.\n\n:param nums: List of integers.\n:param k: Number of steps to rotate the list.", "function_declaration": "def rotate_list(nums, k):", "function_name": "rotate_list", "parameter_list": "(nums, k)" }, { ...
[ 1, 1, 0, 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 rotate_list(nums, k):\n \"\"\"\n Rotates nums to the right by k steps and modifies nums in-place.\n \"\"\"\n if not nums or k <= 0:\n return...
trial_gpt4o_9
{ "original_instruction": "Write a Python function `rotate_list` that takes a list of integers `nums` and an integer `k`, and returns the list after rotating it to the right by `k` steps. The rotation should be done in-place with O(1) extra space complexity. For example:\n\n```python\nrotate_list([1, 2, 3, 4, 5, 6, 7...
0.70506
Evol_7454
C
[ "rotate_list", "reverse" ]
2
[ [ "rotate_list", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
224973050cbb5b1b4bb08e6f75aeec052a118b0a
7f1934ecd33410374fc47801b160cfdbdc44db31
v1.0
complete
Evol
Evol_8285_C
def is_prime(n: int) -> bool: """ Checks if a number is prime. """ ... def extract_primes_and_sum(int_list: List[int]) -> Tuple[List[int], int]: """ Takes a list of integers as input and returns a tuple with two elements: 1. A list of prime numbers from the input list. 2. The sum of the extrac...
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def extract_primes_and_sum(int_list): """ Takes a list of integers as input and returns a tuple with two ...
from solution import extract_primes_and_sum def test_extract_primes_and_sum_all_primes(): result = extract_primes_and_sum([2, 3, 5, 7, 11]) assert result == ([2, 3, 5, 7, 11], 28) def test_extract_primes_and_sum_mixed_numbers(): result = extract_primes_and_sum([1, 2, 3, 4, 5, 6, 7]) assert result == (...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers as input and returns a tuple with two elements:\n1. A list of prime numbers from the input list.\n2. The...
[ 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 == 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": "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. Additionally, provide the sum of the prime numbers extracted. Your function should return a tuple with two elements: the list of prime numbers and their sum....
0.762782
Evol_8285
C
[ "is_prime", "extract_primes_and_sum" ]
2
[ [ "extract_primes_and_sum", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b49eba2606fb9d86e35b696a934955664d2a01a8
fa7f46b5bc2f8ad6cff49adf54b617f5fc3f1b72
v1.0
complete
Evol
Evol_6734_C
import numpy as np def initialize_centroids(X, K): """ Randomly initialize K centroids from the dataset X. """ pass def assign_clusters(X, centroids): """ Assign each data point in X to the closest centroid. """ pass def update_centroids(X, labels, K): """ Update the centroids to the mean of the ...
import numpy as np def initialize_centroids(X, K): """ Randomly initialize K centroids from the dataset X. """ np.random.seed(42) # For reproducible results random_indices = np.random.permutation(X.shape[0]) centroids = X[random_indices[:K]] return centroids def assign_clusters(X, centroids): ...
from solution import initialize_centroids, assign_clusters, update_centroids, compute_sse, k_means import numpy as np X = np.array([[1.1, 2.2], [1.5, 1.8], [5.4, 6.3], [1.0, 1.7], [0.9, 1.2], [4.5, 5.8], [5.2, 5.9], [3.9, 4.5], [9.1, 8.7], [8.1, 9.0]]) def test_initialize_centroids(): centroids = i...
[ { "docstring": "Randomly initialize K centroids from the dataset X. ", "function_declaration": "def initialize_centroids(X, K):", "function_name": "initialize_centroids", "parameter_list": "(X, K)" }, { "docstring": "Assign each data point in X to the closest centroid. ", "function_decla...
[ 1, 0, 0, 1, 0, 0, 0, 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": "import numpy as np\n\ndef initialize_centroids(X, k):\n \"\"\"\n Randomly initializes the centroids from the dataset.\n \"\"\"\n indices = np.random.ch...
trial_gpt4o_9
{ "original_instruction": "Implement a K-means clustering algorithm from scratch to cluster a given dataset into a specified number of clusters (K). The algorithm should initialize the cluster centroids randomly, assign data points to the nearest centroids, update the centroids based on the mean of the assigned point...
0.804495
Evol_6734
C
[ "initialize_centroids", "assign_clusters", "update_centroids", "compute_sse", "k_means" ]
5
[ [ "k_means", "assign_clusters" ], [ "k_means", "compute_sse" ], [ "k_means", "initialize_centroids" ], [ "k_means", "update_centroids" ] ]
4
[]
false
[]
false
pytest
true
[ "numpy" ]
false
d936a291d63d74121848a61968e3bf06ca518cd8
139af7981f9dfbc8a81a55c1153b73f87db26335
v1.0
complete
Evol
Evol_7341_C
import json import os def load_json_data(json_file): """ Loads JSON data from a file and returns it. """ # Your code here def count_students(json_file): """ Returns the number of students in the JSON data file. >>> count_students('students.json') == 4 """ # Your code here def get_...
import json import os def load_json_data(json_file): """ Loads JSON data from a file and returns it. """ if not os.path.exists(json_file): raise FileNotFoundError(f"The file {json_file} does not exist.") with open(json_file, 'r') as f: data = json.load(f) return data ...
import os import json from solution import ( load_json_data, count_students, get_students_above_age, calculate_average_grade, save_students_above_grade ) import pytest # Sample data for testing sample_data = [ {"name": "Alice", "age": 23, "grades": [85, 90, 78], "city": "New York"}, {"name...
[ { "docstring": "Loads JSON data from a file and returns it.", "function_declaration": "def load_json_data(json_file):", "function_name": "load_json_data", "parameter_list": "(json_file)" }, { "docstring": "Returns the number of students in the JSON data file.", "function_declaration": "d...
[ 0, 0, 1, 0, 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": "import json\nimport os\n\ndef count_students(json_file):\n try:\n with open(json_file, 'r') as file:\n students = json.load(file)\n ...
trial_gpt4o_4
{ "original_instruction": "You are given a JSON file containing an array of student records, each with `name`, `age`, `grades`, and `city`. Write a Python script to analyze this data. Your script should provide the following functionalities:\n\n1. Load the JSON data from a file.\n2. Display the number of students.\n3...
0.633293
Evol_7341
C
[ "load_json_data", "count_students", "get_students_above_age", "calculate_average_grade", "save_students_above_grade" ]
5
[ [ "calculate_average_grade", "load_json_data" ], [ "count_students", "load_json_data" ], [ "get_students_above_age", "load_json_data" ], [ "save_students_above_grade", "load_json_data" ] ]
4
[]
false
[]
false
pytest
true
[]
true
765fdb0d382cfb11f127d21911fefa988889263a
55f3848bc9661aa3113c4ae72587992f32520941
v1.0
complete
Evol
Evol_7495_C
def first_n_primes(n: int) -> Tuple[List[int], int]: """ Implement a function that takes an integer `n` as input and returns the first `n` prime numbers in a list, along with the sum of these prime numbers. Handle cases where the input `n` is less than 1 by returning an empty list and a sum of 0. >>> f...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def first_n_primes(n): if ...
from solution import first_n_primes def test_no_primes(): assert first_n_primes(0) == ([], 0) assert first_n_primes(-1) == ([], 0) def test_first_prime(): assert first_n_primes(1) == ([2], 2) def test_first_few_primes(): assert first_n_primes(3) == ([2, 3, 5], 10) assert first_n_primes(5) == ([2,...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def first_n_primes(n):", "function_name": "first_n_primes", "parameter_list": "(n)" } ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_4
{ "original_instruction": "Implement a function that takes an integer `n` as input and returns the first `n` prime numbers in a list. Additionally, the function should calculate the sum of these prime numbers and return both the list of prime numbers and their sum. Handle cases where the input `n` is less than 1 by r...
0.763259
Evol_7495
C
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a1021c400ca1cd22161fe77f00d594578015c48e
8fdbae1333f7f3f21140b9d24c49edda5ecb9dd0
v1.0
complete
Evol
Evol_8173_C
from typing import List from collections import Counter def is_anagram_of_palindrome(s: str) -> bool: """ Check if the given string is an anagram of a palindrome. >>> is_anagram_of_palindrome("civic") True >>> is_anagram_of_palindrome("ivicc") True >>> is_anagram_of_palindrome("hello") False >>...
from collections import Counter def is_anagram_of_palindrome(s): """ Check if the given string is an anagram of a palindrome. """ s = s.lower().replace(' ', '') count = Counter(s) odd_count = sum(1 for val in count.values() if val % 2 != 0) return odd_count <= 1 def filter_anagrams_of_pali...
from solution import is_anagram_of_palindrome, filter_anagrams_of_palindrome, add_and_filter_anagrams_of_palindrome def test_is_anagram_of_palindrome(): assert is_anagram_of_palindrome("civic") == True assert is_anagram_of_palindrome("ivicc") == True assert is_anagram_of_palindrome("hello") == False as...
[ { "docstring": "Check if the given string is an anagram of a palindrome.", "function_declaration": "def is_anagram_of_palindrome(s):", "function_name": "is_anagram_of_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns a list of strings that are anagrams of a palindrome.", "f...
[ 0, 0, 0, 1, 0, 1, 1, 1, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def can_form_palindrome(s):\n \"\"\"\n Returns True if the string s can be rearranged to form a palindrome.\n \"\"\"\n s = s.lower()\n char_count = ...
trial_gpt4o_7
{ "original_instruction": "Write a function that takes a list of strings and returns a new list containing all the strings that are anagrams of a palindrome. A string is an anagram of a palindrome if it can be rearranged into a palindrome. The program should be case-insensitive. Additionally, provide an option for th...
0.706572
Evol_8173
C
[ "is_anagram_of_palindrome", "filter_anagrams_of_palindrome", "add_and_filter_anagrams_of_palindrome" ]
3
[ [ "add_and_filter_anagrams_of_palindrome", "filter_anagrams_of_palindrome" ], [ "filter_anagrams_of_palindrome", "is_anagram_of_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
452f20001a5cab8d9b8e89968189470b4fc3cad3
7f564198cc9cfeacad8cfe73e5cce2c9a0d66ba6
v1.0
complete
Evol
Evol_7329_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is a prime number. """ def filter_primes(numbers: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from the original list. >>> filter_primes([]) [] >>> filter_primes([1, 4, 6, 8, 9, 1...
def is_prime(n): """ Helper function to check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import filter_primes def test_filter_primes_empty_list(): assert filter_primes([]) == [] def test_filter_primes_no_primes(): assert filter_primes([1, 4, 6, 8, 9, 10]) == [] def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13]) == [2, 3, 5, 7, 11, 13] def test_filt...
[ { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the provided list of integers.", "function_declaration": "def...
[ 1, 1, 0, 1, 0, 1, 1, 1, 1, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n 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": "Develop a Python function that takes 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. Implement the algorithm without using any externa...
0.770099
Evol_7329
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7da3e14208424f2d882e0af663991ce07d489708
3beabba17511782fffb2a7b34ade366656d5837a
v1.0
complete
Evol
Evol_8361_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, else False. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(17) == True >>> is_prime(18) == False >>> is_prime(19) == True >>> is_prime(-1) == False >>> is_prime(0) == Fal...
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i...
from solution import is_prime, prime_list def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(-1) == False assert is_prime(0) == False ...
[ { "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": "Takes a list of integers and returns a list of booleans indicating whether each integer is a prime number.", ...
[ 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 Determines whether a given number is prime.\n \n Parameters:\n num (int): The number to check for primality.\n \n ...
trial_gpt4o_7
{ "original_instruction": "Can you write a Python function that takes in a list of integers and returns a list of booleans indicating whether each integer is a prime number? The function should be optimized for performance for lists containing large integers.", "prompt_id": "00008361", "row_id": 8361, "seed_ids...
0.864485
Evol_8361
C
[ "is_prime", "prime_list" ]
2
[ [ "prime_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7d2bd98a6b24a5f76b0a2c99658c158740d8d3fa
c60969663180229bde8fa19e83979c05bb378e09
v1.0
complete
Evol
Evol_7774_C
import numpy as np import pandas as pd from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.metrics.pairwise import linear_kernel import random def collaborative_filtering(user_item_matrix, user_id, item_id, k=20): """Collaborative Filtering using user-item matrix and matrix factorization (SVD)...
import numpy as np import pandas as pd from sklearn.metrics import mean_squared_error, mean_absolute_error from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.metrics.pairwise import linear_kernel from sklearn.model_selection import train_test_split import random # Collaborative Filtering using us...
from solution import collaborative_filtering, content_based_filtering, hybrid_recommendation, generate_synthetic_data def test_collaborative_filtering(): num_users, num_items = 10, 5 user_ids, item_ids, user_item_matrix, _ = generate_synthetic_data(num_users, num_items) user_id, item_id = 0, 0 pre...
[ { "docstring": null, "function_declaration": "def collaborative_filtering(user_item_matrix, user_id, item_id, k=20):", "function_name": "collaborative_filtering", "parameter_list": "(user_item_matrix, user_id, item_id, k=20)" }, { "docstring": null, "function_declaration": "def content_b...
[ 0, 1, 1, 0, 0, 0, 0, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom sklearn.metrics import mean_squared_error, mean_absolute_error\nfrom scipy.sparse.linalg import svds\nfrom sklearn.metrics.pairwise import...
trial_gpt4o_1
{ "original_instruction": "Design and implement an e-commerce recommendation system that suggests products to users based on previous purchase history and browsing behavior. Use collaborative filtering to predict user ratings for different products, as well as content-based filtering to recommend items that are simil...
0.683473
Evol_7774
C
[ "collaborative_filtering", "content_based_filtering", "hybrid_recommendation", "generate_synthetic_data", "evaluate_model" ]
5
[ [ "evaluate_model", "collaborative_filtering" ], [ "hybrid_recommendation", "collaborative_filtering" ], [ "hybrid_recommendation", "content_based_filtering" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy", "pandas", "sklearn" ]
false
d7ddad5f4ddeb1115563dc27099b6c0b62657a59
2056cb0572c22a910ddcc462a5626905e7c27422
v1.0
complete
Evol
Evol_8019_C
from typing import List def is_prime(n: int) -> bool: """ Determine whether a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(-1) False >>> is_prime(11) True """ pass def filter_and_sort_primes(numbers: List[int]) ->...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter...
from solution import filter_and_sort_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False assert is_prime(-...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list, sorted in increasing order.", "function_declara...
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "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 if n <= 3:\n retur...
trial_gpt4o_6
{ "original_instruction": "Write a function in Python that takes an unsorted list of integers and returns a new list containing only the prime numbers from the original list, but sorted in increasing order. Ensure your function handles edge cases such as negative numbers and zero correctly.", "prompt_id": "00008019...
0.775818
Evol_8019
C
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d5d2f9657064f638148343c284216c4b714dc91b
62ce5afc53f1dd7512aa5455e57e4071b597b6a1
v1.0
complete
Evol
Evol_7098_C
def is_prime(n): """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if n is a prime number, False otherwise. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return...
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 find_primes_in_range(start, end): """ Finds and prints all prime numbers in ...
from solution import is_prime, find_primes_in_range import pytest 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(0) == False assert is_prime(1) == False assert is_prime(-5) == False def test...
[ { "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": "Finds and prints all prime numbers in the range [start, end].\nFor each prime number found, also prints ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if the number n is a prime number.\n \n Parameters:\n - n: integer\n \n Returns:\n - True if n is a prime...
trial_gpt4o_6
{ "original_instruction": "Design and implement a Python program that prompts the user for a starting number and an ending number. The program should print all the prime numbers within that specified range. For each prime number, the program should also print the number of prime factors of that prime number (which wi...
0.774867
Evol_7098
C
[ "is_prime", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb0d288b20bdb968e58acce13b642b6dd969f32f
ee0ceb165f97ad804fcbd3522d366d2c853a6ce6
v1.0
complete
Evol
Evol_8597_C
from typing import List, Tuple def sum_diagonal_and_count_primes(matrix: List[List[int]]) -> Tuple[int, int]: """ Write a function that receives an n x n matrix consisting of positive integers and returns the sum of the diagonal elements of the matrix along with the count of prime numbers in the mat...
import math 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: ...
from solution import sum_diagonal_and_count_primes def test_sum_diagonal_and_count_primes_small_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert sum_diagonal_and_count_primes(matrix) == (15, 4) def test_sum_diagonal_and_count_primes_single_element_matrix(): matrix ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of the diagonal elements of the matrix\nand the count of prime numbers in the matrix.", ...
[ 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 math\n\ndef sum_diagonal_and_count_primes(matrix):\n \"\"\"\n Receives an n x n matrix of positive integers and returns a tuple:\n - sum of the dia...
trial_gpt4o_1
{ "original_instruction": "Write a function that receives an n x n matrix consisting of positive integers and returns the sum of the diagonal elements of the matrix along with the count of prime numbers in the matrix. The function should handle matrices of various sizes efficiently. Ensure that the solution exhibits ...
0.641705
Evol_8597
C
[ "is_prime", "sum_diagonal_and_count_primes" ]
2
[ [ "sum_diagonal_and_count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
efd15295425132102edeb6e0b2ff3aeaf82a0801
90c61a9c9d3b855e5b19ca2129ce2d4d4b220157
v1.0
complete
Evol
Evol_8278_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(10) == False >>> is_prime(23) == True >>> is_prime(1) == Fals...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True # 2 is a prime number if n % 2 == 0: return False # if n is even and not 2, it's not a prime number for i in range(3, int(n**0.5) + 1, 2): ...
from solution import is_prime, get_primes_from_list def test_is_prime(): # Test cases for is_prime function 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(23) == True assert is_pri...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.\nPreserves the order of num...
[ 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 containing only the prime numbers from the original list. The order of numbers in the original list must be preserved in the new list. You are not allowed to use any built-in functions for prime detection; you must imple...
0.802479
Evol_8278
C
[ "is_prime", "get_primes_from_list" ]
2
[ [ "get_primes_from_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
faab4ba9d2a2a5f2517ba460b0d02cfb302415c6
fc152ad576150f525669a1d51c4ee1a9efc775a3
v1.0
complete
Evol
Evol_8661_C
from typing import List, Tuple def closest_pairs(points: List[Tuple[int, int]]) -> List[Tuple[Tuple[int, int], Tuple[int, int]]]: """ Given a list of points represented as tuples of (x, y), return a list of pairs of points (tuples of tuples) that are closest to each other. Each point must appear in exactly one pai...
from itertools import combinations import math def euclidean_distance(p1, p2): """ Calculate the Euclidean distance between two points p1 and p2. """ return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def closest_pairs(points): """ Given a list of points represented as tuples of (x,...
from solution import closest_pairs def test_closest_pairs_basic(): points = [(1, 1), (2, 2), (3, 3), (4, 4)] expected = [((1, 1), (2, 2)), ((3, 3), (4, 4))] assert closest_pairs(points) == expected def test_closest_pairs_same_distance(): points = [(0, 0), (1, 1), (3, 3), (4, 4)] expected = [((0, 0...
[ { "docstring": "Calculate the Euclidean distance between two points p1 and p2.", "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": "Given a list of points represented as tuples of (x, y),\nreturn a...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from scipy.spatial import distance\nimport itertools\n\ndef closest_pairs(points):\n \"\"\"\n Returns a list of pairs of points that are the closest to each ...
trial_gpt4o_9
{ "original_instruction": "Create a function `closest_pairs(points)` that takes a list of points represented as tuples of two integers (x, y) and returns a list of pairs of points (tuples of tuples) that are the closest to each other. Each point should appear in exactly one pair. If there are multiple points with the...
0.751966
Evol_8661
C
[ "euclidean_distance", "closest_pairs" ]
2
[ [ "closest_pairs", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bf457c7e8697b2d39a8f919651dd2fe3719557a8
33ba77978970c44b74dbe578450457452e94b92a
v1.0
complete
Evol
Evol_7849_C
from typing import List def filter_primes(numbers: List[int]) -> List[int]: """ Takes in a list of integers and returns a new list containing only the prime numbers from the original list. Negative numbers and zero are not considered prime. >>> filter_primes([2, 3, 5, 7, 11]) [2, 3, 5, 7, 11]...
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 max_divisor = int(n ** 0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def ...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 10, 12]) == [] def test_filter_primes_mixed(): assert filter_primes([29, 15, -7, 13, 6, 23, -2]) == [29, 13...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the list of numbers and returns a list of prime numbers.", "function_declaration": "def filter_primes(numbers):", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Efficiently checks if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes in a list of integers and returns a new list containing only the prime numbers from the original list. You must implement an efficient algorithm to check for prime numbers, considering the performance for large inputs. The function should handle both positive an...
0.649082
Evol_7849
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20a91fc4f16bf51c77fb189da0f88c152f14b25a
fbb7b85588f2c063109e25de0863a89c9e6f2152
v1.0
complete
Evol
Evol_8092_C
def is_palindrome(s: str) -> bool: """ Helper function to check if a string is a palindrome. """ length = len(s) for i in range(length // 2): if s[i] != s[length - 1 - i]: return False return True def filter_palindromes(strings: List[str]) -> List[str]: """ Returns a...
def is_palindrome(s): """ Helper function to check if a string is a palindrome. """ length = len(s) for i in range(length // 2): if s[i] != s[length - 1 - i]: return False return True def filter_palindromes(strings): """ Returns a list containing only the palindromes...
from solution import filter_palindromes def test_filter_palindromes_all_palindromes(): assert filter_palindromes(["madam", "racecar", "level"]) == ["madam", "racecar", "level"] def test_filter_palindromes_mixed_strings(): assert filter_palindromes(["hello", "radar", "world", "deified"]) == ["radar", "deified"...
[ { "docstring": "Helper function to check if a string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns a list containing only the palindromes from the input list of strings.", "function...
[ 0, 1, 0, 0, 1, 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_palindrome(s):\n \"\"\"\n Helper function to check if a given string is a palindrome.\n \"\"\"\n left, right = 0, len(s) - 1\n while left < r...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of strings and returns a new list containing only the strings that are palindromes. A string is considered a palindrome if it reads the same forward and backward, case-sensitive. Do not use any built-in Python functions for reversing strings.", "p...
0.787869
Evol_8092
C
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20f8cb8d5cbe011db98764e790e7d320adfe4bc3
6df7c396ef5a2a9056582e68a098e935e20dca9f
v1.0
complete
Evol
Evol_7845_C
import math from typing import List def is_prime(n: int) -> bool: """ Checks if a number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2)...
import math def is_prime(n): """ Checks if a number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import filter_primes_greater_than_10 def test_filter_primes_greater_than_10(): assert filter_primes_greater_than_10([2, 17, 4, 19, 23, 6, 20]) == [17, 19, 23] assert filter_primes_greater_than_10([11, 13, 15, 17, 18, 19]) == [11, 13, 17, 19] assert filter_primes_greater_than_10([29, 31, 33]) ...
[ { "docstring": "Checks if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the integers from the input list that are\nboth prime and greater than 10.", "funct...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is a prime.\n A prime number is greater than 1 and has no divisors other than 1 and itself.\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "Develop a function that takes a list of integers and returns a new list containing only those integers that are both prime and greater than 10. For instance, given the input list [2, 17, 4, 19, 23, 6, 20], the function should return [17, 19, 23]. Ensure that your solution efficiently checks...
0.730352
Evol_7845
C
[ "is_prime", "filter_primes_greater_than_10" ]
2
[ [ "filter_primes_greater_than_10", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
904a0ec10dd68984973094b7c82ce324d15a9ea2
af042be1eb75e58d8f9b57c345b59c88a4e08494
v1.0
complete
Evol
Evol_8604_C
class NegativeNumberError(Exception): """ Custom exception raised when a list contains negative numbers. """ pass def is_prime(number: int) -> bool: """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(1) False """ pass def filt...
class NegativeNumberError(Exception): """ Custom exception raised when a list contains negative numbers. """ pass def is_prime(number): """ Helper function to check if a number is prime. """ if number < 2: return False for i in range(2, int(number ** 0.5) + 1): if nu...
import pytest from solution import NegativeNumberError, filter_primes, is_prime def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert not is_prime(1) assert is_prime(17) assert not is_prime(0) def test_filter_primes(): assert filter_primes([2, 3, 4, 5, 6,...
[]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "class NegativeNumberError(Exception):\n \"\"\"Custom exception raised when a negative number is encountered.\"\"\"\n pass\n\ndef is_prime(n):\n if n <= 1:...
trial_gpt4o_8
{ "original_instruction": "Design a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Additionally, if the list contains any negative numbers, the function should raise a custom exception, \"NegativeNumberError\". Provide the definition of the exce...
0.590141
Evol_8604
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[ "NegativeNumberError" ]
true
pytest
true
[]
true
e7935886644da398ac559947690551a2cff79741
a6e58b65b0edf672602fe98b2b5299e13aaef024
v1.0
complete
Evol
Evol_8338_C
from typing import Dict, List def get_unique_languages(people_languages: Dict[str, List[str]]) -> int: """ Calculates the total number of unique languages spoken across the list. >>> get_unique_languages({'Alice': ['English', 'Spanish'], 'Bob': ['French'], 'Charlie': ['Spanish', 'French'], 'David': ['Engli...
def get_unique_languages(people_languages): """ Calculates the total number of unique languages spoken across the list. """ unique_languages = set() for languages in people_languages.values(): for language in languages: unique_languages.add(language) return len(unique_languag...
from solution import (get_unique_languages, get_language_speakers, languages_spoken_by_at_least_n_people, find_other_people_with_same_languages) people_languages = { 'Alice': ['English', 'Spanish'], 'Bob': ['French'], 'Charlie': ['Spanish', 'French'], 'David'...
[ { "docstring": "Calculates the total number of unique languages spoken across the list.", "function_declaration": "def get_unique_languages(people_languages):", "function_name": "get_unique_languages", "parameter_list": "(people_languages)" }, { "docstring": "Determine the number of people s...
[ 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 get_unique_languages(people_languages):\n \"\"\"\n Calculate the total number of unique languages spoken across the list.\n \"\"\"\n unique_languag...
trial_gpt4o_8
{ "original_instruction": "Given a list of people's names along with their known languages, write a program that accomplishes the following:\n\n1. Calculate the total number of unique languages spoken across the list.\n\n2. Determine the number of people speaking each language.\n\n3. Identify all languages spoken by ...
0.594962
Evol_8338
C
[ "get_unique_languages", "get_language_speakers", "languages_spoken_by_at_least_n_people", "find_other_people_with_same_languages" ]
4
[ [ "languages_spoken_by_at_least_n_people", "get_language_speakers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2b47691964a15b1c97959e4d5515ccf34cdea223
dd3c41357f04117186c0525ab8f18cade045385c
v1.0
complete
Evol
Evol_8820_C
def is_prime(n): """ Check if a number is a prime number. """ pass def evaluate_sequence(num_list): """ Given a list of integers, the function should return a list of unique prime numbers that are greater than 10. If there are no such prime numbers, it should return the count of all even number...
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import evaluate_sequence def test_evaluate_sequence_with_primes(): assert evaluate_sequence([2, 3, 5, 7, 13, 19, 23]) == [13, 19, 23] def test_evaluate_sequence_with_no_primes(): assert evaluate_sequence([6, 9, 12, 15, 18, 21]) == 3 def test_evaluate_sequence_with_no_primes_and_few_multiples_of...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, the function returns a list of unique prime numbers\nthat are greater than 10. If there are no ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "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": "Develop a function that analyses a specified sequence of integers and returns either a filtered list or a specific count:\n\ndef evaluate_sequence(num_list):\n '''\n Given a list of integers, the function should return a list of unique prime numbers that are greater than 10. If there ...
0.847561
Evol_8820
C
[ "is_prime", "evaluate_sequence" ]
2
[ [ "evaluate_sequence", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
92930d1c0a3ccdde26c6a73575dd0ab15e3fc709
b33e23b267807b9851698ab48f7f0623def21869
v1.0
complete
Evol
Evol_8694_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(4) False >>> is_prime(13) True """ def filter_primes(lst: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers from...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(15) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-7) == Fal...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.", "function_declaration...
[ 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 if n == 2:\n retur...
trial_gpt4o_5
{ "original_instruction": "Write a Python function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Use predefined functions to determine if a number is prime. Your solution should handle edge cases such as empty lists and lists with no primes. Be sure to ...
0.740359
Evol_8694
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4215fec670cd28db99f07544adb5732eb77f63e4
aa51b79c234d66d8f1cd60824f2267a54538aabe
v1.0
complete
Evol
Evol_8752_C
def is_prime(num: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(11) True >>> is_prime(12) False >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-1) False ""...
def is_prime(num): """ Check if a number is a prime number. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while (i * i) <= num: if num % i == 0 or num % (i + 2) == 0: return False ...
from solution import 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(5) == True assert is_prime(11) == True assert is_prime(12) == False assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Calculate the sum of all prime numbers less than a given number n.", "function_declaration": "def sum_of_primes(n...
[ 1, 1, 1, 0, 1, 1, 1, 1, 1 ]
8
easy
0.889
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def 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_1
{ "original_instruction": "Calculate the sum of all prime numbers less than a given positive integer `n`. Write a function that accepts an integer `n` and returns this sum. For instance, if `n` is 10, the prime numbers less than 10 are 2, 3, 5, and 7, and their sum is 17.", "prompt_id": "00008752", "row_id": 8752...
0.805577
Evol_8752
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
acd2492cfd6c016d21e76d02784cce5125175930
08243367d3b60f84507a273a7708f9e60909eec6
v1.0
complete
Evol
Evol_8991_C
def is_prime(n: int) -> bool: """Determine if a number is prime.""" pass def filter_primes(lst: List[int]) -> List[int]: """ Takes a list of integers and returns a new list containing only the prime numbers. >>> filter_primes([]) == [] >>> filter_primes([0, 1, 4, 6, 8, 9, 10]) == [] >>> fi...
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 filter_primes def test_empty_list(): assert filter_primes([]) == [] def test_no_primes(): assert filter_primes([0, 1, 4, 6, 8, 9, 10]) == [] def test_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13]) == [2, 3, 5, 7, 11, 13] def test_mixed_list(): assert filter_primes([2, ...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a new list containing only the prime numbers.", "function_declarat...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
9
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_7
{ "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. The function should ensure that the order of prime numbers in the output list matches their order in the input list. Additionally, include edge cases such as hand...
0.803328
Evol_8991
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
93604171902def6acc9e4061ac63e9449dd8c03d
7b66f2348fd77ded487122a8cca4ddee6d3c9624
v1.0
complete
Evol
Evol_8125_C
from typing import List, Tuple import random def create_board(rows: int, cols: int, mines: int) -> List[List[int]]: """ Creates a Minesweeper board of given dimensions with a specified number of mines. """ board = [[0 for _ in range(cols)] for _ in range(rows)] return board def update_adjacent_cel...
import random def create_board(rows, cols, mines): """ Creates a Minesweeper board of given dimensions with a specified number of mines. """ # Initialize an empty board board = [[0 for _ in range(cols)] for _ in range(rows)] # Place mines randomly mines_placed = 0 while mines_placed < m...
import pytest from solution import create_board, make_move, print_board, init_revealed_board @pytest.fixture def sample_board(): rows, cols, mines = 5, 5, 3 board = create_board(rows, cols, mines) revealed = init_revealed_board(rows, cols) return board, revealed def test_create_board(): board = cr...
[ { "docstring": "Creates a Minesweeper board of given dimensions with a specified number of mines.", "function_declaration": "def create_board(rows, cols, mines):", "function_name": "create_board", "parameter_list": "(rows, cols, mines)" }, { "docstring": "Updates the count of adjacent mines ...
[ 0, 0, 1, 1, 1, 0, 0, 0, 0, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import random\n\ndef create_board(rows, cols, mine_count):\n \"\"\"\n Create a minesweeper board with the given dimensions and place the specified number of ...
trial_gpt4o_2
{ "original_instruction": "Implement a text-based Minesweeper game. The game should use a two-dimensional list to represent the board where mines are marked by '*'. Allow the user to input the dimensions of the board (M x N) and the number of mines. After placing the mines randomly, the board should display the numbe...
0.524198
Evol_8125
C
[ "create_board", "update_adjacent_cells", "print_board", "make_move", "reveal_cells", "init_revealed_board" ]
6
[ [ "create_board", "update_adjacent_cells" ], [ "make_move", "reveal_cells" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a77b16f77c575fbe1e41de088b00bf0d3bade09b
b78dab7d1bbc2901982b0d94b37835f622aeb5ec
v1.0
complete
Evol
Evol_8934_C
from typing import List def is_prime(n: int) -> bool: """ Checks if a number n 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 retu...
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def filter_primes(numbers): ...
from solution import filter_primes def test_filter_primes_with_mixed_numbers(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_with_all_prime_numbers(): assert filter_primes([2, 3, 5, 7, 11, 13, 17]) == [2, 3, 5, 7, 11, 13, 17] def test_filter_primes_with_all_non_pr...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters out the prime numbers from the given list of numbers.", "function_declaration": "def filter_primes(numbers):", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ...
trial_gpt4o_7
{ "original_instruction": "Create a function that takes a list of numbers and returns a new list containing only the prime numbers from the original list. Validate your function by testing it with the list [2, 3, 4, 5, 6, 7, 8, 9, 10].", "prompt_id": "00008934", "row_id": 8934, "seed_ids": "[41091]" }
0.793542
Evol_8934
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c9d06575f1528173127d7867be8ff29a7701e30
5ededf76ff21b1d3cf7d5f12533f9b73a06690af
v1.0
complete
Evol
Evol_9045_C
def is_palindrome(num: int) -> bool: """ Check if a number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False """ pass def find_largest_palindrome(n: int) -> int: """ Identify the largest palindromic number that is less than or equal to n. >>> find_largest_pal...
def is_palindrome(num): """ Helper function to check if a number is a palindrome. """ return str(num) == str(num)[::-1] def find_largest_palindrome(n): """ Function to find the largest palindromic number less than or equal to a given number n. """ for i in range(n, -1, -1): if i...
from solution import find_largest_palindrome def test_find_largest_palindrome_with_large_palindrome(): assert find_largest_palindrome(12321) == 12321 def test_find_largest_palindrome_with_non_palindrome(): assert find_largest_palindrome(132) == 131 def test_find_largest_palindrome_single_digit(): assert ...
[ { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Function to find the largest palindromic number less than or equal to a given number n.", ...
[ 1, 1, 1, 0, 1, 0, 1, 0, 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 find_largest_palindrome(n):\n def is_palindrome(num):\n return str(num) == str(num)[::-1]\n \n for i in range(n, -1, -1):\n if is_palind...
trial_gpt4o_1
{ "original_instruction": "Write a function called `find_largest_palindrome` that takes a single argument, a positive integer `n`. This function should identify the largest palindromic number that is less than or equal to `n`. A palindromic number reads the same forwards and backwards (e.g., 121, 484). If there is no...
0.731007
Evol_9045
C
[ "is_palindrome", "find_largest_palindrome" ]
2
[ [ "find_largest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83a1403e23a60eda848882973400f43b51ef307e
d96e1ea1f5a8af55865abeff6875b4d320f7fd31
v1.0
complete
Evol
Evol_9124_C
def is_quasi_palindrome(s: str) -> bool: """ Implement a function that determines whether a given string is a "quasi-palindrome." A quasi-palindrome is defined as a string that can be transformed into a palindrome by removing exactly one character. Args: s (str): The input string. Returns:...
def is_palindrome(s: str) -> bool: """ Helper function to check if the given string is a palindrome. """ return s == s[::-1] def is_quasi_palindrome(s: str) -> bool: """ Returns whether a string is a quasi-palindrome, meaning it can be transformed into a palindrome by removing exactly one chara...
from solution import is_quasi_palindrome def test_is_quasi_palindrome_basic_cases(): assert is_quasi_palindrome("abca") == True # removing 'b' or 'c' assert is_quasi_palindrome("racecar") == False # already a palindrome assert is_quasi_palindrome("abcdef") == False # can't be a palindrome assert is_...
[ { "docstring": "Helper function to check if the given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns whether a string is a quasi-palindrome, meaning it can be transformed into a p...
[ 0, 0, 0, 0, 0, 0, 1, 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 is_quasi_palindrome(s: str) -> bool:\n def is_palindrome(st):\n return st == st[::-1]\n \n left, right = 0, len(s) - 1\n while left < right:...
trial_gpt4o_9
{ "original_instruction": "Implement a function that determines whether a given string is a \"quasi-palindrome.\" A quasi-palindrome is defined as a string that can be transformed into a palindrome by removing exactly one character. \n\n### Function Signature\n```python\ndef is_quasi_palindrome(s: str) -> bool:\n ...
0.82025
Evol_9124
C
[ "is_palindrome", "is_quasi_palindrome" ]
2
[ [ "is_quasi_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6aec387e22a5bc8ffe588fed3ad7a83c7e171fe8
d72ea7f780d002b7adc733d87565b956296c6e64
v1.0
complete
Evol
Evol_8497_C
import re from collections import Counter import string from typing import List, Tuple def read_file(file_path: str) -> str: """ Reads the content of a file and returns it. If the file cannot be read, an exception is raised. :param file_path: Path to the text file :return: Content of the file as a...
import re from collections import Counter import string def read_file(file_path): """ Reads the content of a file and returns it. If the file cannot be read, an exception is raised. :param file_path: Path to the text file :return: Content of the file as a string """ try: with open(...
from solution import analyze_text_file, read_file, preprocess_text, get_word_frequency, get_top_n_words import pytest def test_read_file(): with pytest.raises(FileNotFoundError): read_file("non_existing_file.txt") def test_preprocess_text(): assert preprocess_text("Hello, World!") == ["hello", "world"...
[ { "docstring": "Reads the content of a file and returns it.\nIf the file cannot be read, an exception is raised.\n\n:param file_path: Path to the text file\n:return: Content of the file as a string", "function_declaration": "def read_file(file_path):", "function_name": "read_file", "parameter_list":...
[ 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import collections\nimport re\nimport os\n\ndef read_file(filepath):\n try:\n with open(filepath, 'r', encoding='utf-8') as file:\n return fil...
trial_gpt4o_9
{ "original_instruction": "Implement a function in Python to analyze a text file containing paragraphs of text. Your function should count the frequency of each word, considering case insensitivity and ignoring punctuation. Additionally, it should be able to handle and report any file-related exceptions (such as file...
0.80168
Evol_8497
C
[ "read_file", "preprocess_text", "get_word_frequency", "get_top_n_words", "analyze_text_file" ]
5
[ [ "analyze_text_file", "get_top_n_words" ], [ "analyze_text_file", "get_word_frequency" ], [ "analyze_text_file", "preprocess_text" ], [ "analyze_text_file", "read_file" ] ]
4
[]
false
[]
false
pytest
true
[]
true
9ce5280591c3b574d798114f6c37d481ae2f02f1
1efd40df69c03a88b50aa519c8a3a47fb88997d8
v1.0
complete
Evol
Evol_8591_C
import socket import threading def handle_client(client_socket, clients): """ Handles communication with a client. """ addr = client_socket.getpeername() print(f"[NEW CONNECTION] {addr} connected.") while True: try: message = client_socket.recv(1024).decode('utf-8') ...
import socket import threading # Server code def handle_client(client_socket, clients): """ Handles communication with a client. """ addr = client_socket.getpeername() print(f"[NEW CONNECTION] {addr} connected.") while True: try: message = client_socket.recv(1024).decod...
import socket import threading import time PORT = 12345 def test_server_client_interaction(): server_thread = threading.Thread(target=start_test_server) server_thread.start() time.sleep(1) # Give the server a moment to start clients = [] for i in range(3): # Connecting three clients fo...
[ { "docstring": "Handles communication with a client.", "function_declaration": "def handle_client(client_socket, clients):", "function_name": "handle_client", "parameter_list": "(client_socket, clients)" }, { "docstring": "Broadcasts a message to all clients except the sender.", "functio...
[ 1, 0, 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 socket\nimport threading\n\n# Server code\ndef handle_client(client_socket, clients):\n \"\"\"\n Handles communication with a client.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "Design a multi-threaded chat server in Python using the socket library. The server should manage multiple client connections simultaneously and allow them to exchange messages. Clients should be able to join and leave the chat dynamically, with the server handling these events appropriately...
0.671801
Evol_8591
C
[ "handle_client", "broadcast", "server_program", "client_program" ]
4
[ [ "handle_client", "broadcast" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5e57cec68ada9a987530c061451084dfb1e0b6c2
719dba237cefb16aea29f2edec8603622a71f661
v1.0
complete
Evol
Evol_8922_C
def is_unique(s: str) -> bool: """ Checks if all characters in the string are unique. >>> is_unique("abc") True >>> is_unique("aba") False >>> is_unique("") True """ pass def can_concatenate(s1: str, s2: str) -> bool: """ Checks if two strings can be concatenated w...
def is_unique(s: str) -> bool: """ Checks if all characters in the string are unique. """ return len(s) == len(set(s)) def can_concatenate(s1: str, s2: str) -> bool: """ Checks if two strings can be concatenated without having repeating characters. """ return len(set(s1).intersection(se...
from solution import is_unique, can_concatenate, get_longest_unique_concatenation def test_is_unique(): assert is_unique("abc") == True assert is_unique("aba") == False assert is_unique("") == True def test_can_concatenate(): assert can_concatenate("abc", "def") == True assert can_concatenate("abc...
[ { "docstring": "Checks if all characters in the string are unique.", "function_declaration": "def is_unique(s):", "function_name": "is_unique", "parameter_list": "(s)" }, { "docstring": "Checks if two strings can be concatenated without having repeating characters.", "function_declaratio...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_unique(s):\n \"\"\"\n Checks if all characters in a string are unique.\n \"\"\"\n return len(s) == len(set(s))\n\ndef can_concatenate(s1, s2):\n...
trial_gpt4o_9
{ "original_instruction": "Write a Python program that reads a list of strings and returns the longest string that can be made by concatenating unique characters from the list without repeating any character. Utilize helper functions to check the uniqueness of characters and the absence of repeating characters betwee...
0.717791
Evol_8922
C
[ "is_unique", "can_concatenate", "get_longest_unique_concatenation" ]
3
[ [ "get_longest_unique_concatenation", "is_unique" ] ]
1
[]
false
[]
false
pytest
true
[]
true
85c6de1e39bad576a8a3b033073fe96a32542514
70a87ac178d22f36994fdce27dacffb16a97d3f7
v1.0
complete
Evol
Evol_9152_C
def merge_sort(arr): """ Sorts a list of integers using the Merge Sort algorithm, implemented using recursion without any helper functions or built-in sort methods. >>> merge_sort([]) == [] >>> merge_sort([1]) == [1] >>> merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] >>> merge_sort([5, ...
def merge_sort(arr): """ Sorts a list of integers using the Merge Sort algorithm. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left = merge_sort(arr[:mid]) right = merge_sort(arr[mid:]) return merge(left, right) def merge(left, right): """ Merges two sorted lis...
from solution import merge_sort def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_sorted_list(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_sorted_list(): assert ...
[ { "docstring": "Sorts a list of integers using the Merge Sort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted lists into one sorted list.", "function_declaration": "def merge(left, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts a list of integers using the Merge Sort algorithm.\n \"\"\"\n if len(arr) > 1:\n mid = len(arr) // 2\n ...
trial_gpt4o_9
{ "original_instruction": "Develop a function that takes a list of integers as input and returns a sorted version of the list. The sorting should be implemented using the Merge Sort algorithm, relying solely on recursion, without using any helper functions or built-in sort methods.", "prompt_id": "00009152", "row...
0.624819
Evol_9152
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
585cb1852333e42425b09946b8037cb7238d1cfb
708558078c6fe4112580c565d8fdce8a32b132c9
v1.0
complete
Evol
Evol_8981_C
from collections import OrderedDict def remove_duplicates(lst: list) -> list: """ Removes duplicates from the list while preserving the order of their first appearance. Args: lst (list): A list of integers. Returns: list: A new list with duplicates removed. >>> remove_duplica...
from collections import OrderedDict def remove_duplicates(lst): """ Removes duplicates from the list while preserving the order of their first appearance. Args: lst (list): A list of integers. Returns: list: A new list with duplicates removed. """ return list(OrderedDict.fromk...
from solution import remove_duplicates import time def test_remove_duplicates(): # Test with some example data assert remove_duplicates([1, 2, 2, 3, 4, 4, 5]) == [1, 2, 3, 4, 5] assert remove_duplicates([1, 1, 1, 1]) == [1] assert remove_duplicates([5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1] ...
[ { "docstring": "Removes duplicates from the list while preserving the order of their first appearance.\n\nArgs:\nlst (list): A list of integers.\n\nReturns:\nlist: A new list with duplicates removed.", "function_declaration": "def remove_duplicates(lst):", "function_name": "remove_duplicates", "para...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def remove_duplicates(lst):\n \"\"\"\n Removes duplicate elements from the list while preserving the order of their first appearance.\n \n Args:\n l...
trial_gpt4o_3
{ "original_instruction": "Design a function named 'remove_duplicates' that takes a list of integers and returns a new list with all the duplicate elements removed, preserving the order of their first appearance. Your implementation should strive to maintain optimal time complexity. Also, create an additional functio...
0.732304
Evol_8981
C
[ "remove_duplicates", "performance_test" ]
2
[ [ "performance_test", "remove_duplicates" ] ]
1
[]
false
[]
false
pytest
true
[]
true
12876fc28b47fd4e9198b081ed47c7891d336027
7390efdf1277164c3e5508a30bbfbf5720f0fec5
v1.0
complete
Evol
Evol_9159_C
def find_words(input_list: List[str], target_word: str) -> List[str]: """ Returns a list of words from input_list that can be formed using the letters of target_word. >>> find_words(["apple", "plea", "lap", "peel", "pal"], "apple") ["apple", "plea", "lap", "pal"] >>> find_words(["banana", "orange", "gra...
def can_form_word(word, target_counts): """ Helper function to check if a word can be formed using the letters of the target word. """ word_counts = {} for char in word: if char in word_counts: word_counts[char] += 1 else: word_counts[char] = 1 for ch...
from solution import find_words def test_find_words_case_1(): input_list = ["apple", "plea", "lap", "peel", "pal"] target_word = "apple" assert find_words(input_list, target_word) == ["apple", "plea", "lap", "pal"] def test_find_words_with_duplicates(): input_list = ["apple", "ape", "peel", "pal", "al...
[ { "docstring": "Helper function to check if a word can be formed using the letters of the target word.", "function_declaration": "def can_form_word(word, target_counts):", "function_name": "can_form_word", "parameter_list": "(word, target_counts)" }, { "docstring": "Returns a list of words f...
[ 1, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def can_form_target(word, target_count):\n word_count = {}\n for letter in word:\n if letter in word_count:\n word_count[letter] += 1\n ...
trial_gpt4o_3
{ "original_instruction": "Develop a function that takes a list of words and a target word. The function should return a list of words from the input list that can be formed using the letters of the target word. Words cannot reuse letters from the target word more than they appear in the target word.\n\nExample: \nin...
0.643238
Evol_9159
C
[ "can_form_word", "find_words" ]
2
[ [ "find_words", "can_form_word" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6bf0f8e710dc6286cedf26d509c9c760270efa33
45d0d4264e157eef384fc5170d184b9e852f6c05
v1.0
complete
Evol
Evol_8800_C
import math from typing import List, Tuple def euclidean_distance(coord1: Tuple[float, float], coord2: Tuple[float, float]) -> float: """Calculate the Euclidean distance between two coordinates.""" return math.sqrt((coord1[0] - coord2[0]) ** 2 + (coord1[1] - coord2[1]) ** 2) def nearest_neighbor_algorithm(cit...
import itertools import math def euclidean_distance(coord1, coord2): return math.sqrt((coord1[0] - coord2[0]) ** 2 + (coord1[1] - coord2[1]) ** 2) def nearest_neighbor_algorithm(cities): if len(cities) <= 1: return cities, 0 start = cities[0] unvisited = cities[:] visited = [start] un...
from solution import nearest_neighbor_algorithm def test_single_city(): cities = [("A", (0, 0))] route, distance = nearest_neighbor_algorithm(cities) assert route == [("A", (0, 0))] and distance == 0 def test_two_cities(): cities = [("A", (0, 0)), ("B", (1, 1))] route, distance = nearest_neighbor_...
[ { "docstring": null, "function_declaration": "def euclidean_distance(coord1, coord2):", "function_name": "euclidean_distance", "parameter_list": "(coord1, coord2)" }, { "docstring": null, "function_declaration": "def nearest_neighbor_algorithm(cities):", "function_name": "nearest_nei...
[ 1, 1, 1, 0, 1, 0, 1, 1, 0, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_distance(city1, city2):\n \"\"\"\n Calculate the Euclidean distance between two cities.\n Each city is a tuple (x, y).\n \...
trial_gpt4o_6
{ "original_instruction": "Develop a program that takes as input a list of cities with their respective coordinates and returns the shortest route that visits each city exactly once, starting and ending at the same city (solving the Traveling Salesman Problem). \n\nThe program must implement a heuristic or approximat...
0.667067
Evol_8800
C
[ "euclidean_distance", "nearest_neighbor_algorithm" ]
2
[ [ "nearest_neighbor_algorithm", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef4c997c82be9dd1c1020d67c9d274fd7974014f
ecc0d2652142037d57097cde0687612b385df2a3
v1.0
complete
Evol
Evol_8865_C
from typing import List def max_subarray(nums: List[int]) -> int: """ Determines the maximum sum of a contiguous subarray using the divide and conquer approach. >>> max_subarray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) 6 >>> max_subarray([1]) 1 >>> max_subarray([5, 4, -1, 7, 8]) 23 """
def max_crossing_sum(nums, left, mid, right): """ A utility function to find the maximum sum of the subarray crossing the midpoint. """ # Include elements on left of mid. sum_left = float('-inf') total = 0 for i in range(mid, left - 1, -1): total += nums[i] if total > sum_lef...
from solution import max_subarray def test_example_1(): assert max_subarray([-2,1,-3,4,-1,2,1,-5,4]) == 6 def test_example_2(): assert max_subarray([1]) == 1 def test_example_3(): assert max_subarray([5,4,-1,7,8]) == 23 def test_all_negative(): assert max_subarray([-1, -2, -3, -4]) == -1 def test_a...
[ { "docstring": "A utility function to find the maximum sum of the subarray crossing the midpoint.", "function_declaration": "def max_crossing_sum(nums, left, mid, right):", "function_name": "max_crossing_sum", "parameter_list": "(nums, left, mid, right)" }, { "docstring": "Use the divide and...
[ 1, 1, 1, 0, 1, 1, 0, 0, 1, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def max_crossing_sum(nums, left, mid, right):\n # Include elements on left of mid\n left_sum = float('-inf')\n sum = 0\n for i in range(mid, left-1, -1...
trial_gpt4o_9
{ "original_instruction": "Determine the Maximum Subarray Sum Using Divide and Conquer\nYou are given an integer array `nums` containing `n` elements. Your task is to determine the maximum sum of a contiguous subarray using the divide and conquer approach.\n\nThe divide and conquer approach involves recursively divid...
0.780894
Evol_8865
C
[ "max_crossing_sum", "max_subarray_sum", "max_subarray" ]
3
[ [ "max_subarray", "max_subarray_sum" ], [ "max_subarray_sum", "max_crossing_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
237c8293fc23c86664ec3e0417ecafa3c0dc4b3b
4f0f098b9aa403e9c211ebeedf64e4c3d8d8830f
v1.0
complete
Evol
Evol_8784_C
from typing import List def is_prime(n: int) -> bool: """ Determines if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ def filter_primes(lst: List[int]) -> List[int]: """ Filters the prime numbers from a list of integers. >>> filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) [2,...
def is_prime(n): """ Determines if a number is prime. Args: n (int): The number to check. Returns: bool: True if n is a prime number, else False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(-5) == Fal...
[ { "docstring": "Determines if a number is prime.\n\nArgs:\n n (int): The number to check.\n\nReturns:\n bool: True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the 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 Checks if a number is prime.\n \n :param n: int - The number to check\n :return: bool - True if the number is prime, Fal...
trial_gpt4o_7
{ "original_instruction": "Using Python, write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. You should use an auxiliary function to check if a number is prime. Demonstrate the functionality of this function with an example. Provide appropria...
0.744928
Evol_8784
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a48c5f013f8b31c0dd39957f9625c20ef6e04934
aded7c5ea81ae83e21da48fd6d6419c345f8c95c
v1.0
complete
Evol
Evol_8988_C
from typing import List def sum_of_non_primes(numbers: List[int]) -> int: """This function takes a list of integers and filters out all prime numbers. It then returns the sum of the remaining integers. If there are no non-prime numbers, it returns 0. >>> sum_of_non_primes([2, 3, 5, 7, 10, 12]) 22 ...
from typing import List def is_prime(n: int) -> bool: """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 ...
def test_sum_of_non_primes_with_mixed_numbers(): assert sum_of_non_primes([2, 3, 5, 7, 10, 12]) == 22 def test_sum_of_non_primes_with_all_prime_numbers(): assert sum_of_non_primes([13, 17, 19, 23]) == 0 def test_sum_of_non_primes_with_all_non_prime_numbers(): assert sum_of_non_primes([4, 6, 8, 9, 10]) == ...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "This function takes a list of integers and filters out all prime numbers. It then returns the sum of the re...
[ 1, 1, 1, 1, 0, 0, 1, 1, 0, 1 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"Helper function to check if a number is a prime number.\"\"\"\n if n <= 1:\n return F...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes a list of integers and filters out all prime numbers. The function should then calculate and return the sum of the remaining integers. If the list contains no non-prime numbers, the function should return 0. A prime number is defined as a number greater than 1 t...
0.685683
Evol_8988
C
[ "is_prime", "sum_of_non_primes" ]
2
[ [ "sum_of_non_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
98df47bc1386c1baaa6111d6f93ede907ba17175
23db55b06afb924d20f47b8e1c43616bc9868682
v1.0
complete
Evol
Evol_9203_C
from typing import List import matplotlib.pyplot as plt def find_primes(arr: List[int]) -> List[int]: """Returns a list of prime numbers from the given list 'arr'. >>> find_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] >>> find_primes([0, 1, 11, 13, 17]) == [11, 13, 17] >>> find_primes([15, 22, ...
import matplotlib.pyplot as plt def sieve_of_eratosthenes(n): """ Generates all prime numbers up to n using the Sieve of Eratosthenes algorithm. """ sieve = [True] * (n+1) p = 2 while (p * p <= n): if sieve[p]: for i in range(p * p, n+1, p): sieve[i] = False ...
from solution import find_primes, plot_prime_frequencies def test_find_primes(): assert find_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert find_primes([0, 1, 11, 13, 17]) == [11, 13, 17] assert find_primes([15, 22, 33, 35]) == [] assert find_primes([29, 29, 29, 29]) == [29, 29, 29, 29] ...
[ { "docstring": "Generates all prime numbers up to n using the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list '...
[ 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": "import matplotlib.pyplot as plt\n\ndef sieve_of_eratosthenes(max_num):\n \"\"\"\n Returns a list of prime numbers up to max_num using the Sieve of Eratosthen...
trial_gpt4o_1
{ "original_instruction": "Create a Python function that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. The function should be optimized for performance using the Sieve of Eratosthenes algorithm. Additionally, include a secondary function that visual...
0.630017
Evol_9203
C
[ "sieve_of_eratosthenes", "find_primes", "plot_prime_frequencies" ]
3
[ [ "find_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib" ]
false
74effab751f171700196ee904a25d5f1a212bdb1
23062746a318989fcee90d79ecd400ee0793c345
v1.0
complete
Evol
Evol_9142_C
from typing import List def is_prime(num: int) -> bool: """ 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 filter_primes(arr: List[int]) -> List[int]: """ Returns an arra...
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 filter_primes(arr): """ Returns an array containing only the prime numbers from the original ar...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7]) == [2, 3, 5, 7] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 10]) == [] def test_filter_primes_mixed_numbers(): assert filter_primes([10, 29, 15, 17, 93, 97]) == [29, 17, 97] ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns an array containing only the prime numbers from the original array in the same order.", "function_declaration": "d...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, in...
trial_gpt4o_8
{ "original_instruction": "Write a function that takes an array of integers as input and returns an array containing only the prime numbers from the original array in the same order. If the input array does not contain any prime numbers, return an empty array.\n\nExample:\nInput: [10, 29, 15, 17, 93, 97]\nOutput: [29...
0.714974
Evol_9142
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
99e90e54dd1e78a2ff1067366cd83a4352c882ed
d13fd976421d56addeb997c019bc1a86718c5259
v1.0
complete
Evol
Evol_8550_C
from typing import List def filter_primes(lst: List[int]) -> List[int]: """ Returns a list containing only the prime numbers from the original list. >>> filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) -> [2, 3, 5, 7] >>> filter_primes([15, 23, 31, 50, 37]) -> [23, 31, 37] >>> filter_primes([1, 2, 3, 4, 9, ...
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 def test_filter_primes_basic(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_some_primes(): assert filter_primes([15, 23, 31, 50, 37]) == [23, 31, 37] def test_filter_primes_mixed_numbers(): assert filter_primes([1, 2, 3, 4, ...
[ { "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, 0, 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 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": "Design 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. Additionally, optimize the function to handle large input sizes efficiently.\n\nExample:\n```\nfilter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) -> [...
0.680931
Evol_8550
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c26750cbbd53fef6730afafaeaa2154117681b8a
3c22bb6a4485ccd5d17d7979c1357ebf22d8a3ed
v1.0
complete
Evol
Evol_9403_C
from typing import List def is_prime(n: int) -> bool: """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True """ # Your code here def filter_primes(nums: List[int]) -> List[int]: """ Returns a new list containing only the prime numbers fro...
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return Tru...
from solution import is_prime, filter_primes def test_is_prime_with_prime_numbers(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(17) == True assert is_prime(19) == True assert is_prime(103) == True def test_is_prime_with_non_prime_numbers(): assert is_prime(1) == Fals...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the input list.", "function_declaration": "def filter_primes(nums):...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2...
trial_gpt4o_9
{ "original_instruction": "Design a function in Python that takes a list of integers as an input and returns a new list containing only the prime numbers from the input list. Ensure your function optimally checks for primality to handle larger inputs efficiently. Additionally, write a brief explanation of the algorit...
0.734656
Evol_9403
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
521168713c2950239fac9d51d395152f7d9d082a
9de5572987adba4ae7c253bc2a9b692fb089eba0
v1.0
complete
Evol
Evol_7787_C
import csv from collections import defaultdict from typing import List, Dict, Tuple def read_csv(filename: str) -> List[Dict[str, str]]: """ Reads a CSV file and returns a list of dictionaries representing each row. """ with open(filename, mode='r') as file: reader = csv.DictReader(file) data =...
import csv from collections import defaultdict def read_csv(filename): with open(filename, mode='r') as file: reader = csv.DictReader(file) data = [row for row in reader] return data def student_average(data): student_grades = defaultdict(list) for record in data: student_grade...
import pytest from solution import student_average, subject_extremes, overall_class_average, class_performance_summary data = [ {'Student Name': 'Alice Johnson', 'Subject': 'Math', 'Grade': '88'}, {'Student Name': 'Alice Johnson', 'Subject': 'Science', 'Grade': '92'}, {'Student Name': 'Bob Smith', 'Subject...
[ { "docstring": null, "function_declaration": "def read_csv(filename):", "function_name": "read_csv", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def student_average(data):", "function_name": "student_average", "parameter_list": "(data)" }, ...
[ 1, 1, 1, 0, 1, 0, 1, 0, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import csv\nfrom collections import defaultdict\n\ndef summarize_class_performance(csv_filename):\n student_grades = defaultdict(list)\n subject_grades = def...
trial_gpt4o_1
{ "original_instruction": "Write a Python program that reads a CSV file containing student records and outputs a summary report of the class's performance. The CSV file will have the following columns: Student Name, Subject, Grade. The program should do the following:\n\n1. Calculate and display each student's averag...
0.784458
Evol_7787
C
[ "read_csv", "student_average", "subject_extremes", "overall_class_average", "class_performance_summary" ]
5
[ [ "class_performance_summary", "overall_class_average" ], [ "class_performance_summary", "read_csv" ], [ "class_performance_summary", "student_average" ], [ "class_performance_summary", "subject_extremes" ] ]
4
[]
false
[]
false
pytest
true
[]
true
f80c7962b69e1aab98ced44aea4c000194faa218
2190609807c48e526887969e6ad9ed907f0c7427
v1.0
complete
Evol
Evol_8901_C
def is_prime(num: int) -> bool: """Check if the given number is prime. >>> is_prime(2) True >>> is_prime(4) False """ def filter_primes(numbers: List[int]) -> List[int]: """Returns a new list containing only the prime numbers from the original list. >>> filter_primes([10, 15, 17, 19, 24, 29...
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 filter_primes(numbers): """ Returns a new list containing only the prime numbers from the original list. """ return [num for num in ...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13]) == [2, 3, 5, 7, 11, 13] def test_filter_primes_mixed(): assert filter_primes([10, 15, 17, 19, 24, 29]) == [17, 19, 29] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 10, ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.", "function_declaration": "def filter_primes(numbers):", "function...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ...
trial_gpt4o_8
{ "original_instruction": "Develop a Python function that takes a list of integers and returns a new list containing only the integers from the original list that are prime numbers. The function should not use any built-in functions specifically designed for prime checking. Implement your own logic for determining if...
0.739762
Evol_8901
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
895c219967b320ab3447cdb292da646197218099
e2b81ba7e27613af0e4c44add5f75f605014fb38
v1.0
complete
Evol
Evol_9078_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. Args: - n (int): The number to check for primality. Returns: - bool: 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...
def is_prime(n): """ Return 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 process_numbers(numbers): """ Processes a list of integers to separate primes...
from solution import process_numbers def test_process_numbers_mixed(): assert process_numbers([10, 3, 5, 8, 13, 4, 16]) == { 'primes': [3, 5, 13], 'non_primes': [4, 8, 10, 16], 'prime_sum': 21, 'non_prime_sum': 38 } def test_process_numbers_all_primes(): assert process_numb...
[ { "docstring": "Return True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Processes a list of integers to separate primes and non-primes, sort each list,\nand calculate their sums...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ret...
trial_gpt4o_9
{ "original_instruction": "Create a function that processes a list of integers and performs the following tasks:\n1. Separate the list into two lists: one containing all the prime numbers and another containing all the non-prime numbers.\n2. Sort both lists in ascending order.\n3. Calculate the sum of the prime numbe...
0.738205
Evol_9078
C
[ "is_prime", "process_numbers" ]
2
[ [ "process_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a3f6b6c027ed0029ae4f0d0d8803a59898ee2d1
877281181e0444402afc5b34b74bb9327a79974e
v1.0
complete
Evol
Evol_8380_C
import os import string from collections import Counter from concurrent.futures import ThreadPoolExecutor def word_frequency(file_path): """ Reads a file and returns a Counter object with the frequency of each word. """ def merge_counters(counters): """ Merges multiple Counter objects into a singl...
import os import string from collections import Counter from concurrent.futures import ThreadPoolExecutor def word_frequency(file_path): """ Reads a file and returns a Counter object with the frequency of each word. """ if not os.path.exists(file_path): raise FileNotFoundError(f"File not found:...
import tempfile import pytest from solution import word_frequency, merge_counters, process_files def create_temp_file(content): """ Helper function to create a temporary file with the given content and return its path. """ fd, path = tempfile.mkstemp() with os.fdopen(fd, 'w') as tmp: tmp.wr...
[ { "docstring": "Reads a file and returns a Counter object with the frequency of each word.", "function_declaration": "def word_frequency(file_path):", "function_name": "word_frequency", "parameter_list": "(file_path)" }, { "docstring": "Merges multiple Counter objects into a single Counter."...
[ 0, 1, 1, 0, 1, 1, 0, 1, 0, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import concurrent.futures\nimport os\nfrom collections import Counter\nimport re\nfrom typing import List, Dict\n\ndef count_words(file_path: str) -> Counter:\n ...
trial_gpt4o_1
{ "original_instruction": "Develop a multi-threaded file processing utility that reads large text files and performs word frequency analysis. The program should be able to concurrently handle multiple files using a thread pool and combine the results to produce a consolidated word frequency count.\n\nThe utility shou...
0.605169
Evol_8380
C
[ "word_frequency", "merge_counters", "process_files" ]
3
[ [ "process_files", "merge_counters" ], [ "process_files", "word_frequency" ] ]
2
[]
false
[]
false
pytest
true
[]
true
891d784ae100c93918cab3458dd49b5c8bb57a95
3900238b05776324b1534c16a9ffdbc49e0228ff
v1.0
complete
Evol
Evol_9133_C
def distance_from_origin(point: tuple) -> float: """ Computes the Euclidean distance from the origin (0,0) for a given point. """ pass def sort_points(points: List[tuple]) -> List[tuple]: """ Sorts a list of points by their distance from the origin (0,0) in ascending order. >>> sort_points([(1, 2),...
import math def distance_from_origin(point): """ Computes the Euclidean distance from the origin (0,0) for a given point. """ return math.sqrt(point[0]**2 + point[1]**2) def sort_points(points): """ Sorts a list of points by their distance from the origin (0,0). Returns a list of sorted po...
from solution import sort_points, verify_sorting def test_sort_points(): points = [(1, 2), (3, 4), (0, -1)] sorted_points = sort_points(points) expected = [(0, -1), (1, 2), (3, 4)] assert sorted_points == expected, f"Expected {expected}, but got {sorted_points}" def test_sort_points_with_all_origin_po...
[ { "docstring": "Computes the Euclidean distance from the origin (0,0) for a given point.", "function_declaration": "def distance_from_origin(point):", "function_name": "distance_from_origin", "parameter_list": "(point)" }, { "docstring": "Sorts a list of points by their distance from the ori...
[ 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 calculate_distance(point):\n \"\"\"\n Calculate the Euclidean distance of a point from the origin (0,0).\n \"\"\"\n return point[0]**2 + point[1]**...
trial_gpt4o_3
{ "original_instruction": "Write a function that takes a list of tuples, with each tuple containing two numerical values representing the coordinates of a point on a 2D plane. The function should return a list of these points sorted by their distance from the origin (0,0), in ascending order.\n\nFor example, if the i...
0.646612
Evol_9133
C
[ "distance_from_origin", "sort_points", "verify_sorting" ]
3
[ [ "verify_sorting", "distance_from_origin" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8678db79c6a9998dd52f7205957e52fc09e6acd5
0115c08643b864b9327cff28e160cc7bd8883d43
v1.0
complete
Evol
Evol_9122_C
import json def calculate_grade(score): """ Calculate the grade based on the score. >>> calculate_grade(95) == "A" >>> calculate_grade(85) == "B" >>> calculate_grade(75) == "C" >>> calculate_grade(65) == "D" >>> calculate_grade(55) == "F" """ pass def process_student_data(file_path): ...
import json def calculate_grade(score): if score >= 90: return "A" elif score >= 80: return "B" elif score >= 70: return "C" elif score >= 60: return "D" else: return "F" def process_student_data(file_path): with open(file_path, 'r') as f: data =...
from solution import process_student_data, calculate_grade import json def test_calculate_grade(): assert calculate_grade(95) == "A" assert calculate_grade(85) == "B" assert calculate_grade(75) == "C" assert calculate_grade(65) == "D" assert calculate_grade(55) == "F" def test_process_student_data...
[ { "docstring": null, "function_declaration": "def calculate_grade(score):", "function_name": "calculate_grade", "parameter_list": "(score)" }, { "docstring": null, "function_declaration": "def process_student_data(file_path):", "function_name": "process_student_data", "parameter_...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import json\n\ndef parse_json(file_path):\n with open(file_path, 'r') as file:\n data = json.load(file)\n return data\n\ndef calculate_individual_scor...
trial_gpt4o_7
{ "original_instruction": "Given a file containing a list of JSON objects, each representing a student's performance in various subjects, write a Python program to:\n1. Read and parse the JSON data.\n2. Calculate and display each student's total score, average score, and their corresponding grade based on the followi...
0.701256
Evol_9122
C
[ "calculate_grade", "process_student_data" ]
2
[ [ "process_student_data", "calculate_grade" ] ]
1
[]
false
[]
false
pytest
true
[]
true
22344f6db2ed489fec82ffa2f8c1ec04326ba810
9682af1b2e409f4c281f08cf93079ed895e13464
v1.0
complete
Evol
Evol_8000_C
import pandas as pd import matplotlib.pyplot as plt def load_data(data): """Load the data into a Pandas DataFrame. >>> data = [ ... {'user_id': 1, 'activity': 'login', 'timestamp': '2023-01-01 08:00:00'}, ... {'user_id': 2, 'activity': 'purchase', 'timestamp': '2023-01-01 09:00:00'} ... ] ...
import pandas as pd import matplotlib.pyplot as plt def load_data(data): df = pd.DataFrame(data) return df def clean_data(df): df['timestamp'] = pd.to_datetime(df['timestamp'], errors='coerce') df.dropna(subset=['timestamp'], inplace=True) return df def transform_data(df): activity_map = {'lo...
from solution import load_data, clean_data, transform_data, aggregate_data, visualize_data, data_analysis_pipeline import pandas as pd def test_load_data(): data = [ {'user_id': 1, 'activity': 'login', 'timestamp': '2023-01-01 08:00:00'}, {'user_id': 2, 'activity': 'purchase', 'timestamp': '2023-01...
[ { "docstring": null, "function_declaration": "def load_data(data):", "function_name": "load_data", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def clean_data(df):", "function_name": "clean_data", "parameter_list": "(df)" }, { "docstring": 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": "import pandas as pd\nimport matplotlib.pyplot as plt\n\ndef load_data(data):\n \"\"\"Load the data into a pandas DataFrame.\"\"\"\n df = pd.DataFrame(data)\n...
trial_gpt4o_9
{ "original_instruction": "# Task: Create a Data Analysis Pipeline \n\n## Context\nYou have been hired as a data scientist for a technology startup, and your first task is to build a data analysis pipeline for user activity data. The startup aims to understand user behavior patterns and improve user engagement throug...
0.706855
Evol_8000
C
[ "load_data", "clean_data", "transform_data", "aggregate_data", "visualize_data", "data_analysis_pipeline" ]
6
[ [ "data_analysis_pipeline", "aggregate_data" ], [ "data_analysis_pipeline", "clean_data" ], [ "data_analysis_pipeline", "load_data" ], [ "data_analysis_pipeline", "transform_data" ], [ "data_analysis_pipeline", "visualize_data" ] ]
5
[]
false
[]
false
pytest
true
[ "matplotlib", "pandas" ]
false
dd49c6e16072744d28d6d48c7a43bbf51886940d
83d43b9ec84bd424d3e869e7dea4d6f702ca5f7d
v1.0
complete
Evol
Evol_9379_C
def is_prime(n: int) -> bool: """ Helper function to check if a number n is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-5) False """ def fil...
def is_prime(n): """ Helper function to check if a number n 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 is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == Fal...
[ { "docstring": "Helper function to check if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the provided list.\nIf the list is empty, returns '...
[ 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_9
{ "original_instruction": "Write a Python program that takes a list of integers and returns a new list containing only the prime numbers from the original list. Your solution should include a helper function to check if a number is prime. Additionally, the program should be optimized to handle lists with a large numb...
0.782026
Evol_9379
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2cb88bdf652c7fa680048a71f7e8b4787e5657d1
5793e9c71e740e6354f84b2a9b0eea513a2db201
v1.0
complete
Evol
Evol_8420_C
from typing import List def is_prime(n: int) -> bool: """ Returns True if the number n is a prime number, otherwise False. """ pass def filter_primes(numbers: List[int]) -> List[int]: """ Filters prime numbers from a list of integers and returns a new list containing only primes. >>> ...
from typing import List def is_prime(n: int) -> bool: """ Returns True if the number n is a prime number, otherwise False. """ 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 ...
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, 9, 10, 12]) == [] def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13]) == [2, 3, 5, 7, 11, 13] def test_fil...
[ { "docstring": "Returns True if the number n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters prime numbers from a list of integers and returns a new list containing only primes."...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n r...
trial_gpt4o_3
{ "original_instruction": "Implement a function in Python that takes in a list of integers and returns a new list containing only the prime numbers from the original list. The algorithm should be efficient in checking the primality of each number and handle large inputs effectively. Ensure you include appropriate err...
0.737656
Evol_8420
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7fcd34b76aff6049a9362f5f96a007164bd8cdd3
29d1f0a3a63901cc1d96923f9ce0346d80cb969a
v1.0
complete
Evol
Evol_8996_C
from typing import List def evaluate_expression(expression: str) -> int: """ This function takes a string representing a mathematical expression involving addition and subtraction of integers, parses the expression, and evaluates the result without using any built-in evaluation functions. Paramete...
def evaluate_expression(expression): """ This function takes a string representing a mathematical expression involving addition and subtraction of integers. It parses the expression and evaluates the result. Parameters: - expression (str): The input string containing the mathematical expression...
from solution import evaluate_expression, authorized_evaluate_expression def test_evaluate_expression_simple(): assert evaluate_expression("12+3-4+5-7") == 9 def test_evaluate_expression_single_number(): assert evaluate_expression("10") == 10 def test_evaluate_expression_all_addition(): assert evaluate_e...
[ { "docstring": "This function takes a string representing a mathematical expression involving addition and subtraction of integers.\nIt parses the expression and evaluates the result.\n\nParameters:\n- expression (str): The input string containing the mathematical expression.\n\nReturns:\n- int: The result of t...
[ 0, 1, 1, 1, 1, 1, 1, 0, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def evaluate_expression(expression):\n \"\"\"\n Evaluates a mathematical expression involving addition and subtraction of integers.\n The function parses ...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a string representing a mathematical expression involving addition and subtraction of integers. Implement a solution that parses the expression and evaluates the result. The expression will not contain any parentheses and will only involve integers, plus and min...
0.598997
Evol_8996
C
[ "evaluate_expression", "authorize_user", "authorized_evaluate_expression" ]
3
[ [ "authorized_evaluate_expression", "authorize_user" ], [ "authorized_evaluate_expression", "evaluate_expression" ] ]
2
[]
false
[]
false
pytest
true
[]
true
233c73dc8c698600ab0e2aef00dd9e533cadccd3
3dda6aa09f87a045063e40784c327a6f1b318e97
v1.0
complete
Evol
Evol_9120_C
from typing import List from collections import deque def min_distance_to_empty_space(grid: List[List[int]]) -> int: """ You are given a 2D grid `grid` representing a city where `blockages` are marked with `-1` and empty spaces are marked with `0`. Some buildings are placed in the city, each represented by a non-z...
from collections import deque def bfs(grid, start): m, n = len(grid), len(grid[0]) directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] visited = [[False] * n for _ in range(m)] queue = deque([(start[0], start[1], 0)]) # (row, col, distance) visited[start[0]][start[1]] = True while queue: ...
def test_example_1(): grid = [[0, 2, -1], [3, 0, 1], [2, -1, 4]] assert min_distance_to_empty_space(grid) == 2 def test_example_2(): grid = [[-1, -1], [-1, -1]] assert min_distance_to_empty_space(grid) == -1 def test_example_3(): grid = [[0, 3, 0], [2, 4, 1], [0, 0, 4]] assert min_distance_to_...
[ { "docstring": null, "function_declaration": "def bfs(grid, start):", "function_name": "bfs", "parameter_list": "(grid, start)" }, { "docstring": null, "function_declaration": "def min_distance_to_empty_space(grid):", "function_name": "min_distance_to_empty_space", "parameter_lis...
[ 0, 0, 0, 1, 1, 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": "from collections import deque\n\ndef min_distance_to_empty_space(grid):\n \"\"\"\n Returns the distance from the building with the maximum height to the near...
trial_gpt4o_3
{ "original_instruction": "You are given a 2D grid `grid` representing a city where `blockages` are marked with `-1` and empty spaces are marked with `0`. Some buildings are placed in the city, each represented by a non-zero positive integer `b`, indicating the height of the building. Your task is to determine the di...
0.656572
Evol_9120
C
[ "bfs", "min_distance_to_empty_space" ]
2
[ [ "min_distance_to_empty_space", "bfs" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a597dc7a564f45b2810c3a145592523339481748
dd6db52145290ab4b9a9ebc3be68d1f3c432e4f2
v1.0
complete
Evol
Evol_9517_C
from typing import List def F(n: int) -> List[int]: """ Returns an array where the ith element is the count of positive divisors of i (1-indexed). >>> F(1) == [1] >>> F(2) == [1, 2] >>> F(3) == [1, 2, 2] >>> F(4) == [1, 2, 2, 3] >>> F(6) == [1, 2, 2, 3, 2, 4] """ def sum_F(m: ...
def F(n): """ Returns an array where the ith element is the count of positive divisors of i (1-indexed). """ divisors_count = [0] * (n + 1) # Count divisors using a modified Sieve of Eratosthenes approach for i in range(1, n + 1): for j in range(i, n + 1, i): divisors_co...
from solution import F, sum_F def test_F(): assert F(1) == [1] assert F(2) == [1, 2] assert F(3) == [1, 2, 2] assert F(4) == [1, 2, 2, 3] assert F(6) == [1, 2, 2, 3, 2, 4] def test_sum_F(): assert sum_F(1) == 1 assert sum_F(2) == 3 # 1 + 2 assert sum_F(3) == 5 # 1 + 2 + 2 assert ...
[ { "docstring": "Returns an array where the ith element is the count of positive divisors of i (1-indexed).", "function_declaration": "def F(n):", "function_name": "F", "parameter_list": "(n)" }, { "docstring": "Returns the sum of the elements in the array returned by F(m).", "function_de...
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def F(n):\n \"\"\"\n Returns an array of length n where each element i (1-indexed) is the count\n of positive divisors of i.\n \"\"\"\n divisors_cou...
trial_gpt4o_9
{ "original_instruction": "<p>Consider the function $F(n)$ which returns an array of length $n$ where each element $i$ (1-indexed) is the count of positive divisors of $i$. For example:</p>\n<p>$F(1) = [1]$<br>\n$F(2) = [1, 2]$<br>\n$F(3) = [1, 2, 2]$<br>\n$F(4) = [1, 2, 2, 3]$</p>\n<p>Implement the function $F(n)$ a...
0.711454
Evol_9517
C
[ "F", "sum_F" ]
2
[ [ "sum_F", "F" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ce88b0da966b6f3b41c9bf33470d1e12656bbefb
d732eff847574f639cae1ebdd006d1f1628eb41a
v1.0
complete
Evol
Evol_9039_C
def astar_search(grid: List[List[int]], start: Tuple[int, int], goal: Tuple[int, int]) -> List[Tuple[int, int]]: """ Implement a simplified version of the A* search algorithm to find the shortest path in a 2D grid. The grid is represented as a list of lists, where 0 indicates a walkable cell and 1 indicate...
import heapq def heuristic(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) def get_neighbors(node, grid): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] neighbors = [] for direction in directions: neighbor = (node[0] + direction[0], node[1] + direction[1]) if 0 <= neighbor[0] < len(...
from solution import astar_search def test_no_obstacles(): grid = [ [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0] ] start = (0, 0) goal = (2, 3) assert astar_search(grid, start, goal) == [(0, 0), (0, 1), (0, 2), (0, 3), (1, 3), (2, 3)] def test_with_obstacles(): grid = [ ...
[ { "docstring": null, "function_declaration": "def heuristic(a, b):", "function_name": "heuristic", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def get_neighbors(node, grid):", "function_name": "get_neighbors", "parameter_list": "(node, grid)" }, ...
[ 1, 1, 0, 1, 0, 0, 0, 1, 0, 0 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import heapq\n\ndef a_star(grid, start, goal):\n \"\"\"\n Implements a simplified version of the A* search algorithm to find the shortest path in a 2D grid.\...
trial_gpt4o_7
{ "original_instruction": "Write a function to implement a simplified version of the A* search algorithm to find the shortest path in a 2D grid. The grid is represented as a list of lists, where a value of 0 indicates a walkable cell and a value of 1 indicates an obstacle. The function should take as input the grid, ...
0.626436
Evol_9039
C
[ "heuristic", "get_neighbors", "astar_search" ]
3
[ [ "astar_search", "get_neighbors" ], [ "astar_search", "heuristic" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6e1cd9bacc2c1cf777ba687517d6531b9279aabe
8fbcf10c522be6a59b78af1142b8ae6118b4b943
v1.0
complete
Evol
Evol_9496_C
def evaluate_expression(expr: str): """ Evaluates a mathematical expression from a string. Args: expr (str): A string representing the mathematical expression. Returns: float or str: The result of the evaluated expression, or an error message if there's a division by zero. """ # Your c...
def evaluate_expression(expr): """ Evaluates a mathematical expression from a string. Args: expr (str): A string representing the mathematical expression. Returns: float or str: The result of the evaluated expression, or an error message if there's a division by zero. """ try: ...
from solution import evaluate_expression, compare_expressions def test_evaluate_expression(): assert evaluate_expression("2 * (3 + 4)") == 14 assert evaluate_expression("14 - 2") == 12 assert evaluate_expression("5 / 0") == "Error: Division by zero" assert evaluate_expression("5 + 5 / 0") == "Error: Di...
[ { "docstring": "Evaluates a mathematical expression from a string.\n\nArgs:\nexpr (str): A string representing the mathematical expression.\n\nReturns:\nfloat or str: The result of the evaluated expression, or an error message if there's a division by zero.", "function_declaration": "def evaluate_expression...
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def evaluate_expression(expr):\n \"\"\"\n Evaluates the given mathematical expression while safely handling division by zero.\n Returns the result if succ...
trial_gpt4o_2
{ "original_instruction": "Create a function that evaluates and compares mathematical expressions formatted as strings. The function should accept two expressions as input and return whether they are equivalent when fully simplified. The expressions can include basic arithmetic operators (+, -, *, /), integers, and p...
0.628622
Evol_9496
C
[ "evaluate_expression", "compare_expressions" ]
2
[ [ "compare_expressions", "evaluate_expression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
47a0b4ca089fc8edb08f1958f9d1f75806d594db
7f52d8f46aa9c93dfe24c7d2f71a419cdeb17115
v1.0
complete
Evol
Evol_9362_C
import math 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(5) True >>> is_prime(10) False """ pass def filter_primes(numbers: List[int]) -> List[i...
def is_prime(n): """Check if a number is prime.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(numbers): """ Return...
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(11) == True assert is_prime(1) == False assert is_prime(0) == False...
[ { "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 input list.", "function_declaration": "def filter_primes(numbers):", "function_na...
[ 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: int\n \n Returns: \n bool: True if n is prime, False otherwise\n \"\"\"\n if...
trial_gpt4o_8
{ "original_instruction": "Create a function that takes a list of integers as input and returns a new list containing only the elements that are prime numbers. The function should maintain the order of elements as they appear in the input list.\n\nexample_list = [2, 3, 4, 5, 6, 7, 8, 9, 10]\n\nOutput for the example:...
0.769599
Evol_9362
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
57e2456099e0b3184759e285486f2f6ae0f8d750
829425315bdc5f3ee3b60da050292f6c3467e275
v1.0
complete
Evol
Evol_9170_C
from typing import List, Tuple def euclidean_distance(point1: List[float], point2: List[float]) -> float: """ Calculate the Euclidean distance between two points in a multidimensional space. >>> euclidean_distance([0, 0], [3, 4]) 5.0 >>> euclidean_distance([1, 1], [4, 5]) 5.0 """ def calcu...
from typing import List, Tuple import random def euclidean_distance(point1: List[float], point2: List[float]) -> float: return sum((x - y) ** 2 for x, y in zip(point1, point2)) ** 0.5 def calculate_centroids(clusters: List[List[List[float]]]) -> List[List[float]]: centroids = [] for cluster in clusters: ...
import random from solution import euclidean_distance, calculate_centroids, assign_clusters, k_means_clustering def test_euclidean_distance(): assert euclidean_distance([0, 0], [3, 4]) == 5.0 assert euclidean_distance([1, 1], [4, 5]) == 5.0 def test_calculate_centroids(): assert calculate_centroids([[[0, ...
[ { "docstring": null, "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def calculate_centroids(clusters):", "function_name": "calculate_centro...
[ 1, 0, 0, 0, 1, 1, 0, 1, 1, 0 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\nimport random\nimport numpy as np\n\ndef k_means_clustering(data: List[List[float]], k: int, max_iter: int) -> Tuple[List[List[floa...
trial_gpt4o_8
{ "original_instruction": "Write a function to implement the k-means clustering algorithm from scratch in Python. The function should take a dataset in the form of a list of lists, the number of clusters `k`, and the maximum number of iterations as input. The function should return the final centroids and the cluster...
0.796995
Evol_9170
C
[ "euclidean_distance", "calculate_centroids", "assign_clusters", "k_means_clustering" ]
4
[ [ "assign_clusters", "euclidean_distance" ], [ "k_means_clustering", "assign_clusters" ], [ "k_means_clustering", "calculate_centroids" ] ]
3
[]
false
[]
false
pytest
true
[]
true
edd84cb46bf595daed913154893c5c7c43ae6433
3dfd8875948b61440b7e4947a9ca5a901a03b3ad
v1.0
complete
Evol
Evol_9408_C
def is_prime(num: int) -> bool: """ Helper function to determine if a number is prime. """ def sum_of_first_n_primes(n: int) -> int: """ Returns the sum of the first n prime numbers. Raises a ValueError for invalid inputs. >>> sum_of_first_n_primes(0) == 0 >>> sum_of_first_n_primes(1) == ...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def sum_of_first_n_primes(n): ...
from solution import sum_of_first_n_primes def test_sum_of_first_n_primes(): assert sum_of_first_n_primes(0) == 0 assert sum_of_first_n_primes(1) == 2 assert sum_of_first_n_primes(2) == 5 assert sum_of_first_n_primes(3) == 10 assert sum_of_first_n_primes(5) == 28 assert sum_of_first_n_primes(10...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of the first n prime numbers.\nRaises a ValueError for invalid inputs.", "function_declaration": "def sum_of_first_n_primes(n):", ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Returns True if num is a prime number, else False.\"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0....
trial_gpt4o_4
{ "original_instruction": "Write a Python function that accepts an integer, `n`, and computes the sum of first `n` prime numbers. Ensure your function includes appropriate error handling to deal with invalid inputs (e.g., non-integer values or negative numbers).", "prompt_id": "00009408", "row_id": 9408, "seed_...
0.799772
Evol_9408
C
[ "is_prime", "sum_of_first_n_primes" ]
2
[ [ "sum_of_first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
162cd88096b4479298f7952c9a052e3f55fd0cc7
83717d6dbf9cd3c6bc3448d30c8f62087e736583
v1.0
complete
Evol
Evol_9557_C
import pandas as pd import matplotlib.pyplot as plt def clean_dataset(df): """ Cleans the dataframe by removing duplicates, filling missing values, and addressing data inconsistencies. Parameters: df (pd.DataFrame): The dataframe to be cleaned. Returns: pd.DataFrame: The cleaned dataf...
import pandas as pd import matplotlib.pyplot as plt def clean_dataset(df): """ Cleans the dataframe by removing duplicates, filling missing values, and addressing data inconsistencies. Parameters: df (pd.DataFrame): The dataframe to be cleaned. Returns: pd.DataFrame: The cleaned dataf...
import pandas as pd from solution import clean_dataset, summary_statistics, plot_histograms def test_clean_dataset(): sample_data = { 'name': ['Alice', 'Bob', 'Charlie', 'Bob', 'Alice'], 'age': [25, 30, 35, None, None], 'city': ['NY', 'LA', 'SF', None, 'NY'] } df = pd.DataFrame(samp...
[ { "docstring": "Cleans the dataframe by removing duplicates, filling missing values,\nand addressing data inconsistencies.\n\nParameters:\ndf (pd.DataFrame): The dataframe to be cleaned.\n\nReturns:\npd.DataFrame: The cleaned dataframe.", "function_declaration": "def clean_dataset(df):", "function_name"...
[ 0, 0, 0, 1, 0, 1, 0, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\ndef clean_and_analyze_dataset(url):\n \"\"\"\n Loads a dataset, cleans it by r...
trial_gpt4o_3
{ "original_instruction": "Use the Pandas library to clean a dataset containing missing values, duplicate entries, and data inconsistencies. After cleaning the data, calculate and display the summary statistics, and plot histograms for all numeric columns to visualize their distribution. For this task, you may use an...
0.739143
Evol_9557
C
[ "clean_dataset", "summary_statistics", "plot_histograms", "load_and_clean_example_dataset" ]
4
[ [ "load_and_clean_example_dataset", "clean_dataset" ], [ "load_and_clean_example_dataset", "plot_histograms" ], [ "load_and_clean_example_dataset", "summary_statistics" ] ]
3
[]
false
[]
false
pytest
true
[ "matplotlib", "pandas" ]
false
f9af5dc476cb1b1cc4324df487d609978e49d107
fca3e7f92c6018d6cda0089fbe446a611ef8b7fc
v1.0
complete
Evol
Evol_9001_C
import pandas as pd from sklearn.preprocessing import StandardScaler from sklearn.cluster import KMeans from sklearn.metrics import silhouette_score import numpy as np def preprocess_data(data: pd.DataFrame) -> np.ndarray: """ Handle missing values and apply feature scaling. Parameters: data (pd.D...
import pandas as pd from sklearn.preprocessing import StandardScaler from sklearn.cluster import KMeans from sklearn.metrics import silhouette_score import numpy as np import matplotlib.pyplot as plt def preprocess_data(data): """ Handle missing values and apply feature scaling. """ # Handle missing va...
import pandas as pd import numpy as np from solution import preprocess_data, find_optimal_clusters, clustering_analysis from sklearn.preprocessing import StandardScaler from sklearn.cluster import KMeans import pytest # Sample data for testing data_dict = { 'age': [25, 34, 45, 23, 35, np.nan, 29], 'annual_inco...
[ { "docstring": "Handle missing values and apply feature scaling.", "function_declaration": "def preprocess_data(data):", "function_name": "preprocess_data", "parameter_list": "(data)" }, { "docstring": "Determine the optimal number of clusters using the Elbow method.", "function_declarat...
[ 0, 0, 0, 1, 0, 1, 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": "import pandas as pd\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.cluster import KMeans\nfrom sklearn.metrics import silhouette_score\nimport mat...
trial_gpt4o_3
{ "original_instruction": "Analyze the customer segmentation dataset and perform a clustering analysis. The data contains customer demographics and purchasing behavior. Your task is to preprocess the data, apply a clustering algorithm, and evaluate the clusters. Specifically, focus on handling missing values, feature...
0.790158
Evol_9001
C
[ "preprocess_data", "find_optimal_clusters", "clustering_analysis" ]
3
[ [ "clustering_analysis", "find_optimal_clusters" ], [ "clustering_analysis", "preprocess_data" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy", "pandas", "sklearn" ]
false
044af47e262df8213b7bd3cfcc80e64e1effed4b
da17c22c572dec1698aa29b6b60222db09fa8f80
v1.0
complete
Evol
Evol_9492_C
def is_prime(k: int) -> bool: """ Returns True if the given integer k is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False """ def check_primes(arr: List[int]) -> List[bool]: """ Returns a list of boolean values indicating the prima...
def is_prime(k): """ Returns True if the given integer k is a prime number, otherwise False. """ if k <= 1: return False for i in range(2, int(k ** 0.5) + 1): if k % i == 0: return False return True def check_primes(arr): """ Returns a list of boolean values ...
from solution import is_prime, check_primes def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(1) assert not is_prime(0) assert not is_prime(-1) assert not is_prime(100) def test_check_primes(): assert check_prim...
[ { "docstring": "Returns True if the given integer k is a prime number, otherwise False.", "function_declaration": "def is_prime(k):", "function_name": "is_prime", "parameter_list": "(k)" }, { "docstring": "Returns a list of boolean values indicating the primality of each integer in the input...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n \n Parameters:\n n (int): The number to check.\n \n Returns:...
trial_gpt4o_7
{ "original_instruction": "Write a Python function that takes an input integer 'k' and returns True if 'k' is a prime number. Additionally, modify the function to handle an input array of integers, checking each number in the array and returning an array of boolean values corresponding to the primality of each intege...
0.819393
Evol_9492
C
[ "is_prime", "check_primes" ]
2
[ [ "check_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62fc48044cd2601993e5c856d217f0f53433b89d
c7e0cf85c6352c041307786e846fd13e9470c4df
v1.0
complete
Evol
Evol_9560_C
def factorial_sum(m: int, n: int) -> int: """ Calculate the sum of factorials of each integer between m and n (inclusive). >>> factorial_sum(1, 4) 33 >>> factorial_sum(0, 3) 10 >>> factorial_sum(3, 3) 6 >>> factorial_sum(4, 6) 864 >>> factorial_sum(0, 0) 1 """
def factorial(n): result = 1 for i in range(2, n + 1): result *= i return result def factorial_sum(m, n): total = 0 for i in range(m, n + 1): total += factorial(i) return total
from solution import factorial_sum def test_factorial_sum_basic(): assert factorial_sum(1, 4) == 33 def test_factorial_sum_zero_start(): assert factorial_sum(0, 3) == 1 + 1 + 2 + 6 def test_factorial_sum_single_value(): assert factorial_sum(3, 3) == 6 def test_factorial_sum_large_values(): asser...
[ { "docstring": null, "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def factorial_sum(m, n):", "function_name": "factorial_sum", "parameter_list": "(m, n)" } ]
[ 0, 1, 0, 0, 0, 1, 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 factorial_sum(m, n):\n \"\"\"\n Calculate the sum of the factorials of each integer between m and n (inclusive).\n \n Args:\n m (int): The lower...
trial_gpt4o_7
{ "original_instruction": "Write a Python function named `factorial_sum` that takes two integers `m` and `n` as input, where \\(0 \\leq m \\leq n\\). The function should calculate the factorial of each integer between `m` and `n` (inclusive) and return the sum of these factorials. Use an iterative approach to compute...
0.709451
Evol_9560
C
[ "factorial", "factorial_sum" ]
2
[ [ "factorial_sum", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4e4412c72b6dc0e9e37a936a58847de28f0b1012
19e1971ddbedca722332c3f04b45638c37a18aad
v1.0
complete
Evol
Evol_9669_C
def is_prime(num): """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def is_palindrome(num): """ Check if a number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False """ pass def prime_palindromes(N): """ ...
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 is_palindrome(num): """ Check if a number is a palindrome. """ return str(num) == str(n...
from solution import is_prime, 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(5) == True assert is_prime(11) == True assert is_prime(20) == False def test_is_palindrome(): assert is_pal...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrom...
[ 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 is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n ...
trial_gpt4o_5
{ "original_instruction": "Write a function that takes a single integer input `N` and outputs a list of all prime numbers up to `N` that are also palindromes. A palindrome is a number that remains the same when its digits are reversed. For example, 131 is a palindrome because it reads the same forward and backward. Y...
0.741561
Evol_9669
C
[ "is_prime", "is_palindrome", "prime_palindromes" ]
3
[ [ "prime_palindromes", "is_palindrome" ], [ "prime_palindromes", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
803d5eecc6d8c50ca2371c21a4e4fb736b0f5c8b
65f066e5109603ee7ee6946c50e1625a16c9720e
v1.0
complete
Evol
Evol_9248_C
import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression from sklearn.tree import DecisionTreeRegressor from sklearn.metrics import mean_squared_error from sklearn.model_selection import TimeSeriesSplit from sklearn.ensemble import VotingRegressor import matplotlib.pyplot as plt def loa...
import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression from sklearn.tree import DecisionTreeRegressor from sklearn.metrics import mean_squared_error from sklearn.model_selection import TimeSeriesSplit from sklearn.ensemble import VotingRegressor import matplotlib.pyplot as plt def loa...
import pytest from solution import load_data, create_lag_features, prepare_data, train_evaluate_model def test_load_data(): url = 'https://raw.githubusercontent.com/jbrownlee/Datasets/master/daily-min-temperatures.csv' df = load_data(url) assert not df.empty assert 'Temp' in df.columns def test_create...
[ { "docstring": null, "function_declaration": "def load_data(url):", "function_name": "load_data", "parameter_list": "(url)" }, { "docstring": null, "function_declaration": "def create_lag_features(data, lag):", "function_name": "create_lag_features", "parameter_list": "(data, lag...
[ 0, 1, 0, 1, 1, 1, 1, 1, 0, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport numpy as np\nfrom sklearn.model_selection import TimeSeriesSplit, GridSearchCV\nfrom sklearn.linear_model import LinearRegression\nfrom...
trial_gpt4o_7
{ "original_instruction": "Using the given dataset of daily temperatures in Seattle (which can be found at this URL: https://raw.githubusercontent.com/jbrownlee/Datasets/master/daily-min-temperatures.csv), develop a temperature prediction model using a combination of a Linear Regression model and a Decision Tree Regr...
0.716468
Evol_9248
C
[ "load_data", "create_lag_features", "prepare_data", "train_evaluate_model", "plot_predictions" ]
5
[ [ "plot_predictions", "create_lag_features" ], [ "prepare_data", "create_lag_features" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy", "pandas", "sklearn" ]
false
5e936a30599a086def1079dc8950436e32d6af8d
bbfcaeaec3ab8ebeadb01ff20722b91a6ba6db0f
v1.0
complete
Evol
Evol_9284_C
from typing import List, Dict def haversine(lon1: float, lat1: float, lon2: float, lat2: float) -> float: """ Calculate the great-circle distance between two points on the Earth surface using the Haversine formula. """ pass def find_nearest_store(stores: List[Dict[str, float]], location: Dict[str...
import math def haversine(lon1, lat1, lon2, lat2): """ Calculate the great-circle distance between two points on the Earth surface using the Haversine formula. """ # Convert decimal degrees to radians lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2]) # Haversine fo...
from solution import find_nearest_store def test_find_nearest_store(): stores = [ {'name': 'Store A', 'longitude': -75.343, 'latitude': 39.984}, {'name': 'Store B', 'longitude': -75.534, 'latitude': 39.984}, {'name': 'Store C', 'longitude': -75.834, 'latitude': 38.984} ] location =...
[ { "docstring": "Calculate the great-circle distance between two points \non the Earth surface using the Haversine formula.", "function_declaration": "def haversine(lon1, lat1, lon2, lat2):", "function_name": "haversine", "parameter_list": "(lon1, lat1, lon2, lat2)" }, { "docstring": "Returns...
[ 1, 1, 0, 1, 1, 1, 1, 0, 1, 0 ]
7
easy
0.7
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import math\n\ndef haversine(lon1, lat1, lon2, lat2):\n \"\"\"\n Calculate the great circle distance in kilometers between two points\n on the earth speci...
trial_gpt4o_8
{ "original_instruction": "Create a Python function called `find_nearest_store` that takes two arguments: a list of dictionaries representing stores, each containing 'name' (string), 'longitude' (float), and 'latitude' (float) fields, and another dictionary representing your current location with 'longitude' (float) ...
0.675123
Evol_9284
C
[ "haversine", "find_nearest_store" ]
2
[ [ "find_nearest_store", "haversine" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8f082cd2c65a51e6971fecbfdb588c41855e0b95
2b04ed61a5e14c00b8dd25be3e37a19004bb0087
v1.0
complete
Evol
Evol_9599_C
from collections import Counter from typing import List, Tuple def gini_impurity(labels: List[int]) -> float: """ Calculate the Gini impurity for a given set of class labels. Args: labels (list): List of class labels. Returns: float: Gini impurity value. """ pass def split_da...
from collections import Counter def gini_impurity(labels): """ Calculate the Gini impurity for a given set of class labels. Args: labels (list): List of class labels. Returns: float: Gini impurity value. """ n = len(labels) if n == 0: return 0.0 label_coun...
from solution import gini_impurity, split_dataset, gini_impurity_split def test_gini_impurity(): assert gini_impurity([1, 1, 1, 1]) == 0.0 assert gini_impurity([1, 0, 0, 0]) == 0.375 assert gini_impurity([1, 0, 1, 0]) == 0.5 assert gini_impurity([]) == 0.0 def test_split_dataset(): dataset = [ ...
[]
[ 0, 0, 0, 1, 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": "from collections import Counter\n\ndef gini_impurity(labels):\n \"\"\"\n Calculate the Gini impurity for a list of class labels.\n \n Parameters:\n ...
trial_gpt4o_3
{ "original_instruction": "Implement a function to calculate the Gini impurity of a dataset. The dataset consists of `n` samples, each belonging to one of `k` classes. The Gini impurity is defined as 1 minus the sum of the squared probabilities of each class. Your function should take as input a list of class labels ...
0.523064
Evol_9599
C
[ "gini_impurity", "split_dataset", "gini_impurity_split" ]
3
[ [ "gini_impurity_split", "gini_impurity" ] ]
1
[]
false
[]
false
pytest
true
[]
true
42b5a6fd65bd1e963da7f4512fcdd09c21d824df
e35a0937c63b34e9e82a93846a2b4cf756a559e4
v1.0
complete
Evol
Evol_9879_C
def filter_primes(numbers: List[int]) -> Union[List[int], str]: """ Takes a list of integers and returns a new list containing only the prime numbers from the original list. If no primes are found, it returns a message indicating this. >>> filter_primes([4, 6, 8, 13, 15, 23, 25]) [13, 23] >>> ...
def is_prime(num): """Helper function to check if a number is a prime number.""" 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 fi...
from solution import filter_primes def test_filter_primes_with_prime_numbers(): assert filter_primes([4, 6, 8, 13, 15, 23, 25]) == [13, 23] def test_filter_primes_no_prime_numbers(): assert filter_primes([4, 6, 8, 10, 12, 14]) == "No prime numbers found" def test_filter_primes_all_prime_numbers(): assert...
[ { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Takes a list of integers and returns a new list containing only the prime numbers \nfrom the origi...
[ 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 n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n r...
trial_gpt4o_9
{ "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. Additionally, if the resulting list of prime numbers is empty, return a message indicating that no prime numbers were found. \n\nInput: [4, 6, 8, 13, 15, 23, 25]\n...
0.703159
Evol_9879
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ff7d273fd97707c8b9cb23837b6e1677e8ca99fa
a376988ba73b9fd086b2ec7d0623664dea8d95bf
v1.0
complete
Evol
Evol_9647_C
import math from typing import List def is_prime(n: int) -> bool: """Helper function to check if a number is prime. >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(5) == True >>> is_prime(6) == False >>> is_prime(29) == True >>> is_prime(1) == False...
import math def is_prime(n): """Helper function to check if a number is prime.""" if n <= 1: return False for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def sum_of_primes(arr): """ Returns the sum of elements that are prime numbers...
from solution import sum_of_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(6) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of elements that are prime numbers in the given array.", "function_declaration": "def sum_o...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if...
trial_gpt4o_7
{ "original_instruction": "Write a function that takes an integer array as input and returns the sum of elements that are prime numbers. The function should handle arrays of varying lengths, including edge cases where the array may be empty or contain no prime numbers.\n\nExample array: [2, 4, 6, 7, 10, 11]\n\nExpect...
0.775293
Evol_9647
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
931df960c41d0ed2aefbdf994c7f43729a0c8cad
1e2fd4a050439e7bc0ecdf3834dafd310f38ff3e
v1.0
complete
Evol
Evol_9630_C
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ pass # Your code here def filter_primes(nums): """ Returns a list containing only the prime numbers from the original list nums. """ pass # Your code here # Tests for is_prime function def test_is_prim...
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def filter_primes(nums): """ Returns a list containing only the prime...
from solution import is_prime, filter_primes # Tests for is_prime function def test_is_prime_with_prime_numbers(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(7) == True def test_is_prime_with_non_prime_numbers(): assert is_prime(1) == False ...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list containing only the prime numbers from the original list nums.", "function_decl...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n ret...
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. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers.\n\ndef is_prime(num):\n if num < 2:\n retu...
0.763812
Evol_9630
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
452efbeaa654881469090e589435de3b3fd6eb3a
fcf1a6ede809fb93e5665783f092bba1e67890ac
v1.0
complete
Evol
Evol_9397_C
from typing import List def numMatchingSubseq(s: str, words: List[str]) -> int: """ You are given a list of words and a string `s`. You need to find how many of the words in the list can be formed by deleting some characters of `s` without rearranging the remaining characters. In other words, for each wo...
from typing import List def is_subsequence(s: str, word: str) -> bool: it = iter(s) return all(char in it for char in word) def numMatchingSubseq(s: str, words: List[str]) -> int: count = 0 for word in words: if is_subsequence(s, word): count += 1 return count
import pytest from solution import numMatchingSubseq def test_example_case(): s = "abcde" words = ["a", "bb", "acd", "ace"] assert numMatchingSubseq(s, words) == 3 def test_all_words_subsequence(): s = "abcdefgh" words = ["abc", "bcd", "cde", "def"] assert numMatchingSubseq(s, words) == 4 def...
[ { "docstring": null, "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": null, "function_declaration": "def numMatchingSubseq(s, words):", "function_name": "numMatchingSubseq", "parameter_list"...
[ 0, 1, 0, 0, 0, 0, 1, 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 numMatchingSubseq(s, words):\n from collections import defaultdict\n import bisect\n\n # Preprocess s to store positions of each character\n char_p...
trial_gpt4o_8
{ "original_instruction": "You are given a list of words and a string `s`. You need to find how many of the words in the list can be formed by deleting some characters of `s` without rearranging the remaining characters. In other words, for each word in the list, check if it is a subsequence of `s`.\n\n### Function S...
0.734583
Evol_9397
C
[ "is_subsequence", "numMatchingSubseq" ]
2
[ [ "numMatchingSubseq", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c3daf8bd75e4aaf593fe261b2751aa5153dbf1ff
ce7de2b3b179105842d5ff59070e6974e94638f0
v1.0
complete
Evol
Evol_9767_C
def merge_sort(arr): """ Sorts an array of integers in ascending order using the merge sort algorithm. >>> merge_sort([34, 7, 23, 32, 5, 62]) [5, 7, 23, 32, 34, 62] >>> merge_sort([3, 1]) [1, 3] >>> merge_sort([1]) [1] >>> merge_sort([]) [] >>> merge_sort([3, -2, 5, -1, 0]) ...
def merge_sort(arr): """ Sorts an array of integers in ascending order using the merge sort algorithm. """ 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(...
from solution import merge_sort def test_merge_sort(): assert merge_sort([34, 7, 23, 32, 5, 62]) == [5, 7, 23, 32, 34, 62] assert merge_sort([3, 1]) == [1, 3] assert merge_sort([1]) == [1] assert merge_sort([]) == [] assert merge_sort([3, -2, 5, -1, 0]) == [-2, -1, 0, 3, 5] assert merge_sort([1...
[ { "docstring": "Sorts an array of integers in ascending order using the merge sort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted arrays into one sorted array.", "function_declarat...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Performs merge sort on the input list of integers.\n \n Parameters:\n arr (list): A list of integers to be sorted.\n...
trial_gpt4o_9
{ "original_instruction": "Create a function that takes an array of integers and returns a new array with the same numbers sorted in ascending order. Your solution should implement the merge sort algorithm to achieve this. Avoid using built-in sorting functions to demonstrate an understanding of the sorting technique...
0.653443
Evol_9767
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e1769784f1a13790c08c80b40c4fe9020b82ff96
e1d630d37cc7fee9702db33f3f2870fa6e41fae5
v1.0
complete
Evol
Evol_9895_C
from typing import List, Dict from functools import reduce def calculate_average(grades: List[int]) -> float: """ Calculates the average of a list of grades. >>> calculate_average([85, 90, 78]) 84.33333333333333 >>> calculate_average([82, 88, 91]) 87.0 >>> calculate_average([]) 0 ""...
from functools import reduce def calculate_average(grades): """ Calculates the average of a list of grades. """ if not grades: return 0 return sum(grades) / len(grades) # Functional Programming Approach def process_student_records_functional(records): """ Processes student records ...
from solution import calculate_average, process_student_records_functional, process_student_records_imperative def test_calculate_average(): assert calculate_average([85, 90, 78]) == 84.33333333333333 assert calculate_average([82, 88, 91]) == 87.0 assert calculate_average([]) == 0 def test_process_student...
[ { "docstring": "Calculates the average of a list of grades.", "function_declaration": "def calculate_average(grades):", "function_name": "calculate_average", "parameter_list": "(grades)" }, { "docstring": "Processes student records to calculate average grade using functional programming.", ...
[ 1, 1, 0, 1, 1, 1, 0, 1, 0, 0 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from functools import reduce\n\ndef average_grade_functional(students):\n \"\"\"\n Calculate the average grades for each student using functional programming...
trial_gpt4o_7
{ "original_instruction": "You are tasked with writing a program that processes a list of student records and calculates the average grade for each student. Follow these guidelines:\n\n1. Each student record is a dictionary containing the student’s name and a list of grades.\n2. Implement two scripts:\n - One using...
0.683035
Evol_9895
C
[ "calculate_average", "process_student_records_functional", "process_student_records_imperative" ]
3
[ [ "process_student_records_functional", "calculate_average" ], [ "process_student_records_imperative", "calculate_average" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2be1f7baedfff92587484f31b9e3ce3113a97ca8
8e013b440b3fe611a9004d6c7d69ea156743ff57
v1.0
complete
Evol
Evol_9747_C
import random from typing import List, Dict def generate_students(num_students: int) -> List[Dict[str, object]]: """ Generates a list of dictionaries, where each dictionary represents a student with 'name', 'age', and 'grades'. >>> students = generate_students(5) >>> len(students) == 5 True ...
import random def generate_students(num_students): """ Generates a list of dictionaries, where each dictionary represents a student with 'name', 'age', and 'grades'. """ students = [] for i in range(num_students): student = { "name": f"Student{i+1}", "age": rando...
from solution import generate_students, sort_students_by_average_grade, top_n_students def test_generate_students(): students = generate_students(5) assert len(students) == 5 for student in students: assert "name" in student assert "age" in student assert "grades" in student ...
[ { "docstring": "Generates a list of dictionaries, where each dictionary represents a student\nwith 'name', 'age', and 'grades'.", "function_declaration": "def generate_students(num_students):", "function_name": "generate_students", "parameter_list": "(num_students)" }, { "docstring": "Sorts ...
[ 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 random\n\ndef generate_students(num_students):\n \"\"\"\n Generates a list of dictionaries, where each dictionary represents a student\n with 'name...
trial_gpt4o_9
{ "original_instruction": "Write a function that generates a list of dictionaries, where each dictionary represents a student with the following attributes: `name` (string), `age` (integer), and `grades` (list of 5 random integers between 0 and 100). Another function should sort the list of dictionaries based on the ...
0.746711
Evol_9747
C
[ "generate_students", "sort_students_by_average_grade", "top_n_students" ]
3
[ [ "top_n_students", "sort_students_by_average_grade" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4eb9bd60c63c5a49c45e738b777234c781a693a3
560ded71fc3bcc4d1080aee9882617f06c2a2720
v1.0
complete
Evol
Evol_9760_C
def calculate_ratio(croissants: int, baguettes: int) -> str: """ Calculate the ratio of croissants to baguettes. Args: croissants (int): Number of croissants. baguettes (int): Number of baguettes. Returns: str: The ratio of croissants to baguettes in the format 'a:b' where a and b ...
def calculate_ratio(croissants, baguettes): """ Calculate the ratio of croissants to baguettes. Args: croissants (int): Number of croissants. baguettes (int): Number of baguettes. Returns: str: The ratio of croissants to baguettes in the format 'a:b' where a and b are the simplest ...
from solution import calculate_ratio def test_calculate_ratio(): assert calculate_ratio(20, 50) == "2:5" assert calculate_ratio(10, 5) == "2:1" assert calculate_ratio(6, 3) == "2:1" assert calculate_ratio(0, 5) == "0:1" assert calculate_ratio(5, 0) == "1:0" assert calculate_ratio(7, 3) == "7:3"...
[ { "docstring": "Calculate the ratio of croissants to baguettes.\n\nArgs:\ncroissants (int): Number of croissants.\nbaguettes (int): Number of baguettes.\n\nReturns:\nstr: The ratio of croissants to baguettes in the format 'a:b' where a and b are the simplest form of the ratio.", "function_declaration": "def...
[ 0, 1, 1, 1, 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": "def croissant_to_baguette_ratio(croissants, baguettes):\n \"\"\"\n Returns the ratio of croissants to baguettes in the simplest form.\n \n Args:\n c...
trial_gpt4o_5
{ "original_instruction": "A bakery currently has 20 croissants and 50 baguettes, and you are asked to determine the ratio of croissants to baguettes. Which of the following options represents this ratio accurately? Is it 2:05, 4:05, 2:04, or 2:03?", "prompt_id": "00009760", "row_id": 9760, "seed_ids": "[45916]...
0.617165
Evol_9760
C
[ "calculate_ratio", "greatest_common_divisor" ]
2
[ [ "calculate_ratio", "greatest_common_divisor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f24b710077a10bd5b7a42c6fc61fe58e5945458f
393cebe986a8fce7cac48298d1baa5ec4f6859ba
v1.0
complete
Evol
Evol_9849_C
def calculate_packs_needed(total_required: int, current_beads: int, pack_size: int) -> int: """ This function calculates the number of bead packs needed. total_required: int - Total beads required for the project current_beads: int - Beads currently available pack_size: int - Number of beads in one ...
def calculate_packs_needed(total_required, current_beads, pack_size): """ This function calculates the number of bead packs needed. total_required: int - Total beads required for the project current_beads: int - Beads currently available pack_size: int - Number of beads in one pack Returns: int ...
from solution import calculate_packs_needed, olivia_beads_packs def test_calculate_packs_needed(): # Given total_required=350, current_beads=200, pack_size=25 assert calculate_packs_needed(350, 200, 25) == 6 # Olivia's case assert calculate_packs_needed(350, 300, 25) == 2 # Needs only 2 packs assert ...
[ { "docstring": "This function calculates the number of bead packs needed.\ntotal_required: int - Total beads required for the project\ncurrent_beads: int - Beads currently available\npack_size: int - Number of beads in one pack\nReturns: int - Number of whole packs needed to buy", "function_declaration": "d...
[ 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 packs_needed(total_beads_needed, current_beads, beads_per_pack):\n \"\"\"\n Calculate the number of packs needed to reach the total beads needed.\n \n...
trial_gpt4o_9
{ "original_instruction": "Olivia needs 350 beads to complete her bracelet project. She currently has 200 beads in her collection. If she buys packs of beads, each containing 25 beads, how many packs does Olivia need to buy to have exactly enough beads for her project?", "prompt_id": "00009849", "row_id": 9849, ...
0.623064
Evol_9849
C
[ "calculate_packs_needed", "olivia_beads_packs" ]
2
[ [ "olivia_beads_packs", "calculate_packs_needed" ] ]
1
[]
false
[]
false
pytest
true
[]
true
52eba72db52fd165e58ee1fee4b28f7ca40edcdf
f40ac8dac77f5d69c1892b7553b3d726a1106e44
v1.0
complete
Evol
Evol_9993_C
from typing import List def classify_numbers(numbers: List[int]) -> List[List[int]]: """ Given a list of integers, group these integers into two categories: Group 1: Numbers that are prime. Group 2: Numbers that are composite. The function should return a list containing two lists: the first list shou...
from typing import List from math import isqrt def is_prime(n: int) -> bool: 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 classify_numbers def test_classify_numbers(): assert classify_numbers([4, 2, 5, 3, 9, 15, 1]) == [[2, 3, 5], [15, 9, 4]] assert classify_numbers([2, 2, 2, 4, 4, 4]) == [[2], [4]] assert classify_numbers([10, 20, 30, 40, 50]) == [[], [50, 40, 30, 20, 10]] assert classify_numbers([11...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def classify_numbers(numbers):", "function_name": "classify_numbers", "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\nfrom math import isqrt\n\ndef is_prime(n: int) -> bool:\n if n <= 1:\n return False\n if n <= 3:\n return True\n if...
trial_gpt4o_0
{ "original_instruction": "Given a list of integers, write a Python function that groups these integers into two categories:\n- Group 1: Numbers that are prime.\n- Group 2: Numbers that are composite.\n\nThe function should return a list containing two lists: the first list should contain all the prime numbers in asc...
0.625624
Evol_9993
C
[ "is_prime", "classify_numbers" ]
2
[ [ "classify_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
162ddbabfd749070aaf3e9143ea447077c63fe3d
f2a2c3123768aca6486237669a3cc4d9d620a659
v1.0
complete
Evol
Evol_9938_C
from typing import List, Dict, Any def advanced_string_manipulation_and_analysis(s: str, actions: List[Dict[str, Any]]) -> List[str]: """ The function processes a given string `s` and applies a series of actions (transformations and analyses) defined in the `actions` list. Each action is a dictionary that ...
from typing import List, Dict, Any import re from collections import Counter def caesar_cipher(s: str, shift: int) -> str: result = [] for char in s: if char.isalpha(): shift_base = ord('A') if char.isupper() else ord('a') result.append(chr((ord(char) - shift_base + shift) % 26 ...
from solution import advanced_string_manipulation_and_analysis def test_substring_count(): actions = [{"type": "substring_count", "value": "hello"}] assert advanced_string_manipulation_and_analysis("hello world", actions) == ["substring_count: 1"] def test_substring_replace(): actions = [{"type": "substri...
[ { "docstring": null, "function_declaration": "def caesar_cipher(s, shift):", "function_name": "caesar_cipher", "parameter_list": "(s, shift)" }, { "docstring": null, "function_declaration": "def find_anagrams_positions(s, word):", "function_name": "find_anagrams_positions", "para...
[ 0, 0, 0, 0, 0, 0, 1, 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": "import re\nfrom collections import Counter\nfrom typing import List, Dict, Any\n\ndef advanced_string_manipulation_and_analysis(s: str, actions: List[Dict[str, Any...
trial_gpt4o_7
{ "original_instruction": "Define a function that modifies and analyses strings based on given criteria:\n\ndef advanced_string_manipulation_and_analysis(s: str, actions: List[Dict[str, Any]]) -> List[str]:\n \"\"\"\n The function processes a given string `s` and applies a series of actions (transformations and...
0.631071
Evol_9938
C
[ "caesar_cipher", "find_anagrams_positions", "advanced_string_manipulation_and_analysis" ]
3
[ [ "advanced_string_manipulation_and_analysis", "caesar_cipher" ], [ "advanced_string_manipulation_and_analysis", "find_anagrams_positions" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4e1e96b914d10a4a6310303a14cd41d99cacb2dc
335bc1ddc0fcd343284c0e474c4b5640552efa3a
v1.0
complete
Evol
Evol_9937_C
import socket import threading from typing import List HOST = 'localhost' PORT = 5000 def handle_client(client_socket, addr, username, clients): """ Handle communication with a connected client. :param client_socket: The socket connected to the client. :param addr: The address of the client. ...
import socket import threading from typing import List # Constants HOST = 'localhost' PORT = 5000 def handle_client(client_socket, addr, username, clients): """ Handle communication with a connected client. :param client_socket: The socket connected to the client. :param addr: The address of the ...
import socket import threading import pytest import time # Assuming the server and client implementations are in a file named 'solution.py' from solution import server_program, client_program def test_server_client_communication(): # Start the server in a separate thread server_thread = threading.Thread(targe...
[ { "docstring": "Handle communication with a connected client.\n\n:param client_socket: The socket connected to the client.\n:param addr: The address of the client.\n:param username: The username of the client.\n:param clients: The list of all connected clients.", "function_declaration": "def handle_client(c...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import socket\nimport threading\n\ndef handle_client(client_socket, username, clients):\n \"\"\"\n Handles communication with a single client.\n \"\"\"\n ...
trial_gpt4o_6
{ "original_instruction": "Develop a Python-based chat application that supports multiple clients connecting to the server simultaneously. The application should allow users to send and receive messages in real-time. Here are the detailed requirements for both the server and client sides:\n\n### Server Requirements:\...
0.651781
Evol_9937
C
[ "handle_client", "broadcast", "remove_client", "server_program", "client_program", "receive_messages" ]
6
[ [ "broadcast", "remove_client" ], [ "handle_client", "broadcast" ], [ "handle_client", "remove_client" ] ]
3
[]
false
[]
false
pytest
true
[]
true
1785f62ee17e489b4bcec3dac37f1ac77611fb75
59e1165ce983c75c91381d348b95d5db29eb134d
v1.0
complete
Evol
Evol_2963_C
import os import multiprocessing from collections import Counter import re class FileNotFoundError(Exception): pass def word_count_in_file(file_name: str, chunk_size: int = 1024*1024) -> dict: """ Reads a large text file and counts the frequency of each word using multiple processes, then merges the resu...
import os import multiprocessing from collections import Counter import re class FileNotFoundError(Exception): pass def read_chunk(file_name, start, size): with open(file_name, "rb") as f: f.seek(start) chunk = f.read(size) return chunk def count_words_in_chunk(chunk): chunk = chunk.d...
import os import pytest from solution import word_count_in_file, FileNotFoundError def create_test_file(): content = "Hello, world! Hello! This is a test file. Hello world! " content *= 10000 # create a large file by repeating the content with open("test_file.txt", "w") as f: f.write(content) @pyt...
[]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "import os\nfrom collections import Counter\nfrom multiprocessing import Process, Pipe\nimport mmap\n\nclass CustomFileNotFoundError(Exception):\n pass\n\ndef co...
trial_gpt4o_9
{ "original_instruction": "Write a function in Python that reads a large text file and counts the frequency of each word using multiple processes. The function should divide the file into chunks and spawn a separate process to count words in each chunk. Ensure that the file reading and word counting operations are th...
0.71245
Evol_2963
C
[ "read_chunk", "count_words_in_chunk", "word_count_in_file", "process_chunk" ]
4
[ [ "process_chunk", "count_words_in_chunk" ], [ "process_chunk", "read_chunk" ], [ "word_count_in_file", "process_chunk" ] ]
3
[]
false
[ "FileNotFoundError" ]
true
pytest
true
[]
true
ce4e2cadcbaaf25407ab507de8228575be628553
d892ce5eaa696becad8ec0d8b16f9ed173f76949
v1.0
complete
Evol
Evol_3218_C
def prime_status(numbers: List[int]) -> Dict[int, bool]: """ Takes a list of integers and returns a dictionary. Keys: original integers from the list. Values: True if the integer is prime, False otherwise. >>> prime_status([2, 3, 5, 7, 11]) == {2: True, 3: True, 5: True, 7: True, 11: True} >>> p...
def is_prime(n): 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 prime_status(numbers): """ Takes a list of integers and returns a dict...
from solution import prime_status def test_prime_numbers(): assert prime_status([2, 3, 5, 7, 11]) == {2: True, 3: True, 5: True, 7: True, 11: True} def test_non_prime_numbers(): assert prime_status([4, 6, 8, 9, 10]) == {4: False, 6: False, 8: False, 9: False, 10: False} def test_mixed_numbers(): assert p...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a dictionary.\nKeys: original integers from the list.\nValues: True if the integer is prime, False otherwise.", "f...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n 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_5
{ "original_instruction": "Write a Python function that accepts a list of integers and returns a dictionary. The keys of the dictionary should be the original integers, and the values should be True if the integer is a prime number and False otherwise.\ndef prime_status(numbers):\n pass", "prompt_id": "00003218"...
0.734651
Evol_3218
C
[ "is_prime", "prime_status" ]
2
[ [ "prime_status", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dd9f0e99209d949eb40ed2fe8d2d082f8472db99
b0532fc1b476f401f9ce4c212195299531456e09
v1.0
complete
Evol
Evol_6470_C
def is_prime(num): """ Helper function to determine if a number is a prime number. """ 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: ...
def is_prime(num): """ Helper function to determine if a number is a prime number. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import find_primes_and_smallest def test_no_numbers(): assert find_primes_and_smallest([]) == ([], None) def test_no_prime_numbers(): assert find_primes_and_smallest([1, 4, 6, 8, 9, 10]) == ([], None) def test_all_prime_numbers(): assert find_primes_and_smallest([2, 3, 5, 7, 11]) == ([2, 3,...
[ { "docstring": "Helper function to determine if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers from the input list and the smallest prime number.\n\n:param 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 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_7
{ "original_instruction": "Write a Python function that takes a list of integers and returns a new list that contains only the prime numbers from the input list. Additionally, your function should return the smallest prime number found in the list. If the input list contains no prime numbers, the function should retu...
0.81572
Evol_6470
C
[ "is_prime", "find_primes_and_smallest" ]
2
[ [ "find_primes_and_smallest", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00f3518786f2144bfcf4b08d39e8d3dfbc1039ab
3cb921beab00894180a11bc005e6dbe33e9067b2
v1.0
complete
Evol
Evol_4644_C
def gcd(x, y): """ Calculate the greatest common divisor (GCD) of x and y using the Euclidean algorithm. """ pass def least_common_multiple(a, b): """ Calculate and return the least common multiple (LCM) of two positive integers a and b using the relationship between LCM and GCD. Raise Valu...
def gcd(x, y): """ Calculate the greatest common divisor of x and y using the Euclidean algorithm. """ while y: x, y = y, x % y return x def least_common_multiple(a, b): """ Calculate and return the least common multiple (LCM) of two positive integers a and b using the relat...
def test_gcd(): assert gcd(48, 18) == 6 assert gcd(7, 5) == 1 assert gcd(100, 10) == 10 assert gcd(27, 9) == 9 def test_least_common_multiple(): assert least_common_multiple(4, 5) == 20 assert least_common_multiple(10, 15) == 30 assert least_common_multiple(3, 7) == 21 assert least_...
[ { "docstring": "Calculate the greatest common divisor of x and y using the\nEuclidean algorithm.", "function_declaration": "def gcd(x, y):", "function_name": "gcd", "parameter_list": "(x, y)" }, { "docstring": "Calculate and return the least common multiple (LCM) of two positive\nintegers a ...
[ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1 ]
9
easy
0.9
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Helper function to find the Greatest Common Divisor (GCD) of two numbers.\n Uses the Euclidean algorithm.\n \"\"\"\n while...
trial_gpt4o_9
{ "original_instruction": "Write a function `least_common_multiple(a, b)` that takes two positive integers, `a` and `b`, and returns their least common multiple (LCM). The LCM of two integers is the smallest positive integer that is divisible by both `a` and `b`. Your function should have a time complexity of O(log(m...
0.851026
Evol_4644
C
[ "gcd", "least_common_multiple" ]
2
[ [ "least_common_multiple", "gcd" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c0a43eab61848a5d6c6dae33f7bb2072d0c4ecc2
d87d088a3e4db04438f3bc6d9784b903e3692d33
v1.0
complete
Evol
Evol_4520_C
def filter_primes(numbers: List[int]) -> List[int]: """ Create a function that accepts a list of integers and returns a new list containing only the prime numbers from the original list. The function should efficiently check for primality to ensure optimal performance for large lists. >>> filter_primes...
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 return T...
from solution import filter_primes def test_filter_primes_with_all_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_primes([1, 4, 6, 8, 9, 10]) == [] def test_filter_primes_with_mixed_numbers(): assert filter_primes([1, 2,...
[ { "docstring": "Check if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list of integers.", "function_declaration": "def filter_primes(numbe...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
10
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_8
{ "original_instruction": "Create a function that accepts a list of integers and returns a new list containing only the prime numbers from the original list. The function should efficiently check for primality to ensure optimal performance for large lists.", "prompt_id": "00004520", "row_id": 4520, "seed_ids": ...
0.700584
Evol_4520
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
52a2d17753ffb99815b7755a9993d8204d0fd35f
5044c06d72d0373b285759b344673378f5d31450
v1.0
complete
Evol
Evol_5563_C
from typing import List def largest_number(nums: List[int]) -> str: """ Write a Python function that takes a list of integers and rearranges the elements to form the largest possible integer. The function should return this largest integer as a string. Assume the input list will contain only non-negative ...
from functools import cmp_to_key def compare(a, b): if a + b > b + a: return -1 elif a + b < b + a: return 1 else: return 0 def largest_number(nums): if not nums: return "" # Convert the numbers to strings for comparison nums_str = list(map(str, nums)) ...
from solution import largest_number def test_largest_number_basic(): assert largest_number([3, 30, 34, 5, 9]) == '9534330' assert largest_number([1, 20, 23, 4, 8]) == '8423201' def test_largest_number_single_element(): assert largest_number([5]) == '5' assert largest_number([0]) == '0' def test_large...
[ { "docstring": null, "function_declaration": "def compare(a, b):", "function_name": "compare", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def largest_number(nums):", "function_name": "largest_number", "parameter_list": "(nums)" } ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare(x, y):\n \"\"\"\n A comparison function that decides the order based on which\n concatenation results in a...
trial_gpt4o_9
{ "original_instruction": "Write a Python function that takes a list of integers and rearranges the elements to form the largest possible integer. The function should return this largest integer as a string. Assume the input list will contain only non-negative integers.\n\nExample:\n```\nInput: [3, 30, 34, 5, 9]\nOut...
0.715319
Evol_5563
C
[ "compare", "largest_number" ]
2
[ [ "largest_number", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5b9450eef61bb81702a3e19db04351a0e4db5f5
58a810cd287e6332a24be099df8bb97e0b8d0bbc
v1.0
complete
Evol
Evol_6189_C
def find_n_primes_in_range(start: int, end: int, N: int) -> list: """ Determines the first N prime numbers in the given range [start, end] and returns them as a list. If there are fewer than N prime numbers in the given range, returns all found prime numbers. Parameters: start (int): The start ...
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 ...
from solution import find_n_primes_in_range def test_find_n_primes_in_range_example1(): assert find_n_primes_in_range(10, 50, 5) == [11, 13, 17, 19, 23] def test_find_n_primes_in_range_example2(): assert find_n_primes_in_range(20, 30, 4) == [23, 29] def test_find_n_primes_in_range_not_enough_primes(): as...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds the first N primes in the given range [start, end].\nIf there are fewer than N primes, return all found p...
[ 1, 1, 1, 0, 1, 1, 1, 1, 0, 1 ]
8
easy
0.8
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is a prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n r...
trial_gpt4o_9
{ "original_instruction": "## Task\nWrite a Python function that determines the first N prime numbers in a given range and returns them as a list. Prime numbers in a given range are numbers that have no positive divisors other than 1 and themselves.\n\n## Objective\n- Write a function that accepts three parameters: `...
0.6834
Evol_6189
C
[ "is_prime", "find_n_primes_in_range" ]
2
[ [ "find_n_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2c1ded36ff7248bc18f7ed7070d76b6b5cb99fa4
9fb97594545e32b33a5bf76655dbcb520b44f14c
v1.0
complete
Evol
Evol_6071_C
def is_prime(n: int) -> bool: """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(-1) False >>> is_prime(17) True >>> is_prime(18) False """ def fil...
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def 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(1) == False assert is_prime(0) == False assert is_prime(-1) == False assert is_prime(17) == True...
[ { "docstring": "Checks 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 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 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": "Write a function in Python that takes in a list of integers and returns a new list containing only the prime numbers from the original list. If the original list is empty or contains no prime numbers, the function should return an empty list. Consider the efficiency of your algorithm.", "...
0.779833
Evol_6071
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
389e004c11ffa911d72be434d19838345b9b17ff
2f123e12d4d46406833468f93b17480bcb31e856
v1.0
complete
Evol
Evol_6742_C
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 i = 3 while i * i <= n: if n % i == 0: return False i += 2 return True def nearest_smaller_pri...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False i = 3 while i * i <= n: if n % i == 0: return False i += 2 return True def nearest_smaller_prime(n): """ If n is prime, returns the nearest pri...
from solution import nearest_smaller_prime def test_nearest_smaller_prime_non_prime(): assert nearest_smaller_prime(10) == 10 # 10 is not prime assert nearest_smaller_prime(1) == 1 # 1 is not prime assert nearest_smaller_prime(4) == 4 # 4 is not prime def test_nearest_smaller_prime_prime(): ass...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "If n is prime, returns the nearest prime number that is smaller than n.\nIf n is not prime, returns n itself.", "function_declaration": "def nearest_sm...
[ 1, 0, 1, 0, 0, 1, 0, 1, 1, 1 ]
6
medium
0.6
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl", "solution_code": "def nearest_smaller_prime(n):\n \"\"\"\n Checks if a given integer is a prime number. \n If it is, returns the nearest prime number that is smaller than t...
trial_gpt4o_9
{ "original_instruction": "Write a function that checks if a given integer is a prime number and if it is, returns the nearest prime number that is smaller than the given integer. If the number is not prime, return the given integer itself.\n\nExample:\n```python\ndef nearest_smaller_prime(n):\n # Your code here\n...
0.838975
Evol_6742
C
[ "is_prime", "nearest_smaller_prime" ]
2
[ [ "nearest_smaller_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63635e35840276f4168e42053b1762cb08d89fbf
0187c78663483f51f235cd76ffd4110fff0cfd95