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
Taco
Taco_19574_I
Paula is organizing a coding competition and needs your help to automate the scoring of the participants. Each participant is required to solve a set of problems and should be scored based on the correctness of their solutions and the time they took to complete each problem. The scoring algorithm works as follows: - ...
def calculate_final_scores(participants): final_scores = [] for participant in participants: N, scores, results, times = participant total_score = 0 total_penalty = 0 for i in range(N): if results[i] == 1: total_score += scores[i] ...
from solution import calculate_final_scores, parse_input def test_calculate_final_scores(): participants = [ (3, [100, 200, 150], [1, 0, 1], [120, 0, 75]), (2, [50, 50], [1, 1], [30, 45]), ] expected = [55, 25] assert calculate_final_scores(participants) == expected def test_parse_inpu...
[ { "docstring": null, "function_declaration": "def calculate_final_scores(participants):", "function_name": "calculate_final_scores", "parameter_list": "(participants)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_final_scores(participants_data):\n \"\"\"\n Calculate the final scores for participants based on their problem-solving\n accuracy and time p...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00019574", "row_id": 19574, "seed_ids": "[17528]" }
0.758899
Taco_19574
I
[ "calculate_final_scores", "parse_input", "run" ]
3
[ [ "run", "calculate_final_scores" ], [ "run", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
d2c6e9be070fdc277508f54c97b37622f53be0b3
60d6b93facd7007200797e02a9ec2c6e26795416
v1.0
instruct
Taco
Taco_19607_I
John is a software developer who is interested in ensuring the security of his applications. He decided to implement a feature that checks for weak passwords in a list of password candidates. A password is considered weak if it matches one of the following criteria: 1. It contains fewer than 8 characters. 2. It does n...
import re def is_weak_password(password): """ This function checks if a `password` is weak based on the criteria provided. """ if len(password) < 8: return "Weak" if not re.search(r'[A-Z]', password): return "Weak" if not re.search(r'[a-z]', password): return "Weak" ...
from solution import is_weak_password, check_passwords def test_is_weak_password(): # Test with strong passwords assert is_weak_password("Password1!") == "Strong" assert is_weak_password("Welc0me!") == "Strong" # Test with weak passwords assert is_weak_password("Pass1!") == "Weak" # Missing e...
[ { "docstring": "This function checks if a `password` is weak based on the criteria provided.", "function_declaration": "def is_weak_password(password):", "function_name": "is_weak_password", "parameter_list": "(password)" }, { "docstring": "This function takes a list of passwords and checks ...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "import re\n\ndef is_weak_password(password):\n \"\"\"\n This function checks if a `password` is weak based on the criteria provided....
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00019607", "row_id": 19607, "seed_ids": "[20412]" }
0.543813
Taco_19607
I
[ "is_weak_password", "check_passwords" ]
2
[ [ "check_passwords", "is_weak_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7ee1d8307c6a3180aa000aa9b23b0a31367f79da
f87424320f1a339812f374ff04cc80af90bd23a4
v1.0
instruct
Taco
Taco_19686_I
You have N (1 ≤ N ≤ 200,000) tasks in a to-do list. Each task i is described by a pair of integers (Si, Ei) where Si is the start time and Ei is the end time of the task. Your goal is to select the maximum number of tasks that you can complete without any overlaps in their times. A task can only be started after the pr...
def max_non_overlapping_tasks(tasks): """ Returns the maximum number of non-overlapping tasks that can be completed. Parameters: tasks (list of tuples): A list where each tuple contains two integers representing the start and end times of a task. ...
import pytest from solution import max_non_overlapping_tasks_from_input def test_example_case(): N = 3 tasks = [(1, 3), (2, 5), (4, 6)] assert max_non_overlapping_tasks_from_input(N, tasks) == 2 def test_no_task_case(): N = 0 tasks = [] assert max_non_overlapping_tasks_from_input(N, tasks) == ...
[ { "docstring": "Returns the maximum number of non-overlapping tasks that can be completed.\n\nParameters:\ntasks (list of tuples): A list where each tuple contains two integers \n representing the start and end times of a task.\n \nReturns:\nint: The maximum number ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_non_overlapping_tasks(tasks):\n \"\"\"\n Returns the maximum number of non-overlapping tasks that can be completed.\n \n Parameters:\n tasks...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00019686", "row_id": 19686, "seed_ids": "[6728]" }
0.632982
Taco_19686
I
[ "max_non_overlapping_tasks", "max_non_overlapping_tasks_from_input" ]
2
[ [ "max_non_overlapping_tasks_from_input", "max_non_overlapping_tasks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9bb1b44eacead8e89b0a7a0239858bd363152d6c
6f70d3282fb34dc2537eb871e8b269c835b29d58
v1.0
instruct
Taco
Taco_19748_I
Anna is developing a strategy game where players need to fortify their kingdoms by constructing a network of roads. The kingdom consists of n cities connected by m bidirectional roads such that each road has a cost associated with it. The cities are numbered from 1 to n. A key aspect of the gameplay involves ensuring ...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[...
from solution import minimum_cost_to_connect_cities def test_example_1(): n = 4 m = 5 roads = [ [1, 2, 1], [1, 3, 4], [2, 3, 2], [3, 4, 3], [1, 4, 5] ] assert minimum_cost_to_connect_cities(n, m, roads) == 6 def test_example_2(): n = 3 m = 1 road...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 1, 0, 1, 1 ]
3
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00019748", "row_id": 19748, "seed_ids": "[23373]" }
0.764847
Taco_19748
I
[ "find", "union", "minimum_cost_to_connect_cities" ]
3
[ [ "minimum_cost_to_connect_cities", "find" ], [ "minimum_cost_to_connect_cities", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
77e39524d15c3c480d017c0015971d1205adf507
7517d5c73ba04f5f54923ba0e8e997e09591ffec
v1.0
instruct
Taco
Taco_19791_I
Given a grid of dimensions MxN filled with integers, determine the maximum sum of all possible subgrids. Input Specifications: The first line contains an integer T, the number of test cases. For each test case: - The first line contains two integers M and N, the dimensions of the grid. - The next M lines each contain...
def max_sum_subgrid(grid, m, n): max_sum = float('-inf') for left in range(n): temp = [0] * m for right in range(left, n): for i in range(m): temp[i] += grid[i][right] current_max = kadane(temp) max_sum = max(max_sum, current_...
def test_max_sum_subgrid(): test_cases = [ (2, [ (2, 2, [ [1, -2], [-3, 4] ]), (3, 3, [ [1, 2, 3], [4, 5, 6], [-1, -2, -3] ]) ]), ] expected_result = [4, 21] ...
[ { "docstring": null, "function_declaration": "def max_sum_subgrid(grid, m, n):", "function_name": "max_sum_subgrid", "parameter_list": "(grid, m, n)" }, { "docstring": null, "function_declaration": "def kadane(arr):", "function_name": "kadane", "parameter_list": "(arr)" }, { ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximum_sum_subgrid(grid):\n \"\"\"\n Given a grid of dimensions MxN filled with integers,\n determine the maximum sum of all possible subgrids.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00019791", "row_id": 19791, "seed_ids": "[10424]" }
0.647884
Taco_19791
I
[ "max_sum_subgrid", "kadane", "max_sum_of_all_subgrids" ]
3
[ [ "max_sum_of_all_subgrids", "max_sum_subgrid" ], [ "max_sum_subgrid", "kadane" ] ]
2
[]
false
[]
false
pytest
false
[]
true
50432a10654145b5c9be4fa17fde2c6ec1402b88
a976f598d238b8596c43da9f7d6317b9a1910642
v1.0
instruct
Taco
Taco_19898_I
Python is a popular high-level programming language known for its simplicity and readability. However, sometimes the fluid nature of its list operations can lead to inefficiencies if not used carefully. One common operation in programming involves manipulating a 2D grid, such as rotating its cells. Consider a square m...
def rotate_matrix_90_clockwise(matrix): """ Rotates a given n x n matrix 90 degrees clockwise. Parameters: matrix (list of list of int): 2D list representing the n x n matrix. Returns: list of list of int: The matrix rotated 90 degrees clockwise. """ n = len(matrix) rotated_matrix ...
from solution import rotate_matrix_90_clockwise, read_and_process_input def test_rotate_matrix_3x3(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] assert rotate_matrix_90_clockwise(matrix) == expected de...
[ { "docstring": "Rotates a given n x n matrix 90 degrees clockwise.\n\nParameters:\nmatrix (list of list of int): 2D list representing the n x n matrix.\n\nReturns:\nlist of list of int: The matrix rotated 90 degrees clockwise.", "function_declaration": "def rotate_matrix_90_clockwise(matrix):", "functio...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_matrix_90_clockwise(n, matrix):\n \"\"\"\n Rotates the given n x n matrix 90 degrees clockwise.\n \n :param n: Size of the matrix\n :para...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00019898", "row_id": 19898, "seed_ids": "[6871]" }
0.658617
Taco_19898
I
[ "rotate_matrix_90_clockwise", "read_and_process_input" ]
2
[ [ "read_and_process_input", "rotate_matrix_90_clockwise" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9825c690fbdc77d2f042099cb63af91c695904d3
901fe955f6bf62c710a8eea55635783ab87d654d
v1.0
instruct
Taco
Taco_19919_I
Given a list of integers, return a new list where each integer is replaced with the sum of its digits. If the sum is a single digit, keep it as is. If the sum has multiple digits, repeat the process until you get a single-digit sum. Example input: ``` [123, 456, 789, 15] ``` Expected output: ``` [6, 6, 6, 6] ```
def sum_of_digits(n): while n >= 10: n = sum(int(digit) for digit in str(n)) return n def replace_with_digit_sum(lst): """ Given a list of integers, return a new list where each integer is replaced with the sum of its digits. If the sum is a single digit, keep it as is. If the sum has m...
from solution import replace_with_digit_sum, sum_of_digits def test_sum_of_digits(): assert sum_of_digits(123) == 6 assert sum_of_digits(456) == 6 assert sum_of_digits(789) == 6 assert sum_of_digits(15) == 6 assert sum_of_digits(5) == 5 assert sum_of_digits(9999) == 9 def test_replace_with_dig...
[ { "docstring": null, "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a new list where each integer is replaced\nwith the sum of its digits. If the sum is a single digit, keep it as ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(n):\n \"\"\"\n Calculate the sum of digits of a number until the sum is a single digit.\n \"\"\"\n while n >= 10:\n n = sum(in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00019919", "row_id": 19919, "seed_ids": "[20801]" }
0.731036
Taco_19919
I
[ "sum_of_digits", "replace_with_digit_sum" ]
2
[ [ "replace_with_digit_sum", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
76f78a116e8c48f5e19027be6e0248926caae015
ed65e05818e3489ee2a483fe96a832c700db69a6
v1.0
instruct
Taco
Taco_19951_I
Petya has been experimenting with binary trees and their various properties. He recently came across a concept called "Left View" of a binary tree. The left view of a binary tree is the set of nodes visible when the tree is viewed from the left side. Now, Petya wants to write a program to find the left view of a given ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): """ Builds a binary tree from a list of values in level order traversal. """ if not nodes or nodes[0] is None: return None ...
from solution import left_view_of_tree def test_left_view_small_tree(): n = 6 values = [1, 2, 3, 4, None, 5, 6] expected_output = [1, 2, 4] assert left_view_of_tree(n, values) == expected_output def test_left_view_with_single_node(): n = 1 values = [1] expected_output = [1] assert left...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00019951", "row_id": 19951, "seed_ids": "[23757]" }
0.568742
Taco_19951
I
[ "build_tree", "left_view", "left_view_of_tree" ]
3
[ [ "left_view_of_tree", "build_tree" ], [ "left_view_of_tree", "left_view" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
532a6334394f4e45e8dff22807b2087a1895da45
a5c7712086052c4e1b1e11d1c1e0559e34e4ff62
v1.0
instruct
Taco
Taco_19982_I
You are given a list of integers and a set of queries. Each query consists of two integers representing lower and upper bounds. Your task is to return the sum of all prime numbers within those bounds for each query. Input format: The first line contains an integer N representing the number of elements in the list. The...
from typing import List, Tuple def is_prime(n: int) -> bool: if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def preprocess_primes(nums: List[int]) -> List[int]: prime_prefix_sum = [0] * (len(nums) + 1) for i in range(1...
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) def test_preprocess_primes(): nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] expected = [0, 2, 5, 5, 10, 10, 17, 17, 17, 17, 28] assert preprocess...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def preprocess_primes(nums):", "function_name": "preprocess_primes", "parameter_list": "(nums)" }, { "doc...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve(limit):\n is_prime = [True] * (limit + 1)\n is_prime[0] = is_prime[1] = False\n for start in range(2, int(limit**0.5) + 1):\n if is_prime...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00019982", "row_id": 19982, "seed_ids": "[10663]" }
0.632654
Taco_19982
I
[ "is_prime", "preprocess_primes", "query_prime_sum", "process_queries" ]
4
[ [ "preprocess_primes", "is_prime" ], [ "process_queries", "preprocess_primes" ], [ "process_queries", "query_prime_sum" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
be0e597cf34bc02cd7e6fb37e58fdafad0e6bd73
1efe3e2e56710f4b76d811230ac936bbfd3bcf8d
v1.0
instruct
Taco
Taco_20031_I
Peter is a competitive programmer who participates in many programming contests. After solving several problems, he realized that he often made mistakes with bracket sequences. He decided to write a program that helps him to check if a sequence of brackets is valid. A sequence of brackets is considered valid if: 1. It...
def is_valid_bracket_sequence(sequence): """ Check if a given sequence of brackets is valid. :param sequence: str :return: bool """ stack = [] bracket_map = {")": "(", "]": "[", "}": "{"} for char in sequence: if char in bracket_map: top_element = stack.pop(...
from solution import is_valid_bracket_sequence, check_bracket_sequence def test_is_valid_bracket_sequence(): assert is_valid_bracket_sequence("([])") == True assert is_valid_bracket_sequence("{[()()]}") == True assert is_valid_bracket_sequence("{[(])}") == False assert is_valid_bracket_sequence("((()}"...
[ { "docstring": "Check if a given sequence of brackets is valid.\n\n:param sequence: str\n:return: bool", "function_declaration": "def is_valid_bracket_sequence(sequence):", "function_name": "is_valid_bracket_sequence", "parameter_list": "(sequence)" }, { "docstring": "Checks if the given bra...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_bracket_sequence(s):\n \"\"\"\n Checks if the sequence of brackets is valid.\n\n Args:\n s (str): The input string containing a sequence o...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020031", "row_id": 20031, "seed_ids": "[3735]" }
0.722979
Taco_20031
I
[ "is_valid_bracket_sequence", "check_bracket_sequence" ]
2
[ [ "check_bracket_sequence", "is_valid_bracket_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2a7c26ba9f2e87480a6ab72b63f7840ca37dfcf3
0199ac4daa7f0e295c23382305eacc99db437f5b
v1.0
instruct
Taco
Taco_20034_I
You are given an integer `n`. You need to find the smallest integer `m` such that the sum of digits of `m` is equal to `n` and `m` is greater than or equal to `n`. If such a number does not exist, return -1. Write a function `findSmallestNumber()` that takes the integer `n` as input and returns the smallest integer `m`...
def sum_of_digits(x): """ Calculate the sum of digits of the integer x. """ return sum(int(digit) for digit in str(x)) def findSmallestNumber(n): """ Find the smallest integer m such that the sum of the digits of m is equal to n and m is greater than or equal to n. If no such number exists...
def test_findSmallestNumber_n10(): assert findSmallestNumber(10) == 19 def test_findSmallestNumber_n5(): assert findSmallestNumber(5) == 5 def test_findSmallestNumber_n27(): assert findSmallestNumber(27) == 999 def test_findSmallestNumber_n18(): assert findSmallestNumber(18) == 99 def test_findSmall...
[ { "docstring": "Calculate the sum of digits of the integer x.", "function_declaration": "def sum_of_digits(x):", "function_name": "sum_of_digits", "parameter_list": "(x)" }, { "docstring": "Find the smallest integer m such that the sum of the digits of m is equal to n \nand m is greater than...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(x):\n \"\"\"\n Calculate the sum of digits of the integer x.\n \"\"\"\n return sum(int(digit) for digit in str(x))\n\ndef findSmalles...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00020034", "row_id": 20034, "seed_ids": "[23844]" }
0.69956
Taco_20034
I
[ "sum_of_digits", "findSmallestNumber" ]
2
[ [ "findSmallestNumber", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5b8e4ea41eebdbc624c6ba72a1940a49526159cc
74c42ad788d030ea78c3ff35cb0c6f2c82ff33b2
v1.0
instruct
Taco
Taco_20062_I
During a series of attempts to crack a mysterious code, you discovered an interesting pattern on an ancient encrypted tablet. The pattern is described as follows: There is a sequence of numbers, and for each number, you are to determine if it is possible to rearrange its digits such that the resulting number is divisib...
def is_divisible_by_3(digits): """ Determines if the sum of the digits of a number is divisible by 3 :param digits: string representing the digits of the number :return: "YES" if the sum of digits is divisible by 3, otherwise "NO" """ total = sum(int(digit) for digit in digits) return "YES" ...
import pytest from solution import analyze_numbers, is_divisible_by_3 def test_is_divisible_by_3(): assert is_divisible_by_3("102") == "YES" assert is_divisible_by_3("123") == "YES" assert is_divisible_by_3("111") == "YES" assert is_divisible_by_3("456") == "YES" assert is_divisible_by_3("789") == ...
[ { "docstring": "Determines if the sum of the digits of a number is divisible by 3\n:param digits: string representing the digits of the number\n:return: \"YES\" if the sum of digits is divisible by 3, otherwise \"NO\"", "function_declaration": "def is_divisible_by_3(digits):", "function_name": "is_divis...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_rearrangeable_divisible_by_3(s):\n \"\"\"\n Check if the digits of the string can be rearranged to form a number divisible by 3.\n \n :param s: ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020062", "row_id": 20062, "seed_ids": "[6072]" }
0.634514
Taco_20062
I
[ "is_divisible_by_3", "analyze_numbers" ]
2
[ [ "analyze_numbers", "is_divisible_by_3" ] ]
1
[]
false
[]
false
pytest
true
[]
true
92a5f2909664abdc16bf56371adf49889709f9d0
170fc01eb3c65d7a58964b7452a4425f8bdc9dd2
v1.0
instruct
Taco
Taco_20086_I
T: Battle Ship Tracker / Can You Find The Position? Story Captain S of a powerful naval fleet always tests the skills of his crew by hiding ships in a Cartesian coordinate system. The ships are represented as vertical or horizontal line segments and the crew has to accurately determine if there is an overlap or inter...
def is_point_on_ship(x1, y1, x2, y2, qx, qy): """ Helper function to determine if the point (qx, qy) lies on the ship defined by the line segment from (x1, y1) to (x2, y2). """ if x1 == x2: # Vertical ship return x1 == qx and min(y1, y2) <= qy <= max(y1, y2) else: # Horizontal ship ...
from solution import battleship_tracker def test_battleship_tracker_example1(): ships = [(0, 0, 3, 0), (1, -1, 1, 2), (-2, 2, 2, 2)] queries = [(0, 0), (1, 0), (1, 1), (4, 2)] assert battleship_tracker(ships, queries) == ["YES", "YES", "YES", "NO"] def test_battleship_tracker_example2(): ships = [(1, ...
[ { "docstring": "Helper function to determine if the point (qx, qy) lies on the ship\ndefined by the line segment from (x1, y1) to (x2, y2).", "function_declaration": "def is_point_on_ship(x1, y1, x2, y2, qx, qy):", "function_name": "is_point_on_ship", "parameter_list": "(x1, y1, x2, y2, qx, qy)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_point_on_ship(x1, y1, x2, y2, qx, qy):\n \"\"\"\n Determine if the point (qx, qy) lies on the ship defined by (x1, y1) to (x2, y2).\n \"\"\"\n #...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020086", "row_id": 20086, "seed_ids": "[25359]" }
0.671299
Taco_20086
I
[ "is_point_on_ship", "battleship_tracker" ]
2
[ [ "battleship_tracker", "is_point_on_ship" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6d948fcbdbf7fd2dd96896a0bb6455b8e6daace8
3730bb3c59b81242a98ce97b84c1d8d873a665bb
v1.0
instruct
Taco
Taco_20093_I
Farmer John has a unique way of planting his crops in a grid. The grid is of size m x n, where each cell can either be empty or contain a crop. The crops are planted on specific positions provided by their coordinates. The challenge for Farmer John is to find the largest rectangle within the grid that consists entirely...
def largest_crop_rectangle(m, n, croppos): """ Returns the area of the largest rectangle consisting of only crops. """ grid = [[0] * n for _ in range(m)] for r, c in croppos: grid[r][c] = 1 max_area = 0 dp = [0] * n for i in range(m): for j in range(n): if g...
from solution import largest_crop_rectangle def test_case_1(): assert largest_crop_rectangle(5, 5, [(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 3)]) == 4 def test_case_2(): assert largest_crop_rectangle(4, 4, [(0, 0), (1, 1), (2, 1), (2, 3), (3, 1), (3, 2), (3, 3)]) == 3 def test_case_3(): assert largest...
[ { "docstring": "Returns the area of the largest rectangle consisting of only crops.", "function_declaration": "def largest_crop_rectangle(m, n, croppos):", "function_name": "largest_crop_rectangle", "parameter_list": "(m, n, croppos)" }, { "docstring": null, "function_declaration": "def ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_crop_rectangle(m, n, crops):\n \"\"\"\n Finds the largest rectangle within the grid that consists entirely of crops.\n :param m: Number of row...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00020093", "row_id": 20093, "seed_ids": "[21218]" }
0.666444
Taco_20093
I
[ "largest_crop_rectangle", "largest_histogram_area" ]
2
[ [ "largest_crop_rectangle", "largest_histogram_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d627a1ccc3c955cea04e738ed4be13e685f9bc5f
ee32e1272bfce88db3e55d4d79dee888f20b213a
v1.0
instruct
Taco
Taco_20097_I
The school cafeteria serves lunch in a very specific way. There are multiple types of dishes available, but each student can pick only one type of dish. Each type of dish can be represented as a number. The cafeteria serves lunch only if the selected dish type's number is prime. Given a student's choice of dish, deter...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def serve_or_not(dish_number): if is_prime(dish_number): print("Serve") ...
from solution import is_prime, serve_or_not def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False assert is_prime(1) == False def test_serve_or_not(capsys): serve_or_not(7) captured ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def serve_or_not(dish_number):", "function_name": "serve_or_not", "parameter_list": "(dish_number)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_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_0
{ "original_instruction": "", "prompt_id": "00020097", "row_id": 20097, "seed_ids": "[15836]" }
0.646373
Taco_20097
I
[ "is_prime", "serve_or_not" ]
2
[ [ "serve_or_not", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b2ad38e4b523cca99096d89cdd7f7dba3e4d99e3
283d3d80613c2f5c5182a3b90353db56d99d047d
v1.0
instruct
Taco
Taco_20115_I
Sam loves playing with numbers, and one of his favorite hobbies is finding beautiful subsequences within an array. A subsequence is considered beautiful if the product of its elements is a perfect square. Given an array of integers, Sam wants to determine the maximum length of a beautiful subsequence. A perfect square...
import math def is_perfect_square(x): r = int(math.isqrt(x)) return r * r == x def max_beautiful_subsequence_length(t, test_cases): results = [] for i in range(t): n = test_cases[i][0] array = test_cases[i][1] dp = [] for j in range(n): if is_perfec...
from solution import max_beautiful_subsequence_length def test_case1(): t = 3 test_cases = [ (4, [1, 2, 3, 4]), (5, [1, 2, 2, 3, 3]), (6, [1, 4, 9, 16, 25, 36]) ] assert max_beautiful_subsequence_length(t, test_cases) == [2, 1, 6] def test_case2(): t = 2 test_cases = [ ...
[ { "docstring": null, "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def max_beautiful_subsequence_length(t, test_cases):", "function_name": "max_beautiful_subsequence_...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(num):\n \"\"\"\n Checks if a number is a perfect square.\n \"\"\"\n root = int(math.isqrt...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00020115", "row_id": 20115, "seed_ids": "[23667]" }
0.716559
Taco_20115
I
[ "is_perfect_square", "max_beautiful_subsequence_length" ]
2
[ [ "max_beautiful_subsequence_length", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
34fba4b7fbff465467dd10eaaf4747dc92f0987a
ac47428f6f307a01a2b012987bc345aef33cb0fb
v1.0
instruct
Taco
Taco_20223_I
You are working on a project management tool where tasks need to be managed. Each task has a unique identifier and a list of dependencies (i.e., other tasks that must be completed before this one can be started). Implement a function to determine the order in which the tasks should be completed. -----Input----- Each i...
from collections import defaultdict, deque def find_task_order(t, tasks): graph = defaultdict(list) indegree = {i: 0 for i in range(1, t + 1)} for task in tasks: task_id = task[0] dependencies = task[1] for dep in dependencies: graph[dep].append(task_id) ind...
from solution import task_order def test_sample_input_1(): assert task_order(4, ["1 2 3", "2", "3 4", "4"]) in ["2 4 3 1", "4 2 3 1", "4 3 2 1"] def test_sample_input_2(): assert task_order(2, ["1 2", "2 1"]) == "IMPOSSIBLE" def test_single_task(): assert task_order(1, ["1"]) == "1" def test_no_dependen...
[ { "docstring": null, "function_declaration": "def find_task_order(t, tasks):", "function_name": "find_task_order", "parameter_list": "(t, tasks)" }, { "docstring": null, "function_declaration": "def task_order(t, task_descriptions):", "function_name": "task_order", "parameter_lis...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_task_order(t, tasks):\n from collections import defaultdict, deque\n\n # Create adjacency list and in-degree dictionary\n adj_list = defaultdict(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00020223", "row_id": 20223, "seed_ids": "[23807]" }
0.535274
Taco_20223
I
[ "find_task_order", "task_order" ]
2
[ [ "task_order", "find_task_order" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2e8e458057099bcdbb906eb4dae78ee612aae738
f72369a74929afff9516515aa20c7836adf4194e
v1.0
instruct
Taco
Taco_20234_I
In the realm of data structures, linked lists are fundamental components that offer a dynamic and flexible way to manage collections of data. One common operation with singly linked lists is the reversal of the list. This involves rearranging the links between the nodes so that the first node becomes the last, the seco...
class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def reverse_linked_list(head): """ Reverses a singly linked list. """ prev = None current = head while current: next_node = current.next current.next = prev pr...
def test_reverse_linked_list(): assert linked_list_to_list(reverse_linked_list(list_to_linked_list([1, 2, 3, 4, 5]))) == [5, 4, 3, 2, 1] assert linked_list_to_list(reverse_linked_list(list_to_linked_list([10, 20, 30, 40]))) == [40, 30, 20, 10] assert linked_list_to_list(reverse_linked_list(list_to_linked_li...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, value=0, next=None):\n self.value = value\n self.next = next\n\ndef reverse_linked_list(head):\n prev = No...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020234", "row_id": 20234, "seed_ids": "[17682]" }
0.624157
Taco_20234
I
[ "reverse_linked_list", "list_to_linked_list", "linked_list_to_list", "process_datasets" ]
4
[ [ "process_datasets", "linked_list_to_list" ], [ "process_datasets", "list_to_linked_list" ], [ "process_datasets", "reverse_linked_list" ] ]
3
[ "process_datasets" ]
false
[ "ListNode" ]
true
pytest
false
[]
true
a31fd14f134ab59904699fc937773cd64b59d46b
2a24fe8ec67476ae39f467b7f6dcf724ec04cef4
v1.0
instruct
Taco
Taco_20242_I
Tom loves palindromes. A palindrome is a string that reads the same forward and backward. For example, "level" and "racecar" are palindromes. Tom has a list of N strings, and he would like to know how many of them are palindromes. Can you help him determine this? -----Input----- The first line of input consists of a s...
def is_palindrome(s: str) -> str: """ Returns "YES" if the string is a palindrome, otherwise returns "NO". """ if s == s[::-1]: return "YES" return "NO" def check_palindromes(strings): return [is_palindrome(s) for s in strings]
from solution import is_palindrome, check_palindromes def test_is_palindrome(): assert is_palindrome("level") == "YES" assert is_palindrome("hello") == "NO" assert is_palindrome("racecar") == "YES" assert is_palindrome("abcba") == "YES" assert is_palindrome("world") == "NO" assert is_palindrome...
[ { "docstring": "Returns \"YES\" if the string is a palindrome, otherwise returns \"NO\".", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def check_palindromes(strings):", "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Checks if a string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef check_palindromes(strings):\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00020242", "row_id": 20242, "seed_ids": "[15274]" }
0.810528
Taco_20242
I
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8306bcc125d58f63c4e21305d6f0a8ade01f0122
fb83320cc01964567d84d63312e876ade4c7e991
v1.0
instruct
Taco
Taco_20281_I
The Kingdom of Wasabia is known for its elaborate network of canals and boats used for transportation. The canals can be represented as a directed graph with $n$ cities (nodes) and $m$ canals (edges), each having a certain travel time. One day, the Queen of Wasabia wants to know if it's possible to travel from the ca...
import heapq def shortest_paths(n, edges, c): """ Computes the shortest paths from the source node c to all other nodes using Dijkstra's algorithm. Parameters: n (int): Number of nodes (cities) edges (List[Tuple[int, int, int]]): List of edges represented as (u, v, t) tuples c (int): The s...
def test_shortest_paths(): n, m = 5, 6 edges = [ (1, 2, 3), (1, 3, 2), (2, 4, 4), (3, 4, 1), (4, 5, 6), (1, 5, 10) ] c = 1 expected = [float('inf'), 0, 3, 2, 3, 9] result = shortest_paths(n, edges, c) assert result == expected def test_travel_...
[ { "docstring": "Computes the shortest paths from the source node c to all other nodes using Dijkstra's algorithm.\n\nParameters:\nn (int): Number of nodes (cities)\nedges (List[Tuple[int, int, int]]): List of edges represented as (u, v, t) tuples\nc (int): The source node (capital city)\n\nReturns:\nList[int]: ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n \"\"\"\n Implements Dijkstra's algorithm to find the shortest paths from `start` to all other cities.\n \...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020281", "row_id": 20281, "seed_ids": "[10550]" }
0.776898
Taco_20281
I
[ "shortest_paths", "travel_queries" ]
2
[ [ "travel_queries", "shortest_paths" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4c721e8e22800584f297f3e6cc60820bae0c193c
11d873f036e9dfac72425f33928b3ad0cb46da80
v1.0
instruct
Taco
Taco_20299_I
You are given a string containing only lowercase letters. Your task is to determine the frequency of each letter in the string and output the results in alphabetical order. -----Input----- A single string S (1 <= |S| <= 10^6) where S consists of only lowercase letters. -----Output----- Output each letter and its freq...
def letter_frequency(s: str): """ Determines the frequency of each letter in the string and returns results in alphabetical order. :param s: Input string containing only lowercase letters :return: A dictionary with letters as keys and their frequencies as values """ from collections import ...
from solution import letter_frequency, pretty_print_frequency def test_letter_frequency_simple(): result = letter_frequency("banana") expected = {'a': 3, 'b': 1, 'n': 2} assert result == expected def test_letter_frequency_single_char(): result = letter_frequency("a") expected = {'a': 1} assert...
[ { "docstring": "Determines the frequency of each letter in the string and returns results in alphabetical order.\n\n:param s: Input string containing only lowercase letters\n:return: A dictionary with letters as keys and their frequencies as values", "function_declaration": "def letter_frequency(s):", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef letter_frequency(s):\n \"\"\"\n Returns the frequency of each letter in the string in alphabetical order.\n \"\"\"\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020299", "row_id": 20299, "seed_ids": "[2173]" }
0.797586
Taco_20299
I
[ "letter_frequency", "pretty_print_frequency" ]
2
[ [ "pretty_print_frequency", "letter_frequency" ] ]
1
[]
false
[]
false
pytest
true
[]
true
22fdb959679e387abb56f62cc94a330c4f0a20e0
2503c017f84dbe367bde32727101a52d393828f5
v1.0
instruct
Taco
Taco_20343_I
You are given a list of integers. You have to generate a new list following these steps: 1. Initialize an empty list called `output`. 2. Process every integer `x` in the given list: - For each divisor of `x` (including 1 and `x` itself), calculate the sum of its digits. - Append the sum of the divisor's digits t...
def sum_of_digits(x): return sum(int(digit) for digit in str(x)) def find_divisors(x): divisors = [] for i in range(1, x + 1): if x % i == 0: divisors.append(i) return divisors def generate_output_list(numbers): output = [] for number in numbers: divisors = find_div...
from solution import sum_of_digits, find_divisors, generate_output_list def test_sum_of_digits(): assert sum_of_digits(12) == 3 assert sum_of_digits(15) == 6 assert sum_of_digits(1) == 1 assert sum_of_digits(100) == 1 def test_find_divisors(): assert find_divisors(12) == [1, 2, 3, 4, 6, 12] as...
[ { "docstring": null, "function_declaration": "def sum_of_digits(x):", "function_name": "sum_of_digits", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def find_divisors(x):", "function_name": "find_divisors", "parameter_list": "(x)" }, { "docstri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(n):\n \"\"\"\n Returns the sum of the digits of n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef get_divisors(n):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00020343", "row_id": 20343, "seed_ids": "[453]" }
0.72401
Taco_20343
I
[ "sum_of_digits", "find_divisors", "generate_output_list" ]
3
[ [ "generate_output_list", "find_divisors" ], [ "generate_output_list", "sum_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
bea7a305d228752bd0ee4e30ceaa3eb08899af9e
d405616421cf69704e0853a98c2924b4ab5437aa
v1.0
instruct
Taco
Taco_20367_I
In a faraway kingdom, the king has an amusement park designed in the shape of a rectangular grid with n rows and m columns. Each cell in the grid can either be empty or contain an obstacle. The goal is to place a large roller coaster track in the park. The track must form a perfect square of size k x k, where k is the ...
def largest_square(n, m, grid): def is_square_placable(x, y, size): if x + size > n or y + size > m: return False for i in range(x, x + size): for j in range(y, y + size): if grid[i][j] == '#': return False return True ...
def test_largest_square(): assert roller_coaster_track(4, 5, [".....", "..#..", ".....", "....."]) == 2 assert roller_coaster_track(3, 3, ["###", "###", "###"]) == 0 assert roller_coaster_track(3, 4, ["....", ".##.", "...."]) == 1 assert roller_coaster_track(5, 5, [".....", ".....", ".....", ".....", "....
[ { "docstring": null, "function_declaration": "def largest_square(n, m, grid):", "function_name": "largest_square", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def roller_coaster_track(n, m, grid):", "function_name": "roller_coaster_track", "p...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_square(grid):\n n = len(grid)\n m = len(grid[0])\n \n # Initialize a matrix to keep track of square sizes\n dp = [[0] * m for _ in range...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00020367", "row_id": 20367, "seed_ids": "[17305]" }
0.681709
Taco_20367
I
[ "largest_square", "roller_coaster_track" ]
2
[ [ "roller_coaster_track", "largest_square" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7789959bd1e863d8e75b38a5fbf7e7ea2d1592d8
965e0b5269a0e358bc5e0c4164e7255ebf16e155
v1.0
instruct
Taco
Taco_20397_I
Given a positive integer N, determine how many numbers from 1 to N are both prime and palindrome. Example 1: Input: N = 10 Output: 4 Explanation: The palindromic primes from 1 to 10 are {2, 3, 5, 7}. Example 2: Input: N = 50 Output: 5 Explanation: The palindromic primes from 1 to 50 are {2, 3, 5, 7, 11}. Your Task: ...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6...
from solution import palindromicPrimeCount def test_palindromicPrimeCount_example1(): assert palindromicPrimeCount(10) == 4 def test_palindromicPrimeCount_example2(): assert palindromicPrimeCount(50) == 5 def test_palindromicPrimeCount_upper_limit(): assert palindromicPrimeCount(10000) == 20 def test_pa...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrom...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_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 p = 3\n while p * p <...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00020397", "row_id": 20397, "seed_ids": "[2704]" }
0.621832
Taco_20397
I
[ "is_prime", "is_palindrome", "palindromicPrimeCount" ]
3
[ [ "palindromicPrimeCount", "is_palindrome" ], [ "palindromicPrimeCount", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9e6303225a248b1a6dd1f7d961b5a1eaec49784a
e6abc1d09b5f605ff0c131330188550b47bb9073
v1.0
instruct
Taco
Taco_20400_I
You are given a grid represented by a list of strings where each character in the string is either '1' or '0'. The grid is of size `N x M`, where `N` is the number of rows and `M` is the number of columns. You are required to process `Q` queries of two types: - `1` $A$ $B$ $X$: Update cell $(A, B)$ to have the value $X...
def largest_rectangle_area(heights): """ Helper function to calculate the largest rectangle area in a histogram. """ stack = [-1] max_area = 0 for i, h in enumerate(heights): while stack[-1] != -1 and heights[stack[-1]] >= h: height = heights[stack.pop()] width =...
import pytest from solution import process_grid def test_initial_grid(): grid = [ ['1', '0', '1', '0', '1'], ['1', '1', '1', '0', '0'], ['1', '1', '0', '1', '0'], ['1', '1', '1', '1', '0'] ] queries = [(2,)] assert process_grid(4, 5, grid, queries) == [6] def test_updat...
[ { "docstring": "Helper function to calculate the largest rectangle area in a histogram.", "function_declaration": "def largest_rectangle_area(heights):", "function_name": "largest_rectangle_area", "parameter_list": "(heights)" }, { "docstring": "Function to calculate the largest rectangle of...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximum_histogram_area(heights):\n stack = []\n max_area = 0\n index = 0\n\n while index < len(heights):\n if not stack or heights[stack[-1]...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00020400", "row_id": 20400, "seed_ids": "[11433]" }
0.715744
Taco_20400
I
[ "largest_rectangle_area", "maximal_rectangle", "process_grid" ]
3
[ [ "maximal_rectangle", "largest_rectangle_area" ], [ "process_grid", "maximal_rectangle" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cf81a87ff680d0b2616792dffcf2659ce5086aed
39edea22d20df10be3f92d6a7bef4254ccb9bcee
v1.0
instruct
Taco
Taco_20418_I
Majority Element in Subarrays Given an array of integers, handle two types of queries. The first type of query updates the value at a specific index in the array. The second type of query finds the majority element within a given subarray. The majority element is the element that appears more than floor((R - L + 1) ...
def update_array(array, index, x): """ Updates the element at the given index with the value x. """ array[index] = x def find_majority_element(array, L, R): """ Finds the majority element in the subarray from index L to R (inclusive). """ subarray = array[L:R+1] count = {} for n...
from solution import process_queries def test_queries(): N = 7 Q = 5 arr = [2, 3, 2, 4, 2, 2, 5] queries = [ [2, 1, 5], [1, 3, 1], [2, 1, 5], [2, 1, 7], [2, 6, 7] ] expected = [2, -1, -1, -1] assert process_queries(N, Q, arr, queries) == expected def...
[ { "docstring": "Updates the element at the given index with the value x.", "function_declaration": "def update_array(array, index, x):", "function_name": "update_array", "parameter_list": "(array, index, x)" }, { "docstring": "Finds the majority element in the subarray from index L to R (inc...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import collections\n\ndef update(arr, i, x):\n arr[i - 1] = x\n\ndef find_majority_element(arr, L, R):\n subarray = arr[L - 1:R]\n count = collections.Cou...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00020418", "row_id": 20418, "seed_ids": "[18148]" }
0.688974
Taco_20418
I
[ "update_array", "find_majority_element", "process_queries" ]
3
[ [ "process_queries", "find_majority_element" ], [ "process_queries", "update_array" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
ed2803e5fa467669663dec89c42ab7dfecd0cbc8
6cfa6d06cfe0b78c90be5198bade2f8ed35c3688
v1.0
instruct
Taco
Taco_20518_I
Your friend has recently developed an interest in creating composite musical notes using a circular array of digital sound generators. Each generator works on a sequence of binary pulses. A pulse is either `0` or `1`, and a musical note is created by blending the pulses from multiple generators at specific time interva...
def is_composite_note_possible(generators): """ Determines if it's possible to perfectly play the composite musical note by blending the active pulses from the generators during the specified intervals. :param generators: List of tuples containing generator information. Each tuple contains: ...
from solution import composite_note_possible def test_single_generator_valid_intervals(): data = """1 8 11001010 2 0 7 8 15""" assert composite_note_possible(data) == "possible" def test_multiple_generators_invalid_intervals(): data = """2 4 1101 2 0 3 4 7 ...
[ { "docstring": "Determines if it's possible to perfectly play the composite musical note \nby blending the active pulses from the generators during the specified intervals.\n\n:param generators: List of tuples containing generator information. Each tuple contains:\n (pulse_sequence, intervals)...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_possible_to_blend(generators):\n def get_pulse_at(generator, time):\n pulse_index = time % len(generator[1])\n ret...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00020518", "row_id": 20518, "seed_ids": "[14850]" }
0.570295
Taco_20518
I
[ "is_composite_note_possible", "process_input", "composite_note_possible" ]
3
[ [ "composite_note_possible", "is_composite_note_possible" ], [ "composite_note_possible", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
2d9cd1f89ed7d7e62ab3c910674ecdef5a0ad45c
095bdf3ceb8880426c657e85da99672c997dbfaa
v1.0
instruct
Taco
Taco_20542_I
Given a list of strings where each string can be either a valid integer or a word, find the longest subsequence of the list such that only valid integers are included and the sum of these integers is maximized. Return the maximum sum. Example: ``` Input: ["apple", "30", "banana", "40", "cherry", "25"] Output: 95 Inpu...
def is_valid_integer(s): """ Checks if the string represents a valid integer. """ try: int(s) return True except ValueError: return False def max_sum_of_valid_integers(strings): """ Returns the maximum sum of the longest subsequence of valid integers in the list. ...
from solution import is_valid_integer, max_sum_of_valid_integers def test_is_valid_integer(): assert is_valid_integer("30") == True assert is_valid_integer("apple") == False assert is_valid_integer("-40") == True assert is_valid_integer("40.5") == False assert is_valid_integer("123abc") == False d...
[ { "docstring": "Checks if the string represents a valid integer.", "function_declaration": "def is_valid_integer(s):", "function_name": "is_valid_integer", "parameter_list": "(s)" }, { "docstring": "Returns the maximum sum of the longest subsequence of valid integers in the list.", "func...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_integer(s):\n \"\"\"\n Checks if the string represents a valid integer.\n \"\"\"\n try:\n int(s)\n return True\n except V...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00020542", "row_id": 20542, "seed_ids": "[1359]" }
0.720578
Taco_20542
I
[ "is_valid_integer", "max_sum_of_valid_integers" ]
2
[ [ "max_sum_of_valid_integers", "is_valid_integer" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd009075472017243f835b080e760eaf0d80bbd8
8419d3968be49735791981bb4b76757a8aee5bb3
v1.0
instruct
Taco
Taco_20557_I
Diana is fascinated by prime numbers and their properties. She recently learned about twin primes, which are pairs of prime numbers that have a difference of 2 (e.g., (3, 5) and (11, 13)). She wants to generate a list of twin prime pairs within a given range. Write a program to help Diana by taking in two numbers repre...
def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def twin_primes(a, b): twin_prime_pairs = [] for i in range(a, b - 1): if is_prime(i) and is_prime(i + 2): twin_prime_pairs.append((i...
from solution import twin_primes def test_twin_primes_range_10_50(): result = twin_primes(10, 50) expected = [(11, 13), (17, 19), (29, 31), (41, 43)] assert result == expected def test_twin_primes_range_2_20(): result = twin_primes(2, 20) expected = [(3, 5), (5, 7), (11, 13), (17, 19)] assert ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def twin_primes(a, b):", "function_name": "twin_primes", "parameter_list": "(a, b)" } ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n retur...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00020557", "row_id": 20557, "seed_ids": "[6755]" }
0.698179
Taco_20557
I
[ "is_prime", "twin_primes" ]
2
[ [ "twin_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0852b82d9b62dd85b1f32b395d1e077c051a0aef
153efcb188d6f17e78c124840c37bb46cda09c9a
v1.0
instruct
Taco
Taco_20559_I
John is fascinated by numbers and patterns. He recently learned about palindromic numbers and prime numbers. A palindromic number is a number that reads the same forward and backward, such as 121 or 1331. A prime number is a number that has no positive divisors other than 1 and itself. John is curious about numbers tha...
def is_palindrome(n): """ Check if a given number is a palindrome. """ s = str(n) return s == s[::-1] def is_prime(n): """ Check if a given number is a prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False...
from solution import is_palindrome, is_prime, prime_palindromes_in_range, prime_palindromes def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1331) == True def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True ...
[ { "docstring": "Check if a given number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Check if a given number is a prime.", "function_declaration": "def is_prime(n):", "function_name": ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\ndef is_prime(n):\n if n < 2:\n return False\n if n in (2, 3):\n return True\n if...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00020559", "row_id": 20559, "seed_ids": "[19906]" }
0.658432
Taco_20559
I
[ "is_palindrome", "is_prime", "prime_palindromes_in_range", "prime_palindromes", "main" ]
5
[ [ "prime_palindromes", "prime_palindromes_in_range" ], [ "prime_palindromes_in_range", "is_palindrome" ], [ "prime_palindromes_in_range", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
f7f75029318dc5b881b3fe4675bb8711eacf5885
b0e5ebcc5549f3773f35f0e03b5544aa0cc64a64
v1.0
instruct
Taco
Taco_20562_I
An adventure with Binary Search Trees! Bob has a love for trees, not just any trees, but Binary Search Trees (BST). One day, while relaxing under a big Oak tree, he thought of a new problem. He wants to find the k-th smallest element in a BST. Since he loves coding, he decides to write a program to do this. A Binary ...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def insert_into_bst(root, value): if not root: return TreeNode(value) if value < root.value: root.left = insert_into_bst(root.left, value) e...
from solution import find_kth_smallest_elements def test_case_1(): test_cases = [ (3, [5, 3, 8, 2, 4, 6, 9]), (1, [7, 3, 9, 2, 5]), ] assert find_kth_smallest_elements(test_cases) == [4, 2] def test_case_k_greater_than_nodes(): test_cases = [ (5, [4, 2, 6, 1, 3, 5, 7]), ...
[]
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef i...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00020562", "row_id": 20562, "seed_ids": "[19590]" }
0.665053
Taco_20562
I
[ "insert_into_bst", "build_bst_from_level_order", "kth_smallest_element", "find_kth_smallest_elements" ]
4
[ [ "find_kth_smallest_elements", "build_bst_from_level_order" ], [ "find_kth_smallest_elements", "kth_smallest_element" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
1c6e1b585f1b5add4488a8640804558dc131cd05
3de5537bd6916fc698777104cafdab8200544366
v1.0
instruct
Taco
Taco_20584_I
Katie is organizing a marathon and wants to design a staggered start time schedule for the runners. Each runner starts at a slightly different time so that no two runners are expected to cross the finish line simultaneously, making it easier to track their times. Katie has a set of runners, each with a given speed rep...
def gcd(a, b): while b: a, b = b, a % b return a def minimum_start_time_difference(n, speeds): speeds_gcd = speeds[0] for speed in speeds[1:]: speeds_gcd = gcd(speeds_gcd, speed) return speeds_gcd # Reading input can be done as follows. Uncomment and use it if running as a scr...
from solution import minimum_start_time_difference def test_case_1(): assert minimum_start_time_difference(4, [2, 3, 5, 7]) == 1 def test_case_2(): assert minimum_start_time_difference(3, [10, 20, 30]) == 10 def test_case_3(): assert minimum_start_time_difference(2, [4, 6]) == 2 def test_case_4(): a...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def minimum_start_time_difference(n, speeds):", "function_name": "minimum_start_time_difference", "parameter_list": "...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef minimum_start_time_difference(n, speeds):\n speeds_gcd = speeds[0]\n for speed in ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00020584", "row_id": 20584, "seed_ids": "[13972]" }
0.629086
Taco_20584
I
[ "gcd", "minimum_start_time_difference" ]
2
[ [ "minimum_start_time_difference", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
09bb985e13b48adbd549cce34637f8b23f50a233
cf9addab0ad580ed316ed58185e4cf56c6d044bb
v1.0
instruct
Taco
Taco_20611_I
Given an array of distinct integers representing steps and an integer target, determine if it is possible to reach exactly the target step by taking a specific sequence of steps. The sequence of steps must strictly follow one of two patterns: either always stepping forward or always stepping backward. Formally, if th...
def can_reach_target(steps, target): """ Determine if it is possible to reach the target step by summing the elements of the steps array exactly or their negatives. Args: steps: List[int] - list of distinct integers representing steps. target: int - target step to reach. Returns: ...
def test_can_reach_target_yes(): assert can_reach_target([1, 3, 5, 7], 8) == "YES" def test_can_reach_target_no(): assert can_reach_target([2, 4, 6], 5) == "NO" def test_can_reach_target_single_step_positive(): assert can_reach_target([10], 10) == "YES" def test_can_reach_target_single_step_negative(): ...
[ { "docstring": "Determine if it is possible to reach the target step by summing the elements\nof the steps array exactly or their negatives.\n\nArgs:\nsteps: List[int] - list of distinct integers representing steps.\ntarget: int - target step to reach.\n\nReturns:\nstr: \"YES\" if it's possible to reach the tar...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_reach_target(steps, target):\n \"\"\"\n Determine if it is possible to reach the target step by summing the elements\n of the steps array exactly ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00020611", "row_id": 20611, "seed_ids": "[3941]" }
0.678851
Taco_20611
I
[ "can_reach_target", "can_sum_to_target" ]
2
[ [ "can_reach_target", "can_sum_to_target" ] ]
1
[]
false
[]
false
pytest
false
[]
true
af1b57b19967df72f915eacc97ef687619cd2652
728d46e952e0a2f514d89fffadf25f757704a817
v1.0
instruct
Taco
Taco_20660_I
You are part of a team developing an application that tracks time logs for different projects. Each project has several tasks, and each task has a start time and an end time. The application needs to generate a report indicating the total time spent on each project, ensuring that overlapping tasks within the same proje...
def merge_intervals(intervals): """ Merges overlapping intervals and returns a list of merged intervals. """ if not intervals: return [] intervals.sort(key=lambda x: x[0]) merged = [intervals[0]] for current in intervals[1:]: previous = merged[-1] if current...
from solution import project_times_from_input def test_example_case(): n = 2 tasks = [ [(1, 5), (2, 6), (8, 10)], [(1, 3), (2, 5)] ] assert project_times_from_input(n, tasks) == [7, 4] def test_non_overlapping_intervals(): n = 1 tasks = [ [(1, 2), (3, 4), (5, 6)] ] ...
[ { "docstring": "Merges overlapping intervals and returns a list of merged intervals.", "function_declaration": "def merge_intervals(intervals):", "function_name": "merge_intervals", "parameter_list": "(intervals)" }, { "docstring": "Returns the total time spent on each project by merging ove...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def merge_intervals(intervals):\n \"\"\"\n Merges overlapping intervals and returns a list of merged intervals.\n \"\"\"\n if ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020660", "row_id": 20660, "seed_ids": "[24854]" }
0.60852
Taco_20660
I
[ "merge_intervals", "total_project_time", "project_times_from_input" ]
3
[ [ "project_times_from_input", "total_project_time" ], [ "total_project_time", "merge_intervals" ] ]
2
[]
false
[]
false
pytest
true
[]
true
792a9084b5152234e81532eed2cb825c53118258
138c6f0ce41dc29c370c7e6cbcab183a82e62dd9
v1.0
instruct
Taco
Taco_20826_I
Given an integer matrix of size $m \times n$ where each cell contains either a 0 or a 1, find the largest rectangle containing only 1s and return its area. Input Format The first line contains an integer, $\boldsymbol{T}$, denoting the number of matrices you must process. Each of the $T$ subsequent blocks describes o...
def maximalRectangle(matrix): if not matrix: return 0 m, n = len(matrix), len(matrix[0]) height = [0] * n max_area = 0 for i in range(m): for j in range(n): if matrix[i][j] == 0: height[j] = 0 else: height[j] += 1 ...
from solution import process_matrices def test_sample_inputs(): T = 2 matrices = [ (4, 4, [ [1, 0, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1], [1, 0, 0, 0] ]), (3, 3, [ [1, 1, 1], [1, 1, 1], [1, 1, 0] ]) ...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximal_rectangle(matrix):\n def largest_histogram_area(heights):\n stack = []\n max_area = 0\n for i, h in enumerate(heights + [0]):\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020826", "row_id": 20826, "seed_ids": "[6519]" }
0.752958
Taco_20826
I
[ "maximalRectangle", "largestRectangleArea", "process_matrices" ]
3
[ [ "maximalRectangle", "largestRectangleArea" ], [ "process_matrices", "maximalRectangle" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8b3b209a344a0b342ea1f8af39eba94cf1cb9a63
1b963d5856c22dee3dacaba7f6662141e3ed2889
v1.0
instruct
Taco
Taco_20840_I
Subarray Sum Query Given an array of integers a_1, a_2, .., a_N. You will be given Q queries, each with two integers l and r. For each query, compute the sum of the elements in the subarray from index l to index r (inclusive). Input N Q a_1 a_2 ... a_N l_1 r_1 l_2 r_2 :: l_q r_q Output sum_1 sum_2 :: sum_q On li...
def precompute_prefix_sums(arr): """ Computes the prefix sums array for the given input array. """ N = len(arr) prefix_sums = [0] * (N + 1) for i in range(1, N + 1): prefix_sums[i] = prefix_sums[i - 1] + arr[i - 1] return prefix_sums def subarray_sum_query(arr, queries): """ ...
from solution import precompute_prefix_sums, subarray_sum_query def test_precompute_prefix_sums(): arr = [1, 2, 3, 4, 5, 6] expected_prefix_sums = [0, 1, 3, 6, 10, 15, 21] assert precompute_prefix_sums(arr) == expected_prefix_sums def test_subarray_sum_query(): arr = [1, 2, 3, 4, 5, 6] queries = [...
[ { "docstring": "Computes the prefix sums array for the given input array.", "function_declaration": "def precompute_prefix_sums(arr):", "function_name": "precompute_prefix_sums", "parameter_list": "(arr)" }, { "docstring": "Processes subarray sum queries using the prefix sums array.", "f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def subarray_sum_query(n, q, array, queries):\n # Compute prefix sums to enable efficient sum calculation\n prefix_sums = [0] * (n + 1)\n \n for i in r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00020840", "row_id": 20840, "seed_ids": "[12406]" }
0.69855
Taco_20840
I
[ "precompute_prefix_sums", "subarray_sum_query" ]
2
[ [ "subarray_sum_query", "precompute_prefix_sums" ] ]
1
[]
false
[]
false
pytest
true
[]
true
719589ded9be7730ad896c9436f24feae70f614a
1e4436e0e838e21312d901b262af16c5faed37c5
v1.0
instruct
Taco
Taco_20874_I
Given a binary tree, where each node contains an integer value, implement a function to determine the longest path of nodes that form a strictly increasing sequence from the root to any leaf. Your function should return the length of this longest increasing path. If there are multiple such paths with the same length, o...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes): node_dict = {} for value, left, right in nodes: if value not in node_dict: node_dict[value] = TreeNode(value) if left != -1: ...
import pytest from solution import find_longest_increasing_path_length def test_example_case(): tree_nodes = [(10, 5, 20), (5, -1, -1), (20, 15, 30), (15, -1, -1), (30, -1, -1)] assert find_longest_increasing_path_length(tree_nodes) == 3 def test_single_node_tree(): tree_nodes = [(1, -1, -1)] assert f...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00020874", "row_id": 20874, "seed_ids": "[11274]" }
0.588025
Taco_20874
I
[ "build_tree", "longest_increasing_path_length", "find_longest_increasing_path_length" ]
3
[ [ "find_longest_increasing_path_length", "build_tree" ], [ "find_longest_increasing_path_length", "longest_increasing_path_length" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
2c52e3cb344069a31fe52293fc5db040defd6865
20a9c9f047d4c87d9883834d203e66413569abce
v1.0
instruct
Taco
Taco_20915_I
You have been assigned the task of developing a new visualization tool for a company dealing with geospatial data. One of the key functionalities of this tool is to analyze whether a given set of points in a 2D plane form a closed shape, and if so, determine the type of polygon (convex or concave). A polygon is convex...
def orientation(p, q, r): # To find orientation of ordered triplet (p, q, r). # The function returns following values # 0 -> p, q and r are collinear # 1 -> Clockwise # 2 -> Counterclockwise val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1]) if val == 0: return ...
from solution import check_polygon_type def test_no_polygon(): assert check_polygon_type([(1, 2), (2, 1)]) == "NO POLYGON" def test_convex_example_1(): assert check_polygon_type([(0, 0), (0, 3), (3, 3), (3, 0)]) == "CONVEX" def test_convex_example_2(): assert check_polygon_type([(1, 2), (2, 1), (3, 0...
[ { "docstring": null, "function_declaration": "def orientation(p, q, r):", "function_name": "orientation", "parameter_list": "(p, q, r)" }, { "docstring": null, "function_declaration": "def is_polygon(points):", "function_name": "is_polygon", "parameter_list": "(points)" }, { ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def cross_product(o, a, b):\n return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])\n\ndef is_convex_polygon(points):\n n = len(points)\n i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00020915", "row_id": 20915, "seed_ids": "[7126]" }
0.571904
Taco_20915
I
[ "orientation", "is_polygon", "check_polygon_type" ]
3
[ [ "check_polygon_type", "is_polygon" ], [ "check_polygon_type", "orientation" ] ]
2
[]
false
[]
false
pytest
true
[]
true
73262970e372c071e5987524e5f9d0e1d6ef050e
a39acc5ec947fe48c23df1a7c08a9b3ed95cc67f
v1.0
instruct
Taco
Taco_20922_I
Chris is working on a custom number sorting algorithm for a class project. He wants to sort a list of numbers in a specific way: all the prime numbers should appear at the beginning of the list (sorted in ascending order), followed by all the non-prime numbers (also sorted in ascending order). A prime number is a nat...
from typing import List def is_prime(n: int) -> bool: """Helper function to determine if a number is prime.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False ...
from solution import custom_sort def test_all_primes(): assert custom_sort([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_no_primes(): assert custom_sort([4, 6, 8, 9, 10]) == [4, 6, 8, 9, 10] def test_mixed_primes_non_primes(): assert custom_sort([10, 3, 2, 11, 1, 4, -5]) == [2, 3, 11, -5, 1, 4, 10] def...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sorts the list such that all prime numbers come first (in ascending order),\nfollowed by non-prime numbers ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00020922", "row_id": 20922, "seed_ids": "[2391]" }
0.676988
Taco_20922
I
[ "is_prime", "custom_sort" ]
2
[ [ "custom_sort", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c4f3ab7ea6d57359b393d51c9cd22542b1c194d7
09cc1f3f77fba2116218d802b204dbde30fdc33b
v1.0
instruct
Taco
Taco_20943_I
You are given a 2D grid representing a map where '1' represents land and '0' represents water. Your objective is to compute the number of distinct islands in the grid. An island is defined as a group of '1's connected 4-directionally (horizontal or vertical). Two islands are distinct if they are not connected. Diagona...
def num_islands(grid): if not grid: return 0 rows = len(grid) cols = len(grid[0]) visited = set() def dfs(r, c): if (r < 0 or r >= rows or c < 0 or c >= cols or grid[r][c] == '0' or (r, c) in visited): return visited.add((r, c)) dfs(r + 1, c)...
from solution import count_islands def test_count_islands(): input_str = "11110\n11010\n11000\n00000\n\n11000\n11000\n00100\n00011\n\n" assert count_islands(input_str) == [1, 3] def test_single_island(): input_str = "111\n111\n111\n\n" assert count_islands(input_str) == [1] def test_no_island(): ...
[ { "docstring": null, "function_declaration": "def num_islands(grid):", "function_name": "num_islands", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(input_str)" }, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def num_islands(grid):\n if not grid:\n return 0\n\n rows = len(grid)\n cols = len(grid[0])\n visited = set()\n\n def dfs(r, c):\n if ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00020943", "row_id": 20943, "seed_ids": "[22809]" }
0.593705
Taco_20943
I
[ "num_islands", "parse_input", "count_islands" ]
3
[ [ "count_islands", "num_islands" ], [ "count_islands", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
4155b851d3cc2d6622228eba0a1cee25ed948430
2080b994d902fe4a88c2e52db6764132d73b6a92
v1.0
instruct
Taco
Taco_21044_I
John is planning his vacation trip and is fascinated by different routes cities can offer. There are N cities, numbered from 1 to N, and each pair of cities has a direct route between them. He wants to visit exactly K different cities during his trip. Wanderlust that he is, he wants to know the number of different ways...
MOD = 10**9 + 7 def mod_factorial(n, mod): if n == 0: return 1 result = 1 for i in range(2, n+1): result = (result * i) % mod return result def mod_comb(n, k, mod): if k > n: return 0 numerator = mod_factorial(n, mod) denominator = (mod_factorial(k, mod) * mod_facto...
from solution import number_of_ways def test_example(): assert number_of_ways(5, 3) == 60 def test_minimum_values(): assert number_of_ways(2, 2) == 2 def test_large_values(): # The specific output should be checked with an independent tool, such as a mathematical software. assert number_of_ways(20000...
[ { "docstring": null, "function_declaration": "def mod_factorial(n, mod):", "function_name": "mod_factorial", "parameter_list": "(n, mod)" }, { "docstring": null, "function_declaration": "def mod_comb(n, k, mod):", "function_name": "mod_comb", "parameter_list": "(n, k, mod)" }, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef comb(n, k):\n \"\"\" Helper function to calculate nCk % MOD \"\"\"\n if k > n:\n return 0\n if k == 0 or k == n:\n re...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00021044", "row_id": 21044, "seed_ids": "[2070]" }
0.638413
Taco_21044
I
[ "mod_factorial", "mod_comb", "number_of_ways" ]
3
[ [ "mod_comb", "mod_factorial" ], [ "number_of_ways", "mod_comb" ], [ "number_of_ways", "mod_factorial" ] ]
3
[]
false
[]
false
pytest
true
[]
true
20a524b43e42e853bb0228e85c09f9ec995175ab
a1b9ac0206899ad79cfb22d8149fbc337afd676f
v1.0
instruct
Taco
Taco_21092_I
Given a list of integers, you are required to sort the list but in a specific way. Sort the list such that all even numbers appear before any odd number, and both even and odd numbers are sorted in ascending order within their respective groups. Try to solve this problem with a time complexity better than `O(N log N)`...
def sort_even_before_odd(test_cases): results = [] for t in range(len(test_cases)): N, array = test_cases[t] even_numbers = sorted([x for x in array if x % 2 == 0]) odd_numbers = sorted([x for x in array if x % 2 != 0]) sorted_array = even_numbers + odd_numbers results.ap...
def test_parse_input(): input_str = "2\n5\n3 1 2 7 4\n4\n-3 -5 -2 -8\n" expected = [ (5, [3, 1, 2, 7, 4]), (4, [-3, -5, -2, -8]) ] assert parse_input(input_str) == expected def test_sort_even_before_odd(): test_cases = [ (5, [3, 1, 2, 7, 4]), (4, [-3, -5, -2, -8]) ...
[ { "docstring": null, "function_declaration": "def sort_even_before_odd(test_cases):", "function_name": "sort_even_before_odd", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def custom_sort(arr):\n \"\"\"\n Sorts the given list such that all even numbers appear before any odd number,\n and both even and odd numbers are sorted ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021092", "row_id": 21092, "seed_ids": "[66]" }
0.678424
Taco_21092
I
[ "sort_even_before_odd", "parse_input", "format_output", "solution" ]
4
[ [ "solution", "format_output" ], [ "solution", "parse_input" ], [ "solution", "sort_even_before_odd" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
a03884f90d26b458d3eadb669351ce885f683dad
49123425336e54858bcaa40107c09cb20a4d58f7
v1.0
instruct
Taco
Taco_21162_I
A large data set has been divided into multiple smaller sub-arrays, and each sub-array might have a different length. You are tasked with calculating the maximum sum of elements in a contiguous sub-array within each of the given sub-arrays. This problem is essentially a variation of the classic "Maximum Subarray Proble...
def max_subarray_sum(arr): current_max = global_max = arr[0] for num in arr[1:]: current_max = max(num, current_max + num) global_max = max(global_max, current_max) return global_max def process_test_cases(T, test_cases): results = [] for case_idx, case in enumerate(test_cases): ...
from solution import solution def test_sample_input_1(): input_str = """2 2 9 -2 1 -3 4 -1 2 1 -5 4 3 1 2 3 1 4 1 -1 -1 1""" expected_output = "Case #1: 6 6\nCase #2: 1" assert solution(input_str) == expected_output def test_large_negative_numbers(): input_str = """1 1 5 -10 -20 -30 -40 -50""" exp...
[ { "docstring": null, "function_declaration": "def max_subarray_sum(arr):", "function_name": "max_subarray_sum", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def process_test_cases(T, test_cases):", "function_name": "process_test_cases", "parameter_li...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_subarray_sum(arr):\n \"\"\"\n Returns the maximum sum of a contiguous sub-array within the given array.\n \"\"\"\n max_sum = arr[0]\n curren...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00021162", "row_id": 21162, "seed_ids": "[24373]" }
0.768429
Taco_21162
I
[ "max_subarray_sum", "process_test_cases", "solution_input_parser", "solution" ]
4
[ [ "process_test_cases", "max_subarray_sum" ], [ "solution", "process_test_cases" ], [ "solution", "solution_input_parser" ] ]
3
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
57abce0f6c03e570637473a5433e5663471a562a
09966b78b0e2fbcfd0c8f25d9b97fab06e3bc7e9
v1.0
instruct
Taco
Taco_21181_I
Yuki and Ken are avid chess players who enjoy creating new challenges for each other. Recently, they’ve devised a puzzle where given a certain position of a knight on a chessboard, they calculate how many legal moves it has. A knight moves in an "L" shape: two squares in one direction and then one square perpendicular,...
def count_knight_moves(position): """ Given a position on a chessboard, returns the number of valid moves a knight can make. """ column, row = position column = ord(column) - ord('a') + 1 # convert column letter to number row = int(row) possible_moves = [ (2, 1), (2, -1), (-2, 1), ...
import pytest from solution import count_knight_moves, process_positions def test_count_knight_moves_center(): assert count_knight_moves("d4") == 8 def test_count_knight_moves_corner(): assert count_knight_moves("a1") == 2 assert count_knight_moves("h8") == 2 def test_count_knight_moves_edge(): asser...
[ { "docstring": "Given a position on a chessboard, returns the number of valid moves a knight can make.", "function_declaration": "def count_knight_moves(position):", "function_name": "count_knight_moves", "parameter_list": "(position)" }, { "docstring": "Processes multiple positions input an...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def knight_moves(position):\n \"\"\"\n Given a position on a chessboard like 'a1', this function will return the number of valid moves a knight can make.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021181", "row_id": 21181, "seed_ids": "[1126]" }
0.713094
Taco_21181
I
[ "count_knight_moves", "process_positions" ]
2
[ [ "process_positions", "count_knight_moves" ] ]
1
[]
false
[]
false
pytest
true
[]
true
311b6ea70419fd29829473349406e48d51c89a7b
0faf13a30122b53cfbaf30fcad5e34604bc5b1fe
v1.0
instruct
Taco
Taco_21184_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. Input Format A list of integers. Output Format A list of integers containing only the prime numbers from the input list. SAMPLE INPUT [10, 15, 3, 7, 17, 22, 33] SAMPLE OUTPUT ...
def is_prime(n): """ Helper function to 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_primes(numbers): """ Returns a list containing only the prime numbe...
from solution import filter_primes def test_filter_primes_with_mixed_numbers(): assert filter_primes([10, 15, 3, 7, 17, 22, 33]) == [3, 7, 17] def test_filter_primes_with_no_primes(): assert filter_primes([4, 6, 8, 10]) == [] def test_filter_primes_with_all_primes(): assert filter_primes([2, 3, 5, 7, 11]...
[ { "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 containing only the prime numbers from the input list.", "function_declaration": "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00021184", "row_id": 21184, "seed_ids": "[13828]" }
0.706648
Taco_21184
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1f18a6a0fc9c7e54048caa775027ec79109645c8
c35b819be72938d170081b9e6a26c22044c4a6e9
v1.0
instruct
Taco
Taco_21222_I
A train moves along a straight line in a data center, transporting storage boxes between different sections. The train stops at exactly N stations positioned along this line. Each station can hold a particular number of boxes and has a storage capacity C. However, the station can never be overloaded beyond its capacity...
def can_transport_boxes(t, test_cases): results = [] for test_case in test_cases: N, K = test_case['N'], test_case['K'] boxes = test_case['boxes'] capacities = test_case['capacities'] remaining_boxes = K can_transport = True for i in range(N): ...
def test_can_transport_boxes(): input_str = "2\n3 4\n3 2 1\n5 5 5\n4 10\n2 4 6 8\n10 10 10 10\n" expected_output = "YES\nNO" assert solve(input_str) == expected_output def test_edge_case_all_stations_barely_fit(): input_str = "1\n3 2\n2 3 4\n4 6 6\n" expected_output = "YES" assert solve(input_s...
[ { "docstring": null, "function_declaration": "def can_transport_boxes(t, test_cases):", "function_name": "can_transport_boxes", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "para...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_transport_boxes(T, cases):\n results = []\n \n for case in cases:\n N, K, boxes, capacities = case\n boxes_needed = K\n \n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021222", "row_id": 21222, "seed_ids": "[9272]" }
0.746484
Taco_21222
I
[ "can_transport_boxes", "parse_input", "solve" ]
3
[ [ "solve", "can_transport_boxes" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
abac47e90b0e7042b676b655e25352ef6df58707
047a472279ca72a10bdb83177188b4b4b9224d2e
v1.0
instruct
Taco
Taco_21225_I
Anya is participating in a circle dance with her friends. The dance starts with each friend positioned in a circle. Each friend can either stay in their current position or switch places with one of the adjacent friends (the friends next to them in the circle). Anya wants to know the minimum number of switches needed t...
def count_inversions(arr): if len(arr) < 2: return arr, 0 mid = len(arr) // 2 left, left_inv = count_inversions(arr[:mid]) right, right_inv = count_inversions(arr[mid:]) merged, split_inv = merge_and_count(left, right) return merged, left_inv + right_inv + split_inv def merge_and_coun...
import pytest from solution import min_swaps_to_rearrange def test_example_case(): assert min_swaps_to_rearrange(6, "abcdef", "fabcde") == 5 def test_no_swaps_needed(): assert min_swaps_to_rearrange(4, "abcd", "abcd") == 0 def test_single_swap(): assert min_swaps_to_rearrange(2, "ab", "ba") == 1 def tes...
[ { "docstring": null, "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def merge_and_count(left, right):", "function_name": "merge_and_count", "parameter_list": "(l...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_switches(n, current, desired):\n \"\"\"\n Returns the minimum number of switches needed to achieve the desired arrangement.\n \"\"\"\n def get_...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00021225", "row_id": 21225, "seed_ids": "[932]" }
0.649879
Taco_21225
I
[ "count_inversions", "merge_and_count", "min_swaps_to_rearrange" ]
3
[ [ "count_inversions", "merge_and_count" ], [ "min_swaps_to_rearrange", "count_inversions" ] ]
2
[]
false
[]
false
pytest
true
[]
true
11ead754e009a148010d73685f6377459151505b
c3416f28b2f396d45f8351d0496ff151b22225f2
v1.0
instruct
Taco
Taco_21278_I
Create a function that accepts 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, return an empty list. Use the function name `filter_primes`. ### Example ```python filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def f...
from solution import filter_primes def test_filter_primes_with_primes(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_with_no_primes(): assert filter_primes([4, 6, 8, 10]) == [] def test_filter_primes_empty_list(): assert filter_primes([]) == [] def test_filt...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Filters and returns a list of prime numbers from the given list of integers.", "function_declaration": ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_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_1
{ "original_instruction": "", "prompt_id": "00021278", "row_id": 21278, "seed_ids": "[16451]" }
0.64056
Taco_21278
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fa2ad2d206b820a395e8cbdcfe60ed1ec4c6e2eb
61f398764c59bfa9a836a030d9809ce97033e246
v1.0
instruct
Taco
Taco_21281_I
Binary Tree Depth Comparator Given two binary trees, your task is to determine if the two trees have the same structure. In other words, if one tree can be transformed into the other by swapping any subtree (left or right) at any level, the two trees are considered to have the same structure. ------ Input Format ----...
def build_tree(preorder): def helper(index): if index[0] >= len(preorder) or preorder[index[0]] == -1: index[0] += 1 return None node = {'val': preorder[index[0]], 'left': None, 'right': None} index[0] += 1 node['left'] = helper(index) node['right'] = ...
def test_binary_tree_depth_comparator(): test_cases = [ ([[1, 2, -1, -1, 3, -1, -1], [1, 3, -1, -1, 2, -1, -1]], ["Yes"]), ([[1, 2, -1, 5, -1, 4, -1, -1, 3, -1, -1], [1, 3, -1, -1, 2, 5, -1, -1, 4, -1, -1]], ["No"]), ([[1, 2, -1, -1, 3, 4, -1, -1, -1], [1, 3, 4, -1, -1, -1, 2, -1, -1]], ["Ye...
[ { "docstring": null, "function_declaration": "def build_tree(preorder):", "function_name": "build_tree", "parameter_list": "(preorder)" }, { "docstring": null, "function_declaration": "def same_structure(tree1, tree2):", "function_name": "same_structure", "parameter_list": "(tree...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def build_tree(preorder):\n def helper(index):\n if index[0] >= len(preorder) or preorder[index[0]] == -1:\n index[0] += 1\n return...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00021281", "row_id": 21281, "seed_ids": "[24060]" }
0.614874
Taco_21281
I
[ "build_tree", "same_structure", "binary_tree_depth_comparator" ]
3
[ [ "binary_tree_depth_comparator", "build_tree" ], [ "binary_tree_depth_comparator", "same_structure" ] ]
2
[]
false
[]
false
pytest
false
[]
true
321c7f2af32133ba5e039c704eb679d1a3f1bf3c
7a4a161ee564d91c2c6bc13e590001f6c2724939
v1.0
instruct
Taco
Taco_21369_I
Little Timmy loves playing a particular game. In this game, he is given a rectangular grid of size `n x m`, and each cell in the grid contains either a '0' or a '1'. The objective of the game is to find the largest continuous rectangular block (submatrix) of '1's in the grid. For example, consider the following 3x4 gr...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 n, m = len(matrix), len(matrix[0]) max_area = 0 height = [0] * m left = [0] * m right = [m] * m for i in range(n): cur_left, cur_right = 0, m for j in range(m): if matrix[...
from solution import findLargestBlock def test_example_case(): n, m = 3, 4 grid = [ [0, 1, 1, 0], [1, 1, 1, 0], [0, 1, 1, 1] ] assert findLargestBlock(n, m, grid) == 6 def test_single_cell(): n, m = 1, 1 grid = [ [1] ] assert findLargestBlock(n, m, grid)...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def findLargestBlock(n, m, grid):", "function_name": "findLargestBlock", "parameter_lis...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n \n n, m = len(matrix), len(matrix[0])\n max_area = 0\n heigh...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00021369", "row_id": 21369, "seed_ids": "[10114]" }
0.667166
Taco_21369
I
[ "maximalRectangle", "findLargestBlock" ]
2
[ [ "findLargestBlock", "maximalRectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b7f98227c2a907ab30e016dfaf47de11f568e8e
15391b9e1e5bdb3c3c8f033361a598a284c72fc1
v1.0
instruct
Taco
Taco_21465_I
You are given N non-negative integers in an array. Your task is to find the sum of the digits of each integer and then output the integer that has the largest sum of digits. If there is a tie, return the smallest integer among them. ------ Input Format ------ The first line contains a single integer T, the number of ...
def sum_of_digits(n): """ Returns the sum of the digits of the integer n. """ return sum(int(digit) for digit in str(n)) def largest_digit_sum(arr): """ Returns the integer with the largest sum of digits from the array. In case of a tie, returns the smallest integer among them. """ ...
import pytest from solution import sum_of_digits, largest_digit_sum, process_test_cases # Tests for sum_of_digits function def test_sum_of_digits_single_digit(): assert sum_of_digits(5) == 5 def test_sum_of_digits_multiple_digits(): assert sum_of_digits(56) == 11 def test_sum_of_digits_with_zeros(): asse...
[ { "docstring": "Returns the sum of the digits of the integer n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the integer with the largest sum of digits from the array.\nIn case of a tie, returns the sm...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(number):\n \"\"\"\n Returns the sum of the digits of the given number.\n \"\"\"\n return sum(int(digit) for digit in str(number))\n\n...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00021465", "row_id": 21465, "seed_ids": "[15864]" }
0.731154
Taco_21465
I
[ "sum_of_digits", "largest_digit_sum", "process_test_cases" ]
3
[ [ "largest_digit_sum", "sum_of_digits" ], [ "process_test_cases", "largest_digit_sum" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
0658c2247404974eba1ed0d8961f170d0cab9e12
9c7b780c6fe95108a844ba9797eb88a1b5c4182e
v1.0
instruct
Taco
Taco_21513_I
You are given a tree with `n` nodes, each node having a unique value between `1` and `n`. The tree is rooted at node `1` and you are given `q` queries. In each query, you are given a node `v` and an integer `k`. Your task is to determine the `k`-th ancestor of the node `v`. If the `k`-th ancestor does not exist, return...
from collections import defaultdict, deque def preprocess_tree(n, edges): parents = [-1] * (n + 1) children = defaultdict(list) for u, v in edges: children[u].append(v) children[v].append(u) def bfs(root): queue = deque([root]) visited = [False] * (n + 1) ...
from solution import preprocess_tree, kth_ancestor, process_queries def test_preprocess_tree(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] expected_parents = [-1, -1, 1, 1, 2, 2] assert preprocess_tree(n, edges) == expected_parents def test_kth_ancestor(): parents = [-1, -1, 1, 1, 2, 2] as...
[ { "docstring": null, "function_declaration": "def preprocess_tree(n, edges):", "function_name": "preprocess_tree", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def kth_ancestor(v, k, parents):", "function_name": "kth_ancestor", "parameter_list":...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef preprocess_tree(n, edges):\n parents = [-1] * (n + 1)\n children = defaultdict(list)\n \n for u, v in...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00021513", "row_id": 21513, "seed_ids": "[154]" }
0.686287
Taco_21513
I
[ "preprocess_tree", "kth_ancestor", "process_queries" ]
3
[ [ "process_queries", "kth_ancestor" ], [ "process_queries", "preprocess_tree" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
336bd2b241d6c2495ea09be5b6efb5c6a99bb5ca
80e5a8ee57a7c5d6a8f019f17f5139e38623f7aa
v1.0
instruct
Taco
Taco_21530_I
Allie and Blake have been working on a group project that involves creating a 3x3 square grid. The project entails placing integers in each cell of the grid in such a way that the entire grid retains a specific property called "Magic Number Symmetry." The grid is considered to have Magic Number Symmetry if, for every ...
def is_magic_square(grid): # Check rows sum_list = [sum(row) for row in grid] # Check columns for i in range(3): sum_list.append(sum(grid[j][i] for j in range(3))) # Check diagonals sum_list.append(grid[0][0] + grid[1][1] + grid[2][2]) sum_list.append(grid[0][2] + grid[1][1...
from solution import is_magic_square, magic_number_symmetry def test_is_magic_square_valid(): grid = [ [8, 1, 6], [3, 5, 7], [4, 9, 2] ] assert is_magic_square(grid) == True def test_is_magic_square_invalid(): grid = [ [8, 1, 6], [3, 5, 7], [4, 2, 9] ...
[ { "docstring": null, "function_declaration": "def is_magic_square(grid):", "function_name": "is_magic_square", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def magic_number_symmetry():", "function_name": "magic_number_symmetry", "parameter_list": "(...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magic_square(grid):\n # Check rows\n sum_list = [sum(row) for row in grid]\n \n # Check columns\n for i in range(3):\n sum_list.append...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00021530", "row_id": 21530, "seed_ids": "[5226]" }
0.707591
Taco_21530
I
[ "is_magic_square", "magic_number_symmetry" ]
2
[ [ "magic_number_symmetry", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
250b0c25f05203b6a7d9552e50309f8184204df5
d21c6c22f3f33b17e6eb824f20d6ad83bd200591
v1.0
instruct
Taco
Taco_21541_I
A group of friends is planning a hiking trip to explore various hiking trails in a national park. The park has `n` different trails identified by numbers from `1` to `n`, and there are `m` connections between the trails. Each connection defines the time it takes to move from one trail to another. The friends want to st...
def floyd_warshall(n, graph): dist = [[float('inf')] * n for _ in range(n)] for i in range(n): dist[i][i] = 0 for u in range(n): for v, w in graph[u]: dist[u][v] = min(dist[u][v], w) for k in range(n): for i in range(n): for j in range(n): ...
import pytest from solution import floyd_warshall, tsp, solve, hiking_trails_solver def test_floyd_warshall(): graph = [ [(1, 1), (2, 2), (3, 3)], [(0, 1), (2, 4), (3, 2)], [(0, 2), (1, 4), (3, 1)], [(0, 3), (1, 2), (2, 1)] ] expected_dist = [ [0, 1, 2, 3], [...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, graph):", "function_name": "floyd_warshall", "parameter_list": "(n, graph)" }, { "docstring": null, "function_declaration": "def tsp(n, dist):", "function_name": "tsp", "parameter_list": "(n, dist)" }, { ...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def prim_mst(n, adj):\n import heapq\n \n mst_cost = 0\n visited = [False] * (n + 1)\n min_heap = [(0, 1)] # (cost, trail)\n \n while min_hea...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00021541", "row_id": 21541, "seed_ids": "[5515]" }
0.718573
Taco_21541
I
[ "floyd_warshall", "tsp", "solve", "hiking_trails_solver" ]
4
[ [ "hiking_trails_solver", "solve" ], [ "solve", "floyd_warshall" ], [ "solve", "tsp" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8184f8db4db7966a16746de2744d60dff0283a34
c17e88334e9800951a2ff391246f783a4f6a15ca
v1.0
instruct
Taco
Taco_21558_I
Read problems statements in Mandarin Chinese, Russian, and Vietnamese as well. Alice and Bob are playing a game with a string S consisting of lowercase English letters. Players take turns, with Alice going first. On each turn, the player selects a contiguous substring of the current string S and removes it if the su...
def is_palindrome(s): return s == s[::-1] def determine_winner(s): if is_palindrome(s): return "Alice" else: return "Bob" def main(t, cases): results = [] for s in cases: results.append(determine_winner(s)) return results
from solution import is_palindrome, determine_winner, main def test_is_palindrome(): assert is_palindrome("a") == True assert is_palindrome("aba") == True assert is_palindrome("abca") == False assert is_palindrome("") == True def test_determine_winner(): assert determine_winner("a") == "Alice" ...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def determine_winner(s):", "function_name": "determine_winner", "parameter_list": "(s)" }, { "d...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n return s == s[::-1]\n\ndef determine_winner(S):\n if is_palindrome(S):\n return \"Alice\"\n elif len(S) % 2 == 0:\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00021558", "row_id": 21558, "seed_ids": "[484]" }
0.740305
Taco_21558
I
[ "is_palindrome", "determine_winner", "main" ]
3
[ [ "determine_winner", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
67c72b759136af8f933cfc639e10b3c9cf623535
1d1b173a023fbbc4fb4d4a8ca3db44c8b2c9c7b8
v1.0
instruct
Taco
Taco_21576_I
Problem Alex has a collection of n unique coins, and each coin has a distinct positive integer value. He likes arranging his coins in a particular way. Specifically, he wants to separate them into two groups such that: 1. The first group consists of coins whose values are prime numbers. 2. The second group consists o...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def arrange_coins(n, ...
from solution import is_prime, arrange_coins def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(17) def test_arrange_coins(): assert arrange_coins(8, [3, 11, 4, 7, 8, 10, 2, ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Arranges the coins into prime and non-prime groups,\nsorts the prime group in descending order,\nand sorts the non-prime grou...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Function to determine if a number is prime.\n \n Args:\n num: int - The number to check.\n\n Returns:\n bool - T...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021576", "row_id": 21576, "seed_ids": "[6567]" }
0.666091
Taco_21576
I
[ "is_prime", "arrange_coins" ]
2
[ [ "arrange_coins", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
01b9c21c40545208b620819724bbb81cf867b9fe
c560c35ec5d9956b87eb509da88262d639966f8f
v1.0
instruct
Taco
Taco_21612_I
A gaming company is developing a new simulation game and needs some help with the logic to manage player interactions. In the game, players can form connections with one another, similar to friendships. The connections follow these rules: 1. A player can initiate a connection with another player, but they cannot conne...
def find_parent(parent, i): if parent[i] == i: return i else: return find_parent(parent, parent[i]) def union(parent, rank, x, y): xroot = find_parent(parent, x) yroot = find_parent(parent, y) if xroot != yroot: if rank[xroot] > rank[yroot]: parent[yroot] = ...
from solution import number_of_connected_groups def test_example_case_1(): T = 2 test_cases = [ [(5, 3), [(1, 2), (2, 3), (4, 5)]], [(4, 2), [(1, 2), (3, 4)]] ] assert number_of_connected_groups(T, test_cases) == [2, 2] def test_no_connections(): T = 1 test_cases = [ [(...
[ { "docstring": null, "function_declaration": "def find_parent(parent, i):", "function_name": "find_parent", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_parent(parent, i):\n if parent[i] == i:\n return i\n else:\n return find_parent(parent, parent[i])\n\ndef union(parent, rank, x, y):\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00021612", "row_id": 21612, "seed_ids": "[4893]" }
0.614605
Taco_21612
I
[ "find_parent", "union", "number_of_connected_groups" ]
3
[ [ "number_of_connected_groups", "find_parent" ], [ "number_of_connected_groups", "union" ], [ "union", "find_parent" ] ]
3
[]
false
[]
false
pytest
true
[]
true
770868d947e933ecaf8e5fb3e80454e70303caf6
e73b4711ea5c298590c887d9762cd951bb433139
v1.0
instruct
Taco
Taco_21626_I
Given a list of distinct integers, you need to determine if there exists a pair of elements whose sum is equal to a given value. If such a pair exists, print "YES", otherwise print "NO". Input:- The first line of input contains an integer T, the number of test cases. Each test case consists of three lines: 1. An integ...
def pair_sum_exists(test_cases): """ For each test case, determine if there exists a pair of elements whose sum is equal to the given value. """ results = [] for case in test_cases: N, elements, K = case found = False seen = set() for num in elements: ...
def test_pair_sum_exists(): input_str = "2\n5\n1 4 45 6 10 8\n16\n4\n1 2 3 9\n8" expected_output = ["YES", "NO"] assert pair_sum_exists_from_input(input_str) == expected_output def test_pair_sum_not_exists(): input_str = "1\n3\n1 2 4\n7" expected_output = ["NO"] assert pair_sum_exists_from_inpu...
[ { "docstring": "For each test case, determine if there exists a pair of elements \nwhose sum is equal to the given value.", "function_declaration": "def pair_sum_exists(test_cases):", "function_name": "pair_sum_exists", "parameter_list": "(test_cases)" }, { "docstring": "Parses the input str...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def has_pair_with_sum(test_cases):\n \"\"\"\n For each test case, find if there is a pair of integers\n in the list whose sum is equal to the given value....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021626", "row_id": 21626, "seed_ids": "[20158]" }
0.713253
Taco_21626
I
[ "pair_sum_exists", "parse_input", "pair_sum_exists_from_input" ]
3
[ [ "pair_sum_exists_from_input", "pair_sum_exists" ], [ "pair_sum_exists_from_input", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
0e575fb8e2e44b9e4e84d28e6b673a4bb64b691f
42eeacc766f2a749b0834b864727b850c4bccb95
v1.0
instruct
Taco
Taco_21668_I
The mayor of a small town is planning a new park, and she wants to ensure that the park design is both beautiful and functional. One feature of the park will be a network of paths that connect all points of interest (POIs) directly, such as benches, fountains, and statues. Each path, however, costs money to construct, ...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif r...
from solution import minimum_cost_to_connect_pois def test_minimum_cost_example1(): n = 4 paths = [(1, 2, 1), (2, 3, 2), (3, 4, 3), (4, 1, 4), (1, 3, 5)] assert minimum_cost_to_connect_pois(n, paths) == 6 def test_minimum_cost_example2(): n = 3 paths = [(1, 2, 1)] assert minimum_cost_to_connec...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_minimum_cost(n, m, edges):\n \"\"\"\n This function uses Kruskal's algorithm to find the minimum cost to construct a network of paths satisfying the...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021668", "row_id": 21668, "seed_ids": "[668]" }
0.679243
Taco_21668
I
[ "find", "union", "minimum_cost_to_connect_pois", "main" ]
4
[ [ "minimum_cost_to_connect_pois", "find" ], [ "minimum_cost_to_connect_pois", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
2f694a41a6f518c053b6507f8fe277e1441bb4f7
75579f4042ac718285437cd512b5b302a3274801
v1.0
instruct
Taco
Taco_21673_I
A transportation agency is modernizing their route planning system to increase efficiency. The agency manages a fleet of buses with different seating capacities, and there are a number of routes with specific passenger demands. Each bus can operate on only one route per day and once assigned to a route, it cannot be r...
def assign_buses_to_routes(routes, buses): # Sort buses by their seating capacity in descending order buses.sort(reverse=True) # Sort routes by their demand and penalty in descending order of demand routes = sorted(routes, key=lambda x: (-x[1], -x[2])) assigned_routes = [] total_penalt...
def test_sample_input_one(): route_demands_penalties = [ (100, 400), (150, 200), (200, 300), (50, 100) ] bus_capacities = [180, 60, 220] solve(bus_capacities, route_demands_penalties) # The expected result must be: # Number of assigned routes: 3 # Total penalt...
[ { "docstring": null, "function_declaration": "def assign_buses_to_routes(routes, buses):", "function_name": "assign_buses_to_routes", "parameter_list": "(routes, buses)" }, { "docstring": null, "function_declaration": "def solve(bus_capacities, route_demands_penalties):", "function_n...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def assign_buses_to_routes(routes, buses):\n # Sort buses by their capacity in descending order\n buses = sorted([(i+1, c) for i, c in enumerate(buses)], key...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021673", "row_id": 21673, "seed_ids": "[4517]" }
0.715909
Taco_21673
I
[ "assign_buses_to_routes", "solve" ]
2
[ [ "solve", "assign_buses_to_routes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
bf4ff3d9a2407b7c36273892ea5e4a607392efb3
57b2943c9daa7b62753641b99ca61fa9ffe409ee
v1.0
instruct
Taco
Taco_21721_I
Maxmillian is a game developer working on a new puzzle game. The game board is a grid of size N x M, and each cell in the grid can either be empty (represented by '.') or contain an obstacle (represented by '#'). The player starts at the top-left corner of the grid (1, 1) and wants to reach the bottom-right corner (N, ...
from collections import deque def min_moves_to_reach_end(N, M, grid): # Directions for moving up, down, left, right directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] # BFS queue initialization queue = deque([(0, 0, 0)]) # (row, col, distance) visited = set((0, 0)) while queue: x, y...
from solution import solve_puzzle_game def test_minimum_moves_possible_path(): N, M = 4, 4 grid = [ "....", ".#..", "..#.", "...." ] assert solve_puzzle_game(N, M, grid) == 6 def test_no_possible_path_due_to_obstacle(): N, M = 4, 4 grid = [ "....", ...
[ { "docstring": null, "function_declaration": "def min_moves_to_reach_end(N, M, grid):", "function_name": "min_moves_to_reach_end", "parameter_list": "(N, M, grid)" }, { "docstring": null, "function_declaration": "def solve_puzzle_game(N, M, grid_lines):", "function_name": "solve_puzz...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef minimum_moves(N, M, grid):\n # Directions for moving up, down, left, right\n directions = [(-1, 0), (1, 0), (0, -1), (0,...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021721", "row_id": 21721, "seed_ids": "[20437]" }
0.837452
Taco_21721
I
[ "min_moves_to_reach_end", "solve_puzzle_game" ]
2
[ [ "solve_puzzle_game", "min_moves_to_reach_end" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a58d34b648af6de0035f1f8a5364b2df05f3ce19
920e59ca48e9959d623aaba6b56286d1a61f33da
v1.0
instruct
Taco
Taco_21805_I
Linked List Reversal with Constraints problem You are given a singly linked list with N nodes and a non-negative integer K. Each node in the linked list contains an integer value. The linked list's nodes are numbered sequentially from 1 to N. You need to perform a constrained reversal on this linked list: starting fr...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reverse_linked_list_section(head, k): prev = None curr = head next = None count = 0 while curr is not None and count < k: next = curr.next curr.next = prev prev = c...
import pytest from solution import ListNode, reverse_linked_list_section, traverse_to_position, linked_list_from_list, list_from_linked_list, constrained_reversal def test_linked_list_basic(): values = [1, 2, 3, 4, 5] head = linked_list_from_list(values) result = list_from_linked_list(head) assert resu...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef parse_linked_list(values):\n dummy = ListNod...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021805", "row_id": 21805, "seed_ids": "[14812]" }
0.724551
Taco_21805
I
[ "reverse_linked_list_section", "traverse_to_position", "linked_list_from_list", "list_from_linked_list", "constrained_reversal" ]
5
[ [ "constrained_reversal", "linked_list_from_list" ], [ "constrained_reversal", "list_from_linked_list" ], [ "constrained_reversal", "reverse_linked_list_section" ], [ "constrained_reversal", "traverse_to_position" ] ]
4
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
1b5612e1e07de24414c032aa255b3d44aa330809
4a1427c26d0e6664e65c6128ab4ab3527b667e04
v1.0
instruct
Taco
Taco_21810_I
Alex is particularly fond of trees, especially binary trees. He enjoys the challenge of finding the minimum value in the path between two nodes in a binary tree. Recently, he encountered a large balanced binary search tree and posed the following problem to you: Given a balanced binary search tree built with N unique ...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def insert_bst(root, value): if root is None: return TreeNode(value) if value < root.value: root.left = insert_bst(root.left, value) else: root.right = insert...
def test_handle_queries(): input_data = "5\n10 5 3 8 2\n3\n2 3 10\n1 8 7\n2 2 5" expected_output = [3, 2] assert handle_queries(input_data) == expected_output def test_single_update(): input_data = "5\n10 5 3 8 2\n1\n1 8 7" expected_output = [] assert handle_queries(input_data) == expected_outp...
[]
[ 0, 0, 0, 0, 0, 1, 1, 0, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00021810", "row_id": 21810, "seed_ids": "[20448]" }
0.673351
Taco_21810
I
[ "insert_bst", "build_bst", "find_node", "lca_bst", "min_in_path", "min_from_node_to_value", "min_path_util", "handle_queries" ]
8
[ [ "build_bst", "insert_bst" ], [ "handle_queries", "build_bst" ], [ "handle_queries", "find_node" ], [ "handle_queries", "min_in_path" ], [ "min_in_path", "lca_bst" ], [ "min_in_path", "min_path_util" ], [ "min_path_util", "min_from_nod...
7
[ "handle_queries" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
c3db55a12a507067bbcdd42a05cff78988286ce2
43a479e469b2b795e0101c7ca8e833f0262334c7
v1.0
instruct
Taco
Taco_21838_I
A superhero is in a grid city consisting of n × m intersections, where each intersection can either have a building (represented by '#') or be an open space (represented by '.'). The superhero starts at a given intersection (sx, sy) and needs to reach a target intersection (tx, ty) to stop a crime. The superhero can mo...
from collections import deque def min_moves_to_target(grid, n, m, sx, sy, tx, ty): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Up, Down, Left, Right def is_valid(x, y): return 0 <= x < n and 0 <= y < m and grid[x][y] == '.' # Convert 1-based coordinates to 0-based start = (sx - ...
from solution import superhero_grid_path def test_case_1(): grid = [ "....", "..#.", "....", ".#.." ] assert superhero_grid_path(4, 4, grid, 1, 1, 4, 4) == 6 def test_case_2(): grid = [ "###", "#.#", "###" ] assert superhero_grid_path(3, ...
[ { "docstring": null, "function_declaration": "def min_moves_to_target(grid, n, m, sx, sy, tx, ty):", "function_name": "min_moves_to_target", "parameter_list": "(grid, n, m, sx, sy, tx, ty)" }, { "docstring": null, "function_declaration": "def superhero_grid_path(n, m, grid, sx, sy, tx, t...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_moves_to_target(grid, n, m, sx, sy, tx, ty):\n directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Up, Down, Left, Right\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00021838", "row_id": 21838, "seed_ids": "[13983]" }
0.686244
Taco_21838
I
[ "min_moves_to_target", "superhero_grid_path" ]
2
[ [ "superhero_grid_path", "min_moves_to_target" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a13086157f9529916d9ba573155ea4fb3cf58c6a
3a9be0f02928b9d8bf1154547b3e1de2da7cc21d
v1.0
instruct
Taco
Taco_21895_I
You are given a 2D grid of dimensions m x n where each cell in the grid can either be 0 (empty) or 1 (obstacle). You are also given a list of points representing starting positions for a robot. The robot can move up, down, left, or right, but cannot move into or through a cell containing an obstacle. The goal of the ro...
from collections import deque MOD = 10**9 + 7 def num_paths(grid, m, n, start_points, dest): def bfs(start): nonlocal dest rows, cols = len(grid), len(grid[0]) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([start]) visited = set([start]) whi...
from solution import solve def test_case_1(): m, n, k = 4, 4, 2 grid = [ [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 0] ] start_points = [(1, 1), (3, 3)] dest = (4, 4) assert solve(m, n, k, grid, start_points, dest) == 2 def test_case_2(): m, n, k = ...
[ { "docstring": null, "function_declaration": "def num_paths(grid, m, n, start_points, dest):", "function_name": "num_paths", "parameter_list": "(grid, m, n, start_points, dest)" }, { "docstring": null, "function_declaration": "def solve(m, n, k, grid, start_points, dest):", "function...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef is_valid(x, y, m, n, grid):\n return 0 <= x < m and 0 <= y < n and grid[x][y] == 0\n\ndef bfs_count_paths(grid, m, n, start, end):\n f...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021895", "row_id": 21895, "seed_ids": "[7473]" }
0.852986
Taco_21895
I
[ "num_paths", "solve" ]
2
[ [ "solve", "num_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7aeaecace528b62f8b431f0ab943049f8e003aaa
aeb2a5e3fd80bbf2416d91bcc46dce88e73238ab
v1.0
instruct
Taco
Taco_21977_I
Chef loves magical sequences of integers and has recently discovered an interest in prime numbers. He defines a magical sequence as a sequence where exactly one element is a prime number and all other elements are composite numbers. Given an integer array, Chef wants to determine if it is possible to rearrange the arr...
def is_prime(num): """ Check if the number is a prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False limit = int(num ** 0.5) + 1 for i in range(3, limit, 2): if num % i == 0: return False return True ...
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(8) == False assert is_prime(11) == True def test_can_form_magical_sequence(): assert can_form_magical_sequence([4, 6, 8, 9, 3]) == True asser...
[ { "docstring": "Check if the number is a prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determine if the array can be rearranged into a magical sequence.", "function_declaration": "def can_form_magical_sequ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00021977", "row_id": 21977, "seed_ids": "[24718]" }
0.61014
Taco_21977
I
[ "is_prime", "can_form_magical_sequence", "magical_sequences" ]
3
[ [ "can_form_magical_sequence", "is_prime" ], [ "magical_sequences", "can_form_magical_sequence" ] ]
2
[]
false
[]
false
pytest
false
[]
true
cd3fb114f95ca18c2cb992e572bd764529cd62f0
9b80840f5d461e61d325ac5b2edccc77d281b6de
v1.0
instruct
Taco
Taco_22000_I
Create a function that takes an integer n and generates the nth sequence in the "look-and-say" series. The "look-and-say" series starts with "1" and each subsequent term is generated by describing the previous term's digits. For example, starting with 1: - 1 is read as "one 1" or "11" - 11 is read as "two 1s" or "21" ...
def next_in_sequence(s): result = [] i = 0 while i < len(s): count = 1 while i + 1 < len(s) and s[i] == s[i + 1]: i += 1 count += 1 result.append(f"{count}{s[i]}") i += 1 return ''.join(result) def look_and_say(n): if n == 1: return "1...
from solution import look_and_say def test_look_and_say_1(): assert look_and_say(1) == "1" def test_look_and_say_2(): assert look_and_say(2) == "11" def test_look_and_say_3(): assert look_and_say(3) == "21" def test_look_and_say_4(): assert look_and_say(4) == "1211" def test_look_and_say_5(): a...
[ { "docstring": null, "function_declaration": "def next_in_sequence(s):", "function_name": "next_in_sequence", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def look_and_say(n):", "function_name": "look_and_say", "parameter_list": "(n)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def look_and_say(n):\n \"\"\"\n Returns the nth term in the look-and-say sequence.\n \"\"\"\n if n == 1:\n return \"1\"\n \n def next_sequ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00022000", "row_id": 22000, "seed_ids": "[21233]" }
0.622187
Taco_22000
I
[ "next_in_sequence", "look_and_say" ]
2
[ [ "look_and_say", "next_in_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
10d9ba706afc441931bddf48c535fc30c8ebe591
976c2daeeafa171dc602569201f936ed93742e44
v1.0
instruct
Taco
Taco_22030_I
A programmer is working on a sequence transformation problem. The task is to transform a given sequence of integers into a new sequence by applying the following rules: 1. If an element is a prime number, it should be increased by 2. 2. If an element is an even number and not prime, it should be divided by 2. 3. If an ...
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 transform_s...
from solution import is_prime, transform_sequence def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False assert is_prime(11) == True def test_transform_sequence(): assert transform_se...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def transform_sequence(sequence):", "function_name": "transform_sequence", "paramete...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00022030", "row_id": 22030, "seed_ids": "[19879]" }
0.650678
Taco_22030
I
[ "is_prime", "transform_sequence" ]
2
[ [ "transform_sequence", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64851698b74fa0183d2fdf3d3dc0dcbb753480f8
441dd8f067f95cb482a2715f578a63d8ba249efe
v1.0
instruct
Taco
Taco_22047_I
In the kingdom of Dreamland, there are N cities connected by M bidirectional roads. Each road has a known travel time associated with it, and any number of teleporter stations can be built, each offering an instant travel between two cities. You are tasked with building the fewest possible teleporter stations such th...
def floyd_warshall(n, adj_matrix): """ Computes shortest paths between all pairs of nodes using the Floyd-Warshall algorithm. """ dist = [[float('inf')] * n for _ in range(n)] for i in range(n): dist[i][i] = 0 for u in range(n): for v in range(n): if...
def test_min_teleporters_needed(): # Test case 1 assert min_teleporters_needed(4, [(1, 2, 3), (2, 3, 4), (3, 4, 2), (4, 1, 6)], 5) == 1 # Test case 2 assert min_teleporters_needed(5, [(1, 2, 1), (2, 3, 2), (3, 4, 4), (4, 5, 5), (1, 3, 7), (2, 5, 6), (1, 4, 8)], 3) == 2 # Test case 3: No teleporter...
[ { "docstring": "Computes shortest paths between all pairs of nodes\nusing the Floyd-Warshall algorithm.", "function_declaration": "def floyd_warshall(n, adj_matrix):", "function_name": "floyd_warshall", "parameter_list": "(n, adj_matrix)" }, { "docstring": null, "function_declaration": "...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef floyd_warshall(graph, N):\n dist = [[float('inf')] * N for _ in range(N)]\n for i in range(N):\n dist[i][i] = 0\n for u in rang...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00022047", "row_id": 22047, "seed_ids": "[9077]" }
0.719569
Taco_22047
I
[ "floyd_warshall", "min_teleporters_needed" ]
2
[ [ "min_teleporters_needed", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
false
[]
true
57c74d6e4662b8df41a92b245606ea61cb1ffd07
1992c82e927ae46988401ccf829534342ff2c107
v1.0
instruct
Taco
Taco_22098_I
Given a string that contains only digits (0-9), write a function to determine if the string can be partitioned into one or more substrings such that each substring represents a prime number. A prime number cannot have leading zeros, except for the number 0 itself, which is not considered a prime. Example 1: Input: "1...
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True def can_partition_to_primes(s): memo = {} def can_partition(start): if start == len(s): return True if start in memo: ...
from solution import can_partition_to_primes def test_example_1(): assert can_partition_to_primes("11373") == True def test_example_2(): assert can_partition_to_primes("1234") == False def test_single_digit_primes(): assert can_partition_to_primes("2357") == True def test_single_digit_non_primes(): ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def can_partition_to_primes(s):", "function_name": "can_partition_to_primes", "parameter_list": "(s)" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n < 2:\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_1
{ "original_instruction": "", "prompt_id": "00022098", "row_id": 22098, "seed_ids": "[16434]" }
0.646883
Taco_22098
I
[ "is_prime", "can_partition_to_primes" ]
2
[ [ "can_partition_to_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02bce0ee46b42e2f61b62f33b2e3ae86330de390
802a46da9530db12d67ecd02a1bec8ed57c52545
v1.0
instruct
Taco
Taco_22133_I
John loves to design weird shapes using straight lines on a 2D plane. One day he drew a convex quadrilateral and wondered what the maximum and minimum distances between pairs of points (vertices) of the quadrilateral were. Your task is to write a program that helps John calculate the maximum and minimum distance betwe...
import math def distance(x1, y1, x2, y2): """ Calculates the distance between two points (x1, y1) and (x2, y2) """ return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def find_max_min_distances(vertices): """ Given the vertices of a convex quadrilateral, returns the maximum and minimum distances...
from solution import find_max_min_distances def test_case_1(): vertices = [ (0, 0), (0, 2), (2, 2), (2, 0) ] max_dist, min_dist = find_max_min_distances(vertices) assert math.isclose(max_dist, 2.83, abs_tol=0.01) assert math.isclose(min_dist, 2.00, abs_tol=0.01) def...
[ { "docstring": "Calculates the distance between two points (x1, y1) and (x2, y2)", "function_declaration": "def distance(x1, y1, x2, y2):", "function_name": "distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": "Given the vertices of a convex quadrilateral, returns the maximum a...
[ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_distances(vertices):\n def distance(p1, p2):\n return math.sqrt((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2)\n\n distance...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00022133", "row_id": 22133, "seed_ids": "[13509]" }
0.651848
Taco_22133
I
[ "distance", "find_max_min_distances" ]
2
[ [ "find_max_min_distances", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
09e73f1c817e557d454c0beca6d751ca9c2bc283
bfe2a6d15c967121b9978c5214c2358bb7669999
v1.0
instruct
Taco
Taco_22190_I
Harry is given a list of integers and he wants to make all the integers equal by performing a series of operations. In one operation, he can increase or decrease any integer by 1. Your task is to write a program that determines the minimum number of operations required to make all the integers in the list equal. Input...
def min_operations_to_equalize(numbers): """ Given a list of integers, returns the minimum number of operations required to make all the integers equal. Each operation can increase or decrease an integer by 1. """ target = int(median(numbers)) return sum(abs(x - target) for x in numbers) ...
from solution import min_operations_to_equalize def test_case_1(): assert min_operations_to_equalize([1, 2, 3]) == 2 def test_case_2(): assert min_operations_to_equalize([1, 2, 2, 3]) == 2 def test_case_3(): assert min_operations_to_equalize([10, 10, 10, 10, 10]) == 0 def test_case_4(): assert min_o...
[ { "docstring": "Given a list of integers, returns the minimum number of operations \nrequired to make all the integers equal. Each operation can increase \nor decrease an integer by 1.", "function_declaration": "def min_operations_to_equalize(numbers):", "function_name": "min_operations_to_equalize", ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimum_operations_to_equalize(nums):\n \"\"\"\n Returns the minimum number of operations required to make all integers in the list equal.\n An operat...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00022190", "row_id": 22190, "seed_ids": "[8892]" }
0.724978
Taco_22190
I
[ "min_operations_to_equalize", "median" ]
2
[ [ "min_operations_to_equalize", "median" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3642947a5e8655d240cc48bc2e0b85313a77f7dd
3dd15201b151cb4c0ebc3bc8df57b0a980d9efe5
v1.0
instruct
Taco
Taco_22213_I
A prestigious treasure hunt competition is held in a large maze. The maze consists of several cells connected by bidirectional paths. Each cell in the maze may contain a valuable treasure, and the goal is to collect as many valuable items as possible while navigating the maze. Each contestant starts from a designated ...
from collections import deque def bfs_max_treasures(grid, start, n, m): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] visited = [[False] * m for _ in range(n)] max_treasures = 0 q = deque([start]) visited[start[0]][start[1]] = True while q: x, y = q.popleft() fo...
from solution import max_treasures_from_any_start def test_example_1(): n, m = 4, 5 grid = [ "S.T#.", ".#...", "S...T", "##T#S" ] assert max_treasures_from_any_start(n, m, grid) == 3 def test_example_2(): n, m = 3, 4 grid = [ "S.T.", "T..T", ...
[ { "docstring": null, "function_declaration": "def bfs_max_treasures(grid, start, n, m):", "function_name": "bfs_max_treasures", "parameter_list": "(grid, start, n, m)" }, { "docstring": null, "function_declaration": "def max_treasures_from_any_start(n, m, grid):", "function_name": "m...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_treasures(grid):\n \"\"\"\n Returns the maximum number of treasures that can be collected starting from any of the starting cells.\n \n Paramet...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00022213", "row_id": 22213, "seed_ids": "[6390]" }
0.68259
Taco_22213
I
[ "bfs_max_treasures", "max_treasures_from_any_start" ]
2
[ [ "max_treasures_from_any_start", "bfs_max_treasures" ] ]
1
[]
false
[]
false
pytest
true
[]
true
099a9f7415c8c48ec6d5d46846b1299003673646
bd654900c3433f18b598d5893fc1aaa64df2242a
v1.0
instruct
Taco
Taco_22216_I
Alice has a collection of old books and she wants to organize them by their publication dates. She decides she will group the books into different eras, defined as centuries. A century is defined as a period of 100 years, starting from the year 1. For example, books from 1901 to 2000 belong to the 20th century. Alice ...
def century_from_year(year): return (year - 1) // 100 + 1 def organize_books_by_century(books): books.sort(key=lambda x: x[1]) result = [] for title, year in books: century = century_from_year(year) result.append(f'"{title}",{century}th century') return result def main(book_data): ...
from solution import century_from_year, organize_books_by_century, main def test_century_from_year(): assert century_from_year(1) == 1 assert century_from_year(100) == 1 assert century_from_year(101) == 2 assert century_from_year(1900) == 19 assert century_from_year(2000) == 20 assert century_f...
[ { "docstring": null, "function_declaration": "def century_from_year(year):", "function_name": "century_from_year", "parameter_list": "(year)" }, { "docstring": null, "function_declaration": "def organize_books_by_century(books):", "function_name": "organize_books_by_century", "pa...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_books_by_century(books):\n \"\"\"\n Sorts the given list of books by their publication years and labels them by the century.\n\n :param books: Li...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00022216", "row_id": 22216, "seed_ids": "[9753]" }
0.580632
Taco_22216
I
[ "century_from_year", "organize_books_by_century", "main" ]
3
[ [ "organize_books_by_century", "century_from_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
253e5ba200b6c0f3de42ce7b14961da0caf85639
21b9d909e14276e4f9d181a001437836338cc662
v1.0
instruct
Taco
Taco_22217_I
Arjun loves playing with strings. One day, he came across a string S consisting of only lower-case alphabets. He wondered if it was possible to transform the string by removing exactly one character such that the transformed string is a palindrome. A palindrome is a string that reads the same backward as forward. Since...
def can_form_palindrome_by_removing_one_char(s): def is_palindrome(x): return x == x[::-1] n = len(s) left, right = 0, n - 1 while left < right: if s[left] != s[right]: return is_palindrome(s[left+1:right+1]) or is_palindrome(s[left:right]) left += 1 right -...
from solution import solve def test_solve(): assert solve(3, ["abca", "racecarx", "aaaa"]) == ["YES", "YES", "NO"] def test_solve_single_char(): assert solve(1, ["a"]) == ["NO"] def test_solve_two_chars(): assert solve(1, ["ab"]) == ["YES"] def test_solve_already_palindrome(): assert solve(1, ["race...
[ { "docstring": null, "function_declaration": "def can_form_palindrome_by_removing_one_char(s):", "function_name": "can_form_palindrome_by_removing_one_char", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def solve(T, strings):", "function_name": "solve", ...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_transform_to_palindrome(s):\n def is_palindrome(s):\n return s == s[::-1]\n\n n = len(s)\n left, right = 0, n - 1\n \n while left < r...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022217", "row_id": 22217, "seed_ids": "[13583]" }
0.825506
Taco_22217
I
[ "can_form_palindrome_by_removing_one_char", "solve" ]
2
[ [ "solve", "can_form_palindrome_by_removing_one_char" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ad6dff0fb48d2e7c5c48278ed342ab0ea9ac9b5b
3db24bb09b5aea65d5385966691d7a1a3cc7dda1
v1.0
instruct
Taco
Taco_22243_I
Write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. Hint You may want to write a helper function to determine whether a given number is prime. A number is prime if it has no divisors other than 1 and itself. Constraints 1 ≤ length of the li...
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 ...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers filtered from the provided list of numbers.", "function_declaration": "de...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n retur...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00022243", "row_id": 22243, "seed_ids": "[20276]" }
0.614876
Taco_22243
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
32ee2fc00365d99e166c7ae1a5b222cafa56c51b
bc0945f4dd208be54509fe066b8bcc91a8d6979f
v1.0
instruct
Taco
Taco_22264_I
You are a game developer working on a turn-based strategy game where the player controls a warrior with limited energy points. The warrior can perform different kinds of actions including moving and attacking, but each action costs a specific amount of energy. Your task is to determine the maximum number of enemies the...
def calculate_energy_cost(x, y, a): """ Calculates the total energy cost for moving to and attacking an enemy at (x, y) with attack cost a. """ distance_cost = abs(x) + abs(y) total_energy_cost = distance_cost + a return total_energy_cost def max_enemies_defeated(energy, enemies): """ D...
def test_calculate_energy_cost(): assert calculate_energy_cost(3, 4, 10) == 17 assert calculate_energy_cost(5, 6, 15) == 26 assert calculate_energy_cost(2, 8, 20) == 30 def test_max_enemies_defeated(): assert max_enemies_defeated(100, [(3, 4, 10), (5, 6, 15), (2, 8, 20)]) == 3 assert max_enemies_de...
[ { "docstring": "Calculates the total energy cost for moving to and attacking an enemy at (x, y) with attack cost a.", "function_declaration": "def calculate_energy_cost(x, y, a):", "function_name": "calculate_energy_cost", "parameter_list": "(x, y, a)" }, { "docstring": "Determines the maxim...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_enemies_defeated(E, enemies):\n \"\"\"\n Determines the maximum number of enemies the warrior can defeat without running out of energy.\n Args:\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022264", "row_id": 22264, "seed_ids": "[12837]" }
0.774667
Taco_22264
I
[ "calculate_energy_cost", "max_enemies_defeated", "max_enemies_per_turn" ]
3
[ [ "max_enemies_defeated", "calculate_energy_cost" ], [ "max_enemies_per_turn", "max_enemies_defeated" ] ]
2
[]
false
[]
false
pytest
false
[]
true
646f2d23b8a39cc6c0bc22dd61ef1f127510afbe
eac278ed81ae170da22c440d761d9bc61b9211b2
v1.0
instruct
Taco
Taco_22279_I
There is a maze represented as a grid of size N x M. Each cell in the grid can be either open (represented by '.') or blocked (represented by '#'). You start at the top-left corner of the maze (0, 0) and your goal is to reach the bottom-right corner (N-1, M-1). You can only move up, down, left, or right, and you cannot...
from collections import deque def minimum_moves_to_reach_end_with_jump(grid): def is_valid(x, y, n, m): return 0 <= x < n and 0 <= y < m def bfs(n, m, grid): # Directions for moving up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(0, 0, 0, F...
import pytest from solution import solve, parse_input def test_simple_case(): input_text = "1\n2 2\n..\n.." test_cases = parse_input(input_text) assert solve(test_cases) == [2] def test_case_with_jumps(): input_text = "1\n4 4\n....\n.#..\n..#.\n...." test_cases = parse_input(input_text) assert...
[ { "docstring": null, "function_declaration": "def minimum_moves_to_reach_end_with_jump(grid):", "function_name": "minimum_moves_to_reach_end_with_jump", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_moves_to_reach_end(grid, N, M):\n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n \n def in_bounds(x, y):\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022279", "row_id": 22279, "seed_ids": "[17202]" }
0.756521
Taco_22279
I
[ "minimum_moves_to_reach_end_with_jump", "solve", "parse_input" ]
3
[ [ "solve", "minimum_moves_to_reach_end_with_jump" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
5815e6b0d6cf078165a691931be4bd9a32ffb960
3d09a445724bcadcbe3f8b1960e8c707b71cea1c
v1.0
instruct
Taco
Taco_22320_I
You are given a list of integers and your task is to form a new list which will be strictly increasing. The new list should be formed by removing the smallest possible number of elements from the original list. ------ Input ------ The first line contains a single integer $T$ denoting the number of test cases. The des...
def longest_increasing_subsequence(arr): if not arr: return [] n = len(arr) dp = [1] * n prev = [-1] * n for i in range(1, n): for j in range(i): if arr[i] > arr[j] and dp[i] < dp[j] + 1: dp[i] = dp[j] + 1 prev[i] = j ...
def test_longest_increasing_subsequence(): assert longest_increasing_subsequence([5, 1, 2, 9, 2, 3]) == [1, 2, 9] assert longest_increasing_subsequence([4, 3, 2, 1]) == [4] assert longest_increasing_subsequence([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] assert longest_increasing_subsequence([10, 22, 9, 33, 21,...
[ { "docstring": null, "function_declaration": "def longest_increasing_subsequence(arr):", "function_name": "longest_increasing_subsequence", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def process_test_cases(T, test_cases):", "function_name": "process_te...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def strictly_increasing_list(T, test_cases):\n \"\"\"\n Returns strictly increasing lists for each test case by removing the smallest possible number of elem...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00022320", "row_id": 22320, "seed_ids": "[11569]" }
0.742901
Taco_22320
I
[ "longest_increasing_subsequence", "process_test_cases", "input_output_handling", "main" ]
4
[ [ "process_test_cases", "longest_increasing_subsequence" ] ]
1
[ "process_test_cases" ]
false
[]
false
pytest
false
[]
true
cf45942358842ac72c8360a09f15ce70620b8877
a3f377383b68d201efc1b7061bc8e8aaf47ad123
v1.0
instruct
Taco
Taco_22327_I
-----Task----- Given a binary tree, implement an algorithm to find the length of the longest path in terms of number of nodes between any two nodes in the tree. The path may or may not pass through the root. Your function should compute this length efficiently. -----Input----- The input consists of a binary tree, wher...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def deserialize(data): if not data or data[0] == -1: return None nodes = [TreeNode(val) if val != -1 else None for val in data] root = nodes[0] ...
from solution import longest_path_length_from_list def test_example_1(): assert longest_path_length_from_list([1, 2, 3, 4, -1, 5, -1, -1, -1, -1, -1]) == 5 def test_example_2(): assert longest_path_length_from_list([1, 2, -1, -1, -1]) == 2 def test_empty_tree(): assert longest_path_length_from_list([]) =...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\nclass Solution:\n def __init__(self):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00022327", "row_id": 22327, "seed_ids": "[11302]" }
0.568419
Taco_22327
I
[ "deserialize", "longest_path_length", "longest_path_length_from_list" ]
3
[ [ "longest_path_length_from_list", "deserialize" ], [ "longest_path_length_from_list", "longest_path_length" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
eac45c3239809212a79ea2676bdcb5b40e644782
4ab86d7ddd4a0bb1438722abda45355af8e60888
v1.0
instruct
Taco
Taco_22416_I
Tina loves collecting coins. She arranges her coin collection in rows, where each row contains at least as many coins as the previous row. Tina decides to form the shape of a pyramid with her coins, where the first row has exactly 1 coin, the second row has exactly 2 coins, and so on, forming a progressively increasing...
def max_pyramid_height(N): """ Returns the maximum height of the pyramid that can be formed with N coins. """ height = 0 while N >= (height + 1): height += 1 N -= height return height def process_cases(T, cases): """ Process the test cases and return the results. """...
from solution import solve_pyramid_height_problem def test_example_cases(): input_data = "3\n1\n5\n8" expected_output = "1\n2\n3" assert solve_pyramid_height_problem(input_data) == expected_output def test_small_cases(): input_data = "2\n2\n3" expected_output = "1\n2" assert solve_pyramid_heig...
[ { "docstring": "Returns the maximum height of the pyramid that can be formed with N coins.", "function_declaration": "def max_pyramid_height(N):", "function_name": "max_pyramid_height", "parameter_list": "(N)" }, { "docstring": "Process the test cases and return the results.", "function_...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximum_height(T, test_cases):\n results = []\n for N in test_cases:\n height = 0\n while N >= (height + 1):\n height += 1\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00022416", "row_id": 22416, "seed_ids": "[1159]" }
0.773663
Taco_22416
I
[ "max_pyramid_height", "process_cases", "solve_pyramid_height_problem" ]
3
[ [ "process_cases", "max_pyramid_height" ], [ "solve_pyramid_height_problem", "process_cases" ] ]
2
[ "process_cases" ]
false
[]
false
pytest
true
[]
true
59a64197f86c79efcc0bd89121fbb0f6d860ad31
c08de5ce0fb3957ea053f1d14e0e5c5946dc326e
v1.0
instruct
Taco
Taco_22472_I
A company is planning to build new office spaces, and they want to minimize the area of the space while ensuring all the necessary departments can be accommodated. Each department needs a rectangular area to function, and the new office space should be a single rectangle. You have been asked to write a program to dete...
def min_rectangle_size(test_cases): res = [] for case in test_cases: dimensions = case['dimensions'] N = case['N'] max_width = 0 total_length = 0 for length, width in dimensions: total_length += length max_width = max(max_width, width) res....
def test_min_rectangle_size(): input_data = "2\n3\n4 5\n2 3\n6 2\n2\n3 6\n5 4" expected_output = [(12, 5), (8, 6)] assert solve(input_data) == expected_output def test_min_rectangle_size_single_case(): input_data = "1\n1\n5 4" expected_output = [(5, 4)] assert solve(input_data) == expected_...
[ { "docstring": null, "function_declaration": "def min_rectangle_size(test_cases):", "function_name": "min_rectangle_size", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def read_input(input_data):", "function_name": "read_input", "parameter_lis...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimum_rectangle_size(test_cases):\n results = []\n for case in test_cases:\n n = case[0]\n departments = case[1:]\n total_length =...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00022472", "row_id": 22472, "seed_ids": "[161]" }
0.657283
Taco_22472
I
[ "min_rectangle_size", "read_input", "solve" ]
3
[ [ "solve", "min_rectangle_size" ], [ "solve", "read_input" ] ]
2
[ "read_input" ]
false
[]
false
pytest
false
[]
true
63a14bc68b7c24569265db4723dc7d12dc474590
411955449e171a002d21af3eb882b0ef5a6cb50e
v1.0
instruct
Taco
Taco_22514_I
Given a list of integers, write a function that returns a list of all integers in the input list that are prime numbers. A prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself. For example, given the input list `[2, 3, 4, 5, 6, 10, 13, 17, 19, 21, 23, 24, 29]`...
def is_prime(num): if num <= 1: return False if num == 2 or 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 filter_prime_n...
from solution import filter_prime_numbers def test_filter_prime_numbers_mixed(): assert filter_prime_numbers([2, 3, 4, 5, 6, 10, 13, 17, 19, 21, 23, 24, 29]) == [2, 3, 5, 13, 17, 19, 23, 29] def test_filter_prime_numbers_with_non_prime(): assert filter_prime_numbers([1, 4, 6, 8, 9, 10]) == [] def test_filter...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers from the input list of integers.", "function_declaration": "def filter_prime_numbers(numbers):", "function_name...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num == 2 or num == 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00022514", "row_id": 22514, "seed_ids": "[4060]" }
0.708523
Taco_22514
I
[ "is_prime", "filter_prime_numbers" ]
2
[ [ "filter_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e4c059c82c8a703a0564c5ef5ddccdc2b78435b
5b5c3bb4503e97bdeb3c7f8c6714423adfc23c6b
v1.0
instruct
Taco
Taco_22650_I
In the near future, a new kind of social network called ConnectU has emerged, focusing on facilitating direct and indirect connections among its users. Each user on ConnectU has a unique user ID and a list of friends represented by their user IDs. Unlike traditional social networks, ConnectU does not display each user'...
from collections import deque, defaultdict def bfs_shortest_path(graph, start, goal): """ Uses BFS to find the shortest path from start to goal in an undirected graph. Returns the length of the shortest path, or -1 if there is no path. """ if start == goal: return 0 visited = set()...
def test_shortest_path(): friendships = [(1, 2), (2, 3), (3, 4), (4, 5)] shortest_path_length, _ = connectu_analysis(5, 4, friendships, 1, 5) assert shortest_path_length == 4 def test_no_path(): friendships = [(1, 2), (3, 4)] shortest_path_length, _ = connectu_analysis(4, 2, friendships, 1, 4) ...
[ { "docstring": "Uses BFS to find the shortest path from start to goal in an undirected graph.\nReturns the length of the shortest path, or -1 if there is no path.", "function_declaration": "def bfs_shortest_path(graph, start, goal):", "function_name": "bfs_shortest_path", "parameter_list": "(graph, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef bfs_shortest_path(graph, start, goal):\n \"\"\"\n Uses BFS to find the shortest path from start to goal in ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00022650", "row_id": 22650, "seed_ids": "[9679]" }
0.625795
Taco_22650
I
[ "bfs_shortest_path", "calculate_user_influence", "connectu_analysis" ]
3
[ [ "connectu_analysis", "bfs_shortest_path" ], [ "connectu_analysis", "calculate_user_influence" ] ]
2
[]
false
[]
false
pytest
false
[]
true
cf0914b699e7864bb644b59c2613860b07cdb3ba
57866b6c40304ecf96dc769251a8bd0319493a88
v1.0
instruct
Taco
Taco_22672_I
Create a program that simulates a basic card game involving a standard 52-card deck. The game will involve dealing five cards to each player and then determining the winner based on the highest card in hand. Aces are considered high cards. ### Input - The first line of input contains a single integer `t` (1 ≤ t ≤ 100...
import random def create_deck(): suits = ['H', 'D', 'C', 'S'] values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] return [value + suit for value in values for suit in suits] def card_value(card): value_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10...
import pytest from solution import create_deck, deal_cards, determine_winner, card_value, simulate_card_game def test_create_deck(): deck = create_deck() assert len(deck) == 52 assert "AS" in deck # Ace of Spades assert "10D" in deck # 10 of Diamonds def test_card_value(): assert card_value("AS"...
[ { "docstring": null, "function_declaration": "def create_deck():", "function_name": "create_deck", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def card_value(card):", "function_name": "card_value", "parameter_list": "(card)" }, { "docstring": n...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef create_deck():\n suits = ['H', 'D', 'C', 'S']\n values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']\n return ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00022672", "row_id": 22672, "seed_ids": "[15769]" }
0.711279
Taco_22672
I
[ "create_deck", "card_value", "deal_cards", "determine_winner", "simulate_card_game", "card_game" ]
6
[ [ "card_game", "simulate_card_game" ], [ "determine_winner", "card_value" ], [ "simulate_card_game", "create_deck" ], [ "simulate_card_game", "deal_cards" ], [ "simulate_card_game", "determine_winner" ] ]
5
[]
false
[]
false
pytest
true
[]
true
049bd34fc1a421a227f7067481fb400185f175eb
ba6e09b26c2b6e307ee736bf1e26e6b50bb1bac1
v1.0
instruct
Taco
Taco_22714_I
I: Organize Strings Problem Statement You have an array of strings, `strings`, and an integer `N`. Your task is to sort the strings in such a way that for each string, you count the number of vowels (a, e, i, o, u) in it. The strings should be sorted based on the number of vowels in descending order. If two strings h...
from typing import List def count_vowels(s: str) -> int: vowels = {'a', 'e', 'i', 'o', 'u'} return sum(1 for char in s if char in vowels) def sort_strings_by_vowels(strings: List[str], N: int) -> List[str]: return sorted(strings, key=lambda s: (-count_vowels(s), s))
from solution import sort_strings_by_vowels def test_example(): N = 5 strings = ["apple", "banana", "grape", "kiwi", "orange"] assert sort_strings_by_vowels(strings, N) == ["banana", "orange", "apple", "grape", "kiwi"] def test_identical_vowel_counts(): N = 4 strings = ["aa", "bb", "cc", "dd"] ...
[ { "docstring": null, "function_declaration": "def count_vowels(s):", "function_name": "count_vowels", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def sort_strings_by_vowels(strings, N):", "function_name": "sort_strings_by_vowels", "parameter_list": "(...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_strings_by_vowels(strings, N):\n \"\"\"\n Sort the strings based on the number of vowels in descending order,\n and lexicographically in ascendin...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00022714", "row_id": 22714, "seed_ids": "[19904]" }
0.759317
Taco_22714
I
[ "count_vowels", "sort_strings_by_vowels" ]
2
[ [ "sort_strings_by_vowels", "count_vowels" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13887b45a4da386836dace6ed9ea10aca3b6ce9e
0cc56ba30bf1f2dfd2d38cacad5959feeeae52d4
v1.0
instruct
Taco
Taco_22731_I
In a certain country, the health ministry wants to ensure that all citizens have access to a hospital within a certain distance. The country is represented as a large grid, with some cells containing hospitals while others are empty. Your task is to determine the minimum distance required so that every citizen has acce...
from collections import deque def bfs_min_distance(grid, m, n): # find all the hospitals hospitals = [] for i in range(m): for j in range(n): if grid[i][j] == 'H': hospitals.append((i, j)) # directions for movement: left, right, up, down directio...
def test_small_grid(): m, n = 3, 3 grid = [ ".H.", "...", "H.H" ] assert min_distance_to_hospital(m, n, grid) == 1 def test_square_grid(): m, n = 4, 4 grid = [ "H..H", "....", "....", "H..H" ] assert min_distance_to_hospital(m, n, ...
[ { "docstring": null, "function_declaration": "def bfs_min_distance(grid, m, n):", "function_name": "bfs_min_distance", "parameter_list": "(grid, m, n)" }, { "docstring": null, "function_declaration": "def min_distance_to_hospital(m, n, grid):", "function_name": "min_distance_to_hospi...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef bfs_min_distance(grid, m, n):\n # find all the hospitals\n hospitals = []\n for i in range(m):\n for j in rang...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00022731", "row_id": 22731, "seed_ids": "[12270]" }
0.695821
Taco_22731
I
[ "bfs_min_distance", "min_distance_to_hospital" ]
2
[ [ "min_distance_to_hospital", "bfs_min_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1fec3f4ee548423722651b101121c5ef686d824d
20defd7c29531fdd61874eb67fa55e437c915d36
v1.0
instruct
Taco
Taco_22794_I
Given a string s of length n, your goal is to determine whether it can be broken into exactly `k` substrings where each substring is a palindrome. A palindrome is a word, phrase, or sequence of characters which reads the same backward as forward. Write a function `canBreakIntoKPalindromes(s: str, k: int) -> bool` that...
def is_palindrome(sub): return sub == sub[::-1] def canBreakIntoKPalindromes(s, k): """ Determine if a string can be broken into exactly k palindromes. """ def can_partition(s, k, start): if k == 0: return start == len(s) for end in range(start + 1, len(s) + 1): ...
from solution import canBreakIntoKPalindromes def test_example_1(): assert canBreakIntoKPalindromes("aab", 2) == True def test_example_2(): assert canBreakIntoKPalindromes("abc", 2) == False def test_example_3(): assert canBreakIntoKPalindromes("aaabb", 3) == True def test_single_character_palindromes()...
[ { "docstring": null, "function_declaration": "def is_palindrome(sub):", "function_name": "is_palindrome", "parameter_list": "(sub)" }, { "docstring": "Determine if a string can be broken into exactly k palindromes.", "function_declaration": "def canBreakIntoKPalindromes(s, k):", "fun...
[ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(sub):\n return sub == sub[::-1]\n\ndef canBreakIntoKPalindromes(s, k):\n n = len(s)\n\n # Helper function to check if we can partition t...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00022794", "row_id": 22794, "seed_ids": "[3394]" }
0.790391
Taco_22794
I
[ "is_palindrome", "canBreakIntoKPalindromes" ]
2
[ [ "canBreakIntoKPalindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
44941ae875ce90e2fd64e23678c06f772e37e5a0
6d4ab9907a47400ee310c7c12dc7231447950344
v1.0
instruct
Taco
Taco_22801_I
Given a tree with n nodes rooted at node 1, you are required to perform q queries on it. Each query gives you two integers $u$ and $v$, representing two nodes in the tree. For each query, you need to determine the number of nodes that lie on the path from $u$ to $v$ (both inclusive). ----Input---- The first line cont...
from collections import defaultdict, deque def calculate_distances(n, edges): """ Calculates the distance (number of nodes in path) between all pairs of nodes in a tree. """ graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) def bfs(star...
import sys from io import StringIO from solution import main def test_case_1(): input_data = """5 1 2 1 3 3 4 3 5 3 2 4 1 5 1 2 """ expected_output = """4 3 2 """ check_test_case(input_data, expected_output) def test_case_2(): input_data = """6 1 2 1 3 2 4 2 5 3 6 4 5 6 1 4 3 4 6 1 """ expected_ou...
[ { "docstring": "Calculates the distance (number of nodes in path) between all pairs of nodes in a tree.", "function_declaration": "def calculate_distances(n, edges):", "function_name": "calculate_distances", "parameter_list": "(n, edges)" }, { "docstring": "For each query (u, v) returns the ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nfrom collections import deque, defaultdict\n\ninput = sys.stdin.read\n\ndef lca_preprocess(tree, root, n):\n # Depth and LCA Arrays\n depth = [-1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00022801", "row_id": 22801, "seed_ids": "[12986]" }
0.718996
Taco_22801
I
[ "calculate_distances", "count_nodes_on_path", "main" ]
3
[ [ "count_nodes_on_path", "calculate_distances" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0c309d6ebde59ed07ee6bc8d267b45fee7d0b189
1313b9e034e35e6fe5b5efa78f5ff8851c10053a
v1.0
instruct
Taco
Taco_22822_I
A popular e-commerce platform wants to improve its online shopping experience by adding a personalized discount system. Each customer is associated with a unique customer ID which is a positive integer. The platform offers different discounts based on certain properties of the customer ID. To achieve this in an effici...
def is_prime(num): """ Returns True if num is a prime number, 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) == 0: ...
from solution import is_prime, qualifies_for_prime_discount def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(1) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) def test_qualifies_for_prime_discount_yes(): assert qualifies_for_prime_discount(41...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determines if the customer ID qualifies for prime discount.\nA customer ID qualifies if the sum of...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00022822", "row_id": 22822, "seed_ids": "[3537]" }
0.630612
Taco_22822
I
[ "is_prime", "qualifies_for_prime_discount" ]
2
[ [ "qualifies_for_prime_discount", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4c0d14f4581178850d18a2bd23a556b06126724c
8e9e863cd43859c305f675246bb6a06158a76d83
v1.0
instruct
Taco
Taco_22915_I
### Task Scheduling Alice works as a task manager and often has to deal with a series of tasks that need to be scheduled. Each task has a start time and an end time, and no two tasks can be active at the same time due to the constraints of the system. Your job is to write a program that determines the maximum number o...
from datetime import datetime def parse_time(time_str): return datetime.strptime(time_str, '%H:%M') def max_non_overlapping_tasks(tasks): tasks.sort(key=lambda x: x[1]) # Sort by end time count = 0 last_end_time = datetime.min for start, end in tasks: if start >= last_end_time: ...
def test_parse_time(): assert parse_time('09:00') == datetime.strptime('09:00', '%H:%M') assert parse_time('23:59') == datetime.strptime('23:59', '%H:%M') def test_max_non_overlapping_tasks(): tasks = [(parse_time('09:00'), parse_time('11:00')), (parse_time('13:00'), parse_time('14:00')), ...
[ { "docstring": null, "function_declaration": "def parse_time(time_str):", "function_name": "parse_time", "parameter_list": "(time_str)" }, { "docstring": null, "function_declaration": "def max_non_overlapping_tasks(tasks):", "function_name": "max_non_overlapping_tasks", "paramete...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\ndef parse_time(time_str):\n return datetime.strptime(time_str, '%H:%M')\n\ndef max_non_overlapping_tasks(tasks):\n tasks.sor...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00022915", "row_id": 22915, "seed_ids": "[2605]" }
0.634423
Taco_22915
I
[ "parse_time", "max_non_overlapping_tasks", "process_input", "main" ]
4
[ [ "process_input", "max_non_overlapping_tasks" ], [ "process_input", "parse_time" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
10b646aab70b32da642e5ba11fb97fbdfc90b6b5
f93b3f32367535183f726cd0f79e86a93d942941
v1.0
instruct
Taco
Taco_22944_I
Roman often loved complex mazes. Monica decided to give him a unique maze design on his birthday, where he has to find the longest path from the start to the end in a grid. Roman can only move up, down, left, or right, and he cannot move through walls. Each cell in the grid is either empty (.) or a wall (#). Monica cle...
def find_start_and_end(grid): start, end = None, None for i in range(len(grid)): for j in range(len(grid[i])): if grid[i][j] == 'S': start = (i, j) if grid[i][j] == 'E': end = (i, j) return start, end def longest_path(grid, start, end): di...
def test_find_start_and_end(): grid = [ ['S', '.', '.', '#'], ['.', '#', '.', 'E'], ['#', '.', '.', '.'] ] assert find_start_and_end(grid) == ((0, 0), (1, 3)) def test_longest_path(): grid = [ ['S', '.', '.', '#'], ['.', '#', '.', 'E'], ['#', '.', '.', '....
[ { "docstring": null, "function_declaration": "def find_start_and_end(grid):", "function_name": "find_start_and_end", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def longest_path(grid, start, end):", "function_name": "longest_path", "parameter_list"...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_path(T, test_cases):\n def valid_move(x, y):\n return 0 <= x < n and 0 <= y < m and grid[x][y] != '#' and not visited[x][y]\n\n def dfs(x,...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00022944", "row_id": 22944, "seed_ids": "[22475]" }
0.643726
Taco_22944
I
[ "find_start_and_end", "longest_path", "solve" ]
3
[ [ "solve", "find_start_and_end" ], [ "solve", "longest_path" ] ]
2
[]
false
[]
false
pytest
false
[]
true
b35081aea76f2f69f005c5b6d629af3b383ef079
770cfbdb7a90d7085974aecbaf000143fbe1f6df
v1.0
instruct
Taco
Taco_22980_I
In a land far away, there is an enchanted forest where magical tiles are laid out in a grid format. Each tile has a specific mana level, which is represented by an integer. The forest is guarded by an ancient spirit who only allows those who can collect a series of tiles such that the sum of their mana levels is exactl...
def can_collect_mana(grid, N, target): """ Determines if a path exists from (0, 0) to (N-1, N-1) with the sum exactly equal to target. """ return dfs(grid, N, target, 0, 0, 0) def dfs(grid, N, target, current_sum, x, y): if x >= N or y >= N: return False current_sum += grid[x][y] if...
def test_enchanted_forest(): test_cases = [ (4, 14, [ [5, 3, 2, 1], [1, 2, 3, 4], [1, 1, 1, 1], [4, 1, 2, 1] ]), (4, 10, [ [5, 3, 2, 1], [1, 2, 3, 4], [1, 1, 1, 1], [4,...
[ { "docstring": "Determines if a path exists from (0, 0) to (N-1, N-1) with the sum exactly equal to target.", "function_declaration": "def can_collect_mana(grid, N, target):", "function_name": "can_collect_mana", "parameter_list": "(grid, N, target)" }, { "docstring": null, "function_dec...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_collect_mana(grid, N, target):\n \"\"\"\n Determines if a path exists from (0, 0) to (N-1, N-1) with the sum exactly equal to target.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00022980", "row_id": 22980, "seed_ids": "[7690]" }
0.62284
Taco_22980
I
[ "can_collect_mana", "dfs", "enchanted_forest" ]
3
[ [ "can_collect_mana", "dfs" ], [ "enchanted_forest", "can_collect_mana" ] ]
2
[]
false
[]
false
pytest
false
[]
true
a67485cbb7ce450ccaf1632b6cf41da4a1d078ca
33636f3e98070dee71a425fcc61ba6a335db2970
v1.0
instruct
Taco
Taco_22991_I
**Problem Statement:** Hiking Alex's Homecoming Alex loves hiking and often goes on long weekend trips into the mountains. He has recorded the altitude at each point along his hike. To better understand his trips, Alex wants to analyze the altitude data by segmenting his hike into individual peaks. A peak is defined ...
def find_peaks(n, altitude): peaks = [] for i in range(1, n - 1): if altitude[i] > altitude[i - 1] and altitude[i] > altitude[i + 1]: peaks.append(i + 1) # Use 1-based index if not peaks: return "No peaks" else: return " ".join(map(str, peaks)) # Function ...
from solution import find_peaks, hiking_alex_homecoming def test_find_peaks_example_1(): assert find_peaks(5, [1, 3, 2, 5, 4]) == "2 4" def test_find_peaks_example_2(): assert find_peaks(4, [1, 1, 1, 1]) == "No peaks" def test_find_peaks_single_peak(): assert find_peaks(3, [1, 3, 1]) == "2" def ...
[ { "docstring": null, "function_declaration": "def find_peaks(n, altitude):", "function_name": "find_peaks", "parameter_list": "(n, altitude)" }, { "docstring": null, "function_declaration": "def hiking_alex_homecoming(n, altitudes):", "function_name": "hiking_alex_homecoming", "p...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_peaks(n, altitudes):\n \"\"\"\n Identifies all the peak points in the given list of altitudes.\n \n Parameters:\n n (int): Number of points...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00022991", "row_id": 22991, "seed_ids": "[395]" }
0.732885
Taco_22991
I
[ "find_peaks", "hiking_alex_homecoming" ]
2
[ [ "hiking_alex_homecoming", "find_peaks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64f5b40604c0b1ca85195b5ee21c9e9885c9a268
18e79ff6f63222ce5728b9c779939970f668b8d2
v1.0
instruct
Taco
Taco_23014_I
Problem You are given a rectangular grid with N rows and M columns. Each cell in the grid contains a positive integer. You want to find the number of distinct path sums when travelling from the top-left corner (cell (1,1)) to the bottom-right corner (cell (N,M)). You can only move right or down at any point in time. ...
def distinct_path_sums(grid): """ Returns the number of distinct path sums from the top-left to the bottom-right of the grid. """ N = len(grid) M = len(grid[0]) from collections import defaultdict dp = defaultdict(set) dp[(0, 0)].add(grid[0][0]) for r in range(N): f...
from solution import process_input_return_distinct_path_sums def test_example_1(): N, M = 3, 3 grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert process_input_return_distinct_path_sums(N, M, grid) == 5 def test_example_2(): N, M = 2, 2 grid = [ [1, 2], [...
[ { "docstring": "Returns the number of distinct path sums from the top-left to the bottom-right of the grid.", "function_declaration": "def distinct_path_sums(grid):", "function_name": "distinct_path_sums", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def pr...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def distinct_path_sums(grid):\n n = len(grid)\n m = len(grid[0])\n \n # We'll use a set for maintaining distinct path sums at each cell\n dp = [[set...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00023014", "row_id": 23014, "seed_ids": "[23047]" }
0.786078
Taco_23014
I
[ "distinct_path_sums", "process_input_return_distinct_path_sums" ]
2
[ [ "process_input_return_distinct_path_sums", "distinct_path_sums" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e35514e39383cbb0b71bd2f1808dfae0d29ceaf9
b605271fe29ccbd4321db24f1f4d15140eb05d46
v1.0
instruct
Taco
Taco_23054_I
In the magical land of Arithmeticia, a string is considered spell-worthy if it can be transformed into a palindrome by removing zero or more characters. A group of wizards is preparing for a great challenge where they need to transform a sequence of strings into spell-worthy strings. As the leading wizard, you are tas...
def can_be_palindrome(s): """ Helper function to check if a string can be transformed into a palindrome. """ def is_palindrome(s): return s == s[::-1] # Check if the string can be reduced to a palindrome n = len(s) i, j = 0, n - 1 while i < j: if s[i] != s[j]: ...
from solution import can_be_palindrome, check_spell_worthy_strings def test_can_be_palindrome(): assert can_be_palindrome("abca") == True assert can_be_palindrome("abc") == False assert can_be_palindrome("aab") == True assert can_be_palindrome("a") == True assert can_be_palindrome("racecar") == Tru...
[ { "docstring": "Helper function to check if a string can be transformed into a palindrome.", "function_declaration": "def can_be_palindrome(s):", "function_name": "can_be_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def check_spell_worthy_strings(...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_transformed_to_palindrome(s):\n \"\"\"\n Determines if a string can be transformed into a palindrome by removing zero or more characters.\n \"\...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00023054", "row_id": 23054, "seed_ids": "[9807]" }
0.795194
Taco_23054
I
[ "can_be_palindrome", "check_spell_worthy_strings" ]
2
[ [ "check_spell_worthy_strings", "can_be_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9e7e7e601ae1f5fd4e292353850d533db237fa9b
698bd0c2b24e2bc38efa7d99cfa91301009d731b
v1.0
instruct
Taco
Taco_23093_I
In an aquarium, there is a rectangular grid of dimensions $n \times m$ representing water tiles. There are some rectangular patches of seaweed on this grid, given by their top-left and bottom-right coordinates $(r1, c1)$ and $(r2, c2)$. The seaweed patches are dense enough that they cannot be walked through, but open w...
from collections import deque def is_valid(x, y, n, m, grid): return 0 <= x < n and 0 <= y < m and grid[x][y] == 0 def bfs(n, m, grid, sx, sy, ex, ey): if sx == ex and sy == ey: return True directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(sx, sy)]) visited = [[False]*m ...
import pytest from solution import traverse_grid def test_basic_path_possible(): n = 5 m = 5 patches = [(1, 2, 2, 3), (4, 4, 5, 5)] queries = [(1, 1, 5, 5), (2, 2, 4, 4), (1, 1, 3, 3)] assert traverse_grid(n, m, patches, queries) == ["NO", "NO", "YES"] def test_no_seaweed(): n = 3 m = 3 ...
[ { "docstring": null, "function_declaration": "def is_valid(x, y, n, m, grid):", "function_name": "is_valid", "parameter_list": "(x, y, n, m, grid)" }, { "docstring": null, "function_declaration": "def bfs(n, m, grid, sx, sy, ex, ey):", "function_name": "bfs", "parameter_list": "(...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_traverse(grid, visited, start, end):\n n = len(grid)\n m = len(grid[0])\n queue = [start]\n directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00023093", "row_id": 23093, "seed_ids": "[14257]" }
0.734699
Taco_23093
I
[ "is_valid", "bfs", "traverse_grid" ]
3
[ [ "bfs", "is_valid" ], [ "traverse_grid", "bfs" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b912e19fac5cf69e5845656dc6e064bd642c6fd2
927e0158aa685a9057ef45621fdedaf1c8b7018a
v1.0
instruct
Taco
Taco_23145_I
You are given a string S consisting of lowercase English letters and an integer K. Your goal is to determine whether it is possible to rearrange the characters in the string S such that there are at most K consecutive identical characters. -----Input:----- - The first line of input contains a single integer T, the num...
def can_rearrange(s, k): from collections import Counter import heapq # Get the frequency of each character counter = Counter(s) # Max-heap of the counts of the characters max_heap = [-cnt for cnt in counter.values()] heapq.heapify(max_heap) # If the maximum frequency of any charac...
from solution import solve, preprocess_input def test_sample_input(): input_data = "3\naabbcc 2\naabbcc 1\naaaabbbbcc 3" tasks = preprocess_input(input_data) assert solve(tasks) == ["YES", "NO", "YES"] def test_identical_characters_k_1(): input_data = "1\naaaa 1" tasks = preprocess_input(input_dat...
[ { "docstring": null, "function_declaration": "def can_rearrange(s, k):", "function_name": "can_rearrange", "parameter_list": "(s, k)" }, { "docstring": null, "function_declaration": "def solve(tasks):", "function_name": "solve", "parameter_list": "(tasks)" }, { "docstring...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_rearrange(s, k):\n from collections import Counter\n import heapq\n\n freq = Counter(s)\n max_freq = max(freq.values())\n\n if (max_freq - 1...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00023145", "row_id": 23145, "seed_ids": "[1896]" }
0.784475
Taco_23145
I
[ "can_rearrange", "solve", "preprocess_input" ]
3
[ [ "solve", "can_rearrange" ] ]
1
[]
false
[]
false
pytest
true
[]
true
164d4c4a6a087017dad70fb15ff7292f7fd29fd8
34485964d6105a097f76c65c003c21068fe8c948
v1.0
instruct
Taco
Taco_23156_I
In a faraway kingdom named CodeLand, the king has a peculiar interest in operations on arrays, especially involving prime numbers. The kingdom's advisors have challenged two of its greatest programmers, Alice and Charlie, to a friendly competition involving a game with arrays. The game goes as follows: 1. Alice and Ch...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
import pytest from solution import find_winner def test_sample_input(): T = 2 test_cases = [(5, [2, 3, 4, 5, 6]), (6, [7, 11, 14, 15, 18, 20])] expected = ["ALICE", "CHARLIE"] assert find_winner(T, test_cases) == expected def test_no_prime_numbers(): T = 1 test_cases = [(5, [4, 6, 8, 9, 10])] ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determines the winner of the game given the array.", "function_declaration": "def determine_winner(arr)...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00023156", "row_id": 23156, "seed_ids": "[19438]" }
0.698804
Taco_23156
I
[ "is_prime", "determine_winner", "find_winner" ]
3
[ [ "determine_winner", "is_prime" ], [ "find_winner", "determine_winner" ] ]
2
[]
false
[]
false
pytest
true
[]
true
68dfc07ea06fbb999b1cff46f52e43c882d5fc4d
f0b6d60eaf295fe9f0f163f403bcfbd933315fee
v1.0
instruct
Taco
Taco_23282_I
Given an undirected graph with N nodes and M edges, your task is to determine the minimum number of edges that can be removed so that there are no cycles in the resulting graph. The input will provide the list of edges in the graph. ### Input - The first line contains two integers, N and M (1 ≤ N ≤ 1000, 0 ≤ M ≤ 5000)...
def find_cycle_edges(n, edges): """ Finds and returns the edges that are part of cycles in the graph. """ parent = list(range(n + 1)) def find(u): if u != parent[u]: parent[u] = find(parent[u]) return parent[u] def union(u, v): root_u = find(u) root_...
from solution import min_edges_to_remove def test_example_1(): n, m = 6, 6 edges = [ (1, 2), (1, 3), (2, 3), (2, 4), (4, 5), (5, 6) ] assert min_edges_to_remove(n, m, edges) == 1 def test_example_2(): n, m = 5, 5 edges = [ (1, 2), ...
[ { "docstring": "Finds and returns the edges that are part of cycles in the graph.", "function_declaration": "def find_cycle_edges(n, edges):", "function_name": "find_cycle_edges", "parameter_list": "(n, edges)" }, { "docstring": "Given a graph with n nodes and m edges, find the minimum numbe...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_edges_to_remove_to_avoid_cycles(N, M, edges):\n \"\"\"\n Function to determine the minimum number of edges that can be removed so that \n there ar...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00023282", "row_id": 23282, "seed_ids": "[2486]" }
0.761445
Taco_23282
I
[ "find_cycle_edges", "min_edges_to_remove" ]
2
[ [ "min_edges_to_remove", "find_cycle_edges" ] ]
1
[]
false
[]
false
pytest
true
[]
true
96865b19e7367f2202de2eda31a45a2e80dc28c9
0795094d77d79a9ad4c06352b10661ec2a1ac5e9