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 | instruct | Evol | Evol_5612_I | A palindrome is a word, phrase, or sequence of characters that reads the same backward as forward. Develop a Python function that takes a list of strings as input and returns a list with the same elements but reversed, only if they are palindromes. If the original string is not a palindrome, keep it unchanged. The func... | def is_palindrome(s):
s = s.lower()
left, right = 0, len(s) - 1
while left < right:
if s[left] != s[right]:
return False
left += 1
right -= 1
return True
def reverse_string(s):
reversed_s = ''
for char in s:
reversed_s = char + reversed_s
return r... | from solution import reverse_palindromes
def test_reverse_palindromes_all_palindromes():
assert reverse_palindromes(['level', 'radar', 'deified']) == ['level', 'radar', 'deified']
def test_reverse_palindromes_mixed():
assert reverse_palindromes(['hello', 'Level', 'world', 'civic']) == ['hello', 'leveL', 'worl... | [
{
"docstring": null,
"function_declaration": "def is_palindrome(s):",
"function_name": "is_palindrome",
"parameter_list": "(s)"
},
{
"docstring": null,
"function_declaration": "def reverse_string(s):",
"function_name": "reverse_string",
"parameter_list": "(s)"
},
{
"docst... | [
0,
1,
0,
0,
0,
0,
1,
1,
0,
0
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_palindrome(s):\n \"\"\"\n Helper function to check if the given string is a palindrome.\n \"\"\"\n s = s.lower()\n n = len(s)\n for i in r... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00005612",
"row_id": 5612,
"seed_ids": "[43684]"
} | 0.778244 | Evol_5612 | I | [
"is_palindrome",
"reverse_string",
"reverse_palindromes"
] | 3 | [
[
"reverse_palindromes",
"is_palindrome"
],
[
"reverse_palindromes",
"reverse_string"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | ed95af1b9027321656a4c46c0ad1ee881bf6db99 | 903f9c9c2e8c2de48ecb5f308c0417fba684660d | |||
v1.0 | instruct | Evol | Evol_5628_I | Write a Python function that takes a list of integers and returns a dictionary where the keys are the integers from the list and the values are the factorial of each key. Provide two different implementations: one using recursion to calculate the factorial and another using an iterative approach. Additionally, implemen... | def factorial_recursion(n, memo=None):
"""
Calculates the factorial of n using recursion.
Optionally uses memoization if a memo dictionary is provided.
"""
if n < 0:
return None
if n == 0 or n == 1:
return 1
if memo is not None and n in memo:
return memo[n]
r... | from solution import factorial_dict, factorial_recursion, factorial_iterative
def test_factorial_dict_with_recursion_no_memoization():
assert factorial_dict([5, 3, -1], use_recursion=True, use_memoization=False) == {5: 120, 3: 6}
assert factorial_dict([], use_recursion=True, use_memoization=False) == {}
as... | [
{
"docstring": "Calculates the factorial of n using recursion.\nOptionally uses memoization if a memo dictionary is provided.",
"function_declaration": "def factorial_recursion(n, memo=None):",
"function_name": "factorial_recursion",
"parameter_list": "(n, memo=None)"
},
{
"docstring": "Calc... | [
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 9 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "from typing import List, Dict\n\ndef factorial_recursive(n: int, memo: Dict[int, int] = None) -> int:\n \"\"\"\n Calculate the factorial of a number recursiv... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00005628",
"row_id": 5628,
"seed_ids": "[47344]"
} | 0.679413 | Evol_5628 | I | [
"factorial_recursion",
"factorial_iterative",
"factorial_dict"
] | 3 | [
[
"factorial_dict",
"factorial_iterative"
],
[
"factorial_dict",
"factorial_recursion"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 5fcfbf0da126c6749d26d31ffff31f98f7000e92 | cdd500628906f536af7ce943cab729e1b98a2757 | |||
v1.0 | instruct | Evol | Evol_5657_I | Write a function that takes an unsorted list of integers and returns a new list containing only the prime numbers from the original list, sorted in ascending order. Ensure that the solution has an optimal time complexity for verification of primality and sorting the numbers. | def is_prime(n):
"""
Checks if a number n is a prime number.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
... | from solution import primes_from_list
def test_single_digit_numbers():
assert primes_from_list([1, 2, 3, 4, 5, 6, 7, 8, 9]) == [2, 3, 5, 7]
def test_mixed_numbers():
assert primes_from_list([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [11, 13, 17, 19]
def test_all_non_prime():
assert primes_from_list... | [
{
"docstring": "Checks if a number n is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Takes an unsorted list of integers and returns a new list containing only \nthe prime numbers from the original list, ... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00005657",
"row_id": 5657,
"seed_ids": "[35535]"
} | 0.618353 | Evol_5657 | I | [
"is_prime",
"primes_from_list"
] | 2 | [
[
"primes_from_list",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7f1e3b4a178136a07d4f717469c081778e222a49 | 7209847dc20e6bfa440b5fa2f557c8c641ac4db0 | |||
v1.0 | instruct | Evol | Evol_5694_I | Write a Python function that accepts a list of integers and returns a list of tuples representing the prime factorization of each integer. Each tuple within the list should contain a prime factor and its exponent in order of smallest to largest prime factor. For example, the prime factorization of 28 is (2, 2), (7, 1).... | def prime_factors(n):
"""
Returns the prime factorization of n as a list of tuples containing
each prime factor and its exponent.
"""
i = 2
factors = []
while i * i <= n:
count = 0
while (n % i) == 0:
n //= i
count += 1
if count > 0:
... | from solution import prime_factors, prime_factorization_list, verify_prime_factorizations
def test_prime_factors():
assert prime_factors(28) == [(2, 2), (7, 1)]
assert prime_factors(30) == [(2, 1), (3, 1), (5, 1)]
assert prime_factors(1) == []
assert prime_factors(100) == [(2, 2), (5, 2)]
assert pr... | [
{
"docstring": "Returns the prime factorization of n as a list of tuples containing\neach prime factor and its exponent.",
"function_declaration": "def prime_factors(n):",
"function_name": "prime_factors",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime factorization for e... | [
0,
1,
1,
1,
1,
0,
1,
1,
1,
1
] | 8 | easy | 0.8 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "from collections import Counter\n\ndef prime_factors(n):\n \"\"\"\n Helper function to return the prime factors of a number n as a list of (prime, exponent) ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00005694",
"row_id": 5694,
"seed_ids": "[33316]"
} | 0.841071 | Evol_5694 | I | [
"prime_factors",
"prime_factorization_list",
"verify_prime_factorizations"
] | 3 | [
[
"prime_factorization_list",
"prime_factors"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8813c134db8a5c27a5a5d6936c3a8094c072b703 | 50ad4166a3130fab76ee56aea931c8baf40ef4d7 | |||
v1.0 | instruct | Evol | Evol_5704_I | Write a Python function that identifies and retrieves the "Happy Number" from a given range. A happy number is defined as a number which eventually reaches 1 when replaced by the sum of the square of each digit. If it loops endlessly in a cycle that does not include 1, then it is not a happy number. Your function shoul... | def is_happy_number(n):
"""
Helper function to determine if a number n is a happy number.
"""
seen = set()
while n != 1 and n not in seen:
seen.add(n)
n = sum(int(x) ** 2 for x in str(n))
return n == 1
def happy_numbers_in_range(start, end):
"""
Returns a list of happy n... | from solution import happy_numbers_in_range, is_happy_number
def test_is_happy_number():
assert is_happy_number(1) == True
assert is_happy_number(19) == True
assert is_happy_number(2) == False
def test_happy_numbers_in_range_single_number():
assert happy_numbers_in_range(19, 19) == [19]
def test_happ... | [
{
"docstring": "Helper function to determine if a number n is a happy number.",
"function_declaration": "def is_happy_number(n):",
"function_name": "is_happy_number",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of happy numbers in the given range [start, end] inclusive.",
"... | [
0,
0,
1,
0,
0,
0,
0,
1,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_happy_number(n):\n \"\"\"\n Helper function to determine if a number is a happy number.\n \"\"\"\n seen = set()\n while n != 1 and n not in s... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00005704",
"row_id": 5704,
"seed_ids": "[22745]"
} | 0.581618 | Evol_5704 | I | [
"is_happy_number",
"happy_numbers_in_range"
] | 2 | [
[
"happy_numbers_in_range",
"is_happy_number"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 58e82b63a174b41395cec6c82b85ede5cd3ea8ab | 78495136cfa4f2dac082bd4145aa1eb9c65d9885 | |||
v1.0 | instruct | Evol | Evol_5738_I | Design a program that performs matrix multiplication for two matrices input by the user. The program should check if the matrices can be multiplied based on their dimensions and handle cases where they cannot be multiplied by displaying an appropriate error message. Additionally, the program should include input valida... | def matrix_multiply(matrix1, matrix2):
"""
Multiplies two matrices if they can be multiplied.
Returns the resulting matrix or raises a ValueError if they cannot be multiplied.
"""
# Check if matrix1 and matrix2 can be multiplied
if len(matrix1[0]) != len(matrix2):
raise ValueError("The m... | import pytest
from solution import input_and_validate_matrices
def test_matrix_multiplication_valid():
matrix1 = [[1, 2],
[3, 4]]
matrix2 = [[2, 0],
[1, 2]]
result = input_and_validate_matrices(matrix1, matrix2)
assert result == [[4, 4],
[10, 8]]
def... | [
{
"docstring": "Multiplies two matrices if they can be multiplied.\nReturns the resulting matrix or raises a ValueError if they cannot be multiplied.",
"function_declaration": "def matrix_multiply(matrix1, matrix2):",
"function_name": "matrix_multiply",
"parameter_list": "(matrix1, matrix2)"
},
... | [
1,
0,
0,
1,
0,
1,
0,
0,
1,
1
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def matrix_multiply(A, B):\n \"\"\"\n Multiplies two matrices A and B if they can be multiplied.\n \n Args:\n A (list of lists of int/float): The fi... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00005738",
"row_id": 5738,
"seed_ids": "[46269]"
} | 0.50019 | Evol_5738 | I | [
"matrix_multiply",
"validate_matrix",
"input_and_validate_matrices"
] | 3 | [
[
"input_and_validate_matrices",
"matrix_multiply"
],
[
"input_and_validate_matrices",
"validate_matrix"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 6a6ef0618c8744ca7c9a397a75475acde9808a13 | c59734357881c3b8cb8a1a54169a82dd2bde8976 | |||
v1.0 | instruct | Evol | Evol_5767_I | Given a dataset of house prices from https://raw.githubusercontent.com/ageron/handson-ml/master/datasets/housing/housing.csv, construct a machine learning model to predict house prices based on the features provided in the dataset. Additionally, discuss and provide the code for at least three advanced data preprocessin... | import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
from sklearn.impute import SimpleImputer
from sklearn.pipeline import Pipeline
from sklearn.ensemble import RandomForestRegressor
from sk... | import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestRegressor
from solution import load_data, preprocess_data, train_model
def test_load_data():
data = load_data()
assert isinstance(data, pd.DataFrame)
assert not data.empty
assert 'median_house_value' in data.columns
def te... | [
{
"docstring": null,
"function_declaration": "def load_data():",
"function_name": "load_data",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def preprocess_data(data):",
"function_name": "preprocess_data",
"parameter_list": "(data)"
},
{
"docstri... | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import pandas as pd\nimport numpy as np\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler, OneHotEncoder\nfro... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00005767",
"row_id": 5767,
"seed_ids": "[26241]"
} | 0.423041 | Evol_5767 | I | [
"load_data",
"preprocess_data",
"train_model"
] | 3 | [
[
"train_model",
"load_data"
],
[
"train_model",
"preprocess_data"
]
] | 2 | [] | false | [] | false | pytest | true | [
"numpy",
"pandas",
"sklearn"
] | false | ed81b11fd08e91a8d3b9267214bd6ca0025cd3a7 | d6aec763f09f26c1a453b37eec5c1551014f2e5e | |||
v1.0 | instruct | Evol | Evol_5827_I | Rewrite the following Python function to improve its performance and readability. The function takes a list of integers and returns a new list containing only the prime numbers from the original list.
"""
def get_primes(numbers):
primes = []
for number in numbers:
is_prime = True
if number > 1:
... | def is_prime(n):
"""
Returns True if n is a prime number, else False.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def get_primes(... | from solution import get_primes
def test_get_primes_empty_list():
assert get_primes([]) == []
def test_get_primes_no_primes():
assert get_primes([1, 4, 6, 8, 10]) == []
def test_get_primes_all_primes():
assert get_primes([2, 3, 5, 7]) == [2, 3, 5, 7]
def test_get_primes_mixed():
assert get_primes([2... | [
{
"docstring": "Returns True if n is a prime number, else False.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime numbers from the input list.",
"function_declaration": "def get_primes(numbers):"... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n ... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00005827",
"row_id": 5827,
"seed_ids": "[20050]"
} | 0.680344 | Evol_5827 | I | [
"is_prime",
"get_primes"
] | 2 | [
[
"get_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 03db6966923143ac60e357250844d06dfaa3b5c4 | 539aeaaa3b083fd2b919fb4cafc943277bd5432d | |||
v1.0 | instruct | Evol | Evol_5955_I | Create a function in Python that takes a string and returns the count of each vowel (a, e, i, o, u) present in the string. The function should be case-insensitive and must return a dictionary with vowels as keys and their counts as values. Additionally, the function should have a time complexity of O(n), where n is the... | def count_vowels(s):
"""
Count the number of each vowel in the string s (case-insensitive).
Parameters:
s (str): The input string.
Returns:
dict: A dictionary with vowels as keys and their counts as values.
"""
s = s.lower()
vowels = 'aeiou'
counts = {vowel: 0 for vowel... | from solution import count_vowels, most_frequent_vowel
def test_count_vowels_all_vowels():
assert count_vowels("aeiou") == {'a': 1, 'e': 1, 'i': 1, 'o': 1, 'u': 1}
def test_count_vowels_repeated_vowels():
assert count_vowels("aaaeeeiiiooouuu") == {'a': 3, 'e': 3, 'i': 3, 'o': 3, 'u': 3}
def test_count_vowels... | [
{
"docstring": "Count the number of each vowel in the string s (case-insensitive).\n\nParameters:\ns (str): The input string.\n\nReturns:\ndict: A dictionary with vowels as keys and their counts as values.",
"function_declaration": "def count_vowels(s):",
"function_name": "count_vowels",
"parameter_... | [
0,
0,
1,
1,
1,
0,
0,
0,
1,
1
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def count_vowels(s):\n \"\"\"\n Returns a dictionary with the count of each vowel (a, e, i, o, u) in the given string.\n \"\"\"\n vowels = 'aeiou'\n ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00005955",
"row_id": 5955,
"seed_ids": "[31332]"
} | 0.836768 | Evol_5955 | I | [
"count_vowels",
"most_frequent_vowel"
] | 2 | [
[
"most_frequent_vowel",
"count_vowels"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8463f9334d26ad88a90495642b35b9b09d8d2700 | a801f5f7fab09dcdcb9ff7018c33157c2ca52010 | |||
v1.0 | instruct | Evol | Evol_6018_I | You are given a collection of short messages obtained from various social media platforms. Implement a text classification pipeline using Python and the scikit-learn library to classify these messages into predefined categories such as spam, advertisement, personal, and news. Your task includes the following steps:
- P... | import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, precision_score, ... | import pytest
from solution import preprocess_text, text_classification_pipeline
def test_preprocess_text():
text = "Hello, World!"
processed_text = preprocess_text(text)
assert processed_text == "hello world"
def test_text_classification_pipeline():
data = pd.DataFrame({
'message': ['This is ... | [
{
"docstring": null,
"function_declaration": "def preprocess_text(text):",
"function_name": "preprocess_text",
"parameter_list": "(text)"
},
{
"docstring": null,
"function_declaration": "def text_classification_pipeline(data):",
"function_name": "text_classification_pipeline",
"p... | [
0,
1,
0,
1,
1,
1,
0,
1,
0,
0
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import pandas as pd\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.naive_bayes im... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00006018",
"row_id": 6018,
"seed_ids": "[46189]"
} | 0.503944 | Evol_6018 | I | [
"preprocess_text",
"text_classification_pipeline",
"evaluate_model"
] | 3 | [
[
"text_classification_pipeline",
"evaluate_model"
],
[
"text_classification_pipeline",
"preprocess_text"
]
] | 2 | [] | false | [] | false | pytest | true | [
"pandas",
"sklearn"
] | false | 4211ab4fdcf432949fb85e5dd9dfb5e151d306fe | 8a7d866b4c8516229c6b1c07bcf24f4a5636a30a | |||
v1.0 | instruct | Evol | Evol_6038_I | Write a function that takes a list of integers and returns a list containing only the prime numbers from the original list. The function should be optimized having a time complexity of O(n * sqrt(m)), where n is the number of integers in the list and m is the largest integer in the list. Also, include error handling to... | import math
def is_prime(n):
"""
Check if a number is prime.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(math.sqrt(n)) + 1, 2):
if n % i == 0:
return False
return True
def filter_primes... | from solution import filter_primes
def test_filter_primes_with_mixed_numbers():
assert filter_primes([10, 17, 23, 33, 42, -5, 3]) == [17, 23, 3]
def test_filter_primes_with_primes_only():
assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11]
def test_filter_primes_with_no_primes():
assert filter_pri... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Return a list containing only the prime numbers from the original list.",
"function_declaration": "def filter_primes(numbers):... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import math\n\ndef is_prime(num):\n if num <= 1:\n return False\n\n for i in range(2, int(math.sqrt(num)) + 1):\n if num % i == 0:\n ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00006038",
"row_id": 6038,
"seed_ids": "[35769]"
} | 0.664734 | Evol_6038 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 644035640f0f97216d00a68d065f08e048798f45 | 133e7ee573d60b2463d86fd9ff09934693da2800 | |||
v1.0 | instruct | Evol | Evol_6050_I | Write a program that takes a list of integers and returns a new list with all the prime numbers removed. If the input list is empty or contains no prime numbers, the output should be an empty list.
[12, 25, 17, 9, 23, 44, 31, 68] | def is_prime(n):
"""
Checks if a number is a prime number.
"""
if n <= 1:
return False
if n == 2:
return True # 2 is the only even prime number
if n % 2 == 0:
return False # other even numbers are not primes
for i in range(3, int(n**0.5) + 1, 2):
if n % i ==... | from solution import remove_primes
def test_remove_primes_with_primes():
assert remove_primes([12, 25, 17, 9, 23, 44, 31, 68]) == [12, 25, 9, 44, 68]
def test_remove_primes_with_non_primes():
assert remove_primes([4, 6, 8, 10]) == [4, 6, 8, 10]
def test_remove_primes_with_all_primes():
assert remove_... | [
{
"docstring": "Checks if a number is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Takes a list of integers and returns a new list with all the prime numbers removed.",
"function_declaration": "def r... | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006050",
"row_id": 6050,
"seed_ids": "[27950]"
} | 0.597197 | Evol_6050 | I | [
"is_prime",
"remove_primes"
] | 2 | [
[
"remove_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | d633be84d47aa8538169777d0aef52b1a5469efd | f62116245cf4008e93dad2d8c47e47da5c72128b | |||
v1.0 | instruct | Evol | Evol_6065_I | Develop a program that simulates a simple network latency and bandwidth tester for multiple servers. Your program should randomly generate latency (in milliseconds) and bandwidth (in Mbps) values for each server and then summarize the results. Additionally, the program should identify and handle exceptional cases where... | import random
def generate_server_data(num_servers):
"""
Generates random latency (ms) and bandwidth (Mbps) values for a number of servers.
Parameters:
num_servers (int): The number of servers to generate data for.
Returns:
list of dict: A list of dictionaries containing latency and bandwidth... | from solution import generate_server_data, analyze_servers, simulate_network_test
def test_generate_server_data():
servers = generate_server_data(5)
assert len(servers) == 5
for server in servers:
assert 1 <= server["latency"] <= 1500
assert 0.5 <= server["bandwidth"] <= 20.0
def test_anal... | [
{
"docstring": "Generates random latency (ms) and bandwidth (Mbps) values for a number of servers.\n\nParameters:\nnum_servers (int): The number of servers to generate data for.\n\nReturns:\nlist of dict: A list of dictionaries containing latency and bandwidth values.",
"function_declaration": "def generate... | [
1,
0,
1,
1,
1,
0,
1,
1,
0,
0
] | 6 | medium | 0.6 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import random\n\ndef generate_server_data(num_servers):\n servers = {}\n for i in range(1, num_servers + 1):\n latency = random.randint(10, 1500)\n ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00006065",
"row_id": 6065,
"seed_ids": "[17856]"
} | 0.472081 | Evol_6065 | I | [
"generate_server_data",
"analyze_servers",
"simulate_network_test"
] | 3 | [
[
"simulate_network_test",
"analyze_servers"
],
[
"simulate_network_test",
"generate_server_data"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 4f0202ba7c2590e5e4c35820670132c56a325ad6 | ce2d51ba5a67fb697f80d85f882cc960bfe01500 | |||
v1.0 | instruct | Evol | Evol_6071_I | 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. | 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": "",
"prompt_id": "00006071",
"row_id": 6071,
"seed_ids": "[3944]"
} | 0.66824 | Evol_6071 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | a6b78b1d37b1749efc2a124eec196164f7936662 | 2f123e12d4d46406833468f93b17480bcb31e856 | |||
v1.0 | instruct | Evol | Evol_6134_I | Implement a Python function that checks whether a given string is a palindrome, ignoring spaces, punctuation, and capitalization. Additionally, write a short helper function that removes all non-alphanumeric characters from the string. Ensure your solution handles potential edge cases such as an empty string or a strin... | import re
def clean_string(s):
"""
Removes all non-alphanumeric characters from the string and converts it to lowercase.
"""
return re.sub(r'[^a-zA-Z0-9]', '', s).lower()
def is_palindrome(s):
"""
Checks whether a given string is a palindrome ignoring spaces, punctuation, and capitalization.
... | from solution import clean_string, is_palindrome
def test_clean_string():
assert clean_string("Was it a car or a cat I saw?") == "wasitacaroracatisaw"
assert clean_string("Hello, World!") == "helloworld"
assert clean_string("") == ""
assert clean_string("!!!!") == ""
def test_is_palindrome():
asse... | [
{
"docstring": "Removes all non-alphanumeric characters from the string and converts it to lowercase.",
"function_declaration": "def clean_string(s):",
"function_name": "clean_string",
"parameter_list": "(s)"
},
{
"docstring": "Checks whether a given string is a palindrome ignoring spaces, p... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def remove_non_alphanumeric(s):\n \"\"\"\n Removes all non-alphanumeric characters from the string.\n \"\"\"\n return ''.join(char for char in s if cha... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006134",
"row_id": 6134,
"seed_ids": "[19412]"
} | 0.823722 | Evol_6134 | I | [
"clean_string",
"is_palindrome"
] | 2 | [
[
"is_palindrome",
"clean_string"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | bddab82a2cdd14cd54508800141a3b2fbbf44094 | 6772131f3c54f8d130ad4b6960e65d4401915473 | |||
v1.0 | instruct | Evol | Evol_6146_I | Construct a function that receives an unsorted list of integers and returns a new list containing the integers in ascending order, but only those integers that are prime numbers. Implement this function using Python, and ensure it efficiently handles lists with a size of up to 10,000 elements. Consider edge cases such ... | def is_prime(n):
"""
Determines if the given integer n is prime.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6... | from solution import is_prime, sort_primes
def test_is_prime_basic_cases():
assert not is_prime(0)
assert not is_prime(1)
assert is_prime(2)
assert is_prime(3)
assert not is_prime(4)
assert is_prime(5)
assert not is_prime(9)
assert is_prime(11)
def test_is_prime_large_prime():
asse... | [
{
"docstring": "Determines if the given integer n is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Given an unsorted list of integers, returns a list of prime numbers sorted in ascending order.",
"function_dec... | [
1,
1,
1,
1,
0,
1,
1,
1,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "from math import isqrt\n\ndef is_prime(n):\n \"\"\"\n Returns True if the given number n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006146",
"row_id": 6146,
"seed_ids": "[42241]"
} | 0.649346 | Evol_6146 | I | [
"is_prime",
"sort_primes"
] | 2 | [
[
"sort_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 9fca9d0f6d72ca068ebb742ce1bfa09d0d86eb55 | 7191d20897e8b349ee8c39aa1920f3a5d97ab001 | |||
v1.0 | instruct | Evol | Evol_6151_I | Design a Python function that parses a log file to extract and count the frequency of distinct IP addresses. The function should handle large files efficiently, avoid loading the entire file into memory at once, and store the results in a dictionary. Additionally, implement a feature to filter out invalid IP addresses ... | import re
from collections import defaultdict
def is_valid_ip(ip):
"""
Validate if the given IP address is valid.
"""
pattern = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')
if pattern.match(ip):
parts = ip.split('.')
return all(0 <= int(part) <= 255 for part in parts)
ret... | from solution import is_valid_ip, count_ip_addresses
def test_is_valid_ip():
assert is_valid_ip("192.168.0.1") == True
assert is_valid_ip("255.255.255.255") == True
assert is_valid_ip("256.256.256.256") == False
assert is_valid_ip("192.168.0") == False
assert is_valid_ip("abc.def.ghi.jkl") == False... | [
{
"docstring": "Validate if the given IP address is valid.",
"function_declaration": "def is_valid_ip(ip):",
"function_name": "is_valid_ip",
"parameter_list": "(ip)"
},
{
"docstring": "Parses the log file to extract and count the frequency of distinct valid IP addresses.\nThe results are wri... | [
0,
0,
1,
1,
1,
0,
1,
1,
1,
1
] | 7 | easy | 0.7 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import re\nfrom collections import defaultdict\n\ndef is_valid_ip(ip):\n \"\"\"\n Validates an IP address.\n \"\"\"\n pattern = re.compile(r'^(\\d{1,3}... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00006151",
"row_id": 6151,
"seed_ids": "[22053]"
} | 0.750929 | Evol_6151 | I | [
"is_valid_ip",
"count_ip_addresses"
] | 2 | [
[
"count_ip_addresses",
"is_valid_ip"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | a0a61f5c4dc2c28adb15c483de3ee8cc84d9d9a3 | bf205f88bb6b6e4e16b9b9b504e930a1c70a60ed | |||
v1.0 | instruct | Evol | Evol_6163_I | Given a directed graph with `n` nodes and `m` edges where each node represents a city and each edge represents a one-way road connecting two cities, your task is to find the number of strongly connected components (SCC) in the graph. A strongly connected component is a maximal subgraph where every pair of nodes is reac... | from sys import setrecursionlimit, stdin, stdout
# Adjust the recursion limit and input/output optimization for performance
setrecursionlimit(200000)
input = stdin.read
def find_scc(n, m, edges):
def dfs(v):
# Depth-first search to order nodes
visited[v] = True
for to in g[v]:
i... | import pytest
from solution import number_of_scc
def test_case_1():
assert number_of_scc(5, 5, [(1, 2), (2, 3), (3, 1), (4, 5), (5, 4)]) == 2
def test_case_2():
assert number_of_scc(3, 3, [(1, 2), (2, 3), (3, 1)]) == 1
def test_case_3():
assert number_of_scc(4, 4, [(1, 2), (2, 3), (3, 4), (4, 1)]) == 1
... | [
{
"docstring": null,
"function_declaration": "def find_scc(n, m, edges):",
"function_name": "find_scc",
"parameter_list": "(n, m, edges)"
},
{
"docstring": null,
"function_declaration": "def number_of_scc(n, m, edges_list):",
"function_name": "number_of_scc",
"parameter_list": "(... | [
0,
1,
1,
1,
0,
0,
0,
1,
0,
1
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "from collections import defaultdict, deque\n\ndef find_scc(n, m, edges):\n \"\"\"\n Finds the number of strongly connected components (SCC) in the graph.\n ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006163",
"row_id": 6163,
"seed_ids": "[43508]"
} | 0.617329 | Evol_6163 | I | [
"find_scc",
"number_of_scc"
] | 2 | [
[
"number_of_scc",
"find_scc"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 5b9ab1cdc5cf11f89c3833ce81bed35d470e2844 | 4e81ea941711389c61edf8f4de12bb4278c3a685 | |||
v1.0 | instruct | Evol | Evol_6189_I | ## Task
Write 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.
## Objective
- Write a function that accepts three parameters: `start`, `end`, and `N`.
- `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": "",
"prompt_id": "00006189",
"row_id": 6189,
"seed_ids": "[27106]"
} | 0.705739 | Evol_6189 | I | [
"is_prime",
"find_n_primes_in_range"
] | 2 | [
[
"find_n_primes_in_range",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 26f35827646ce24c52f0b0dd4cbaaa3539b25fef | 9fb97594545e32b33a5bf76655dbcb520b44f14c | |||
v1.0 | instruct | Evol | Evol_6208_I | Write a program in Python that accepts a list of integers as input and returns a new list containing only the prime numbers from the original list. The program should include a helper function to determine if a number is prime. Additionally, ensure that your code can handle negative numbers and zero appropriately, by n... | def is_prime(n):
"""
Helper function to determine if a number is prime.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
max_divisor = int(n**0.5) + 1
for d in range(3, max_divisor, 2):
if n % d == 0:
return False
... | from solution import is_prime, prime_numbers
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(0) == False
assert is_prime(1) == False
assert is_prime(-3) == False
assert is_prime(17) == True
def test_prime_numbers():
... | [
{
"docstring": "Helper function to determine if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Accepts a list of integers and returns a new list containing only the prime numbers.",
"function_declar... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n return True... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00006208",
"row_id": 6208,
"seed_ids": "[17067]"
} | 0.689569 | Evol_6208 | I | [
"is_prime",
"prime_numbers"
] | 2 | [
[
"prime_numbers",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | aefdbabb831ad452dad07a9f1ac4219304aacbe3 | 8621fece8a99bb1b21101dfa73a48045e6b5c248 | |||
v1.0 | instruct | Evol | Evol_6219_I | Design a function that takes a list of integers and returns a new list that contains only the prime numbers from the input list. If the input list is empty, contains non-integer values, or no prime numbers are found, the function should handle these scenarios appropriately by returning specific error messages or an emp... | def is_prime(n):
if n <= 1:
return False
if n == 2:
return True # 2 is the only even prime number
if n % 2 == 0:
return False # other even numbers are not prime
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def extract_p... | from solution import extract_primes, is_prime
def test_is_prime():
assert is_prime(2)
assert is_prime(3)
assert not is_prime(4)
assert is_prime(5)
assert not is_prime(9)
assert is_prime(11)
assert not is_prime(-1)
assert not is_prime(0)
assert not is_prime(1)
def test_extract_prime... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Extracts all prime numbers from the given list of numbers.\n\nArgs:\nnums (list): A list of integers.\n\nReturns:\nlist: A list containing all prime number... | [
1,
1,
1,
0,
1,
1,
1,
1,
0,
1
] | 8 | easy | 0.8 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"Helper function to determine if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00006219",
"row_id": 6219,
"seed_ids": "[8692]"
} | 0.688199 | Evol_6219 | I | [
"is_prime",
"extract_primes"
] | 2 | [
[
"extract_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 658a6cdbcefc18ee07bc02f50cca618fc699825f | c8a20bb9e09ada3ca396efbd16ce0bb1a63fde9c | |||
v1.0 | instruct | Evol | Evol_6266_I | Write a function in Python that takes a list of integers as an input and returns a list containing only the prime numbers found in the input list.
### Constraints:
1. The input list will have at least one integer and no more than 1000 integers.
2. Each integer in the input list will be a positive number less than 10^... | def is_prime(num):
"""
Helper function that returns True if the number is prime, otherwise False.
"""
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2... | from solution import extract_primes
def test_extract_primes_example_1():
assert extract_primes([10, 15, 3, 7, 11, 20]) == [3, 7, 11]
def test_extract_primes_example_2():
assert extract_primes([4, 6, 8, 9, 10]) == []
def test_extract_primes_single_prime():
assert extract_primes([2]) == [2]
def test_extra... | [
{
"docstring": "Helper function that returns True if the number is prime, otherwise False.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Function that takes a list of integers and returns a list of prime numbers foun... | [
1,
1,
1,
0,
1,
1,
1,
1,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006266",
"row_id": 6266,
"seed_ids": "[32895]"
} | 0.669189 | Evol_6266 | I | [
"is_prime",
"extract_primes"
] | 2 | [
[
"extract_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 389cf542ae0933146767131f49ef50f3f1b51928 | 16d209213f50155263ba8a62fdd6e498fd8ad994 | |||
v1.0 | instruct | Evol | Evol_6297_I | Create an advanced Python script capable of interfacing with a RESTful API to gather and process real-time data streams from multiple sources. The script should efficiently handle the streaming data by employing multithreading or asynchronous programming techniques to manage varying data arrival times and ensure minima... | import requests
import asyncio
import aiohttp
import concurrent.futures
from datetime import datetime
import logging
logging.basicConfig(level=logging.INFO)
API_ENDPOINTS = [
'https://api.example.com/data/source1',
'https://api.example.com/data/source2',
# Add more API endpoints as needed
]
def clean_dat... | import pytest
import asyncio
from unittest.mock import patch, AsyncMock
from solution import clean_data, aggregate_data, generate_insights, fetch_data, gather_data, process_data
def test_clean_data():
raw_data = {'a': 1, 'b': None, 'c': 2}
cleaned_data = clean_data(raw_data)
assert cleaned_data == {'a': 1,... | [
{
"docstring": "Cleans received data. Implement specific data cleaning logic here.",
"function_declaration": "def clean_data(data):",
"function_name": "clean_data",
"parameter_list": "(data)"
},
{
"docstring": "Aggregates data from multiple sources.",
"function_declaration": "def aggrega... | [
0,
1,
1,
1,
0,
0,
0,
0,
0,
1
] | 4 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import asyncio\nimport aiohttp\nimport json\nfrom datetime import datetime, timedelta\n\nclass DataProcessor:\n def __init__(self, api_urls):\n self.api_... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00006297",
"row_id": 6297,
"seed_ids": "[30274]"
} | 0.425221 | Evol_6297 | I | [
"clean_data",
"aggregate_data",
"generate_insights",
"fetch_data",
"gather_data",
"process_data"
] | 6 | [
[
"fetch_data",
"clean_data"
],
[
"gather_data",
"fetch_data"
],
[
"process_data",
"aggregate_data"
],
[
"process_data",
"gather_data"
],
[
"process_data",
"generate_insights"
]
] | 5 | [
"process_data"
] | false | [] | false | pytest | true | [
"aiohttp",
"requests"
] | false | 54d64da1b400d3f7cad80f4f1f141539aa5aa50c | a61780b2dee716a1e9320c6b9dfd2d85e280a231 | |||
v1.0 | instruct | Evol | Evol_6302_I | Write a program that accepts an integer array as input and returns an array containing only the prime numbers from the input array. Additionally, the program should remove any duplicate prime numbers in the output array and return them in ascending order.
For example, if the input array is [3, 5, 8, 3, 10, 13, 5, 2, 9... | def is_prime(n):
"""
Check if the number n is a prime number.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def extract_primes(arr)... | from solution import is_prime, extract_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(29) == True
assert is_prime(1) == False
assert is_prime(0) == False
assert is_prime(-5) == False
def test_extract_primes():
... | [
{
"docstring": "Check if the number n is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Accepts an integer array as input and returns an array containing only the prime numbers,\nwithout duplicates and in ... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00006302",
"row_id": 6302,
"seed_ids": "[30625]"
} | 0.675421 | Evol_6302 | I | [
"is_prime",
"extract_primes"
] | 2 | [
[
"extract_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | bc4cdd5ed115219f80e6cf6ace52af7c96df1905 | 05e7ad32c3417a88af83e2db1c7582951f00f265 | |||
v1.0 | instruct | Evol | Evol_6310_I | Write a program to determine if a given string is a palindrome and the length of the longest palindromic substring within the given string.
For the given input string "babad", the program should return:
Is Palindrome: False
Longest Palindromic Substring: "bab"
Length: 3 | def is_palindrome(s: str) -> bool:
"""
Returns True if the string s is a palindrome, False otherwise.
"""
return s == s[::-1]
def longest_palindromic_substring(s: str) -> str:
"""
Returns the longest palindromic substring in s.
"""
n = len(s)
if n == 0:
return ""
longes... | from solution import is_palindrome, longest_palindromic_substring, get_palindrome_info
def test_is_palindrome():
assert is_palindrome("racecar") == True
assert is_palindrome("hello") == False
assert is_palindrome("a") == True
assert is_palindrome("") == True
def test_longest_palindromic_substring():
... | [
{
"docstring": "Returns True if the string s is a palindrome, False otherwise.",
"function_declaration": "def is_palindrome(s):",
"function_name": "is_palindrome",
"parameter_list": "(s)"
},
{
"docstring": "Returns the longest palindromic substring in s.",
"function_declaration": "def lo... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_palindrome(s):\n \"\"\"\n Returns True if the string s is a palindrome, False otherwise.\n \"\"\"\n return s == s[::-1]\n\ndef longest_palindrom... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00006310",
"row_id": 6310,
"seed_ids": "[43923]"
} | 0.825211 | Evol_6310 | I | [
"is_palindrome",
"longest_palindromic_substring",
"get_palindrome_info"
] | 3 | [
[
"get_palindrome_info",
"is_palindrome"
],
[
"get_palindrome_info",
"longest_palindromic_substring"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | cf9bf24d1878ec7babf91f54f88ed5f4d4181ecf | 2103412796998851c92ea563f00d27f8787e0080 | |||
v1.0 | instruct | Evol | Evol_6311_I | Given a large text corpus, write a function to identify the longest palindromic substring within the document. The function should be efficient to handle texts with lengths up to a few million characters. Additionally, the algorithm should ignore spaces, punctuation, and case variations when determining palindromes. Pr... | def preprocess_string(s):
"""
Converts the string to lower case and removes all non-alphanumeric characters.
"""
return ''.join(c.lower() for c in s if c.isalnum())
def longest_palindromic_substring(s):
"""
Returns the longest palindromic substring in the given document.
Ignoring spaces, pu... | from solution import preprocess_string, longest_palindromic_substring
def test_preprocess_string():
assert preprocess_string("A man, a plan, a canal: Panama") == "amanaplanacanalpanama"
assert preprocess_string("No 'x' in Nixon") == "noxinnixon"
assert preprocess_string("") == ""
assert preprocess_stri... | [
{
"docstring": "Converts the string to lower case and removes all non-alphanumeric characters.",
"function_declaration": "def preprocess_string(s):",
"function_name": "preprocess_string",
"parameter_list": "(s)"
},
{
"docstring": "Returns the longest palindromic substring in the given docume... | [
0,
1,
0,
1,
0,
0,
0,
0,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import re\n\ndef longest_palindromic_substring(text):\n \"\"\"\n Returns the longest palindromic substring from the provided text while ignoring spaces,\n ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00006311",
"row_id": 6311,
"seed_ids": "[45206]"
} | 0.745333 | Evol_6311 | I | [
"preprocess_string",
"longest_palindromic_substring"
] | 2 | [
[
"longest_palindromic_substring",
"preprocess_string"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2458265866aded5cc5fdec8664241a2a5210a04f | 65b31d3327ef32d45e69e411e02b3224ae6295d8 | |||
v1.0 | instruct | Evol | Evol_6367_I | Write a function that takes a string of lowercase alphabets and returns a new string where each character is replaced by the character occurring `n` positions after it in the alphabet. If a shift moves past 'z', it should wrap around to 'a'. For instance, shifting 'z' by 1 would result in 'a'. Implement a helper functi... | def shift_character(char, n):
"""
Shifts a character by n positions in the alphabet, wrapping around if necessary.
:param char: Single lowercase character to be shifted
:param n: Number of positions to shift
:return: Shifted character
"""
new_position = (ord(char) - ord('a') + n) % 26
... | from solution import shift_string
def test_shift_string_positive_shift():
assert shift_string('abc', 1) == 'bcd'
assert shift_string('xyz', 2) == 'zab'
def test_shift_string_negative_shift():
assert shift_string('bcd', -1) == 'abc'
assert shift_string('zab', -2) == 'xyz'
def test_shift_string_zero_sh... | [
{
"docstring": "Shifts a character by n positions in the alphabet, wrapping around if necessary.\n\n:param char: Single lowercase character to be shifted\n:param n: Number of positions to shift\n:return: Shifted character",
"function_declaration": "def shift_character(char, n):",
"function_name": "shift... | [
0,
1,
1,
1,
1,
0,
1,
0,
0,
0
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def shift_char(c, n):\n \"\"\"\n Shifts a character c by n positions in the alphabet. Supports both positive\n and negative shifts. Wraps around if the sh... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00006367",
"row_id": 6367,
"seed_ids": "[33481]"
} | 0.703782 | Evol_6367 | I | [
"shift_character",
"shift_string"
] | 2 | [
[
"shift_string",
"shift_character"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 46102067c3ef310668139a12e0380b253dff04eb | 46f543b86be07fc81e3fed6099d6fc099e6dfcea | |||
v1.0 | instruct | Evol | Evol_6376_I | Given a list of tuples where each tuple represents a flight with the following information: (departure_city, destination_city, departure_time, arrival_time, cost, airline), write a function to find the cheapest flight route from a given departure city to a destination city that consists of one or more connecting flight... | from datetime import datetime
import heapq
def parse_time(time_str):
"""
Parses a string to a datetime object.
"""
return datetime.strptime(time_str, '%Y-%m-%d %H:%M')
def find_cheapest_route(flights, departure_city, destination_city):
"""
Finds the cheapest flight route from departure_city to... | from solution import find_cheapest_route, incorrect_find_cheapest_route
import pytest
def test_parse_time():
assert parse_time('2023-10-10 10:10') == datetime(2023, 10, 10, 10, 10)
def test_cheapest_route_single_flight():
flights = [
('A', 'B', '2023-10-10 10:00', '2023-10-10 12:00', 100.0, 'Airline1'... | [
{
"docstring": "Parses a string to a datetime object.",
"function_declaration": "def parse_time(time_str):",
"function_name": "parse_time",
"parameter_list": "(time_str)"
},
{
"docstring": "Finds the cheapest flight route from departure_city to destination_city.",
"function_declaration":... | [
0,
0,
0,
0,
1,
0,
1,
0,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import datetime\n\ndef parse_time(time_str):\n return datetime.datetime.strptime(time_str, \"%Y-%m-%d %H:%M\")\n\ndef find_cheapest_flight_route(flights, depart... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00006376",
"row_id": 6376,
"seed_ids": "[37867]"
} | 0.570319 | Evol_6376 | I | [
"parse_time",
"find_cheapest_route",
"incorrect_find_cheapest_route"
] | 3 | [
[
"find_cheapest_route",
"parse_time"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 68b291de2458a76c468fff1dd1c49dd24b19a1f1 | 28f7f233fcccd3def21a3b9f33eca09a15ebc829 | |||
v1.0 | instruct | Evol | Evol_6396_I | Create a function that accepts a list of strings and returns a new list containing only the strings that are palindromes. A palindrome is a string that reads the same forwards and backwards, ignoring case and non-alphanumeric characters.
### Sample Function Signature
```python
def filter_palindromes(strings: list) -> ... | import re
def is_palindrome(s: str) -> bool:
# Remove non-alphanumeric characters and convert to lowercase
clean_s = re.sub(r'[^a-zA-Z0-9]', '', s).lower()
# Compare the cleaned string with its reverse
return clean_s == clean_s[::-1]
def filter_palindromes(strings: list) -> list:
return [s for s i... | from solution import filter_palindromes, is_palindrome
def test_is_palindrome():
assert is_palindrome("madam") == True
assert is_palindrome("racecar") == True
assert is_palindrome("apple") == False
assert is_palindrome("Step on no pets") == True
assert is_palindrome("Was it a car or a cat I saw") =... | [
{
"docstring": null,
"function_declaration": "def is_palindrome(s):",
"function_name": "is_palindrome",
"parameter_list": "(s)"
},
{
"docstring": null,
"function_declaration": "def filter_palindromes(strings):",
"function_name": "filter_palindromes",
"parameter_list": "(strings)"... | [
0,
0,
1,
1,
1,
1,
1,
1,
0,
1
] | 7 | easy | 0.7 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import re\n\ndef filter_palindromes(strings: list) -> list:\n \"\"\"\n Filters out palindromic strings from the list. \n Ignores case and non-alphanumeric... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006396",
"row_id": 6396,
"seed_ids": "[11654]"
} | 0.74374 | Evol_6396 | I | [
"is_palindrome",
"filter_palindromes"
] | 2 | [
[
"filter_palindromes",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 5e659b93464d6ed9a68e5d6d8a90f7c762b642dc | 02f9e0984b0192d45a9faef752d3c5f6f6c7825f | |||
v1.0 | instruct | Evol | Evol_6402_I | 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.
Additionally, the function should handle invalid inputs, such as lists containing non-integer elements, b... | 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": "",
"prompt_id": "00006402",
"row_id": 6402,
"seed_ids": "[25676]"
} | 0.651125 | Evol_6402 | I | [
"is_prime",
"sum_of_primes"
] | 2 | [
[
"sum_of_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 14be7964f60bec18e1d7e3450300cf10defa3bad | 7761a136144da163d579e7367c1a7e3d731e5d9a | |||
v1.0 | instruct | Evol | Evol_6403_I | **Write a function in Python that takes a list of integers and returns a new list containing only the prime numbers from the original list.**
Function Signature:
```python
def filter_primes(numbers: list[int]) -> list[int]:
pass
```
## Example
```python
numbers = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
assert filter_pri... | def is_prime(number: int) -> bool:
"""
Returns True if the number is a prime, else False.
"""
if number <= 1:
return False
if number == 2:
return True
if number % 2 == 0:
return False
for i in range(3, int(number**0.5) + 1, 2):
if number % i == 0:
... | from solution import filter_primes, is_prime
def test_is_prime():
assert is_prime(0) == False
assert is_prime(1) == False
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) == Tru... | [
{
"docstring": "Returns True if the number is a prime, else False.",
"function_declaration": "def is_prime(number):",
"function_name": "is_prime",
"parameter_list": "(number)"
},
{
"docstring": "Filters the list of integers, returning only the prime numbers.",
"function_declaration": "de... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "from typing import List\n\ndef is_prime(number: int) -> bool:\n \"\"\"\n Returns True if the number is a prime, else False.\n A prime number is greater th... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006403",
"row_id": 6403,
"seed_ids": "[3534]"
} | 0.751127 | Evol_6403 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c7dd6c0fefa23b27a6c01f91915ee44ee91e2867 | 56d82fd0d0440272405043f3aa647e7fd0918076 | |||
v1.0 | instruct | Evol | Evol_6470_I | 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 return an empty list and `None` f... | 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": "",
"prompt_id": "00006470",
"row_id": 6470,
"seed_ids": "[43685]"
} | 0.677937 | Evol_6470 | I | [
"is_prime",
"find_primes_and_smallest"
] | 2 | [
[
"find_primes_and_smallest",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4771cf47e0c99ae16500e1e77bdc542bd9db014f | 3cb921beab00894180a11bc005e6dbe33e9067b2 | |||
v1.0 | instruct | Evol | Evol_6512_I | Write a Python function that takes a list of integers and returns a list of tuples. Each tuple should contain two elements: an integer from the original list and the sum of its digits. Ensure the function maintains the original order of the integers in the returned list. | def sum_of_digits(n):
"""
Returns the sum of the digits of an integer n.
"""
return sum(int(digit) for digit in str(abs(n)))
def list_with_sum_of_digits(lst):
"""
Returns a list of tuples with each integer and the sum of its digits.
"""
return [(num, sum_of_digits(num)) for num in lst] | from solution import list_with_sum_of_digits
def test_list_with_sum_of_digits_empty():
assert list_with_sum_of_digits([]) == []
def test_list_with_sum_of_digits_single_element():
assert list_with_sum_of_digits([123]) == [(123, 6)]
assert list_with_sum_of_digits([0]) == [(0, 0)]
assert list_with_sum_of... | [
{
"docstring": "Returns the sum of the digits of an integer n.",
"function_declaration": "def sum_of_digits(n):",
"function_name": "sum_of_digits",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of tuples with each integer and the sum of its digits.",
"function_declaration": "... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def sum_of_digits(n):\n \"\"\"\n Returns the sum of the digits of an integer n.\n \"\"\"\n return sum(int(digit) for digit in str(abs(n)))\n\ndef list_... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006512",
"row_id": 6512,
"seed_ids": "[48478]"
} | 0.724066 | Evol_6512 | I | [
"sum_of_digits",
"list_with_sum_of_digits"
] | 2 | [
[
"list_with_sum_of_digits",
"sum_of_digits"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fdfc60f99a5c5787a36d3e0fc85f9058caf7b25a | 9e22a68b63d9bcc2b4d68a4061d4d7aa172d81bc | |||
v1.0 | instruct | Evol | Evol_6618_I | Create a function that implements the Binary Search algorithm in Python and use it to search for an element in a sorted list. Additionally, use the `time` module to measure the performance (execution time) of your function for different input sizes. Discuss how the input size affects the performance, and print the exec... | import time
def binary_search(arr, target):
"""
Performs binary search on a sorted list to find the index of the target element.
Returns the index of the target if found, otherwise returns -1.
:param arr: List of sorted elements
:param target: Element to search for
:return: Index of target... | from solution import binary_search
def test_binary_search_found():
assert binary_search([1, 2, 3, 4, 5], 3) == 2
assert binary_search([10, 20, 30, 40, 50], 40) == 3
assert binary_search([100, 200, 300, 400, 500], 100) == 0
def test_binary_search_not_found():
assert binary_search([1, 2, 3, 4, 5], 6) ==... | [
{
"docstring": "Performs binary search on a sorted list to find the index of the target element.\nReturns the index of the target if found, otherwise returns -1.\n\n:param arr: List of sorted elements\n:param target: Element to search for\n:return: Index of target if found, -1 otherwise",
"function_declarat... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import time\n\ndef binary_search(arr, target):\n \"\"\"\n Binary search algorithm to find the target in the sorted list arr.\n If target is found, return ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006618",
"row_id": 6618,
"seed_ids": "[7973]"
} | 0.582992 | Evol_6618 | I | [
"binary_search",
"measure_performance"
] | 2 | [
[
"measure_performance",
"binary_search"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | be1199dba1ea112aca6111aa6a947b88c43742bf | bec8c2c703e4882a0d4034443f2badd3a52c7f9d | |||
v1.0 | instruct | Evol | Evol_6641_I | Create a function in Python that takes a list of integers and returns another list containing only the prime numbers from the input list. Additionally, the function should also sort the prime numbers in ascending order before returning the list. Ensure the function handles edge cases, such as empty lists or lists with ... | def is_prime(n):
"""
Helper function to check if a number n is a prime number.
"""
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
def filter_and_sort_primes(numbers):
"""
This function takes a list of int... | import pytest
from solution import filter_and_sort_primes
def test_filter_and_sort_primes_empty_list():
assert filter_and_sort_primes([]) == []
def test_filter_and_sort_primes_no_primes():
assert filter_and_sort_primes([1, 4, 6, 8, 10, 12]) == []
def test_filter_and_sort_primes_with_primes():
assert filt... | [
{
"docstring": "Helper function to check if a number n is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "This function takes a list of integers and returns a list with only the prime\nnumbers sorted in asc... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(n... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006641",
"row_id": 6641,
"seed_ids": "[26732]"
} | 0.635327 | Evol_6641 | I | [
"is_prime",
"filter_and_sort_primes"
] | 2 | [
[
"filter_and_sort_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | d4758f814bb769ad2711800e04ff910ebdfa426d | 2c8dbf3d59031accc7482f0063b723e58739d192 | |||
v1.0 | instruct | Evol | Evol_6662_I | 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:
1. It should contain exactly one "@" symbol.
2. The domain part (after "@") should c... | 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": "",
"prompt_id": "00006662",
"row_id": 6662,
"seed_ids": "[18853]"
} | 0.526227 | Evol_6662 | I | [
"is_valid_email",
"validate_emails"
] | 2 | [
[
"validate_emails",
"is_valid_email"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2c7cefe8550125ef88eb6bfffbad88c58526883e | 1bc95ead17999dfa8b990cf87aa4b73a8aa9b7e8 | |||
v1.0 | instruct | Evol | Evol_6673_I | 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 task is to:
1. Read the data fro... | 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": "",
"prompt_id": "00006673",
"row_id": 6673,
"seed_ids": "[43668]"
} | 0.615166 | Evol_6673 | I | [
"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 | 21caa4f4ea556f26b1400371dd360ee0d7e39581 | 0250a88f7503ae5479aaa28985b657b40040b35d | |||
v1.0 | instruct | Evol | Evol_6708_I | Create a program that takes a list of integers and returns a new list containing only the prime numbers from the original list, in the same order they appeared. Ensure that your implementation efficiently checks for prime numbers and handles edge cases such as negative numbers and non-integer inputs. | def is_prime(n):
"""
Returns True if n is a prime number, False otherwise.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def filter... | from solution import is_prime, filter_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(-1) == False
assert is_prime(0) == False
assert is_prime(1) == False
assert is_prime(17) == True... | [
{
"docstring": "Returns True if n is a prime number, False otherwise.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a new list containing only the prime numbers from the original list.",
"function_declaration... | [
0,
0,
1,
1,
1,
1,
1,
1,
1,
1
] | 8 | easy | 0.8 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00006708",
"row_id": 6708,
"seed_ids": "[12282]"
} | 0.623031 | Evol_6708 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 91ab6fd76870d49bae69279d51d79cff053c19b5 | cad3404ec14b026ea13eda56bb57fdfd12d87994 | |||
v1.0 | instruct | Evol | Evol_6711_I | Implement a genetic algorithm to solve the traveling salesman problem. Your solution should include mechanisms for selection, crossover, and mutation operations. Ensure that your algorithm maintains diversity in the population and converges efficiently to a near-optimal solution. | import random
import numpy as np
def create_route(city_list):
return random.sample(city_list, len(city_list))
def initial_population(pop_size, city_list):
population = []
for i in range(pop_size):
population.append(create_route(city_list))
return population
def rank_routes(population):
fi... | from solution import (create_route, initial_population, rank_routes, selection,
mating_pool, breed, breed_population, mutate, mutate_population,
next_generation, genetic_algorithm)
def test_create_route():
city_list = [(0, 0), (1, 1), (2, 2)]
route = create_route(c... | [
{
"docstring": null,
"function_declaration": "def create_route(city_list):",
"function_name": "create_route",
"parameter_list": "(city_list)"
},
{
"docstring": null,
"function_declaration": "def initial_population(pop_size, city_list):",
"function_name": "initial_population",
"pa... | [
0,
0,
0,
0,
1,
1,
0,
0,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import random\nimport numpy as np\n\ndef initialize_population(problem_size, population_size):\n \"\"\"\n Initializes a population for the TSP with given pro... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00006711",
"row_id": 6711,
"seed_ids": "[37671]"
} | 0.415062 | Evol_6711 | I | [
"create_route",
"initial_population",
"rank_routes",
"route_fitness",
"route_distance",
"selection",
"mating_pool",
"breed",
"breed_population",
"mutate",
"mutate_population",
"next_generation",
"genetic_algorithm"
] | 13 | [
[
"breed_population",
"breed"
],
[
"genetic_algorithm",
"initial_population"
],
[
"genetic_algorithm",
"next_generation"
],
[
"genetic_algorithm",
"rank_routes"
],
[
"initial_population",
"create_route"
],
[
"mutate_population",
"mutate"
],
[
... | 13 | [] | false | [] | false | pytest | true | [
"numpy"
] | false | c2d04a802844df6f9606418f073407afe085f046 | 99e83ff1d6c1d943d6ab7df3520e07806fba5c71 | |||
v1.0 | instruct | Evol | Evol_6713_I | Given a list of strings representing mathematical expressions in infix notation, write a function that converts each expression into its equivalent postfix notation and evaluates the result. The input list can contain any valid arithmetic expressions involving the operators +, -, *, /, and parentheses. For simplicity, ... | def infix_to_postfix(expression):
precedence = {'+': 1, '-': 1, '*': 2, '/': 2}
stack = []
postfix = []
for char in expression:
if char.isdigit():
postfix.append(char)
elif char == '(':
stack.append(char)
elif char == ')':
while stack and ... | from solution import infix_to_postfix, evaluate_postfix, process_expressions
def test_infix_to_postfix():
assert infix_to_postfix("3+4") == "34+"
assert infix_to_postfix("2*(5+1)") == "251+*"
assert infix_to_postfix("(1+2)*(3+4)") == "12+34+*"
def test_evaluate_postfix():
assert evaluate_postfix("34+"... | [
{
"docstring": null,
"function_declaration": "def infix_to_postfix(expression):",
"function_name": "infix_to_postfix",
"parameter_list": "(expression)"
},
{
"docstring": null,
"function_declaration": "def evaluate_postfix(postfix_expr):",
"function_name": "evaluate_postfix",
"par... | [
0,
0,
1,
1,
1,
1,
1,
0,
1,
0
] | 6 | medium | 0.6 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def infix_to_postfix(expression):\n \"\"\"\n Convert infix expression to postfix expression.\n \"\"\"\n precedence = {'+': 1, '-': 1, '*': 2, '/': 2, '... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00006713",
"row_id": 6713,
"seed_ids": "[779]"
} | 0.579934 | Evol_6713 | I | [
"infix_to_postfix",
"evaluate_postfix",
"process_expressions"
] | 3 | [
[
"process_expressions",
"evaluate_postfix"
],
[
"process_expressions",
"infix_to_postfix"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | bf2f86bc793a43b8dc3b65391e1ade64e6ad6328 | 37dcfa29203b80ad5620511ca4d5185790a59309 | |||
v1.0 | instruct | Evol | Evol_6720_I | Write a program that reads a text file containing pairs of names and their corresponding ages. Sort these pairs based on age in ascending order. If two people have the same age, sort them alphabetically by their names. After sorting, save the output to a new text file in the same format. Additionally, the program shoul... | import datetime
def read_pairs(file_path):
"""
Reads pairs of names and ages from the given file.
Returns a list of tuples (name, age).
Logs any errors encountered to 'error_log.txt'.
"""
pairs = []
with open(file_path, 'r') as file:
for line in file:
try:
... | from solution import read_pairs, sort_pairs, write_pairs, sort_names_by_age, log_error
import os
def test_read_pairs():
input_file = 'test_input.txt'
with open(input_file, 'w') as file:
file.write("Alice 30\nBob 25\nCharlie 25\nEve 22\nInvalidLine\nJohn 30\nJane\n")
pairs = read_pairs(input_fi... | [
{
"docstring": "Reads pairs of names and ages from the given file.\nReturns a list of tuples (name, age).\nLogs any errors encountered to 'error_log.txt'.",
"function_declaration": "def read_pairs(file_path):",
"function_name": "read_pairs",
"parameter_list": "(file_path)"
},
{
"docstring": ... | [
0,
0,
1,
1,
1,
0,
1,
1,
1,
1
] | 7 | easy | 0.7 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import logging\nfrom datetime import datetime\n\ndef read_and_sort(file_path, output_path, error_log_path):\n \"\"\"\n Reads a file with pairs of names and a... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006720",
"row_id": 6720,
"seed_ids": "[25119]"
} | 0.573066 | Evol_6720 | I | [
"read_pairs",
"sort_pairs",
"write_pairs",
"log_error",
"sort_names_by_age"
] | 5 | [
[
"read_pairs",
"log_error"
],
[
"sort_names_by_age",
"read_pairs"
],
[
"sort_names_by_age",
"sort_pairs"
],
[
"sort_names_by_age",
"write_pairs"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | a19a60bdfbe55f075d6efb756d472d12496544f4 | 41cb49420c8c069874a3a39e37ffaf1a956bbf5c | |||
v1.0 | instruct | Evol | Evol_6734_I | 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 points, and repeat these steps unt... | 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": "",
"prompt_id": "00006734",
"row_id": 6734,
"seed_ids": "[47095]"
} | 0.697137 | Evol_6734 | I | [
"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 | 8ecc5a804e1905e812d298e4c69e8abc61b5c5a0 | 139af7981f9dfbc8a81a55c1153b73f87db26335 | |||
v1.0 | instruct | Evol | Evol_6742_I | 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.
Example:
```python
def nearest_smaller_prime(n):
# Your code here
# Test Cases
print(nearest_smaller... | 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": "",
"prompt_id": "00006742",
"row_id": 6742,
"seed_ids": "[11487]"
} | 0.732541 | Evol_6742 | I | [
"is_prime",
"nearest_smaller_prime"
] | 2 | [
[
"nearest_smaller_prime",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | bd2c37d362e0642693571ad988208df702e03496 | 0187c78663483f51f235cd76ffd4110fff0cfd95 | |||
v1.0 | instruct | Evol | Evol_6746_I | Write a Python program that will take a CSV file containing product sales data and analyze the data to identify sales patterns. The program should be able to perform the following tasks:
1. Parse the CSV file and store the data in an appropriate data structure.
2. Calculate and display the total sales for each product... | import csv
from collections import defaultdict
import matplotlib.pyplot as plt
from datetime import datetime
def parse_csv(file_path):
sales_data = defaultdict(lambda: defaultdict(int))
try:
with open(file_path, newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in... | import pytest
from solution import parse_csv, calculate_total_sales, product_with_highest_sales, analyze_sales
def setup_module(module):
# Create a sample CSV file for testing purposes
csv_content = """Product,Date,Quantity,Price
ProductA,2023-01-15,10,20
ProductB,2023-01-17,5,30
ProductA,2023-02-03,8,20
Produ... | [
{
"docstring": null,
"function_declaration": "def parse_csv(file_path):",
"function_name": "parse_csv",
"parameter_list": "(file_path)"
},
{
"docstring": null,
"function_declaration": "def calculate_total_sales(sales_data):",
"function_name": "calculate_total_sales",
"parameter_l... | [
1,
0,
1,
0,
0,
0,
0,
0,
1,
0
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import csv\nfrom collections import defaultdict\nimport matplotlib.pyplot as plt\nfrom datetime import datetime\n\ndef parse_csv(file_path):\n \"\"\"\n Parse... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00006746",
"row_id": 6746,
"seed_ids": "[45823]"
} | 0.723755 | Evol_6746 | I | [
"parse_csv",
"calculate_total_sales",
"product_with_highest_sales",
"plot_monthly_sales_trend",
"analyze_sales"
] | 5 | [
[
"analyze_sales",
"calculate_total_sales"
],
[
"analyze_sales",
"parse_csv"
],
[
"analyze_sales",
"plot_monthly_sales_trend"
],
[
"analyze_sales",
"product_with_highest_sales"
]
] | 4 | [] | false | [] | false | pytest | true | [
"matplotlib"
] | false | bf84a93248dc41ac77c7ebfc5b5c1752db4712ad | bab88b407439c63e2be3c0de09ae60fba647dd3e | |||
v1.0 | instruct | Evol | Evol_6803_I | Write a function in Python that accepts a dictionary of word-frequency pairs and returns a dictionary with the words sorted alphabetically and their frequencies. The function should take care of case-insensitivity, considering 'Apple' and 'apple' as the same word. Additionally, the function should be able to handle pun... | import re
from collections import defaultdict
def normalize_word(word):
"""
Normalize the word by converting it to lowercase and
removing any punctuation.
"""
return re.sub(r'[^\w\s]', '', word).lower()
def sorted_word_frequencies(word_freq_dict):
"""
Accepts a dictionary of word-frequenc... | import pytest
from solution import sorted_word_frequencies, normalize_word
def test_normalize_word():
assert normalize_word("Hello!") == "hello"
assert normalize_word("ApPlE") == "apple"
assert normalize_word("Fruits,") == "fruits"
def test_sorted_word_frequencies_simple():
word_freq_dict = {
... | [
{
"docstring": "Normalize the word by converting it to lowercase and \nremoving any punctuation.",
"function_declaration": "def normalize_word(word):",
"function_name": "normalize_word",
"parameter_list": "(word)"
},
{
"docstring": "Accepts a dictionary of word-frequency pairs and returns a ... | [
1,
1,
1,
0,
1,
1,
1,
1,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import re\n\ndef normalize_word(word):\n \"\"\"\n Normalize the word by making it lowercase and removing punctuation.\n \"\"\"\n return re.sub(r'\\W+',... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006803",
"row_id": 6803,
"seed_ids": "[4808]"
} | 0.660195 | Evol_6803 | I | [
"normalize_word",
"sorted_word_frequencies",
"example"
] | 3 | [
[
"example",
"sorted_word_frequencies"
],
[
"sorted_word_frequencies",
"normalize_word"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | c51ffd1e6f9237c2da2a4567a906a6aea49215c7 | c2e0ab3c75e09343679d62bf46dbe4f426d156de | |||
v1.0 | instruct | Evol | Evol_6811_I | Using the following URL: https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data, download and preprocess the dataset to classify wines into one of three categories according to their origin. Utilize the scikit-learn library to build and evaluate a classification model. Ensure your code handles missing... | import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.impute import SimpleImputer
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
d... | from solution import download_and_preprocess_data, train_and_evaluate_model
def test_preprocess_data():
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data'
X_train, X_test, y_train, y_test = download_and_preprocess_data(url)
# Check if shapes are correct
assert X_train... | [
{
"docstring": null,
"function_declaration": "def download_and_preprocess_data(url):",
"function_name": "download_and_preprocess_data",
"parameter_list": "(url)"
},
{
"docstring": null,
"function_declaration": "def train_and_evaluate_model():",
"function_name": "train_and_evaluate_mo... | [
0,
0,
1,
1,
1,
1,
0,
1,
1,
1
] | 7 | easy | 0.7 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import pandas as pd\nimport numpy as np\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.imput... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00006811",
"row_id": 6811,
"seed_ids": "[43214]"
} | 0.321588 | Evol_6811 | I | [
"download_and_preprocess_data",
"train_and_evaluate_model"
] | 2 | [
[
"train_and_evaluate_model",
"download_and_preprocess_data"
]
] | 1 | [] | false | [] | false | pytest | true | [
"numpy",
"pandas",
"sklearn"
] | false | 64517182a8f1c31c8f054f2bf2fbf7526a663cf4 | 8c41bc7972c158bb2060b954c7c39f7a6fe66a63 | |||
v1.0 | instruct | Evol | Evol_6860_I | Design a program in Python that reads a large text file (e.g., a book) and identifies the frequency of each word. The program should output the ten most common words along with their frequencies. Your solution should efficiently handle memory usage and consider the removal of punctuation and common stop words (e.g., "t... | import re
from collections import Counter
import string
# Define the set of common stop words
STOP_WORDS = set([
"the", "and", "in", "of", "to", "a", "is", "it", "that", "for", "on",
"with", "as", "at", "this", "by", "an", "are", "be", "from", "which",
"or", "we", "can", "not", "all", "one", "have", "has... | from solution import count_word_frequencies, query_word_frequency
def test_count_word_frequencies():
# Set up a mock text file content
mock_text = """This is a test.
This test is an example of text processing.
The aim of this test is to test the counting frequency."""
... | [
{
"docstring": "Remove punctuation and convert text to lowercase.",
"function_declaration": "def clean_text(text):",
"function_name": "clean_text",
"parameter_list": "(text)"
},
{
"docstring": "Count the frequency of each word in the given text file.\nReturns the ten most common words along ... | [
0,
1,
0,
0,
0,
0,
1,
0,
0,
1
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import re\nfrom collections import Counter\n\ndef preprocess_text(text):\n \"\"\"\n Preprocess the text by removing punctuation and common stop words, and co... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006860",
"row_id": 6860,
"seed_ids": "[41720]"
} | 0.780277 | Evol_6860 | I | [
"clean_text",
"count_word_frequencies",
"query_word_frequency"
] | 3 | [
[
"count_word_frequencies",
"clean_text"
],
[
"query_word_frequency",
"clean_text"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | b76762ca6256225277d56215d436f8463236cbd3 | 91714eccc2953af4e1c98269e3f5bdc875b84136 | |||
v1.0 | instruct | Evol | Evol_6885_I | Write a Python program that iterates through all numbers from 1 to 50, and prints the numbers that are both divisible by 3 and are prime numbers. Use a while loop for iteration and ensure that the program only prints numbers meeting both criteria. Avoid using any built-in Python functions like `filter`, `map`, or any m... | def is_prime(n):
"""
Check if a number is prime.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
p = 3
while p * p <= n:
if n % p == 0:
return False
p += 2
return True
def divisible_by_3_and_prime():
... | from solution import is_prime, divisible_by_3_and_prime
def test_is_prime():
assert not is_prime(0)
assert not is_prime(1)
assert is_prime(2)
assert is_prime(3)
assert not is_prime(4)
assert is_prime(5)
assert not is_prime(9)
assert is_prime(11)
def test_divisible_by_3_and_prime():
... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Iterates through numbers from 1 to 50 and prints numbers that are both divisible by 3 and primes.",
"function_declaration": "d... | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is a prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006885",
"row_id": 6885,
"seed_ids": "[30102]"
} | 0.690671 | Evol_6885 | I | [
"is_prime",
"divisible_by_3_and_prime"
] | 2 | [
[
"divisible_by_3_and_prime",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | a54e4a1675ac9f37c68507c0ba2b3cc0778d5c1b | e2ddd3fc6f1804310b3b5dd6422964edfd112dc9 | |||
v1.0 | instruct | Evol | Evol_6892_I | 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 ranges and optimize for performanc... | 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": "",
"prompt_id": "00006892",
"row_id": 6892,
"seed_ids": "[3897]"
} | 0.63395 | Evol_6892 | I | [
"is_prime",
"count_primes_in_range"
] | 2 | [
[
"count_primes_in_range",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6825958e0c9b03ee09583d7875e18ea91282e1ae | 69c17f915cc7d10a8faf22e208254da77340c7c8 | |||
v1.0 | instruct | Evol | Evol_6906_I | Write a Python function that takes a list of integers as input and returns a new list containing only the prime numbers from the input list. Additionally, the function should sort these prime numbers in descending order. Provide a piece of erroneous code as a reference and ask for its correction along with an explanati... | def is_prime(n):
"""
Check if a number is a prime number.
"""
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def filter_and_sort_primes(input_list):
"""
Filters the prime numbers from the input list and ret... | from solution import filter_and_sort_primes
def test_filter_and_sort_primes_with_primes():
assert filter_and_sort_primes([10, 3, 5, 7, 9, 11, 2]) == [11, 7, 5, 3, 2]
def test_filter_and_sort_primes_mixed_numbers():
assert filter_and_sort_primes([10, 4, 16, 20, 25, 33, 18]) == []
def test_filter_and_sort_prim... | [
{
"docstring": "Check if a number is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Filters the prime numbers from the input list and returns them sorted in descending order.\n\nParameters:\ninput_list (li... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Determines if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00006906",
"row_id": 6906,
"seed_ids": "[34643]"
} | 0.492375 | Evol_6906 | I | [
"is_prime",
"filter_and_sort_primes"
] | 2 | [
[
"filter_and_sort_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4bf197822266f9022b00b3f795811b4f6dfbd36d | 3fee9ec9365418aa3ba4b10d0bfaffa1cd2d7e9d | |||
v1.0 | instruct | Evol | Evol_6925_I | Develop a Python program that determines if a given string is a palindrome. A palindrome is a sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). For instance, the strings "A man, a plan, a canal, Panama!" and "Was it a car or a cat I saw?" are palindromes... | import re
def clean_string(s):
"""
Removes non-alphanumeric characters and converts the string to lowercase.
"""
cleaned = re.sub(r'[^a-zA-Z0-9]', '', s)
return cleaned.lower()
def is_palindrome(s):
"""
Returns True if the processed string is a palindrome, False otherwise.
"""
clea... | from solution import clean_string, is_palindrome, is_palindrome_substrings
def test_clean_string():
assert clean_string("A man, a plan, a canal, Panama!") == "amanaplanacanalpanama"
assert clean_string("Was it a car or a cat I saw?") == "wasitacaroracatisaw"
def test_is_palindrome():
assert is_palindrome(... | [
{
"docstring": "Removes non-alphanumeric characters and converts the string to lowercase.",
"function_declaration": "def clean_string(s):",
"function_name": "clean_string",
"parameter_list": "(s)"
},
{
"docstring": "Returns True if the processed string is a palindrome, False otherwise.",
... | [
1,
1,
0,
1,
0,
1,
0,
0,
0,
0
] | 4 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import re\n\ndef clean_string(s):\n \"\"\"\n Removes non-alphanumeric characters from the string and converts it to lowercase.\n \"\"\"\n return re.sub... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00006925",
"row_id": 6925,
"seed_ids": "[18687]"
} | 0.7754 | Evol_6925 | I | [
"clean_string",
"is_palindrome",
"is_palindrome_substrings"
] | 3 | [
[
"is_palindrome",
"clean_string"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0488c98ba3f9f5a6f3585f17b453659910dac130 | 61632f2cb4116d1cddb59d01603aec2ba3ef0511 | |||
v1.0 | instruct | Evol | Evol_6973_I | Write a Python function that receives a list of integers and a key integer K (1 ≤ K ≤ 100) as input, and returns a new list that contains only those integers from the original list that are divisible by K. Your function should also create an input validation function that checks if the provided list contains valid inte... | def is_valid_input(numbers, K):
"""
Validates the input to check if `numbers` is a list of integers and `K` is an integer within the range 1 to 100.
"""
if not isinstance(numbers, list):
return False
if not all(isinstance(num, int) for num in numbers):
return False
if not isinsta... | import pytest
from solution import filter_divisible
def test_filter_divisible_valid_input():
assert filter_divisible([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]
assert filter_divisible([10, 15, 20, 25, 30], 5) == [10, 15, 20, 25, 30]
assert filter_divisible([], 3) == []
def test_filter_divisible_with_no_multiples... | [
{
"docstring": "Validates the input to check if `numbers` is a list of integers and `K` is an integer within the range 1 to 100.",
"function_declaration": "def is_valid_input(numbers, K):",
"function_name": "is_valid_input",
"parameter_list": "(numbers, K)"
},
{
"docstring": "Returns a new l... | [
1,
1,
1,
0,
1,
1,
1,
1,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def filter_divisible(nums, K):\n \"\"\"\n Returns a new list containing only those integers from the nums list that are divisible by K.\n \"\"\"\n # Ca... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006973",
"row_id": 6973,
"seed_ids": "[39156]"
} | 0.712894 | Evol_6973 | I | [
"is_valid_input",
"filter_divisible"
] | 2 | [
[
"filter_divisible",
"is_valid_input"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0c9fddb909eb63a6df964d01d774f3636997c20e | 12f43f963d00d945e05f1db256ad2a471d7e2453 | |||
v1.0 | instruct | Evol | Evol_6984_I | Write a Python function that accepts a dictionary where the keys are strings and the values are integers or lists of integers (which can also contain nested lists up to two levels). The function should return a new dictionary where each key maps to the sum of all integers (including nested ones) associated with that ke... | def sum_nested_elements(nested_list):
"""
Helper function to sum all integers in a nested list structure.
It can contain nested lists up to two levels.
"""
total_sum = 0
for element in nested_list:
if isinstance(element, int):
total_sum += element
elif isinstance(elem... | from solution import sum_dictionary_values
def test_single_integers():
assert sum_dictionary_values({'a': 5, 'd': 7}) == {'a': 5, 'd': 7}
def test_nested_lists():
assert sum_dictionary_values({'b': [3, 4, [1, 2]], 'c': [2, [3, 4]]}) == {'b': 10, 'c': 9}
def test_mixed_values():
assert sum_dictionary_valu... | [
{
"docstring": "Helper function to sum all integers in a nested list structure.\nIt can contain nested lists up to two levels.",
"function_declaration": "def sum_nested_elements(nested_list):",
"function_name": "sum_nested_elements",
"parameter_list": "(nested_list)"
},
{
"docstring": "Retur... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def sum_nested_integers(input_dict):\n \"\"\"\n Given a dictionary where the keys are strings and the values are integers or lists of integers \n (which c... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00006984",
"row_id": 6984,
"seed_ids": "[38669]"
} | 0.612236 | Evol_6984 | I | [
"sum_nested_elements",
"sum_dictionary_values"
] | 2 | [
[
"sum_dictionary_values",
"sum_nested_elements"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8dd9b514e3fe2a5e752fdc9252629f35969ba23a | 599fb1cab511d229a6ff0a2b7e327e6978fb0003 | |||
v1.0 | instruct | Evol | Evol_7036_I | 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.
Example input: [11, 4, 5, 17, 11, 18, 5, 23]
Example output: [11, 5, 17, 23] | 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": "",
"prompt_id": "00007036",
"row_id": 7036,
"seed_ids": "[4363]"
} | 0.601137 | Evol_7036 | I | [
"is_prime",
"filter_unique_primes"
] | 2 | [
[
"filter_unique_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e4286152b8279277fa84191502dec31434d0e66c | 6761efa89961b897879cbd46474e8d6e97311917 | |||
v1.0 | instruct | Evol | Evol_7056_I | Implement a function in Python that takes a list of integers and returns a new list containing only the prime numbers from the original list. Do not use any built-in functions that directly check for prime numbers. Instead, write your own logic to determine if a number is prime.
### Example
Input:
```
[2, 3, 4, 5, ... | def is_prime(n):
"""
Returns True if n is a prime number, otherwise False.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
i = 3
while i * i <= n:
if n % i == 0:
return False
i += 2
return True
def fi... | from solution import is_prime, filter_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(10) == False
assert is_prime(11) == True
assert is_prime(1) == False
assert is_prime(0) == False... | [
{
"docstring": "Returns True if n is a prime number, otherwise False.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime numbers from the given list `numbers`.",
"function_declaration": "def filter... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00007056",
"row_id": 7056,
"seed_ids": "[1940]"
} | 0.751562 | Evol_7056 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8b761439f0dec87cee4945742a8518a20d89f86c | 0898f822939817b6d52906b08e999df3384fe13c | |||
v1.0 | instruct | Evol | Evol_7078_I | Write a function that takes a list of integers as input and returns a list containing only the prime numbers from the input list. The function should handle both positive and negative numbers, and zero. For example, for the input [-3, 2, 4, 5, 8, -11, 13, 0], the output should be [2, 5, 13]. | def is_prime(n):
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
max_divisor = int(n**0.5) + 1
for d in range(3, max_divisor, 2):
if n % d == 0:
return False
return True
def filter_primes(numbers):
"""
Returns a list... | from solution import is_prime, filter_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(0) == False
assert is_prime(-3) == False
assert is_prime(-11) == False
def test_filter_primes():
... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime numbers from the given list of integers.",
"function_declaration": "def filter_primes(numbers):",
"function_name": "filter_... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007078",
"row_id": 7078,
"seed_ids": "[39154]"
} | 0.6452 | Evol_7078 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7a2d334ffa3a28de41f88564d2cf0a5d0a01f515 | f130da216edd2031fa3849630d29729b1af04179 | |||
v1.0 | instruct | Evol | Evol_7097_I | 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. If the input list is empty or contains no prime numbers, the function should return an empty list.
Example:
```python
input_list = [2, 3, 4, 5, 6, 7, 8, 9, 10]
output_list = extract_pri... | def is_prime(n):
"""
Check if a number is prime.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
p = 3
while p * p <= n:
if n % p == 0:
return False
p += 2
return True
def extract_primes(numbers):
... | from solution import extract_primes
def test_extract_primes_basic():
assert extract_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7]
def test_extract_primes_with_negatives_and_zero():
assert extract_primes([-10, -2, 0, 1, 2, 3, 4, 5, 6]) == [2, 3, 5]
def test_extract_primes_empty_list():
assert e... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime numbers from the given list.",
"function_declaration": "def extract_primes(numbers):",
"function_n... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00007097",
"row_id": 7097,
"seed_ids": "[47680]"
} | 0.656428 | Evol_7097 | I | [
"is_prime",
"extract_primes"
] | 2 | [
[
"extract_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 550ce0f5a18aedce3455d49cbee06709e63f6167 | 0db1278a081d433062a8b3a4cb2416fae9446035 | |||
v1.0 | instruct | Evol | Evol_7098_I | 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 will always be 2: 1 and the num... | 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": "",
"prompt_id": "00007098",
"row_id": 7098,
"seed_ids": "[34200]"
} | 0.725201 | Evol_7098 | I | [
"is_prime",
"find_primes_in_range"
] | 2 | [
[
"find_primes_in_range",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 70967378b5d1699dafdff4ed7a2e924ff7a4cfc6 | ee0ceb165f97ad804fcbd3522d366d2c853a6ce6 | |||
v1.0 | instruct | Evol | Evol_7126_I | 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. For example, given the list `... | 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": "",
"prompt_id": "00007126",
"row_id": 7126,
"seed_ids": "[3569]"
} | 0.751471 | Evol_7126 | I | [
"can_construct",
"longest_concatenated_word"
] | 2 | [
[
"longest_concatenated_word",
"can_construct"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6893660ee48d0d79b2024ad6c215da27b41d7d8b | 8087bb474262bf8192fb94f7044aa8ac1983f5d1 | |||
v1.0 | instruct | Evol | Evol_7131_I | Create a function that accepts a list of integers and returns a new list containing only the elements that are prime numbers. For this purpose, a prime number is defined as an integer greater than 1 that has no positive divisors other than 1 and itself. | 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(lst):
"""
Returns a l... | 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_mixed_numbers():
assert filter_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 3, 5, 7, 11]
def test_filter_primes_no_primes():
assert filter_primes... | [
{
"docstring": "Check if a number is prime",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list containing only the prime numbers from the input list.\n\n:param lst: List of integers\n:return: List of prime integ... | [
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_8 | {
"original_instruction": "",
"prompt_id": "00007131",
"row_id": 7131,
"seed_ids": "[41370]"
} | 0.622595 | Evol_7131 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 42f53803fda66bb038e8c497372f65c01127db1e | 1f99a3045effe4593f0c9d457cdc7af8229fbffb | |||
v1.0 | instruct | Evol | Evol_7141_I | Design a software module that implements a caching mechanism for the factorial of large numbers. The module should be capable of computing and storing factorized results of numbers up to 100,000! to prevent redundant calculations. Ensure your implementation is optimized for both time and space complexity, using memoiza... | import functools
import math
import pickle
from typing import List
import threading
import os
import time
CACHE_FILE = 'factorial_cache.pkl'
CACHE_EXPIRATION = 3600 # 1 hour in seconds
# Create a lock for thread-safe operations
lock = threading.Lock()
# Load cache from file if it exists and not expired
def load_cac... | from solution import factorial_with_caching, factorial_multiple_queries
import pytest
def test_factorial_with_caching():
assert factorial_with_caching(0) == 1
assert factorial_with_caching(1) == 1
assert factorial_with_caching(5) == 120
assert factorial_with_caching(10) == 3628800
def test_factorial_w... | [
{
"docstring": null,
"function_declaration": "def load_cache():",
"function_name": "load_cache",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def save_cache(cache):",
"function_name": "save_cache",
"parameter_list": "(cache)"
},
{
"docstring": n... | [
1,
1,
0,
0,
1,
0,
0,
0,
0,
1
] | 4 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import functools\nimport os\nimport pickle\nimport time\nfrom typing import List\n\nCACHE_FILE = \"factorial_cache.pkl\"\nCACHE_TIMEOUT = 3600 # seconds\n\n\nclas... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007141",
"row_id": 7141,
"seed_ids": "[41279]"
} | 0.565057 | Evol_7141 | I | [
"load_cache",
"save_cache",
"factorial_with_caching",
"factorial_multiple_queries"
] | 4 | [
[
"factorial_multiple_queries",
"factorial_with_caching"
],
[
"factorial_with_caching",
"save_cache"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 65190f380404a5ae7d3a660a5522a6d929aeb4c1 | 14e83a0d5a8dbe59c1170515e7df1ca423a01464 | |||
v1.0 | instruct | Evol | Evol_7155_I | You are given a dataset of historical weather data with various attributes such as temperature, humidity, wind speed, and date taken for different cities. Your task is to write a Python script that achieves the following objectives:
1. Parse the dataset and load it into an appropriate data structure.
2. Calculate the ... | import pandas as pd
import matplotlib.pyplot as plt
def load_weather_data(file_path):
"""
Load weather data from a CSV file.
"""
return pd.read_csv(file_path)
def preprocess_data(data):
"""
Preprocess data by parsing dates and handling missing/incomplete data.
"""
data['date'] = pd.to_... | import pandas as pd
from io import StringIO
from solution import load_weather_data, preprocess_data, calculate_monthly_statistics, identify_extreme_cities, analyze_weather_data
def test_load_weather_data():
data = "date,city,temperature\n2023-01-01,CityA,30\n2023-01-02,CityA,25"
df = load_weather_data(StringIO... | [
{
"docstring": "Load weather data from a CSV file.",
"function_declaration": "def load_weather_data(file_path):",
"function_name": "load_weather_data",
"parameter_list": "(file_path)"
},
{
"docstring": "Preprocess data by parsing dates and handling missing/incomplete data.",
"function_de... | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
1
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import pandas as pd\nimport matplotlib.pyplot as plt\n\ndef load_dataset(file_path):\n \"\"\"\n Loads the weather dataset from a specified file path into a p... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007155",
"row_id": 7155,
"seed_ids": "[32007]"
} | 0.676675 | Evol_7155 | I | [
"load_weather_data",
"preprocess_data",
"calculate_monthly_statistics",
"identify_extreme_cities",
"plot_temperature_comparison",
"analyze_weather_data"
] | 6 | [
[
"analyze_weather_data",
"calculate_monthly_statistics"
],
[
"analyze_weather_data",
"identify_extreme_cities"
],
[
"analyze_weather_data",
"load_weather_data"
],
[
"analyze_weather_data",
"plot_temperature_comparison"
],
[
"analyze_weather_data",
"preprocess... | 5 | [] | false | [] | false | pytest | true | [
"matplotlib",
"pandas"
] | false | 78d5bd8fc29cfab415cabf39f672bfef480882a4 | 7f1b851bcc12a0390429c79cb95e2852a2f95f72 | |||
v1.0 | instruct | Evol | Evol_7169_I | Develop a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Implement the function in Python and ensure it is optimized for performance. Test your function with a variety of inputs, including edge cases such as empty lists, lists with no prime number... | def is_prime(num):
if num < 2:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
def filter_primes(numbers):
return [num for num in numbers if is_prime(num)] | from solution import filter_primes
def test_empty_list():
assert filter_primes([]) == []
def test_no_primes():
assert filter_primes([0, 1, -1, -2, 4, 6, 8, 9, 10]) == []
def test_all_primes():
assert filter_primes([2, 3, 5, 7, 11, 13, 17]) == [2, 3, 5, 7, 11, 13, 17]
def test_mixed_numbers():
assert... | [
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def filter_primes(numbers):",
"function_name": "filter_primes",
"parameter_list": "(numbers)"
}
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "from math import isqrt\n\ndef is_prime(num):\n \"\"\"\n Checks if a number is a prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00007169",
"row_id": 7169,
"seed_ids": "[20143]"
} | 0.586979 | Evol_7169 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 852a2d91c5397d0212cd4f5ee6714f682354637b | 3ac1b269dba6b03cb3a1325715602245e4c6fe43 | |||
v1.0 | instruct | Evol | Evol_7180_I | Write a function that takes a list of integers as input and returns a subset of the list consisting of elements that are prime numbers. Additionally, the subset should be in descending order. For example, given the input list [10, 3, 7, 4, 11, 20], the output should be [11, 7, 3]. | def is_prime(n):
"""
Helper function to check if a number is prime.
"""
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def get_prime_subset(nums):
"""
Returns a subset of the input list consisting of prime ... | from solution import get_prime_subset
def test_get_prime_subset_mixed_numbers():
assert get_prime_subset([10, 3, 7, 4, 11, 20]) == [11, 7, 3]
def test_get_prime_subset_all_primes():
assert get_prime_subset([2, 3, 5, 7, 11]) == [11, 7, 5, 3, 2]
def test_get_prime_subset_no_primes():
assert get_prime_subse... | [
{
"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 subset of the input list consisting of prime elements in descending order.",
"function_declaratio... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is a prime number\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007180",
"row_id": 7180,
"seed_ids": "[48117]"
} | 0.598135 | Evol_7180 | I | [
"is_prime",
"get_prime_subset"
] | 2 | [
[
"get_prime_subset",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 1db60703bb059f99c9614fb7bb1f059e74e5a7c2 | 884936b2d6c89bdda0dd4cfb122477c543d4f2f9 | |||
v1.0 | instruct | Evol | Evol_7189_I | Design an algorithm for a stock trading strategy analysis using the Moving Average Convergence Divergence (MACD) indicator. Your solution should include functions for reading historical stock price data from a CSV file, calculating both the MACD line and the signal line, and finally, generating buy or sell signals base... | import pandas as pd
def read_stock_data(file_path):
"""Reads historical stock price data from a CSV file."""
return pd.read_csv(file_path)
def calculate_macd(data, short_window=12, long_window=26, signal_window=9):
"""Calculates the MACD line and the signal line."""
data['EMA12'] = data['Close'].ewm(s... | import pandas as pd
import numpy as np
from io import StringIO
# Mock data to simulate historical stock price data
mock_data = """
Date,Close
2023-01-01,150
2023-01-02,152
2023-01-03,151
2023-01-04,153
2023-01-05,155
2023-01-06,157
2023-01-07,158
2023-01-08,160
2023-01-09,159
2023-01-10,158
2023-01-11,157
2023-01-12,1... | [
{
"docstring": "Reads historical stock price data from a CSV file.",
"function_declaration": "def read_stock_data(file_path):",
"function_name": "read_stock_data",
"parameter_list": "(file_path)"
},
{
"docstring": "Calculates the MACD line and the signal line.",
"function_declaration": "... | [
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 pandas as pd\n\ndef read_stock_data(file_path):\n \"\"\"\n Reads historical stock price data from a CSV file.\n :param file_path: Path to the CSV f... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00007189",
"row_id": 7189,
"seed_ids": "[31582]"
} | 0.451192 | Evol_7189 | I | [
"read_stock_data",
"calculate_macd",
"generate_signals",
"analyze_stock"
] | 4 | [
[
"analyze_stock",
"calculate_macd"
],
[
"analyze_stock",
"generate_signals"
],
[
"analyze_stock",
"read_stock_data"
]
] | 3 | [] | false | [] | false | pytest | false | [
"numpy",
"pandas"
] | false | 4b380784c641fac4f3fd8fc2736c86f1f80dad2f | d8d0e93cceb145303cc64fefcf27644ae3b3050e | |||
v1.0 | instruct | Evol | Evol_7213_I | Implement a function in Python that takes a list of integers and returns a new list containing only the prime numbers from the original list. Your function should efficiently check for primes and should preserve the order of the numbers from the initial list.
Example:
```python
Input: [3, 4, 7, 10, 17]
Output: [3, 7, ... | def is_prime(n):
"""
Check if a number is a prime number.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n ** 0.5) + 1, 2):
if n % i == 0:
return False
return True
def filter_primes(numbers... | from solution import is_prime, filter_primes
# Tests for is_prime function
def test_is_prime_with_prime_numbers():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(5) == True
assert is_prime(17) == True
def test_is_prime_with_non_prime_numbers():
assert is_prime(1) == False
... | [
{
"docstring": "Check if a number is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Filter and return a list of prime numbers from the given list.",
"function_declaration": "def filter_primes(numbers):... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00007213",
"row_id": 7213,
"seed_ids": "[38108]"
} | 0.676212 | Evol_7213 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 85f3075c3fcf5b10ededbfa484add081a20996f5 | 0d852cde3ec9af868af0fead5ff40066f8d996cb | |||
v1.0 | instruct | Evol | Evol_7247_I | Write a Python function that takes a single integer input `n` and returns a list of the first `n` prime numbers. Prime numbers are integers greater than 1 that have no positive divisors other than 1 and themselves. Make sure the function handles edge cases appropriately, such as when `n` is less than or equal to 0. | def is_prime(num):
"""Helper function to determine if a number is prime."""
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while (i * i) <= num:
if num % i == 0 or num % (i + 2) == 0:
return False... | from solution import first_n_primes
def test_first_n_primes_zero():
assert first_n_primes(0) == []
def test_first_n_primes_negative():
assert first_n_primes(-5) == []
def test_first_n_primes_one():
assert first_n_primes(1) == [2]
def test_first_n_primes_five():
assert first_n_primes(5) == [2, 3, 5, ... | [
{
"docstring": "Helper function to determine if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns a list of the first n prime numbers.\n\nParameters:\nn (int): The number of prime numbers to ge... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00007247",
"row_id": 7247,
"seed_ids": "[27080]"
} | 0.722833 | Evol_7247 | I | [
"is_prime",
"first_n_primes"
] | 2 | [
[
"first_n_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 9ba6634a5a8135a0bf0454e6e80b9aa1fe7724a6 | 82c018eeeb0dfe7855d4092910ccecd6e6dcc722 | |||
v1.0 | instruct | Evol | Evol_7253_I | In a software simulation of a wildlife habitat, you need to model the movement of various animals. Implement a system that tracks and updates animals' positions within a two-dimensional space. Each animal has a type, an initial position, and a movement pattern. Your task is to implement the function `track_animal_movem... | class Animal:
def __init__(self, type: str, position: tuple, movement: tuple):
self.type = type
self.position = position
self.movement = movement
def move_animal(animal: Animal):
"""Helper function to update the animal's position based on its movement pattern."""
new_x = animal.posi... | from solution import Animal, track_animal_movements, move_animal
def test_move_animal():
deer = Animal(type="deer", position=(0, 0), movement=(1, 0))
assert move_animal(deer) == (1, 0)
rabbit = Animal(type="rabbit", position=(2, 1), movement=(0, 1))
assert move_animal(rabbit) == (2, 2)
def test_t... | [] | [
0,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "class Animal:\n def __init__(self, type: str, position: tuple, movement: tuple):\n self.type = type\n self.position = position\n self.movem... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007253",
"row_id": 7253,
"seed_ids": "[27070]"
} | 0.536487 | Evol_7253 | I | [
"move_animal",
"track_animal_movements"
] | 2 | [
[
"track_animal_movements",
"move_animal"
]
] | 1 | [] | false | [
"Animal"
] | true | pytest | true | [] | true | 77d84eba250efb8dece0deb7c0e94e6d58db2828 | 77fc8296f52d209b0c0ba055aef219fbe02156d2 | |||
v1.0 | instruct | Evol | Evol_7254_I | 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 clusters using the elbow method... | 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": "",
"prompt_id": "00007254",
"row_id": 7254,
"seed_ids": "[25888]"
} | 0.570513 | Evol_7254 | I | [
"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 | 7e7b80bccab0844d0ce3b98a1c4133ffeba9c119 | 7665c5ab79698e3fb86388540a5a6c2bd149d81b | |||
v1.0 | instruct | Evol | Evol_7259_I | Write a function in Python that takes a list of integers and an integer threshold as inputs and returns a new list containing only the elements from the original list that are greater than the given threshold. Your function should handle edge cases such as an empty list or a threshold that none of the elements meet. Ad... | def filter_greater_than_threshold(lst, threshold):
"""
Returns a list containing only the elements from lst that are greater than threshold.
Parameters:
lst (list): List of integers
threshold (int): The threshold integer
Returns:
list: New list with elements greater than threshold
... | from solution import filter_greater_than_threshold, validate_inputs
import pytest
def test_filter_greater_than_threshold():
assert filter_greater_than_threshold([1, 2, 3, 4, 5], 3) == [4, 5]
def test_filter_greater_than_threshold_with_empty_list():
assert filter_greater_than_threshold([], 3) == []
def test_f... | [
{
"docstring": "Returns a list containing only the elements from lst that are greater than threshold.\n\nParameters:\nlst (list): List of integers\nthreshold (int): The threshold integer\n\nReturns:\nlist: New list with elements greater than threshold",
"function_declaration": "def filter_greater_than_thres... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def filter_greater_than_threshold(numbers, threshold):\n \"\"\"\n Filters elements in the list greater than the given threshold.\n\n :param numbers: List ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007259",
"row_id": 7259,
"seed_ids": "[39156]"
} | 0.812916 | Evol_7259 | I | [
"filter_greater_than_threshold",
"validate_inputs"
] | 2 | [
[
"filter_greater_than_threshold",
"validate_inputs"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2e5da9d9b3903a9b80a0ab35ce64eecf8a534345 | 77f7e70103568c8086877480227fc12e1ae03866 | |||
v1.0 | instruct | Evol | Evol_7277_I | Create a Python function that takes a list of integers and returns a list of tuples, where each tuple contains two elements: the original integer and its factorial. You are not allowed to use any Python built-in functions or libraries for the factorial calculation. Additionally, add appropriate comments to explain your... | def calculate_factorial(n):
"""
Manually computes the factorial of a given integer n.
If n is negative, returns None as the factorial of a negative number is undefined.
"""
if n < 0:
return None
factorial = 1
for i in range(2, n + 1):
factorial *= i
return factorial
def ... | from solution import calculate_factorial, list_integers_with_factorial
def test_calculate_factorial():
assert calculate_factorial(0) == 1
assert calculate_factorial(1) == 1
assert calculate_factorial(5) == 120
assert calculate_factorial(10) == 3628800
assert calculate_factorial(-3) == None
def tes... | [
{
"docstring": "Manually computes the factorial of a given integer n.\nIf n is negative, returns None as the factorial of a negative number is undefined.",
"function_declaration": "def calculate_factorial(n):",
"function_name": "calculate_factorial",
"parameter_list": "(n)"
},
{
"docstring":... | [
1,
1,
1,
1,
1,
1,
0,
1,
0,
1
] | 8 | easy | 0.8 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def calculate_factorial(n):\n \"\"\"\n Computes the factorial of a non-negative integer n.\n For negative integers, returns None.\n \"\"\"\n if n < ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007277",
"row_id": 7277,
"seed_ids": "[20376]"
} | 0.705338 | Evol_7277 | I | [
"calculate_factorial",
"list_integers_with_factorial"
] | 2 | [
[
"list_integers_with_factorial",
"calculate_factorial"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b884e460bbfd982ef82923ccedef194ab5d78123 | 4484fec19eeca8cf65ca29ccf29d73fa80281ab4 | |||
v1.0 | instruct | Evol | Evol_7289_I | Write a function in Python that takes a list of strings and a target string, and returns the list of strings sorted by the number of characters they have in common with the target string. Only consider common characters once (even if they occur multiple times in both strings). If two strings have the same number of com... | def count_common_chars(s, target_set):
"""
Counts the number of unique characters in s that are also in the target_set.
"""
return len(set(s) & target_set)
def sort_by_common_chars(strings, target):
"""
Sorts a list of strings based on the number of unique characters they have in common with th... | from solution import sort_by_common_chars
def test_sort_by_common_chars_example_case():
assert sort_by_common_chars(['apple', 'banana', 'pear', 'peach'], 'pale') == ['apple', 'pear', 'peach', 'banana']
def test_sort_by_common_chars_empty_list():
assert sort_by_common_chars([], 'pale') == []
def test_sort_by_... | [
{
"docstring": "Counts the number of unique characters in s that are also in the target_set.",
"function_declaration": "def count_common_chars(s, target_set):",
"function_name": "count_common_chars",
"parameter_list": "(s, target_set)"
},
{
"docstring": "Sorts a list of strings based on the ... | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def sort_by_common_chars(strings, target):\n def common_chars_count(s1, s2):\n count = 0\n s1_set = set(s1)\n s2_set = set(s2)\n cou... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00007289",
"row_id": 7289,
"seed_ids": "[3429]"
} | 0.644614 | Evol_7289 | I | [
"count_common_chars",
"sort_by_common_chars"
] | 2 | [
[
"sort_by_common_chars",
"count_common_chars"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 40d03e6bcdf31073632c76422d86ceb6e6c7de0b | a53afeba0f6b087ea5a02707f879a19efeb86635 | |||
v1.0 | instruct | Evol | Evol_7303_I | Write a function named `merge_and_sort` that takes two lists of integers as input, merges them into a single list, and returns the merged list sorted in ascending order. You are not allowed to use any built-in sorting functions. Ensure efficiency by leveraging a sorting algorithm such as merge sort or quicksort. Test y... | def merge_and_sort(list1, list2):
"""
Merges two lists and sorts them using merge sort algorithm.
Returns the sorted merged list.
"""
merged_list = list1 + list2
return merge_sort(merged_list)
def merge_sort(lst):
if len(lst) <= 1:
return lst
mid = len(lst) // 2
left_ha... | from solution import merge_and_sort
def test_merge_and_sort_simple_case():
assert merge_and_sort([3, 1, 4], [2, 6, 5]) == [1, 2, 3, 4, 5, 6]
def test_merge_and_sort_with_empty_lists():
assert merge_and_sort([], []) == []
assert merge_and_sort([3, 1, 4], []) == [1, 3, 4]
assert merge_and_sort([], [2, 6... | [
{
"docstring": "Merges two lists and sorts them using merge sort algorithm.\nReturns the sorted merged list.",
"function_declaration": "def merge_and_sort(list1, list2):",
"function_name": "merge_and_sort",
"parameter_list": "(list1, list2)"
},
{
"docstring": null,
"function_declaration"... | [
1,
1,
1,
0,
0,
1,
1,
0,
1,
1
] | 7 | easy | 0.7 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def merge_and_sort(list1, list2):\n \"\"\"\n Merges two lists and returns a new list sorted in ascending order.\n \"\"\"\n merged_list = list1 + list2\... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007303",
"row_id": 7303,
"seed_ids": "[32199]"
} | 0.620846 | Evol_7303 | I | [
"merge_and_sort",
"merge_sort",
"merge"
] | 3 | [
[
"merge_and_sort",
"merge_sort"
],
[
"merge_sort",
"merge"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 65708581067989e66959b26c7e7879fda6b79ae8 | aba7abb379ff6fb66fad773b6df589ff04088acc | |||
v1.0 | instruct | Evol | Evol_7313_I | Create a function that takes a list of integers and returns a new list containing only the integers that are perfect squares, sorted in ascending order. Additionally, your function should count the number of perfect squares identified and append this count as the last element of the returned list.
For example, given ... | import math
def is_perfect_square(n):
if n < 0:
return False
root = int(math.sqrt(n))
return root * root == n
def perfect_squares(lst):
"""
Returns a new list that contains only the perfect squares from the input list,
sorted in ascending order, and appends the count of perfect squares... | from solution import perfect_squares
def test_perfect_squares():
assert perfect_squares([16, 10, 25, 7, 1, 30, 4]) == [1, 4, 16, 25, 4]
assert perfect_squares([49, 50, 51, 52, 9, 3, 2]) == [9, 49, 2]
assert perfect_squares([0, 1, 2, 3, 4, 5]) == [0, 1, 4, 3]
assert perfect_squares([-1, -4, -9, 8, 26, 6... | [
{
"docstring": null,
"function_declaration": "def is_perfect_square(n):",
"function_name": "is_perfect_square",
"parameter_list": "(n)"
},
{
"docstring": "Returns a new list that contains only the perfect squares from the input list,\nsorted in ascending order, and appends the count of perfe... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_perfect_square(n):\n \"\"\"\n Check if a number is a perfect square.\n \"\"\"\n if n < 0:\n return False\n root = int(n**0.5)\n ret... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00007313",
"row_id": 7313,
"seed_ids": "[3194]"
} | 0.638421 | Evol_7313 | I | [
"is_perfect_square",
"perfect_squares"
] | 2 | [
[
"perfect_squares",
"is_perfect_square"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3653d42d15276b1c1a9d438480bac1f23457bb06 | f1a1c7719dcb79cb973f5b2484df01c2fa6816b3 | |||
v1.0 | instruct | Evol | Evol_7314_I | Write a Python program that reads a CSV file containing movie data and performs the following tasks:
- Calculate the average rating of all the movies.
- List the top 10 highest rated movies with their respective ratings.
- Find and list the number of movies released each year.
- Identify and list the 5 most common genr... | 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": "",
"prompt_id": "00007314",
"row_id": 7314,
"seed_ids": "[31021]"
} | 0.519943 | Evol_7314 | I | [
"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 | 02232f894399ed969b1d1ca8adecf93cc4eb4a9d | 801867eeed4609976f161a9e8e4d31d4feb40a13 | |||
v1.0 | instruct | Evol | Evol_7323_I | Your task is to design an algorithm that can read a text document and identify the k most frequently occurring words. The document may contain punctuation and special characters, which should be ignored in the word count. Words are case-insensitive, meaning "Word" and "word" should be considered the same.
Here is what... | import re
from collections import Counter
def clean_text(text):
"""
Takes a string and returns a cleaned version of the string,
where all characters are converted to lowercase,
and all punctuation and special characters are removed.
"""
# Convert to lowercase
text = text.lower()
# Remov... | import pytest
from solution import clean_text, get_word_frequencies, top_k_frequent_words
def test_clean_text():
assert clean_text("Hello, World!") == "hello world"
assert clean_text("Python3.8 is great!") == "python38 is great"
assert clean_text("No special@characters!") == "no specialcharacters"
def tes... | [
{
"docstring": "Takes a string and returns a cleaned version of the string,\nwhere all characters are converted to lowercase,\nand all punctuation and special characters are removed.",
"function_declaration": "def clean_text(text):",
"function_name": "clean_text",
"parameter_list": "(text)"
},
{... | [
1,
1,
1,
0,
0,
0,
0,
1,
0,
0
] | 4 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import re\nfrom collections import Counter\n\ndef clean_text(text):\n \"\"\"\n Cleans the input text by converting to lowercase and removing punctuation and ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00007323",
"row_id": 7323,
"seed_ids": "[3327]"
} | 0.760771 | Evol_7323 | I | [
"clean_text",
"get_word_frequencies",
"top_k_frequent_words"
] | 3 | [
[
"top_k_frequent_words",
"clean_text"
],
[
"top_k_frequent_words",
"get_word_frequencies"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 318673a4569020703dbe07996b1adf48a6d96d51 | 7f9b4b8baa22f1239c4df650213fd203de83aac2 | |||
v1.0 | instruct | Evol | Evol_7329_I | 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 external libraries for prime-checkin... | 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": "",
"prompt_id": "00007329",
"row_id": 7329,
"seed_ids": "[34322]"
} | 0.682943 | Evol_7329 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7051f46dbabce2b1a1fb818a065c40c672761233 | 3beabba17511782fffb2a7b34ade366656d5837a | |||
v1.0 | instruct | Evol | Evol_7341_I | 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:
1. Load the JSON data from a file.
2. Display the number of students.
3. Display the names of students w... | 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": "",
"prompt_id": "00007341",
"row_id": 7341,
"seed_ids": "[35630]"
} | 0.61305 | Evol_7341 | I | [
"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 | 583a5a2d2a3c98dfa36ccf422fec21fb9f271abd | 55f3848bc9661aa3113c4ae72587992f32520941 | |||
v1.0 | instruct | Evol | Evol_7382_I | Write a Python function that processes a CSV file containing user data with columns such as "UserID," "Name," "Email," and "SignupDate." Your function should parse the CSV file and retrieve the top 5 most recent signups. Ensure your function also validates email addresses using a regex pattern to discard any invalid em... | import csv
import re
from datetime import datetime
def is_valid_email(email):
"""
Validates the email address using a regex pattern.
"""
regex = r'^\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
return re.match(regex, email) is not None
def process_csv(input_file, output_file):
"""
P... | import pytest
import os
from solution import process_csv, is_valid_email
def test_is_valid_email():
assert is_valid_email('test@example.com')
assert not is_valid_email('invalid-email')
assert is_valid_email('user.name+tag+sorting@example.com')
assert not is_valid_email('user.name@.com')
def test_proce... | [
{
"docstring": "Validates the email address using a regex pattern.",
"function_declaration": "def is_valid_email(email):",
"function_name": "is_valid_email",
"parameter_list": "(email)"
},
{
"docstring": "Processes the CSV file to retrieve the top 5 most recent signups,\nvalidates emails, an... | [
1,
0,
1,
0,
1,
0,
1,
0,
1,
1
] | 6 | medium | 0.6 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import csv\nimport re\nfrom datetime import datetime\n\ndef process_csv(input_file, output_file):\n \"\"\"\n Processes the CSV file to retrieve the top 5 mos... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007382",
"row_id": 7382,
"seed_ids": "[15966]"
} | 0.616439 | Evol_7382 | I | [
"is_valid_email",
"process_csv"
] | 2 | [
[
"process_csv",
"is_valid_email"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e6596168fa43da31ba48e5ef293bdb75874400de | edfd517808c47388d4b464f7463510dc8edbe976 | |||
v1.0 | instruct | Evol | Evol_7396_I | Design a function to determine if a given string is a rotation of another string. For instance, the string "waterbottle" is a rotation of "erbottlewat". Implement a function `is_rotation(s1: str, s2: str) -> bool` that returns True if `s1` is a rotation of `s2`, and False otherwise. Assume you have a helper function `i... | def is_substring(s1: str, s2: str) -> bool:
return s1 in s2
def is_rotation(s1: str, s2: str) -> bool:
"""
Determines if s2 is a rotation of s1.
:param s1: Original string
:param s2: String to check if it is a rotation of s1
:return: True if s2 is a rotation of s1, False otherwise
"""
... | from solution import is_rotation
def test_is_rotation_positive_cases():
assert is_rotation("waterbottle", "erbottlewat")
assert is_rotation("abcdef", "cdefab")
assert is_rotation("rotation", "tationro")
def test_is_rotation_negative_cases():
assert not is_rotation("abc", "abd")
assert not is_rotat... | [
{
"docstring": null,
"function_declaration": "def is_substring(s1, s2):",
"function_name": "is_substring",
"parameter_list": "(s1, s2)"
},
{
"docstring": "Determines if s2 is a rotation of s1.\n\n:param s1: Original string\n:param s2: String to check if it is a rotation of s1\n:return: True ... | [
1,
1,
1,
0,
1,
1,
0,
1,
0,
0
] | 6 | medium | 0.6 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_substring(s1, s2):\n \"\"\"\n Checks if s1 is a substring of s2.\n \"\"\"\n return s1 in s2\n\ndef is_rotation(s1, s2):\n \"\"\"\n Determi... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00007396",
"row_id": 7396,
"seed_ids": "[13789]"
} | 0.705482 | Evol_7396 | I | [
"is_substring",
"is_rotation"
] | 2 | [
[
"is_rotation",
"is_substring"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b9ec912b57ad912da9d3ad6b0c77dcf5428757d3 | 2f67d81a8de7d8bb2b6b2fdc6b29aa5e79a4fe22 | |||
v1.0 | instruct | Evol | Evol_7454_I | 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:
```python
rotate_list([1, 2, 3, 4, 5, 6, 7], 3) => [5, 6, 7, 1, 2, 3, 4]
r... | 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": "",
"prompt_id": "00007454",
"row_id": 7454,
"seed_ids": "[38393]"
} | 0.699611 | Evol_7454 | I | [
"rotate_list",
"reverse"
] | 2 | [
[
"rotate_list",
"reverse"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | ff2afe6f8019eb431a4cff80f4967f233bfcd77e | 7f1934ecd33410374fc47801b160cfdbdc44db31 | |||
v1.0 | instruct | Evol | Evol_7480_I | Implement a spell checker in Python. The spell checker should take a dictionary of correctly spelled words and a sentence as inputs. It should identify the words in the sentence that are not in the dictionary and suggest corrections. If there is more than one possible correction, it should return the one that has the s... | import numpy as np
def levenshtein_distance(str1, str2):
"""
Returns the Levenshtein distance between str1 and str2.
"""
n, m = len(str1), len(str2)
if n > m:
str1, str2 = str2, str1
n, m = m, n
current_row = range(n + 1)
for i in range(1, m + 1):
previous_row, curr... | from solution import levenshtein_distance, spell_checker
def test_levenshtein_distance():
assert levenshtein_distance("kitten", "sitting") == 3
assert levenshtein_distance("flaw", "lawn") == 2
assert levenshtein_distance("", "") == 0
assert levenshtein_distance("gumbo", "gambol") == 2
def test_spell_c... | [
{
"docstring": "Returns the Levenshtein distance between str1 and str2.",
"function_declaration": "def levenshtein_distance(str1, str2):",
"function_name": "levenshtein_distance",
"parameter_list": "(str1, str2)"
},
{
"docstring": "Identifies misspelled words in the sentence and suggests cor... | [
0,
1,
1,
0,
0,
0,
1,
1,
0,
1
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "from typing import List, Dict\nimport numpy as np\n\ndef levenshtein_distance(s1: str, s2: str) -> int:\n \"\"\"\n Compute the Levenshtein distance between t... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007480",
"row_id": 7480,
"seed_ids": "[32681]"
} | 0.473596 | Evol_7480 | I | [
"levenshtein_distance",
"spell_checker"
] | 2 | [
[
"spell_checker",
"levenshtein_distance"
]
] | 1 | [] | false | [] | false | pytest | true | [
"numpy"
] | false | 972ffe9c510be49196e80c7b57026e762eb31480 | 69b637e1701e8e5351dceb57a48a3608c447427d | |||
v1.0 | instruct | Evol | Evol_7495_I | 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 returning an empty list and a ... | 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": "",
"prompt_id": "00007495",
"row_id": 7495,
"seed_ids": "[25608]"
} | 0.729848 | Evol_7495 | I | [
"is_prime",
"first_n_primes"
] | 2 | [
[
"first_n_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8198bc97a1b844e58ed34f67280cb3b49ac33bf1 | 8fdbae1333f7f3f21140b9d24c49edda5ecb9dd0 | |||
v1.0 | instruct | Evol | Evol_7545_I | Given an unsorted array of integers, write a function to find the "Kth" largest element in the array without using any built-in sorting functions. The function should run in O(n) average time complexity. Discuss the approach and reasoning behind your solution. | def partition(arr, low, high):
pivot = arr[high]
i = low - 1
for j in range(low, high):
if arr[j] >= pivot: # We use >= to arrange in non-increasing order
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
def quicksele... | from solution import find_kth_largest
def test_kth_largest_in_middle():
arr = [3, 2, 1, 5, 6, 4]
assert find_kth_largest(arr, 2) == 5
def test_kth_largest_at_end():
arr = [3, 2, 3, 1, 2, 4, 5, 5, 6]
assert find_kth_largest(arr, 4) == 4
def test_kth_largest_single_element():
arr = [1]
assert f... | [
{
"docstring": null,
"function_declaration": "def partition(arr, low, high):",
"function_name": "partition",
"parameter_list": "(arr, low, high)"
},
{
"docstring": null,
"function_declaration": "def quickselect(arr, low, high, k):",
"function_name": "quickselect",
"parameter_list... | [
1,
1,
1,
0,
1,
1,
1,
1,
1
] | 8 | easy | 0.889 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def partition(arr, low, high):\n pivot = arr[high]\n i = low\n \n for j in range(low, high):\n if arr[j] > pivot: # Note: '>' for finding Kth l... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007545",
"row_id": 7545,
"seed_ids": "[11421]"
} | 0.656793 | Evol_7545 | I | [
"partition",
"quickselect",
"find_kth_largest"
] | 3 | [
[
"find_kth_largest",
"quickselect"
],
[
"quickselect",
"partition"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 49d3212a0ea86cdbb995d8bbe17d0d958fcffeb2 | f3eeaa824ad86f01877a4bce4140d662859efdf4 | |||
v1.0 | instruct | Evol | Evol_7560_I | Write a function that receives a list of strings and returns a new list containing only those strings that are palindromes. A palindrome is a word that reads the same backward as forward, ignoring spaces, punctuation, and case. The function should be insensitive to capitalization and spaces but must handle punctuation ... | import re
def is_palindrome(s):
"""
Checks if the given string is a palindrome, ignoring spaces,
punctuation, and case.
"""
# Using regex to remove non-alphanumeric characters and convert to lowercase
cleaned = re.sub(r'[^A-Za-z0-9]', '', s).lower()
return cleaned == cleaned[::-1]
def filt... | from solution import filter_palindromes
def test_filter_palindromes_single_word():
assert filter_palindromes(["racecar", "hello", "madam"]) == ["racecar", "madam"]
def test_filter_palindromes_with_spaces_and_punctuation():
assert filter_palindromes(["A man, a plan, a canal, Panama", "No lemon, no melon", "Was... | [
{
"docstring": "Checks if the given string is a palindrome, ignoring spaces,\npunctuation, and case.",
"function_declaration": "def is_palindrome(s):",
"function_name": "is_palindrome",
"parameter_list": "(s)"
},
{
"docstring": "Returns a list of strings that are palindromes.",
"function... | [
1,
1,
0,
1,
1,
1,
1,
1,
1,
1
] | 9 | easy | 0.9 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "import re\n\ndef is_palindrome(s):\n \"\"\"\n Checks if the given string is a palindrome, ignoring spaces, punctuation, and case.\n \"\"\"\n # Remove s... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007560",
"row_id": 7560,
"seed_ids": "[15770]"
} | 0.72537 | Evol_7560 | I | [
"is_palindrome",
"filter_palindromes"
] | 2 | [
[
"filter_palindromes",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c3c03a8ecb9e150ba6fc13021ccbd73880bb28b6 | c828a24eae49476d7325ee3b3dba3a8c6fa3e24f | |||
v1.0 | instruct | Evol | Evol_7567_I | Write a program to sort an array of integers such that all prime numbers appear before non-prime numbers, while keeping the relative order of the prime and non-prime numbers the same. The input will be a single line containing integers separated by spaces. Ensure to include input validation to verify that the input con... | def is_prime(num):
"""
Returns True if the given number is prime, otherwise False.
"""
if num <= 1:
return False
if num == 2:
return True # 2 is the only even prime number
if num % 2 == 0:
return False
for i in range(3, int(num**0.5) + 1, 2):
if num % i == 0:... | from solution import is_prime, sort_array, parse_input
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(1) == False
assert is_prime(0) == False
def test_sort_array():
assert sort_array([3, 4, ... | [
{
"docstring": "Returns True if the given number is prime, otherwise False.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Sorts the array such that prime numbers come before non-prime numbers.",
"function_declara... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007567",
"row_id": 7567,
"seed_ids": "[45757]"
} | 0.58387 | Evol_7567 | I | [
"is_prime",
"sort_array",
"parse_input"
] | 3 | [
[
"sort_array",
"is_prime"
]
] | 1 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | d9d825803ed2ce6c74af7d9871bc1d12b1e57929 | e7872611f202e8cce72680d96ec1ffd97e516a9c | |||
v1.0 | instruct | Evol | Evol_7599_I | Design a Python function that takes a list of integers and returns a new list that contains only the prime numbers from the original list. Ensure the solution is efficient by implementing an optimal primality test.
Next, write a unit test for this function using the unittest framework in Python. Your test should cove... | from math import isqrt
def is_prime(n):
"""
Returns True if the number n is a prime number, otherwise False.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i ... | 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": "Returns a list of prime numbers from the given list of integers.",
"function_declaration"... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n 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_3 | {
"original_instruction": "",
"prompt_id": "00007599",
"row_id": 7599,
"seed_ids": "[9546]"
} | 0.625463 | Evol_7599 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 39ab1a9dacf67c7be587f09d75f80e141cb99316 | fd41c58d5bc1ad3b37a5a01fb2632d9bfc4aabc2 | |||
v1.0 | instruct | Evol | Evol_7655_I | Write a function in Python that takes a list of integers as input and returns a new list containing only the prime numbers from the original list. To determine if a number is prime, you should implement a helper function `is_prime()`. Optimize your code for efficiency with respect to both time and space. | def is_prime(n):
"""
Determines if a number n is prime.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
retu... | 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(13) == True
assert is_prime(25) == False
assert is_prime(29) == True
assert is_prime(1) == False
def test_filter_primes_empty_... | [
{
"docstring": "Determines if a number n is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime numbers from the input list.",
"function_declaration": "def filter_primes(numbers):",
"func... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Checks if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n %... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00007655",
"row_id": 7655,
"seed_ids": "[44820]"
} | 0.709748 | Evol_7655 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4ba24c79f1d30147819917473501c6b53385870d | 40ed0e4abf9974fc01134282016cbd0ed2cdc71c | |||
v1.0 | instruct | Evol | Evol_7738_I | 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 prime. Additionally, ensure y... | 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": "",
"prompt_id": "00007738",
"row_id": 7738,
"seed_ids": "[222]"
} | 0.699186 | Evol_7738 | I | [
"is_prime",
"prime_counts"
] | 2 | [
[
"prime_counts",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 07acb4c4b8d2fc5096b825088a15964115fc564d | 75320208ebfb0c5ca3abacadc01c8251737ac48f | |||
v1.0 | instruct | Evol | Evol_7768_I | Write a function that takes a list of timestamps representing the start and end times of various appointments in a 24-hour format "HH:MM". The function should return the total time in minutes when all appointments overlap.
Example:
appointments = [('09:00', '12:30'), ('11:15', '14:00'), ('10:00', '11:45')]
In this ex... | from datetime import datetime
def compute_overlap_minutes(appointments):
"""
Returns the total time in minutes when all appointments overlap.
:param appointments: List of tuples where each tuple is (start_time, end_time)
with time in "HH:MM" 24-hour format.
:return: Total ... | from solution import compute_overlap_minutes
def test_no_overlap():
appointments = [('09:00', '10:00'), ('11:00', '12:00'), ('13:00', '14:00')]
assert compute_overlap_minutes(appointments) == 0
def test_full_overlap():
appointments = [('09:00', '12:00'), ('10:00', '11:00')]
assert compute_overlap_minu... | [
{
"docstring": "Returns the total time in minutes when all appointments overlap.\n\n:param appointments: List of tuples where each tuple is (start_time, end_time)\n with time in \"HH:MM\" 24-hour format.\n:return: Total overlapping time in minutes.",
"function_declaration": "def compute_... | [
0,
1,
0,
0,
0,
0,
0,
0,
1,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "def calculate_overlap_minutes(appointments):\n \"\"\"\n Returns the total time in minutes when all appointments overlap.\n \"\"\"\n from datetime impor... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00007768",
"row_id": 7768,
"seed_ids": "[14604]"
} | 0.563993 | Evol_7768 | I | [
"compute_overlap_minutes",
"convert_to_minutes"
] | 2 | [
[
"compute_overlap_minutes",
"convert_to_minutes"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | ca9d29323b16e92517f3cc2e8b89ede0c34bbfd6 | a124ac78907d890582d865f06d101e48911cedd5 | |||
v1.0 | instruct | Evol | Evol_7774_I | 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 similar to those the user has show... | 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": "",
"prompt_id": "00007774",
"row_id": 7774,
"seed_ids": "[43968]"
} | 0.362404 | Evol_7774 | I | [
"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 | 418b55a4b58d8c7052b298e338ac964ad5408886 | 2056cb0572c22a910ddcc462a5626905e7c27422 | |||
v1.0 | instruct | Evol | Evol_7787_I | 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:
1. Calculate and display each student's average grade.
2. Determine the highe... | 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": "",
"prompt_id": "00007787",
"row_id": 7787,
"seed_ids": "[46997]"
} | 0.699945 | Evol_7787 | I | [
"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 | ae7aefb321067d9115caa7b5a674bb1f80a078a7 | 2190609807c48e526887969e6ad9ed907f0c7427 | |||
v1.0 | instruct | Evol | Evol_7845_I | 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 for prime numbers and correc... | 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": "",
"prompt_id": "00007845",
"row_id": 7845,
"seed_ids": "[17283]"
} | 0.59738 | Evol_7845 | I | [
"is_prime",
"filter_primes_greater_than_10"
] | 2 | [
[
"filter_primes_greater_than_10",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | edf2eb079311cc54d2e32ab876479cd481ad117e | af042be1eb75e58d8f9b57c345b59c88a4e08494 | |||
v1.0 | instruct | Evol | Evol_7849_I | 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 and negative integers, ignoring... | 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": "",
"prompt_id": "00007849",
"row_id": 7849,
"seed_ids": "[34974]"
} | 0.621886 | Evol_7849 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0e624287d07ada0a3d2854aca48d52ab3360b20f | fbb7b85588f2c063109e25de0863a89c9e6f2152 | |||
v1.0 | instruct | Evol | Evol_7978_I | Create a 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 number greater than 1 that has no positive divisors other than 1 and itself. Write a function `filter_primes(numbers: List[int]) -> List[int]` that accomplishes this.
###... | from typing import List
def is_prime(n: int) -> bool:
"""
Helper function to check if a number is prime.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return Fa... | from solution import filter_primes
def test_filter_primes_mixed_numbers():
assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7]
def test_filter_primes_no_primes():
assert filter_primes([4, 6, 8, 10, 15, 22]) == []
def test_filter_primes_all_primes():
assert filter_primes([2, 3, 5, 7, 11, 13... | [
{
"docstring": "Helper function to check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime numbers from the given list of integers.",
"function_declaration": "def filter_prim... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 10 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_evol-i2i_10000_1735980704_sanitized_prepared_0_results_combined.jsonl",
"solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n re... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00007978",
"row_id": 7978,
"seed_ids": "[1417]"
} | 0.647561 | Evol_7978 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 262cc5eb4daa442cd2c36ceec56e4a95e795ff31 | 2652809d8f8da88fd8937770295840a2df87a838 | |||
v1.0 | instruct | Evol | Evol_8000_I | # Task: Create a Data Analysis Pipeline
## Context
You 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 through data-driven decisions. Use the... | 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": "",
"prompt_id": "00008000",
"row_id": 8000,
"seed_ids": "[11198]"
} | 0.675552 | Evol_8000 | I | [
"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 | f1af4520a3935d23b15617bbd7dd5d0e1e0515bd | 83d43b9ec84bd424d3e869e7dea4d6f702ca5f7d | |||
v1.0 | instruct | Evol | Evol_8019_I | 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. | 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": "",
"prompt_id": "00008019",
"row_id": 8019,
"seed_ids": "[20819]"
} | 0.671053 | Evol_8019 | I | [
"is_prime",
"filter_and_sort_primes"
] | 2 | [
[
"filter_and_sort_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7de0d7fceafba4dc18ea064d1cf5d2d01709b478 | 62ce5afc53f1dd7512aa5455e57e4071b597b6a1 | |||
v1.0 | instruct | Evol | Evol_8049_I | 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 for large inputs.
Example:
In... | 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": "",
"prompt_id": "00008049",
"row_id": 8049,
"seed_ids": "[20404]"
} | 0.694625 | Evol_8049 | I | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c9682bd9be909abb1f7cb7e75eed7ed6b5fab168 | 8cd34f1e9c06560ae183384710c6f5e2d07a1ac8 | |||
v1.0 | instruct | Evol | Evol_8092_I | 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. | 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": "",
"prompt_id": "00008092",
"row_id": 8092,
"seed_ids": "[36215]"
} | 0.790855 | Evol_8092 | I | [
"is_palindrome",
"filter_palindromes"
] | 2 | [
[
"filter_palindromes",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 1fadb8d7dae6c837f4a300352d8965ee4432f746 | 6df7c396ef5a2a9056582e68a098e935e20dca9f | |||
v1.0 | instruct | Evol | Evol_8106_I | 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? | 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": "",
"prompt_id": "00008106",
"row_id": 8106,
"seed_ids": "[43471]"
} | 0.459547 | Evol_8106 | I | [
"apples_kept_by_sarah",
"sarahs_apples"
] | 2 | [
[
"sarahs_apples",
"apples_kept_by_sarah"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 34d45a4504e56482b2ac49b11293a8dbe4a8602a | 5f2572d3bedaaa1b034ad4ae10f4f6411d46e1c7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.