version
stringclasses
1 value
style
stringclasses
2 values
subset
stringclasses
12 values
question_id
stringlengths
9
23
question
stringlengths
27
8.13k
solution
stringlengths
99
5.97k
test
stringlengths
105
4.45k
test_info
listlengths
0
13
gpt_pass_sequence
listlengths
1
10
gpt_pass_trial_num
int64
1
10
gpt_difficulty
stringclasses
3 values
gpt_pass_percentage
float64
0.1
1
trials
dict
chosen_trial
stringclasses
10 values
metadata
dict
benchmark_similarity
float64
0.16
0.93
benchmark_instruction
stringclasses
1 value
benchmark_task_id
stringclasses
1 value
filter_reason
stringclasses
1 value
base_id
stringlengths
7
21
variant
stringclasses
2 values
top_function_names
listlengths
2
13
n_top_functions
int64
2
13
helper_call_edges
listlengths
1
16
n_helper_call_edges
int64
1
16
harness_functions
listlengths
0
3
structural_wrapper
bool
1 class
class_names
listlengths
0
5
has_class
bool
2 classes
test_kind
stringclasses
1 value
test_has_solution_import
bool
2 classes
third_party_imports
listlengths
0
5
stdlib_only
bool
2 classes
question_norm_sha1
stringlengths
40
40
solution_ast_sha1
stringlengths
40
40
v1.0
complete
Taco
Taco_33261_C
from typing import List, Tuple def min_train_scheduling_time(n: int, m: int, track_list: List[Tuple[int, int, int]]) -> int: """ Determine the minimum total time needed so that all trains can reach their destinations while ensuring that no two trains use the same track at the same time. Parameters...
def find(parent, i): if parent[i] == i: return i else: return find(parent, 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[yroot]: parent[yroot] ...
from solution import min_train_scheduling_time def test_min_train_scheduling_time_case1(): n, m = 4, 4 track_list = [ (1, 2, 5), (1, 3, 10), (2, 4, 3), (3, 4, 4) ] assert min_train_scheduling_time(n, m, track_list) == 12 def test_min_train_scheduling_time_case2(): n...
[ { "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, 1 ]
1
hard
0.2
{ "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 return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_4
{ "original_instruction": "Train Scheduling\n\nA busy railway system consists of multiple tracks on which trains can travel. Each track connects two stations directly. However, each track allows only one train to travel at a given time. This means that once a train starts its journey on a track, no other train can us...
0.693824
Taco_33261
C
[ "find", "union", "kruskal", "min_train_scheduling_time" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "min_train_scheduling_time", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
d71dd2dcf40f876620be3269bd21692f0d3dc455
10dd59e4216a6d2fbbdf5c989a9ecf5e4efda0e4
v1.0
complete
Taco
Taco_33297_C
import math from typing import List def is_prime(num: int) -> bool: """ Checks if a number is prime. >>> is_prime(7) True >>> is_prime(4) False """ pass def smallest_prime_greater_than(n: int) -> int: """ Finds the smallest prime number greater than n. >>> smallest_prime_gr...
import math def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import is_prime, smallest_prime_greater_than, solve def test_is_prime(): assert is_prime(7) == True assert is_prime(4) == False assert is_prime(2) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(29) == True def test_smallest_prime_greater_than(): ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds the smallest prime number greater than n.", "function_declaration": "def smallest_prime_greater_than(n):", "fun...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n retu...
trial_gpt4o_0
{ "original_instruction": "John has recently started practicing his mathematical skills and has taken a special interest in prime numbers. He came up with an engaging problem to challenge himself. The problem is to find the smallest prime number greater than a given number N.\n\nYour task is to help John by writing a...
0.739767
Taco_33297
C
[ "is_prime", "smallest_prime_greater_than", "solve" ]
3
[ [ "smallest_prime_greater_than", "is_prime" ], [ "solve", "smallest_prime_greater_than" ] ]
2
[]
false
[]
false
pytest
true
[]
true
692a6ab439990aff8fd959208f092369107de7e7
f26848bcb4a166da8ac88dad36de2ab4a8dc2d12
v1.0
complete
Taco
Taco_33576_C
def largest_rectangle_area(matrix: List[str]) -> int: """ Find the largest rectangle containing only 1s in a given grid and return its area. Args: matrix (List[str]): A list of strings representing the grid. Returns: int: The area of the largest rectangle containing only 1s. Examples: ...
def max_histogram_area(histogram): """ Helper function to calculate the largest rectangular area in a histogram. """ stack = [] max_area = 0 index = 0 while index < len(histogram): if not stack or histogram[stack[-1]] <= histogram[index]: stack.append(index) ...
def test_largest_rectangle_area_sample1(): matrix = [ "1010", "1011", "1110", "1000" ] assert largest_rectangle_area(matrix) == 4 def test_largest_rectangle_area_sample2(): matrix = [ "11100", "11110", "01110" ] assert largest_rectangle_ar...
[ { "docstring": "Helper function to calculate the largest rectangular area in a histogram.", "function_declaration": "def max_histogram_area(histogram):", "function_name": "max_histogram_area", "parameter_list": "(histogram)" }, { "docstring": null, "function_declaration": "def largest_re...
[ 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_histogram_area(histogram):\n \"\"\"\n Helper function to calculate the largest rectangular area in a histogram.\n \"\"\"\n stack = []\n max_...
trial_gpt4o_0
{ "original_instruction": "You have a grid of size `M x N` consisting of only 0s and 1s. You want to find the largest rectangle containing only 1s and return its area. \n\nInput Format:\n\nThe first line contains two integers `M` and `N`, denoting the number of rows and columns in the grid respectively.\nThe next `M`...
0.719111
Taco_33576
C
[ "max_histogram_area", "largest_rectangle_area" ]
2
[ [ "largest_rectangle_area", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c62e729c011c10a31389511ca635c2440170a190
c63185f0baf792bf8ae6b71d46f42141c3b0e172
v1.0
complete
Taco
Taco_32867_C
def max_subgrid_sum(matrix): """ Function to calculate the maximum sum of any rectangular subgrid within the given grid. Uses Kadane's algorithm for 2D arrays. """ pass def max_kadane(array): """ Helper function to calculate the maximum sum subarray using Kadane's algorithm. """ pas...
def max_subgrid_sum(matrix): """ Function to calculate the maximum sum of any rectangular subgrid within the given grid. Uses Kadane's algorithm for 2D arrays. """ rows, cols = len(matrix), len(matrix[0]) max_sum = float('-inf') for left in range(cols): temp = [0] * rows for...
from solution import process_input def test_max_subgrid_sum_example(): data = [ "4 5", "1 2 -1 -4 -20", "-8 -3 4 2 1", "3 8 10 1 3", "-4 -1 1 7 -6", "3 3", "1 2 3", "4 5 6", "7 8 9", "0 0" ] result = process_input(data) as...
[ { "docstring": "Function to calculate the maximum sum of any rectangular subgrid within the given grid.\nUses Kadane's algorithm for 2D arrays.", "function_declaration": "def max_subgrid_sum(matrix):", "function_name": "max_subgrid_sum", "parameter_list": "(matrix)" }, { "docstring": "Helper...
[ 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 maxSumRect(grid):\n rows, cols = len(grid), len(grid[0])\n max_sum = float('-inf')\n \n # Helper function to find the maximum sum subarray\n def...
trial_gpt4o_2
{ "original_instruction": "You are given a grid with R rows and C columns, where each cell contains an integer number. Your task is to find the maximum sum of values in any rectangular subgrid within the given grid. A rectangular subgrid is defined by selecting two rows and two columns within the grid and includes al...
0.634253
Taco_32867
C
[ "max_subgrid_sum", "max_kadane", "process_input" ]
3
[ [ "max_subgrid_sum", "max_kadane" ], [ "process_input", "max_subgrid_sum" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
fb2828a90766279f3fcef7c3dbb55537f43bb1cb
063a37c26b5ba81f7d7a2629ba4a6d5b6fc08bd1
v1.0
complete
Taco
Taco_33365_C
def warehouse_stock_management(input_data: str) -> List[int]: """ Manage the stock levels in a warehouse and answer queries about the stock levels during specific periods. Args: input_data (str): The string input describing datasets, transactions, and queries. Returns: List[int]: A lis...
def manage_stock(datasets): results = [] for dataset in datasets: transactions = dataset["transactions"] queries = dataset["queries"] stock_changes = {} for trans in transactions: t, i, v, a = trans if i not in stock_changes: ...
import pytest from solution import warehouse_stock_management def test_single_dataset(): input_data = "3 5\n60 1 10 1\n120 2 20 0\n180 1 5 0\n240 3 15 1\n300 2 5 1\n3\n0 240 1\n60 300 2\n0 300 3\n0 0\n" expected_output = [5, -15, 15] assert warehouse_stock_management(input_data) == expected_output def tes...
[ { "docstring": null, "function_declaration": "def manage_stock(datasets):", "function_name": "manage_stock", "parameter_list": "(datasets)" }, { "docstring": null, "function_declaration": "def process_input(input_data):", "function_name": "process_input", "parameter_list": "(inpu...
[ 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 warehouse_stock_levels(datasets):\n output = []\n for data in datasets:\n n, t, transactions, q, queries = data\n\n # Initialize stock leve...
trial_gpt4o_2
{ "original_instruction": "You are tasked with developing a system to manage the stock levels of a warehouse. The warehouse records the addition and removal of items continuously, and you need to write a program to track the current stock levels of each item in the inventory, as well as answer queries about the stock...
0.640589
Taco_33365
C
[ "manage_stock", "process_input", "warehouse_stock_management" ]
3
[ [ "warehouse_stock_management", "manage_stock" ], [ "warehouse_stock_management", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
38a5ac1ed793db8e5429104b59ef1436bffa707c
053df1d211878f1ef3aa69140dbb3bf2a8710cc7
v1.0
complete
Taco
Taco_33680_C
from typing import List, Optional class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def is_symmetric_tree(level_order_values: List[Optional[int]]) -> str: """ Given a binary tree in level-order traversal, determine if the tree is symmet...
# Define TreeNode class to create a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def isSymmetric(root): """ Determines whether the binary tree with the given root is symmetric. """ def isMirror(t1, t2): ...
from solution import is_symmetric_tree def test_symmetric_tree(): assert is_symmetric_tree([1, 2, 2, 3, 4, 4, 3]) == "true" def test_asymmetric_tree(): assert is_symmetric_tree([1, 2, 2, None, 3, None, 3]) == "false" def test_single_node_tree(): assert is_symmetric_tree([1]) == "true" def test_empty_tre...
[]
[ 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 typing import List, Optional\n\nclass TreeNode:\n def __init__(self, x: int):\n self.val = x\n self.left: Optional[TreeNode] = None\n ...
trial_gpt4o_2
{ "original_instruction": "Given a binary tree, determine if the tree is a mirror of itself (i.e., symmetric around its center).\n\n### Input Format\n\n- A single line containing a list of integers representing the values of nodes in the binary tree in level-order traversal. Use `null` to represent null nodes in the ...
0.614672
Taco_33680
C
[ "isSymmetric", "build_tree_from_level_order", "is_symmetric_tree" ]
3
[ [ "is_symmetric_tree", "build_tree_from_level_order" ], [ "is_symmetric_tree", "isSymmetric" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
87c80ffb9926aadb3d447e316e1c03f9aa4db351
37e0d36d1b117cda00bb51416a26281b8ab97dbb
v1.0
complete
Taco
Taco_33004_C
from typing import List, Tuple def submatrix_boundary_sum(matrix: List[List[int]], top_left: Tuple[int, int], bottom_right: Tuple[int, int]) -> int: """ Returns the sum of the boundary elements of the submatrix defined by top_left and bottom_right. """ pass def find_max_boundary_sum_submatrix(matrix:...
def submatrix_boundary_sum(matrix, top_left, bottom_right): """ Returns the sum of the boundary elements of the submatrix defined by top_left and bottom_right. """ i1, j1 = top_left i2, j2 = bottom_right sum_val = 0 # Top boundary for j in range(j1, j2 + 1): sum_val += matri...
import pytest from solution import submatrix_boundary_sum, find_max_boundary_sum_submatrix, process_test_cases def test_submatrix_boundary_sum_case1(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert submatrix_boundary_sum(matrix, (0, 0), (2, 2)) == 40 def test_submatrix_bounda...
[ { "docstring": "Returns the sum of the boundary elements of the submatrix defined by top_left and bottom_right.", "function_declaration": "def submatrix_boundary_sum(matrix, top_left, bottom_right):", "function_name": "submatrix_boundary_sum", "parameter_list": "(matrix, top_left, bottom_right)" }...
[ 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 find_max_boundary_matrix(T, test_cases):\n def submatrix_value(matrix, top_left, bottom_right):\n top, left = top_left\n bottom, right = botto...
trial_gpt4o_6
{ "original_instruction": "You are given a matrix M of size N x N with distinct positive integers.\n\nConsider all possible submatrices of M. Define the *value* of a submatrix as the sum of the elements on its boundary.\n\nFind the submatrix with the maximum *value*. If multiple submatrices have the same *value*, con...
0.594813
Taco_33004
C
[ "submatrix_boundary_sum", "find_max_boundary_sum_submatrix", "process_test_cases" ]
3
[ [ "find_max_boundary_sum_submatrix", "submatrix_boundary_sum" ], [ "process_test_cases", "find_max_boundary_sum_submatrix" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
4b2429ff346870599d5f44f2222fa54391b4532d
e420f3e56f5459817030e6899bfaeb63c42439e2
v1.0
complete
Taco
Taco_33762_C
import re from typing import List def validate_passwords(test_cases: List[str]) -> List[str]: """ Validate a list of passwords to ensure they meet the security rules. >>> validate_passwords(["SecurePa$$word123"]) == ["VALID"] >>> validate_passwords(["123456"]) == ["INVALID"] >>> validate_passwords(["In...
import re def validate_passwords(test_cases): results = [] special_characters = re.compile(r'[!@#$%^&*()]') for password in test_cases: if len(password) < 8: results.append("INVALID") elif ' ' in password: results.append("INVALID") elif not any(char.isup...
from solution import validate_passwords def test_valid_passwords(): assert validate_passwords(["SecurePa$$word123"]) == ["VALID"] def test_short_password(): assert validate_passwords(["123456"]) == ["INVALID"] def test_password_with_space(): assert validate_passwords(["InvaliD @9"]) == ["INVALID"] as...
[ { "docstring": null, "function_declaration": "def validate_passwords(test_cases):", "function_name": "validate_passwords", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def validate_password_input():", "function_name": "validate_password_input", ...
[ 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": "import re\n\ndef validate_password(password):\n if len(password) < 8:\n return \"INVALID\"\n if ' ' in password:\n return \"INVALID\"\n \n ...
trial_gpt4o_2
{ "original_instruction": "A smartphone application requires users to set up a password that follows specific security rules. The rules are as follows:\n- The password must be at least 8 characters long.\n- The password must not contain any space characters.\n- The password must contain at least one uppercase letter....
0.602208
Taco_33762
C
[ "validate_passwords", "validate_password_input" ]
2
[ [ "validate_password_input", "validate_passwords" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4a7d437ade0fa7082d703ddfbd2a22fb97773f5a
e9686615994cc99305238145fc362f6f207a1dc1
v1.0
complete
Taco
Taco_33643_C
from typing import List def maximalRectangle(matrix: List[List[str]]) -> int: """ Given a city represented as a grid with buildings and vacant lots, determine the largest rectangular area that can be developed into a park. The city is represented by a 2D binary matrix where '1' represents a building and '0' re...
def maximalRectangle(matrix): if not matrix: return 0 m, n = len(matrix), len(matrix[0]) heights = [0] * n max_area = 0 for i in range(m): for j in range(n): if matrix[i][j] == '0': heights[j] += 1 else: heights[j] = 0...
from solution import maximalRectangle def test_example1(): matrix = [ ["1", "0", "1", "0", "0"], ["1", "0", "1", "1", "1"], ["1", "0", "1", "1", "1"], ["1", "0", "0", "0", "1"] ] assert maximalRectangle(matrix) == 4 def test_example2(): matrix = [ ["0", "1"], ...
[ { "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 maximalRectangle(matrix):\n if not matrix:\n return 0\n max_area = 0\n row_len = len(matrix[0])\n heights = [0] * (row_len + 1)\n for row...
trial_gpt4o_1
{ "original_instruction": "Given a city represented as a grid with buildings and vacant lots, you need to determine the largest rectangular area that can be developed into a park. The city is represented by a 2D binary matrix where '1' represents a building and '0' represents a vacant lot. Your task is to find the ma...
0.706049
Taco_33643
C
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8bcfea4cf9824f1448de596d289ce92669025e09
7635f8bf0c9b6b5e230abd5b8d97cd73ce2f057f
v1.0
complete
Taco
Taco_33529_C
def prime_sieve(limit): """ Generate a list of booleans where True indicates that the index is a prime number (valid up to the limit). """ # Implement this function def count_primes_in_range(primes, A, B): """ Count the number of prime numbers between A and B inclusive using the preco...
def prime_sieve(limit): """ Generate a list of booleans where True indicates that the index is a prime number (valid up to the limit). """ primes = [True] * (limit + 1) primes[0], primes[1] = False, False # 0 and 1 are not primes p = 2 while (p * p <= limit): if (primes[p] == T...
def test_prime_sieve(): limit = 20 primes = prime_sieve(limit) expected_primes_indices = [2, 3, 5, 7, 11, 13, 17, 19] for i in range(limit + 1): if i in expected_primes_indices: assert primes[i] == True else: assert primes[i] == False def test_count_primes_in_ran...
[ { "docstring": "Generate a list of booleans where True indicates that \nthe index is a prime number (valid up to the limit).", "function_declaration": "def prime_sieve(limit):", "function_name": "prime_sieve", "parameter_list": "(limit)" }, { "docstring": "Count the number of prime numbers b...
[ 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 prime_sieve(limit):\n \"\"\"\n Generate a list of booleans where True indicates that \n the index is a prime number (valid up to the limit).\n \"\"...
trial_gpt4o_0
{ "original_instruction": "Carol is organizing a friendly math competition in her school. As part of the competition, she has created a unique game involving prime numbers. The game is designed as follows: given two integers \\(A\\) and \\(B\\), the task is to find how many prime numbers exist between \\(A\\) and \\(...
0.672581
Taco_33529
C
[ "prime_sieve", "count_primes_in_range", "number_of_primes" ]
3
[ [ "number_of_primes", "count_primes_in_range" ], [ "number_of_primes", "prime_sieve" ] ]
2
[]
false
[]
false
pytest
false
[]
true
0e6527442cab1a8f7b3886b7d1f1e64cccceeb64
57d5df8b3db0c1b3c3f5e17060f8e7a4b7848af0
v1.0
complete
Taco
Taco_33557_C
from typing import List MOD = 10**9 + 7 def preprocess(arr: List[int]) -> List[int]: """ Create a prefix product array for efficient range product querying. """ pass def update(arr: List[int], index: int, value: int, prefix_prod: List[int]) -> None: """ Update the array and rebuild the prefix...
MOD = 10**9 + 7 def preprocess(arr): """ Create a prefix product array for efficient range product querying. """ n = len(arr) prefix_prod = [1] * (n + 1) for i in range(1, n + 1): prefix_prod[i] = (prefix_prod[i - 1] * arr[i - 1]) % MOD return prefix_prod def update(arr, index, val...
from solution import process_queries def test_example_1(): n = 5 arr = [1, 2, 3, 4, 5] queries = [ [2, 1, 3], [1, 3, 6], [2, 1, 3], [2, 3, 5], [1, 5, 2], ] expected = [6, 12, 120] assert process_queries(n, arr, queries) == expected def test_small_array()...
[ { "docstring": "Create a prefix product array for efficient range product querying.", "function_declaration": "def preprocess(arr):", "function_name": "preprocess", "parameter_list": "(arr)" }, { "docstring": "Update the array and rebuild the prefix product array.", "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": "MOD = 10**9 + 7\n\nclass ProductArray:\n def __init__(self, array):\n self.array = array\n self.n = len(array)\n self.product_tree = [1] * ...
trial_gpt4o_1
{ "original_instruction": "Given an array of integers, implement a system that answers the following types of queries efficiently:\n\n1. **Update Query:** Update the value at a specific index in the array.\n2. **Range Query:** Calculate the product of values in a specified subarray.\n\n### Input\n\nThe first line con...
0.581968
Taco_33557
C
[ "preprocess", "update", "range_product", "process_queries" ]
4
[ [ "process_queries", "preprocess" ], [ "process_queries", "range_product" ], [ "process_queries", "update" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
9153932831a46a1023a206c6953739c05020fa46
c0fdec9b158a59ca7de9530a8d17ae1c8536aafe
v1.0
complete
Taco
Taco_33915_C
def solve(input_data: str) -> int: """ Given a 2D grid with `.` representing open cells the robot can move through, and `#` representing blocked cells, find the shortest path from the starting position to the target position. The robot can move up, down, left, or right, but cannot move into any of th...
from collections import deque def shortest_path(grid, start, end): rows, cols = len(grid), len(grid[0]) sx, sy = start ex, ey = end # Directions for moving in the grid directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Helper function to check if a position is within bounds and open ...
from solution import solve def test_case_1(): input_data = "5 6\n..#...\n....#.\n#..#..\n....#.\n..#...\n0 0 4 4\n" assert solve(input_data) == 8 def test_case_2(): input_data = "3 3\n...\n.#.\n...\n0 0 2 2\n" assert solve(input_data) == 4 def test_case_3(): input_data = "4 4\n....\n....\n....\n#...
[ { "docstring": null, "function_declaration": "def shortest_path(grid, start, end):", "function_name": "shortest_path", "parameter_list": "(grid, start, end)" }, { "docstring": null, "function_declaration": "def solve(lines):", "function_name": "solve", "parameter_list": "(lines)"...
[ 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 shortest_path(grid, start, end):\n rows, cols = len(grid), len(grid[0])\n sx, sy = start\n ex, ey = end\n \n # ...
trial_gpt4o_0
{ "original_instruction": "A robot is placed in a 2D grid where certain cells are blocked, and it needs to find the shortest path from its starting position to a target position. The robot can move up, down, left, or right, but cannot move into any of the blocked cells.\n\n-----Input-----\n\nThe input data consists o...
0.693006
Taco_33915
C
[ "shortest_path", "solve", "main" ]
3
[ [ "solve", "shortest_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7d5693944c929e833ee648e2ba1fcd0929e3013a
97dcfbbcf076543b9889ae122261af4254230250
v1.0
complete
Taco
Taco_33638_C
def calculate_word_score(word: str) -> int: """ Calculate the score of a word based on the sum of positions of its letters in the alphabet. >>> calculate_word_score('a') 1 >>> calculate_word_score('abc') 6 >>> calculate_word_score('cat') 24 """ pass def highest_scoring_word...
def calculate_word_score(word): """ Calculate the score of a word based on the sum of positions of its letters in the alphabet. """ score = sum(ord(letter) - ord('a') + 1 for letter in word) return score def highest_scoring_word(words): """ Given a list of words, return the word with the hi...
from solution import calculate_word_score, highest_scoring_word def test_calculate_word_score(): assert calculate_word_score('a') == 1 assert calculate_word_score('abc') == 6 assert calculate_word_score('cat') == 24 assert calculate_word_score('dog') == 26 assert calculate_word_score('zebra') == 52...
[ { "docstring": "Calculate the score of a word based on the sum of positions of its letters in the alphabet.", "function_declaration": "def calculate_word_score(word):", "function_name": "calculate_word_score", "parameter_list": "(word)" }, { "docstring": "Given a list of words, return the wo...
[ 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 word_score(word):\n \"\"\"\n Returns the score of a given word.\n The score is computed as the sum of positions of its letters in the alphabet (a = 1,...
trial_gpt4o_1
{ "original_instruction": "Given a list of words, write a program that will determine the word with the highest score. The score of a word is defined as the sum of the positions of its letters in the alphabet (i.e., a = 1, b = 2, ..., z = 26).\n\nFor example, the score of the word \"abc\" is 1 + 2 + 3 = 6.\n\nIf two ...
0.700519
Taco_33638
C
[ "calculate_word_score", "highest_scoring_word" ]
2
[ [ "highest_scoring_word", "calculate_word_score" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9b9e982b0e621db818d18da5256d9bde758a807d
bab972fe1769b4e9500930c239b342bea3eec30f
v1.0
complete
Taco
Taco_33924_C
from typing import List, Tuple def sum_of_shortest_paths(n: int, m: int, edges: List[Tuple[int, int, int]], start: int) -> int: """ Determine the sum of the shortest path distances from the starting city to all other cities. Args: n (int): Number of cities (nodes). m (int): Number of roads (edges...
import heapq def dijkstra(n, edges, start): graph = {i: [] for i in range(1, n+1)} for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) distances = {i: float('inf') for i in range(1, n+1)} distances[start] = 0 priority_queue = [(0, start)] while priority_queue...
import pytest from solution import sum_of_shortest_paths def test_sample_input_1(): n = 4 m = 4 edges = [ (1, 2, 4), (1, 3, 2), (2, 3, 1), (3, 4, 5) ] start = 1 assert sum_of_shortest_paths(n, m, edges, start) == 12 def test_sample_input_2(): n = 3 m = 3...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start):", "function_name": "dijkstra", "parameter_list": "(n, edges, start)" }, { "docstring": null, "function_declaration": "def sum_of_shortest_paths(n, m, edges, start):", "function_name": "sum_of_shortest_paths"...
[ 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": "import heapq\n\ndef dijkstra(n, m, edges, start):\n graph = [[] for _ in range(n + 1)]\n for u, v, w in edges:\n graph[u].append((v, w))\n grap...
trial_gpt4o_5
{ "original_instruction": "Problem Statement\n\nYou are given an undirected graph represented as an adjacency list. Each node of the graph represents a city, and each edge represents a road connecting two cities. The length of each road is given. Your task is to determine the shortest path from a given starting city ...
0.740239
Taco_33924
C
[ "dijkstra", "sum_of_shortest_paths" ]
2
[ [ "sum_of_shortest_paths", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
470b270adff23dc5648c42eac21ad8de512345f9
f370add377f72167caba9cecf913c5df698cbf1a
v1.0
complete
Taco
Taco_34075_C
def is_prime(n: int) -> bool: """ Determine if n is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(10) False >>> is_prime(23) True """ def find_primes(numbers: List[int]) -> List[str]: """ Print the position and ...
def is_prime(n): """ Determine if n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 retur...
from solution import is_prime, find_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(23) == True assert is_prime(50) == False assert is_prime(31) == True ...
[ { "docstring": "Determine if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Print the position and value of each prime number in the list.", "function_declaration": "def find_primes(numbers):", ...
[ 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 a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_1
{ "original_instruction": "You are given a list of numbers. For each number in the list, if it is a prime number, print it along with its position in the list. If the number is not prime, skip it.\n\nPrime number is defined as an integer greater than 1 that has no positive divisors other than 1 and itself.\n\nConstra...
0.858277
Taco_34075
C
[ "is_prime", "find_primes" ]
2
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cb924b0fd7f3050adc10addd4a570dcf47ef6e91
41dacb1d2cd3cfcc42c7a9fea56b4f124d2e56bb
v1.0
complete
Taco
Taco_33927_C
def process_tournament(n: int, edge_list: List[Tuple[int, int]], q: int, game_list: List[Tuple[int, int]]) -> List[Tuple[int, int]]: """ Determine the strengths of the nodes involved in every game in the tournament. Parameters: n (int): The number of nodes in the tree. edge_list (List[Tuple[int, i...
def node_strengths(n, edges, queries): from collections import defaultdict def build_degree_map(n, edges): degree_map = defaultdict(int) for u, v in edges: degree_map[u] += 1 degree_map[v] += 1 return degree_map degree_map = build_degree_map(n, edges...
from solution import process_tournament def test_example1(): n = 5 edge_list = [(1, 2), (1, 3), (2, 4), (3, 5)] q = 3 game_list = [(1, 2), (4, 5), (3, 5)] expected_output = [(2, 2), (1, 1), (2, 1)] assert process_tournament(n, edge_list, q, game_list) == expected_output def test_example2(): ...
[ { "docstring": null, "function_declaration": "def node_strengths(n, edges, queries):", "function_name": "node_strengths", "parameter_list": "(n, edges, queries)" }, { "docstring": null, "function_declaration": "def process_tournament(n, edge_list, q, game_list):", "function_name": "p...
[ 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 tree_strengths(n, edges, q, games):\n from collections import defaultdict\n\n # Create a defaultdict to compute the degree of each node\n degree = def...
trial_gpt4o_4
{ "original_instruction": "Bella is organizing a unique tournament where she uses trees. A tree is a connected acyclic graph. She labels each node starting from 1 to n. The tournament is constituted in such a way that two players play against each other if there is a direct path between the nodes they are on. Each ga...
0.64574
Taco_33927
C
[ "node_strengths", "process_tournament" ]
2
[ [ "process_tournament", "node_strengths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c3698974b1e3d1585a7ef95f4025b62b4b204032
31af0d72b2f51f336884dec24e91ca97f0437192
v1.0
complete
Taco
Taco_32751_C
from collections import deque from typing import List, Tuple class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(n: int, nodes_info: List[Tuple[int, int, int]]) -> dict: """ Build a binary tree from the given node information....
from collections import deque, defaultdict class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(n, nodes_info): nodes = {} for value, left, right in nodes_info: if value not in nodes: nodes[value] = Tree...
def test_build_tree(): n = 3 nodes_info = [ (1, 2, 3), (2, -1, -1), (3, -1, -1) ] nodes = build_tree(n, nodes_info) assert nodes[1].value == 1 assert nodes[1].left.value == 2 assert nodes[1].right.value == 3 assert nodes[2].left == None assert nodes[2].right =...
[]
[ 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\nclass TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n ...
trial_gpt4o_1
{ "original_instruction": "Given a binary tree:\n\n- Perform a breadth-first search (BFS) traversal.\n- For a given node, find and output the sum of values of its left and right children. If a node does not have a left or right child, treat it as 0.\n\nConstraints:\n* Each node's value is within the range $[-1,000,00...
0.614949
Taco_32751
C
[ "build_tree", "breadth_first_search", "find_children_sum", "process_queries" ]
4
[ [ "process_queries", "build_tree" ], [ "process_queries", "find_children_sum" ] ]
2
[ "process_queries" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
f8cfc7e6c47dba6f2914ab4d50050e89251816f6
d2718834758623faf94416c68ed191da0543d502
v1.0
complete
Taco
Taco_34404_C
def minimize_max_pages(n: int, books: List[int]) -> int: """ Organize the books such that the time it takes for the friend reading the most pages is minimized. Args: n: Number of friends. books: A list of integers representing the number of pages of each book. Returns: The minimum possible...
def is_possible(books, n, max_pages): current_sum = 0 required_friends = 1 for pages in books: if current_sum + pages > max_pages: required_friends += 1 current_sum = pages if required_friends > n: return False else: current_sum...
from solution import minimize_max_pages def test_minimize_max_pages_example1(): assert minimize_max_pages(2, [10, 20, 30, 40]) == 60 def test_minimize_max_pages_example2(): assert minimize_max_pages(3, [10, 20, 30, 40]) == 40 def test_minimize_max_pages_single_friend(): assert minimize_max_pages(1, [10, ...
[ { "docstring": null, "function_declaration": "def is_possible(books, n, max_pages):", "function_name": "is_possible", "parameter_list": "(books, n, max_pages)" }, { "docstring": null, "function_declaration": "def minimize_max_pages(n, books):", "function_name": "minimize_max_pages", ...
[ 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 find_min_max_pages(n, books):\n def can_distribute(books, n, max_pages):\n current_sum, num_friends = 0, 1\n for pages in books:\n ...
trial_gpt4o_1
{ "original_instruction": "Alice is organizing a new reading corner for her friends. She has a list of books, each with a specific number of pages. Alice wants to distribute the books among her friends such that the time it takes for the friend reading the most pages is minimized.\n\nGiven a list of integers represen...
0.662849
Taco_34404
C
[ "is_possible", "minimize_max_pages" ]
2
[ [ "minimize_max_pages", "is_possible" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aff668e8b09a1e98d66bab38f98b686a3acaf33a
1af8cd363f6e4fb2967501fe7c37ea7a6f64a010
v1.0
complete
Taco
Taco_34274_C
def traffic_lights_max_distance(input_str: str) -> int: """ Calculate the maximum Manhattan distance from any intersection without a traffic light to the nearest intersection with a traffic light in the given grid of Codeville city. Parameters: input_str (str): A string representing the grid d...
def max_distance_to_traffic_light(n, m, k, lights): max_distance = 0 for x in range(1, n+1): for y in range(1, m+1): if (x, y) not in lights: min_distance = float('inf') for (lx, ly) in lights: min_distance = min(min_distance, abs(x - ...
from solution import traffic_lights_max_distance def test_traffic_lights_max_distance_basic(): input_str = '4 4 3\n1 2\n3 4\n4 1\n' assert traffic_lights_max_distance(input_str) == 2 def test_traffic_lights_max_distance_single_traffic_light(): input_str = '3 3 1\n2 2\n' assert traffic_lights_max_dista...
[ { "docstring": null, "function_declaration": "def max_distance_to_traffic_light(n, m, k, lights):", "function_name": "max_distance_to_traffic_light", "parameter_list": "(n, m, k, lights)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "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 max_distance(n, m, k, traffic_lights):\n max_dist = 0\n\n # Iterate through each intersection in the grid\n for x in range(1, n+1):\n for y in ...
trial_gpt4o_4
{ "original_instruction": "In the fictional city of Codeville, there is a unique traffic system organized in a grid layout. The city is divided into an n x m grid of intersections. Each intersection is represented by its coordinates (x, y) where 1 <= x <= n and 1 <= y <= m. Some intersections have traffic lights, whi...
0.600205
Taco_34274
C
[ "max_distance_to_traffic_light", "parse_input", "traffic_lights_max_distance" ]
3
[ [ "traffic_lights_max_distance", "max_distance_to_traffic_light" ], [ "traffic_lights_max_distance", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
07ff8947aea5bb0be7bbbe3bb5f3e75a8a53fb82
009777de77601a55ddc2dfcfd3d8c156994143b7
v1.0
complete
Taco
Taco_33935_C
import heapq from typing import List, Tuple def dijkstra(n: int, adj: List[List[Tuple[int, int]]], start: int) -> List[int]: dist = [float('inf')] * (n + 1) dist[start] = 0 heap = [(0, start)] while heap: current_dist, u = heapq.heappop(heap) if current_dist > dist[u]: conti...
import heapq def dijkstra(n, adj, start): dist = [float('inf')] * (n + 1) dist[start] = 0 heap = [(0, start)] while heap: current_dist, u = heapq.heappop(heap) if current_dist > dist[u]: continue for neighbor, weight in adj[u]: distance = current_dist + w...
from solution import find_shortest_paths def test_single_path(): edges = [ (1, 2, 1) ] queries = [ (1, 2), (2, 1) ] assert find_shortest_paths(2, edges, queries) == [1, -1] def test_multiple_paths(): edges = [ (1, 2, 1), (2, 3, 1), (1, 3, 4) ...
[ { "docstring": null, "function_declaration": "def dijkstra(n, adj, start):", "function_name": "dijkstra", "parameter_list": "(n, adj, start)" }, { "docstring": null, "function_declaration": "def find_shortest_paths(n, edges, queries):", "function_name": "find_shortest_paths", "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": "import sys\nimport heapq\n\ndef dijkstra(graph, n, start):\n distances = [sys.maxsize] * (n + 1)\n distances[start] = 0\n priority_queue = [(0, start)]\n ...
trial_gpt4o_2
{ "original_instruction": "\"Sherlock Holmes, the famous detective, received an urgent request for help: someone stole jewelry from a hotel but left a peculiar note! The note simply had a series of numbers. After some careful thinking, Holmes figured out that the numbers might represent the weight of connected compon...
0.655831
Taco_33935
C
[ "dijkstra", "find_shortest_paths" ]
2
[ [ "find_shortest_paths", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
68eefd7edd64d0799154b7f57f5321a327643f73
c72c763fa42160442018746fbf97eb29373e19a9
v1.0
complete
Taco
Taco_34329_C
def count_subsequences(s: str, words: List[str]) -> int: """ Returns the count of how many words from the list are found as a subsequence in the string. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative...
def is_subsequence(s, word): """ Helper function to check if word is a subsequence of s. """ it = iter(s) return all(char in it for char in word) def count_subsequences(s, words): """ Returns the count of how many words from the list are found as subsequences in the string. """ coun...
from solution import count_subsequences def test_subsequences_in_abc(): assert count_subsequences("abc", ["a", "b", "c", "d", "ac"]) == 4 def test_subsequences_in_abc_ab_bc_abc(): assert count_subsequences("abc", ["ab", "bc", "abc", "cab"]) == 3 def test_subsequences_in_empty_string(): assert count_subse...
[ { "docstring": "Helper function to check if word is a subsequence of s.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Returns the count of how many words from the list are found as subsequences in...
[ 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 count_subsequences(s, words):\n \"\"\"\n Counts how many words from the list are found as a subsequence in the string s.\n \n Parameters:\n s (s...
trial_gpt4o_1
{ "original_instruction": "Write a function that receives a string and a list of words, and returns the count of how many words from the list are found as a subsequence in the string.\n\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without cha...
0.76102
Taco_34329
C
[ "is_subsequence", "count_subsequences" ]
2
[ [ "count_subsequences", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
256023bac78f46a67b7795b8104306b3e4638d47
87fad80af14ee38d9e8693623724ea3c41dff499
v1.0
complete
Taco
Taco_34428_C
def prefix_sums(arr): """ Returns an array of prefix sums """ pass # Replace this with your implementation def range_sum_queries(arr, queries): """ Returns the sum of the elements in the array between indices L and R (inclusive) for each query. Utilizes prefix sums for efficient calculatio...
def prefix_sums(arr): """ Returns an array of prefix sums """ prefix = [0] * (len(arr) + 1) for i in range(1, len(prefix)): prefix[i] = prefix[i-1] + arr[i-1] return prefix def range_sum_queries(arr, queries): """ Returns the sum of the elements in the array between indices L an...
from solution import range_sum_queries def test_single_query(): arr = [1, 2, 3, 4, 5] queries = [(1, 3)] assert range_sum_queries(arr, queries) == [6] def test_multiple_queries(): arr = [1, 2, 3, 4, 5] queries = [(1, 3), (2, 4), (1, 5)] assert range_sum_queries(arr, queries) == [6, 9, 15] def...
[ { "docstring": "Returns an array of prefix sums", "function_declaration": "def prefix_sums(arr):", "function_name": "prefix_sums", "parameter_list": "(arr)" }, { "docstring": "Returns the sum of the elements in the array between indices L and R (inclusive) for each query.\nUtilizes prefix su...
[ 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 array_query_sum(N, array, queries):\n \"\"\"\n Computes the sum of elements between indices L and R for each query.\n \n Parameters:\n N (int): ...
trial_gpt4o_2
{ "original_instruction": "You are given an array of $N$ integers, followed by $Q$ queries. Each query provides two integers, $L$ and $R$. Find the sum of the elements in the array between indices $L$ and $R$ (inclusive), for each query.\n\n-----Input-----\n- The first line of the input contains a single integer $N$ ...
0.62663
Taco_34428
C
[ "prefix_sums", "range_sum_queries" ]
2
[ [ "range_sum_queries", "prefix_sums" ] ]
1
[]
false
[]
false
pytest
true
[]
true
464bbfe72044026fbdc24d783c669f543b03c696
b9ba3e97d66433543fbe0c1a5cfdbf5b16fd4a1f
v1.0
complete
Taco
Taco_34498_C
import math from typing import List def is_prime(n: int) -> bool: """ Helper function to determine if n is a prime number. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(1) False """ pass def filter_primes(arr: List[int]) -> List[int]: """...
import math def is_prime(n): """ Helper function to determine if n is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False retur...
from solution import is_prime, filter_primes def test_is_prime(): # test non-prime numbers assert is_prime(1) == False assert is_prime(4) == False assert is_prime(9) == False assert is_prime(15) == False # test prime numbers assert is_prime(2) == True assert is_prime(3) == True ass...
[ { "docstring": "Helper function to determine if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the input list.", "function_declaration": "def ...
[ 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 == 2:\n return ...
trial_gpt4o_2
{ "original_instruction": "Create a function that takes an array of integers and returns a new array containing only the elements that are prime numbers. A prime number is defined as a whole number greater than 1 that has no positive divisors other than 1 and itself. The order of the elements in the output array shou...
0.76687
Taco_34498
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a22e87e3b881b14a9ed0f6cfe7b4b23545babb9d
072bfd1e075607fa6e831010dd8d429d27bf1889
v1.0
complete
Taco
Taco_34543_C
import math from typing import List def solve_tsp_problems(input_data: str) -> List[str]: """ Solves multiple TSP problems given the input format. The input format consists of multiple test cases, each including an integer 'n' indicating the number of cities followed by 'n' lines of integers represen...
import math from itertools import permutations def distance(city1, city2): """ Calculate Euclidean distance between two cities. """ return math.sqrt((city2[0] - city1[0])**2 + (city2[1] - city1[1])**2) def travelling_salesman(cities): """ Calculates the shortest possible route to visit all cit...
from solution import solve_tsp_problems def test_case_1(): input_data = "4\n0 0\n0 1\n1 0\n1 1\n" output = solve_tsp_problems(input_data) assert output == ["4.000000"] def test_case_2(): input_data = "3\n0 0\n2 0\n4 0\n" output = solve_tsp_problems(input_data) assert output == ["8.000000"] de...
[ { "docstring": "Calculate Euclidean distance between two cities.", "function_declaration": "def distance(city1, city2):", "function_name": "distance", "parameter_list": "(city1, city2)" }, { "docstring": "Calculates the shortest possible route to visit all cities and return to the starting c...
[ 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 itertools import permutations\nimport math\n\ndef calculate_distance(city1, city2):\n \"\"\"\n Calculates and returns the Euclidean distance between two...
trial_gpt4o_2
{ "original_instruction": "A large food distribution company wants to optimize its delivery routes across multiple cities. You are tasked to implement a program that helps in computing the shortest possible route to deliver food to all cities in a given list and return to the original city. This problem is often refe...
0.636706
Taco_34543
C
[ "distance", "travelling_salesman", "solve_tsp_problems" ]
3
[ [ "solve_tsp_problems", "travelling_salesman" ], [ "travelling_salesman", "distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d57e226e22aca46796e916c98d582a572ad5bc55
7be4f75cbbb097f19dfefa71d6bea273a6b46a79
v1.0
complete
Taco
Taco_34167_C
from typing import List, Tuple def minimum_travel_times(input_string: str) -> List[int]: """ Given the number of test cases, each containing the number of locations, routes, the starting location, and the ending location, along with the routes and their travel times, this function returns the minimum t...
import heapq def dijkstra(graph, start, end, n): """ Find the shortest path using Dijkstra's algorithm. """ distances = {i: float('infinity') for i in range(1, n+1)} distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq....
def test_example(): input_string = "2\n5 6 1 5\n1 2 10\n1 3 5\n2 3 2\n3 4 2\n4 5 3\n3 5 20\n3 3 1 3\n1 2 5\n2 3 10\n1 3 15\n" expected_output = [10, 15] assert minimum_travel_times(input_string) == expected_output def test_no_path(): input_string = "1\n3 2 1 3\n1 2 5\n2 3 10\n" expected_output = [1...
[ { "docstring": "Find the shortest path using Dijkstra's algorithm.", "function_declaration": "def dijkstra(graph, start, end, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, end, n)" }, { "docstring": null, "function_declaration": "def find_min_travel_times(test_case...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, edges, start, end):\n graph = {i: [] for i in range(1, n + 1)}\n for u, v, w in edges:\n graph[u].append((v, w))\n ...
trial_gpt4o_2
{ "original_instruction": "A logistics company is planning to optimize its delivery routes using a new software system. They have several delivery locations represented as nodes and the routes between them as edges in a graph. Each route between two locations has a specific travel time. The company needs to find the ...
0.634263
Taco_34167
C
[ "dijkstra", "find_min_travel_times", "parse_input", "minimum_travel_times" ]
4
[ [ "find_min_travel_times", "dijkstra" ], [ "minimum_travel_times", "find_min_travel_times" ], [ "minimum_travel_times", "parse_input" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
b4214b078c9399dee408d5a77523ac9f4304ebbd
afba3c7d3ec6ecc749be6ba3c1bf0a38751869d2
v1.0
complete
Taco
Taco_34203_C
from typing import List def is_prime(n: int) -> bool: """Helper function to check if the number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def can_form_magic_sequence(k: int) -> List[int]: """Returns a possible magic sequence of length k or -1 if not possible. >>...
def is_prime(n): """Helper function to check if the number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(1) assert not is_prime(0) assert not is_prime(-3) assert is_prime(17) def test_can_form_magic_sequence(): assert can_form_magic_sequence(1) == [1] assert can_...
[ { "docstring": "Helper function to check if the number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a possible magic sequence of length k or -1 if not possible.", "function_declaration": "def can_f...
[ 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.125
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\nimport sympy\n\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n return sympy.isprime(n)\n\ndef find_magic_se...
trial_gpt4o_7
{ "original_instruction": "Monocarp is organizing a small coding contest. He wants to design a custom sequence of integers that has special properties. Monocarp defines a \"magic sequence\" as a sequence of integers where for a given sequence length $k$, the sequence contains integers from $1$ to $k$ (inclusive) such...
0.634536
Taco_34203
C
[ "is_prime", "can_form_magic_sequence", "magic_sequence" ]
3
[ [ "magic_sequence", "can_form_magic_sequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
501f3bac144c5910cb159801fe2751183e68d9fe
1699ab1edff395a92900d196c97218607b596e9f
v1.0
complete
Taco
Taco_34712_C
def count_sunset_view_buildings(buildings: List[int]) -> int: """ Returns the number of buildings that have a view of the sunset. >>> count_sunset_view_buildings([3, 7, 8, 3, 6, 1]) 3 >>> count_sunset_view_buildings([1, 2, 3, 4, 5]) 1 >>> count_sunset_view_buildings([5, 4, 3, 2, 1]) ...
def count_sunset_view_buildings(buildings): """ Returns the number of buildings that have a view of the sunset. """ max_height = 0 count = 0 # Loop through buildings from right to left for height in reversed(buildings): if height > max_height: count += 1 max_h...
def test_count_sunset_view_buildings(): assert count_sunset_view_buildings([3, 7, 8, 3, 6, 1]) == 3 assert count_sunset_view_buildings([1, 2, 3, 4, 5]) == 1 assert count_sunset_view_buildings([5, 4, 3, 2, 1]) == 5 assert count_sunset_view_buildings([10, 20, 30, 40]) == 1 assert count_sunset_view_bui...
[ { "docstring": "Returns the number of buildings that have a view of the sunset.", "function_declaration": "def count_sunset_view_buildings(buildings):", "function_name": "count_sunset_view_buildings", "parameter_list": "(buildings)" }, { "docstring": null, "function_declaration": "def su...
[ 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 count_sunset_view_buildings(buildings):\n \"\"\"\n Returns the number of buildings that have a view of the sunset.\n \"\"\"\n max_height = 0\n c...
trial_gpt4o_0
{ "original_instruction": "You are given a list of integers where each integer represents the height of a building. The buildings form a row and are placed next to each other. A building with a greater height blocks the view of buildings to its right that are shorter. Your task is to determine the number of buildings...
0.551079
Taco_34712
C
[ "count_sunset_view_buildings", "sunset_views", "process_input_and_output" ]
3
[ [ "process_input_and_output", "sunset_views" ], [ "sunset_views", "count_sunset_view_buildings" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fbc62105522af8a96a0184b34cb74b6ac240398b
5e03d4862f51abd9fa96feed9b56ff181eac8b16
v1.0
complete
Taco
Taco_34659_C
def validate_isbn(isbn: str) -> str: """ Validates a single ISBN-13 number. :param isbn: A 13-digit string representing the ISBN number. :return: A string "valid" if the ISBN is valid, otherwise "invalid". >>> validate_isbn("9780470059029") 'valid' >>> validate_isbn("1234567890123") ...
def validate_isbn(isbn): """ Validates a single ISBN-13 number. :param isbn: A 13-digit string representing the ISBN number. :return: A string "valid" if the ISBN is valid, otherwise "invalid". """ total_sum = 0 for i, digit in enumerate(isbn): n = int(digit) if i % 2 =...
from solution import validate_isbn, validate_isbns def test_single_valid_isbn(): assert validate_isbn("9780470059029") == "valid" assert validate_isbn("9781593275846") == "valid" def test_single_invalid_isbn(): assert validate_isbn("1234567890123") == "invalid" assert validate_isbn("9780470059028") ==...
[ { "docstring": "Validates a single ISBN-13 number.\n\n:param isbn: A 13-digit string representing the ISBN number.\n:return: A string \"valid\" if the ISBN is valid, otherwise \"invalid\".", "function_declaration": "def validate_isbn(isbn):", "function_name": "validate_isbn", "parameter_list": "(isb...
[ 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 validate_isbn(isbn):\n \"\"\"\n Validates a single ISBN-13 number.\n\n :param isbn: A 13-digit string representing the ISBN number.\n :return: A st...
trial_gpt4o_0
{ "original_instruction": "Sam is building a new library system for an online bookstore. Each book in the library will be uniquely identified by an International Standard Book Number (ISBN). Each ISBN in this system is a 13-digit number, but to prevent errors in storing and accessing these ISBNs, Sam wants to validat...
0.533985
Taco_34659
C
[ "validate_isbn", "validate_isbns" ]
2
[ [ "validate_isbns", "validate_isbn" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8126ff99e2a19424c0d38fe6b97ce95e8be0a8fb
882e87199863f6a06018a04de8498ea7f0f18962
v1.0
complete
Taco
Taco_34787_C
from typing import List, Tuple def find_minimum_to_remove(arr: List[int]) -> int: """ Find the minimum value of the integer that can be removed such that the sum of the remaining elements is divisible by N-1. >>> find_minimum_to_remove([1, 2, 3, 4]) 1 >>> find_minimum_to_remove([1, -1, 1, -1, 2]) 2...
def find_minimum_to_remove(arr): n = len(arr) total_sum = sum(arr) if total_sum % (n - 1) == 0: return min(arr) for num in arr: if (total_sum - num) % (n - 1) == 0: return num return -1 def process_test_cases(test_cases): results = [] for n, arr in test_cases: ...
from solution import find_minimum_to_remove, process_test_cases, input_processing def test_find_minimum_to_remove(): assert find_minimum_to_remove([1, 2, 3, 4]) == 1 assert find_minimum_to_remove([1, -1, 1, -1, 2]) == 2 assert find_minimum_to_remove([2, 2, 2]) == 2 def test_find_minimum_to_remove_no_solut...
[ { "docstring": null, "function_declaration": "def find_minimum_to_remove(arr):", "function_name": "find_minimum_to_remove", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def process_test_cases(test_cases):", "function_name": "process_test_cases", "par...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_removal_to_divisible(arr):\n N = len(arr)\n total_sum = sum(arr)\n \n possible_removals = [x for x in arr if (total_sum - x) % (N - 1) == 0]\n ...
trial_gpt4o_5
{ "original_instruction": "You are given an array A of N integers. Your task is to remove exactly one integer from the array such that the sum of the remaining elements is divisible by N-1.\n\nIf multiple such integers exist, output the minimum value among them. If there is no such integer, output -1.\n\n------ Input...
0.624664
Taco_34787
C
[ "find_minimum_to_remove", "process_test_cases", "input_processing" ]
3
[ [ "process_test_cases", "find_minimum_to_remove" ] ]
1
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
ec54c993d3e183694d20b09d0516dad52d50f368
4b9df6d5f551b4b19283c8547fb97642501d0652
v1.0
complete
Taco
Taco_35023_C
from typing import List def largestNumber(nums: List[int]) -> str: """ Returns the largest number that can be formed by combining the integers. >>> largestNumber([3, 30, 34, 5, 9]) '9534330' >>> largestNumber([10]) '10' >>> largestNumber([0, 0, 0]) '0' >>> largestNumber([1, 20, 23, 4, 8...
from functools import cmp_to_key def compare(x, y): # Compare two numbers by concatenating them in both possible orders if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largestNumber(nums): """ Returns the largest number that can be formed by ...
from solution import largestNumber def test_single_number(): assert largestNumber([10]) == "10" def test_two_numbers(): assert largestNumber([10, 2]) == "210" def test_multiple_numbers(): assert largestNumber([3, 30, 34, 5, 9]) == "9534330" def test_leading_zeros(): assert largestNumber([0, 0, 0]) =...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Returns the largest number that can be formed by combining the integers.", "function_declaration": "def largestNumber(nums):", "function_name":...
[ 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": "from functools import cmp_to_key\n\ndef compare(x, y):\n # Compare two numbers as strings in both possible orders\n if x + y > y + x:\n return -1\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of integers, the task is to find the largest number that can be formed by combining the integers.\n\nExample 1:\nInput: [3, 30, 34, 5, 9]\nOutput: 9534330\n\nYour Task:\nYou don't need to read input or print anything. Your task is to complete the function largestNumber(...
0.753625
Taco_35023
C
[ "compare", "largestNumber" ]
2
[ [ "largestNumber", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7037fa18a4d18d4b5e58c07847466275c3dd260b
a8bbc244cf219c144a3c46aa73c3bed4db050ccf
v1.0
complete
Taco
Taco_34844_C
def is_valid(segment: str) -> bool: """ Check if a segment of the IP address is valid. >>> is_valid("255") True >>> is_valid("256") False >>> is_valid("0") True >>> is_valid("00") False >>> is_valid("1") True >>> is_valid("01") False >>> is_valid("10") True ...
def is_valid(segment): """ Check if a segment of the IP address is valid. """ if len(segment) > 1 and segment[0] == '0': return False return 0 <= int(segment) <= 255 def generate_ip_addresses(s): """ Generate all valid IP addresses from a given string of digits. """ def back...
from solution import generate_ip_addresses, process_cases, is_valid def test_is_valid(): assert is_valid("255") assert not is_valid("256") assert is_valid("0") assert not is_valid("00") assert is_valid("1") assert not is_valid("01") assert is_valid("10") def test_generate_ip_addresses_case...
[ { "docstring": "Check if a segment of the IP address is valid.", "function_declaration": "def is_valid(segment):", "function_name": "is_valid", "parameter_list": "(segment)" }, { "docstring": "Generate all valid IP addresses from a given string of digits.", "function_declaration": "def g...
[ 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 restore_ip_addresses(s):\n def is_valid(segment):\n if not segment:\n return False\n if len(segment) > 1 and segment[0] == '0':\n ...
trial_gpt4o_1
{ "original_instruction": "Given a string containing only digits, generate all possible valid IP addresses that can be obtained by inserting three dots into the string. A valid IP address consists of exactly four integers (each between 0 and 255, inclusive) separated by dots, where the string must not contain any lea...
0.617761
Taco_34844
C
[ "is_valid", "generate_ip_addresses", "process_cases" ]
3
[ [ "generate_ip_addresses", "is_valid" ], [ "process_cases", "generate_ip_addresses" ] ]
2
[ "process_cases" ]
false
[]
false
pytest
true
[]
true
c95c82342934a2b4cc6aab1715380c432bac6b96
d31179ae32cc7a43b843a2dd5c19603062afe2ab
v1.0
complete
Taco
Taco_34845_C
import math from typing import List, Tuple def max_time_to_report_issue(n: int, r: int, t: int, coordinates: List[Tuple[int, int]]) -> int: """ Given the number of nodes, radius of spread, maximum time possible, and the list of node coordinates, returns the maximum time required for the problem to reach a...
import math from collections import deque def calculate_distance(node1, node2): return math.sqrt((node1[0] - node2[0]) ** 2 + (node1[1] - node2[1]) ** 2) def max_time_to_report_issue(n, r, t, coordinates): if n == 1: return 0 if t >= 0 else -1 graph = {i: [] for i in range(n)} for i in range(...
from solution import max_time_to_report_issue def test_example_1(): n = 4 r = 5 t = 10 coordinates = [(0, 0), (3, 4), (-3, -4), (6, 8)] assert max_time_to_report_issue(n, r, t, coordinates) == 2 def test_example_2(): n = 3 r = 2 t = 5 coordinates = [(0, 0), (5, 5), (-1, -1)] as...
[ { "docstring": null, "function_declaration": "def calculate_distance(node1, node2):", "function_name": "calculate_distance", "parameter_list": "(node1, node2)" }, { "docstring": null, "function_declaration": "def max_time_to_report_issue(n, r, t, coordinates):", "function_name": "max...
[ 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": "import math\nfrom collections import deque\n\ndef time_to_report_issue(n, r, t, nodes):\n def euclidean_distance(node1, node2):\n return math.sqrt((node1...
trial_gpt4o_3
{ "original_instruction": "In a futuristic city, a new transportation system called TelePort has been introduced, which allows people to instantly travel between special nodes placed at various coordinates on an infinite 2D grid. The system is controlled by a central computer that tracks the status of each node. \n\n...
0.576292
Taco_34845
C
[ "calculate_distance", "max_time_to_report_issue" ]
2
[ [ "max_time_to_report_issue", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6be2e630d3f3ac589e39c976d1f85344a1b6738a
6d33da670fe0f2ecf918125614b4a2fda994c023
v1.0
complete
Taco
Taco_35143_C
def min_additional_routes_to_connect(n: int, m: int, routes: List[Tuple[int, int]]) -> int: """ Determines the minimum number of additional routes that must be added to make all the bus stops connected. >>> min_additional_routes_to_connect(5, 3, [(0, 1), (1, 2), (3, 4)]) == 1 >>> min_additional_routes_...
def find_connected_components(n, routes): """ Finds the connected components in the graph represented by the bus stops and routes """ from collections import defaultdict, deque # Create a graph as an adjacency list graph = defaultdict(list) for u, v in routes: graph[u].append(v)...
def test_min_additional_routes_to_connect(): assert min_additional_routes_to_connect(5, 3, [(0, 1), (1, 2), (3, 4)]) == 1 assert min_additional_routes_to_connect(4, 2, [(0, 1), (2, 3)]) == 1 assert min_additional_routes_to_connect(6, 0, []) == 5 assert min_additional_routes_to_connect(1, 0, []) == 0 ...
[ { "docstring": "Finds the connected components in the graph represented by the bus stops and routes", "function_declaration": "def find_connected_components(n, routes):", "function_name": "find_connected_components", "parameter_list": "(n, routes)" }, { "docstring": "Returns the minimum numb...
[ 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 needed_routes_to_connect_all_bus_stops(N, M, routes):\n \"\"\"\n Determines the minimum number of additional routes needed to make all bus stops connecte...
trial_gpt4o_1
{ "original_instruction": "The city of Byteburg has recently implemented a new offline bus ticket system. Each bus stop in the city is numbered with a non-negative integer and provides tickets that can be collected by travelers. Travelers can pick up their journey from any bus stop and reach any other bus stop by tak...
0.660323
Taco_35143
C
[ "find_connected_components", "min_additional_routes_to_connect" ]
2
[ [ "min_additional_routes_to_connect", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
false
[]
true
39e1846c1116df9d75b31ec4f26e6e36291dad3c
52eaf228aed32596809fff19780fdc9a16b369aa
v1.0
complete
Taco
Taco_34714_C
from typing import List def min_transformations(initial: str, target: str, dictionary: List[str]) -> int: """ Determine the minimum number of transformations required to convert the initial word to the target word. Each transformation must change exactly one letter and each intermediate word must be a val...
from collections import deque def is_one_letter_different(word1, word2): """ Check if the two words differ by exactly one letter. """ count = 0 for a, b in zip(word1, word2): if a != b: count += 1 if count > 1: return False return count == 1 def min_tran...
def test_min_transformations_possible(): assert min_transformations("hit", "cog", ["hot", "dot", "dog", "lot", "log", "cog"]) == 4 def test_min_transformations_impossible(): assert min_transformations("apple", "radar", ["grape", "tiger", "sugar", "lemon", "radar"]) == -1 def test_min_transformations_no_steps_...
[ { "docstring": "Check if the two words differ by exactly one letter.", "function_declaration": "def is_one_letter_different(word1, word2):", "function_name": "is_one_letter_different", "parameter_list": "(word1, word2)" }, { "docstring": null, "function_declaration": "def min_transformat...
[ 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 is_one_letter_different(word1, word2):\n \"\"\"\n Check if the two words differ by exactly one letter.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "Emma loves solving puzzles and one day she stumbled upon an interesting puzzle involving letters and words. Given an initial and a target word, the goal is to transform the initial word into the target word by changing one letter at a time. Each intermediate word formed in this process must...
0.653724
Taco_34714
C
[ "is_one_letter_different", "min_transformations" ]
2
[ [ "min_transformations", "is_one_letter_different" ] ]
1
[]
false
[]
false
pytest
false
[]
true
84ccb08b5f70f0dea65cbe8fe2071f5eb5258645
914ec78665e2c99f2d4ac46b058dba03ccb52e3e
v1.0
complete
Taco
Taco_34585_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes): """ Build a binary tree from the given node descriptions. Args: nodes: A list of tuples where each tuple contains three integers. (value, left_index...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes): if not nodes: return None tree_nodes = {i: TreeNode(value) for i, (value, _, _) in enumerate(nodes)} for i, (value, left, right) in enumerate(nodes): ...
import pytest from solution import is_magic_tree_multiple_cases def test_single_case_no_root(): assert is_magic_tree_multiple_cases([(0, [])]) == ["YES"] def test_single_case_single_node(): assert is_magic_tree_multiple_cases([(1, [(5, -1, -1)])]) == ["YES"] def test_single_case_magic_tree(): nodes = [ ...
[]
[ 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": "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 b...
trial_gpt4o_3
{ "original_instruction": "In a distant galaxy, there exists a special binary tree called \"Magic-Tree\". Each node in the Magic-Tree has a non-negative integer value associated with it. The special property of the Magic-Tree is that every path from the root to any leaf node has the same sum of values. Your task is t...
0.552397
Taco_34585
C
[ "build_tree", "is_magic_tree", "is_magic_tree_multiple_cases" ]
3
[ [ "is_magic_tree_multiple_cases", "build_tree" ], [ "is_magic_tree_multiple_cases", "is_magic_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
969db3acff5daf040a712c4039b815a9e984c2f9
1dd9a7ab4a366a7dbf4df5f4f3c72c22845a46c5
v1.0
complete
Taco
Taco_35100_C
from typing import List, Tuple def determine_winner(t: int, games: List[Tuple[int, List[int]]]) -> List[str]: """ Determine the winner of each game based on the initial array. Each game consists of `n` integers. Liam and Noah take turns to remove elements with a common GCD > 1. The player who cannot m...
from math import gcd from functools import reduce def calculate_gcd_of_list(num_list): return reduce(gcd, num_list) def determine_winner(t, games): results = [] for game in games: n, arr = game if len(arr) == 1: # When there is only one element, that single element's GCD i...
from solution import determine_winner def test_single_game(): assert determine_winner(1, [(3, [2, 3, 4])]) == ["NOAH"] assert determine_winner(1, [(4, [5, 10, 15, 20])]) == ["LIAM"] def test_multiple_games(): games = [ (3, [2, 3, 4]), (4, [5, 10, 15, 20]) ] assert determine_winner(...
[ { "docstring": null, "function_declaration": "def calculate_gcd_of_list(num_list):", "function_name": "calculate_gcd_of_list", "parameter_list": "(num_list)" }, { "docstring": null, "function_declaration": "def determine_winner(t, games):", "function_name": "determine_winner", "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": "import math\nfrom collections import defaultdict\n\ndef game_winner(t, games):\n \"\"\"\n Determine the winner for each game.\n \n Arguments:\n t --...
trial_gpt4o_2
{ "original_instruction": "Liam and Noah are playing a game with arrays! The game's rules are as follows:\n\nThe game starts with an array of $n$ integers.\nLiam always moves first and they take alternating turns. The first player with no available move loses the game.\nDuring each move, the player selects any number...
0.711733
Taco_35100
C
[ "calculate_gcd_of_list", "determine_winner", "main" ]
3
[ [ "determine_winner", "calculate_gcd_of_list" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7f23d310813cdf99b059575b6cdb2439f15f6fae
13daebcb4056497f76b4c33e83a4913f1fd85e99
v1.0
complete
Taco
Taco_34784_C
def findCelebrity(n: int) -> int: """ Determine who the celebrity is or verify that there is no celebrity at the party. >>> findCelebrity(4) # should return the index of the celebrity or -1 if there is no celebrity """ # Helper function `knows(a, b)` is assumed to be provided by the system. You shou...
def findCelebrity(n): # Helper function `knows(a, b)` is assumed to be provided by the system. You should not implement it. # Step 1: Identify a potential candidate for being the celebrity candidate = 0 for i in range(1, n): if knows(candidate, i): candidate = i # Step ...
import pytest from solution import findCelebrity # Mocking the `knows` function using pytest's monkeypatch feature def test_findCelebrity_with_celebrity(monkeypatch): def knows(a, b): # Example setup with 4 people and person 2 as the celebrity known_relations = { (0, 1): True, (0, 2): T...
[ { "docstring": null, "function_declaration": "def findCelebrity(n):", "function_name": "findCelebrity", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def knows(a, b):", "function_name": "knows", "parameter_list": "(a, b)" } ]
[ 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 findCelebrity(n: int) -> int:\n \"\"\"\n Returns the index of the celebrity if there is one, otherwise returns -1.\n \"\"\"\n # Assume the first pe...
trial_gpt4o_8
{ "original_instruction": "Celebrity Problem\n\nImagine you are at a party with `n` people and among them, there may be a celebrity. A celebrity is defined as someone who is known by everyone but knows no one else at the party. You are given a helper function `knows(a, b)` that returns:\n\n- `True` if person `a` know...
0.500253
Taco_34784
C
[ "findCelebrity", "knows" ]
2
[ [ "findCelebrity", "knows" ] ]
1
[]
false
[]
false
pytest
true
[]
true
784a9eda3aecb7467080cdc9ecc1d53687ae0eab
05aa78d40ac084ebc22533a61bceb30c0e4806c6
v1.0
complete
Taco
Taco_35253_C
def findNextPrimeWithPrimeDigits(N: int) -> int: """ Given a positive integer N, find the next smallest integer greater than N which is a prime and contains only prime digits (2, 3, 5, 7). >>> findNextPrimeWithPrimeDigits(10) 23 >>> findNextPrimeWithPrimeDigits(30) 37 """
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def has_only_prime_digits(num)...
def test_findNextPrimeWithPrimeDigits_case1(): assert findNextPrimeWithPrimeDigits(10) == 23 def test_findNextPrimeWithPrimeDigits_case2(): assert findNextPrimeWithPrimeDigits(30) == 37 def test_findNextPrimeWithPrimeDigits_case3(): assert findNextPrimeWithPrimeDigits(2) == 3 def test_findNextPrimeWithPr...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def has_only_prime_digits(num):", "function_name": "has_only_prime_digits", "parameter_list": "(num)" }, ...
[ 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(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "Given a positive integer N. The problem is to print the next smallest integer greater than N which is a prime and contains only prime digits (2, 3, 5, 7). \n\nExample 1:\nInput:\nN = 10\nOutput: 23\nExplanation:\nThe next prime number after 10 is 11. However, 11 contains the digit 1, which ...
0.700989
Taco_35253
C
[ "is_prime", "has_only_prime_digits", "findNextPrimeWithPrimeDigits" ]
3
[ [ "findNextPrimeWithPrimeDigits", "has_only_prime_digits" ], [ "findNextPrimeWithPrimeDigits", "is_prime" ] ]
2
[]
false
[]
false
pytest
false
[]
true
1f879d4b04109d9389e765ac6607a42cf3a6628f
962e655b0838cc106b50aa2ff0702a802c1c83c2
v1.0
complete
Taco
Taco_34611_C
def max_heapify(arr, n, i): """ Helper function to heapify a subtree rooted with node i. This is an index in arr[]. n is the size of the heap. """ pass def build_max_heap(arr): """ Transform an unsorted array into a max heap. >>> build_max_heap([3, 1, 5, 7, 2, 4]) [7, 3, 5, 1, 2, ...
def max_heapify(arr, n, i): """ To heapify a subtree rooted with node i which is an index in arr[]. n is the size of the heap. """ largest = i left = 2 * i + 1 right = 2 * i + 2 # See if left child of root exists and is greater than root if left < n and arr[left] > arr[largest]: ...
from solution import build_max_heap def is_valid_max_heap(arr): """ Helper function to verify if the array is a valid max heap. """ n = len(arr) for i in range(n // 2): left = 2 * i + 1 right = 2 * i + 2 if left < n and arr[i] < arr[left]: return False if...
[ { "docstring": "To heapify a subtree rooted with node i which is an index in arr[].\nn is the size of the heap.", "function_declaration": "def max_heapify(arr, n, i):", "function_name": "max_heapify", "parameter_list": "(arr, n, i)" }, { "docstring": "Function to build a Max-Heap from the gi...
[ 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 max_heapify(arr, N, i):\n \"\"\"\n Function to heapify a subtree rooted with node i which is an index in arr[].\n N is the size of heap.\n \"\"\"\n...
trial_gpt4o_2
{ "original_instruction": "John is working on implementing a sorting algorithm. He is fascinated by heaps and heap sort particularly caught his interest. However, John is having trouble understanding how to construct a valid max heap from an unsorted array. Help John by writing a function to transform any given unsor...
0.620768
Taco_34611
C
[ "max_heapify", "build_max_heap" ]
2
[ [ "build_max_heap", "max_heapify" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5e08ed93c4f4b3144d5eac7829a9f5dfe648604b
289fcd7290bf8f8aa4149f868211a1490a8e164f
v1.0
complete
Taco
Taco_34936_C
def can_find_k_edge_cycle(n, m, edges, k): """ Determines if there exists a path in the graph that visits exactly K distinct edges and returns to the starting vertex. :param n: Number of vertices in the graph :param m: Number of edges in the graph :param edges: List of tuples representing the edges...
def can_find_k_edge_cycle(n, m, edges, k): from collections import defaultdict import itertools graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) def dfs(current, visited_edges, path_len, start): if path_len == k and current == ...
def test_sample1(): input_data = "5 6\n1 2\n1 3\n2 3\n3 4\n4 5\n5 1\n5\n" assert solve(input_data) == "YES" def test_sample2(): input_data = "4 3\n1 2\n2 3\n3 4\n3\n" assert solve(input_data) == "NO" def test_no_possible_cycle(): input_data = "3 3\n1 2\n2 3\n3 1\n4\n" assert solve(input_data) ...
[ { "docstring": null, "function_declaration": "def can_find_k_edge_cycle(n, m, edges, k):", "function_name": "can_find_k_edge_cycle", "parameter_list": "(n, m, edges, k)" }, { "docstring": null, "function_declaration": "def solve(input_data):", "function_name": "solve", "parameter...
[ 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 find_cycle(N, M, edges, K):\n from collections import defaultdict, deque\n\n def dfs(vertex, start, depth, visited, current_path):\n if depth == K...
trial_gpt4o_2
{ "original_instruction": "You are given an undirected graph represented as an adjacency list, with vertices numbered from 1 to N and M edges. \n\nYour task is to determine if there exists a path in this graph that visits exactly K distinct edges and returns to the starting vertex. If such a path exists, output \"YES...
0.694678
Taco_34936
C
[ "can_find_k_edge_cycle", "solve" ]
2
[ [ "solve", "can_find_k_edge_cycle" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3e472a6d2ecf3b6e51f451cabea51741c06012be
e1c838a7028f11b7d7feaf85cf2e73a2d0f9ce91
v1.0
complete
Taco
Taco_34686_C
from typing import List, Tuple def minimize_diameter(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """ Calculate the minimum travel time between the most distant intersections after optimally placing the new train stations. >>> minimize_diameter(6, 7, [(1, 2, 4), (2, 3, 3), (3, 4, 5), (1, 5, 8...
import heapq def dijkstra(n, graph, start): distances = [float('inf')] * n distances[start] = 0 queue = [(0, start)] while queue: current_dist, u = heapq.heappop(queue) if current_dist > distances[u]: continue for v, weight in graph[u]: ...
from solution import minimize_diameter def test_example_case(): n = 6 m = 7 edges = [ (1, 2, 4), (2, 3, 3), (3, 4, 5), (1, 5, 8), (5, 6, 6), (4, 6, 1), (3, 6, 4) ] assert minimize_diameter(n, m, edges) == 8 def test_small_case(): n = 2 ...
[ { "docstring": null, "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def calculate_diameter_with_train_station(n, roads):", "function_name": "calculate_diamet...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "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 Perform Dijkstra's algorithm to find shortest paths from start node to all other nodes.\n \"\"\"...
trial_gpt4o_8
{ "original_instruction": "In a city, there are n intersections connected by m bidirectional roads. Each road has a length in minutes it takes to travel. The city is planning to construct a new train line to expedite transportation. The train line consists of two stations, each located at one of the intersections. \n...
0.644134
Taco_34686
C
[ "dijkstra", "calculate_diameter_with_train_station", "minimize_diameter" ]
3
[ [ "calculate_diameter_with_train_station", "dijkstra" ], [ "minimize_diameter", "calculate_diameter_with_train_station" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4322830e35af79917f44f973985f193d9214e944
4d776ed80c63cf7c00d2963ba612375f4d883969
v1.0
complete
Taco
Taco_34856_C
def distinct_paths(n: int, m: int, grid: List[List[str]]) -> int: """ Determine the number of distinct paths a robot can take to move from the top-left corner to the bottom-right corner of the grid avoiding obstacles. Args: n (int): The number of rows in the grid. m (int): The number of colum...
def count_paths(grid, n, m): """ Returns the number of distinct paths from the top-left corner to the bottom-right corner of the grid. """ if grid[0][0] == '#' or grid[n-1][m-1] == '#': return 0 dp = [[0] * m for _ in range(n)] dp[0][0] = 1 # Start position for i in range(n): ...
from solution import distinct_paths def test_example_1(): grid = [ ['.', '.', '.'], ['.', '#', '.'], ['.', '.', '.'] ] assert distinct_paths(3, 3, grid) == 2 def test_example_2(): grid = [ ['.', '#', '.'], ['#', '.', '#'], ['.', '.', '.'] ] asser...
[ { "docstring": "Returns the number of distinct paths from the top-left corner to the bottom-right corner of the grid.", "function_declaration": "def count_paths(grid, n, m):", "function_name": "count_paths", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration":...
[ 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 num_paths(grid, n, m):\n # Use dynamic programming to compute the number of paths\n if grid[0][0] == '#' or grid[n-1][m-1] == '#':\n return 0\n ...
trial_gpt4o_2
{ "original_instruction": "Gretta is a roboticist participating in RoboCon, a competition for autonomous robots. In the competition, each robot needs to navigate through a grid from the top-left corner to the bottom-right corner. However, there are obstacles scattered across the grid that the robots need to avoid.\n\...
0.645074
Taco_34856
C
[ "count_paths", "distinct_paths" ]
2
[ [ "distinct_paths", "count_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fe532dd734784ed9c0cb2b658f84510ce787ddbc
89ae97aadaa3399cc1e94310a6d84d9735d38bc8
v1.0
complete
Taco
Taco_35247_C
def min_cost_to_connect_all_cities(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """ Calculate the minimum cost required to connect all the cities in the kingdom using a subset of the possible roads. Return -1 if it is not possible to connect all the cities. >>> min_cost_to_connect_all_cities(...
def find_parent(parent, i): if parent[i] == i: return i return find_parent(parent, parent[i]) def union(parent, rank, x, y): root_x = find_parent(parent, x) root_y = find_parent(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root...
def test_input_1(): n, m = 4, 5 edges = [ (1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 3, 6), (1, 4, 7) ] assert min_cost_to_connect_all_cities(n, m, edges) == 12 def test_input_2(): n, m = 3, 3 edges = [ (1, 2, 1), (2, 3, 2), (3, 1, 3) ...
[ { "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, 0 ]
2
easy
0.667
{ "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 return find_parent(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = fi...
trial_gpt4o_0
{ "original_instruction": "The kingdom of Graphlandia is planning to build a new transportation network of roads connecting its cities. The kingdom has decided to use a system of weighted, undirected edges to represent the roads, where each edge connects two distinct cities and has a certain cost associated with it.\...
0.699079
Taco_35247
C
[ "find_parent", "union", "kruskal", "min_cost_to_connect_all_cities" ]
4
[ [ "kruskal", "find_parent" ], [ "kruskal", "union" ], [ "min_cost_to_connect_all_cities", "kruskal" ], [ "union", "find_parent" ] ]
4
[]
false
[]
false
pytest
false
[]
true
420a0c32d4b4d776b54b327c300f3eff2de9fe44
ebed8ff70e974232214f805311f61ea97615d0b8
v1.0
complete
Taco
Taco_35368_C
def minimum_swaps_to_sort(arr: List[int]) -> int: """ Determine the minimum number of adjacent swaps needed to sort the flower pots in non-decreasing order. Args: arr (List[int]): A list of integers representing the heights of the flower pots. Returns: int: The minimum number of adjac...
def merge_and_count(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 # Conditions are checked to ensure that i doesn't exceed mid and j doesn't exceed right ...
def test_minimum_swaps_to_sort(): assert minimum_swaps_to_sort([5, 1, 3, 2, 4]) == 5 assert minimum_swaps_to_sort([1, 2, 3, 4, 5]) == 0 assert minimum_swaps_to_sort([5, 4, 3, 2, 1]) == 10 assert minimum_swaps_to_sort([2, 3, 8, 6, 1]) == 5 assert minimum_swaps_to_sort([1]) == 0 assert minimum_swa...
[ { "docstring": null, "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, right):", "function_name": "merge_and_count", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_arr, left, r...
[ 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 count_inversions(arr):\n \"\"\"\n Returns the number of inversions in the array.\n \"\"\"\n def merge_and_count(arr, temp_arr, left, mid, right):\n...
trial_gpt4o_2
{ "original_instruction": "A gardener is arranging flower pots of different heights into a sequence. Given a list of integers representing the heights of the flower pots, the gardener has a rule that only after arranging them in non-decreasing order can she start planting flowers in them. However, she can perform an ...
0.602396
Taco_35368
C
[ "merge_and_count", "merge_sort_and_count", "minimum_swaps_to_sort", "main" ]
4
[ [ "merge_sort_and_count", "merge_and_count" ], [ "minimum_swaps_to_sort", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
false
[]
true
86c3eb294e93db646caead04391bd2d971d96785
dd89d9a7a99b185303f11f376c10581e3f22b778
v1.0
complete
Taco
Taco_35311_C
from typing import List def max_subset_sum(numbers: List[int], target: int) -> List[int]: """Given a list of numbers, find the subset with the maximum possible sum that does not exceed a given target sum. >>> max_subset_sum([1, 2, 3, 4], 10) [1, 2, 3, 4] >>> max_subset_sum([4, 5, 2, 1, 3], 10) [1, ...
from itertools import combinations def max_subset_sum(numbers, target): """ Finds the subset with the maximum possible sum that does not exceed the target sum. Returns the subset with the fewest elements or lexicographically smallest if there are ties. """ n = len(numbers) best_sum = 0 best...
from solution import max_subset_sum def test_example_1(): assert max_subset_sum([1, 2, 3, 4], 10) == [1, 2, 3, 4] def test_example_2(): assert max_subset_sum([4, 5, 2, 1, 3], 10) == [1, 4, 5] def test_example_3(): assert max_subset_sum([8, 7, 6], 15) == [7, 8] def test_example_small_sum(): assert ma...
[ { "docstring": "Finds the subset with the maximum possible sum that does not exceed the target sum.\nReturns the subset with the fewest elements or lexicographically smallest if there are ties.", "function_declaration": "def max_subset_sum(numbers, target):", "function_name": "max_subset_sum", "para...
[ 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 itertools import combinations\n\ndef find_max_subset(n, target, elements):\n \"\"\"\n Returns the subset with the maximum possible sum that does not exc...
trial_gpt4o_1
{ "original_instruction": "Given a list of numbers, find the subset with the maximum possible sum that does not exceed a given target sum. If there are multiple subsets with the maximum sum, return the one with the fewest elements. If there are still multiple subsets, return the lexicographically smallest subset.\n\n...
0.677554
Taco_35311
C
[ "max_subset_sum", "solve" ]
2
[ [ "solve", "max_subset_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ccc2af091be6ce42a7bf2f36f365ac5939df2a4
f0ce40fcb4119683a3c37b83c0885025d1803244
v1.0
complete
Taco
Taco_35571_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def is_full_binary_tree(root): """ Check if the binary tree is a full binary tree. >>> is_full_binary_tree(TreeNode(1)) True """ def build_tree_from_level_order(data): """ B...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def is_full_binary_tree(root): if root is None: return True # If a node has one child, it's not a full binary tree if (root.left is None and root.right is not None) or (root...
from solution import check_full_binary_tree def test_full_binary_tree(): assert check_full_binary_tree([1, 2, 3, -1, -1, 4, 5]) == "Yes" def test_not_full_binary_tree_with_one_child(): assert check_full_binary_tree([1, 2, 3, 4, -1]) == "No" def test_single_node_tree(): assert check_full_binary_tree([1]) ...
[]
[ 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": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef insert_level_order(arr, roo...
trial_gpt4o_1
{ "original_instruction": "You are given a binary tree. Your task is to write a function to check if the tree is a full binary tree or not. A full binary tree is a tree in which every node has either 0 or 2 children.\n\nInput:\nThe input contains the elements of the binary tree in level order traversal where -1 repre...
0.606867
Taco_35571
C
[ "is_full_binary_tree", "build_tree_from_level_order", "check_full_binary_tree" ]
3
[ [ "check_full_binary_tree", "build_tree_from_level_order" ], [ "check_full_binary_tree", "is_full_binary_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
530d4dfc0046807836c2aaf2d216c73c97618d0e
3d6d492cc18d14f257b8671306edece0cd8f4e5a
v1.0
complete
Taco
Taco_35478_C
def min_total_travel_time(n, m, roads): """ Computes the minimum total travel time required for Amy to deliver the mail to all houses. :param n: Number of houses. :param m: Number of roads. :param roads: List of tuples (A, B, T) representing there is a road between house A and B with travel time T. ...
import heapq def prim_mst(graph, n): """ Prim's Algorithm to find the minimum spanning tree (MST) of a graph. :param graph: adjacency list representing graph. :param n: number of nodes in the graph. :return: total weight of the minimum spanning tree. """ min_heap = [(0, 1)] # (weight,...
from solution import min_total_travel_time def test_example(): assert min_total_travel_time(5, 6, [(1, 2, 4), (1, 3, 2), (3, 4, 3), (2, 4, 5), (2, 5, 6), (4, 5, 1)]) == 10 def test_no_additional_path(): assert min_total_travel_time(2, 1, [(1, 2, 5)]) == 5 def test_additional_complexity(): assert min_tota...
[ { "docstring": "Prim's Algorithm to find the minimum spanning tree (MST) of a graph.\n\n:param graph: adjacency list representing graph.\n:param n: number of nodes in the graph.\n:return: total weight of the minimum spanning tree.", "function_declaration": "def prim_mst(graph, n):", "function_name": "pr...
[ 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 heapq\n\ndef prim_mst(graph, n):\n \"\"\"\n Prim's Algorithm to find the minimum spanning tree (MST) of a graph.\n \n :param graph: adjacency li...
trial_gpt4o_0
{ "original_instruction": "problem\n\nIn a town where there are several roads, Amy wants to deliver mail from the post office to specific houses. The houses are numbered from 1 to N and the post office is located at house 1. Amy has information about the time it takes to travel between some pairs of houses and must c...
0.696246
Taco_35478
C
[ "prim_mst", "min_total_travel_time" ]
2
[ [ "min_total_travel_time", "prim_mst" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3b6d78537362044e2d7ff043d42a480e807eea8a
c2911e969b7d27203d6e62136583a27a70fbfdbe
v1.0
complete
Taco
Taco_35436_C
from typing import List def SumOfDivided(lst: List[int]) -> List[List[int]]: """ Write a function that takes in a list of positive integers and returns a list of lists where each sublist contains a prime number and the sum of all the integers in the input list that are divisible by that prime number. >>> ...
import math from collections import defaultdict def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return Tru...
from solution import SumOfDivided def test_SumOfDivided_basic(): assert SumOfDivided([12, 15]) == [[2, 12], [3, 27], [5, 15]] def test_SumOfDivided_single_number(): assert SumOfDivided([30]) == [[2, 30], [3, 30], [5, 30]] def test_SumOfDivided_prime_only(): assert SumOfDivided([2, 3, 5, 7]) == [[2, 2], [...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": null,...
[ 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 \"\"\"\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_3
{ "original_instruction": "Write a function `SumOfDivided(list)` that takes in a list of positive integers and returns a list of lists where each sublist contains a prime number and the sum of all the integers in the input list that are divisible by that prime number.\n\nFor example:\n```python\nlist = [12, 15]\nSumO...
0.665332
Taco_35436
C
[ "is_prime", "prime_factors", "SumOfDivided" ]
3
[ [ "SumOfDivided", "is_prime" ], [ "SumOfDivided", "prime_factors" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8b0a5ce55eafce64787cb0b0b53c346d57191dce
80a99cff1d7e5aac000b8a1312c8e8b8c17a0d09
v1.0
complete
Taco
Taco_35542_C
import collections from typing import List, Tuple def optimal_festival_stalls(n: int, k: int, p: List[int], roads: List[Tuple[int, int]]) -> int: """ Determine the optimal configuration for setting up stalls to minimize the total distance among them. Args: n: An integer representing the number of ...
from collections import deque, defaultdict def bfs_distances(tree, start, n): distances = [-1] * (n + 1) queue = deque([start]) distances[start] = 0 while queue: node = queue.popleft() for neighbor in tree[node]: if distances[neighbor] == -1: distances[neigh...
def test_optimal_festival_stalls(): n = 6 k = 3 p = [1, 1, 2] roads = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6)] assert optimal_festival_stalls(n, k, p, roads) == 4 def test_single_intersection(): n = 1 k = 1 p = [1] roads = [] assert optimal_festival_stalls(n, k, p, roa...
[ { "docstring": null, "function_declaration": "def bfs_distances(tree, start, n):", "function_name": "bfs_distances", "parameter_list": "(tree, start, n)" }, { "docstring": null, "function_declaration": "def optimal_festival_stalls(n, k, p, roads):", "function_name": "optimal_festival...
[ 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": "from collections import deque, defaultdict\n\ndef min_sum_of_distances(n, k, products, roads):\n def bfs(start):\n distances = [-1] * n\n distance...
trial_gpt4o_4
{ "original_instruction": "Optimal Festival Stalls\n\nCharlie is setting up stalls for a festival in a city that consists of n intersections and n-1 bidirectional roads, forming a tree structure. Charlie wants to set up k stalls, each offering a specific type of product, denoted by pi (1 ≤ pi ≤ k). He wants each stal...
0.610876
Taco_35542
C
[ "bfs_distances", "optimal_festival_stalls" ]
2
[ [ "optimal_festival_stalls", "bfs_distances" ] ]
1
[]
false
[]
false
pytest
false
[]
true
339a0e2a5ba6b5a98f94007708204a0b7e5c1d6e
b064b74b4bd80553b3ab0c9d694248f2c323f31b
v1.0
complete
Taco
Taco_35740_C
def min_operations_to_prime(s: int, t: int) -> int: """ Given a starting number s and a target number t, determine the minimum number of operations necessary to transform s into a prime number greater than or equal to t. The operations allowed are: - Add 1 - Subtract 1 - Multiply by 2 >>> min_o...
import math from collections import deque 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...
from solution import min_operations_to_prime def test_min_operations_case_1(): assert min_operations_to_prime(10, 20) == 3 def test_min_operations_case_2(): assert min_operations_to_prime(14, 17) == 2 def test_min_operations_case_3(): assert min_operations_to_prime(2, 3) == 1 def test_min_operations_cas...
[ { "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 the minimum number of operations to transform s into a prime number\ngreater than or equal to t.", ...
[ 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": "import heapq\n\ndef is_prime(n):\n \"\"\" \n Check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_3
{ "original_instruction": "In a vast labyrinthine dungeon, Raaneth the explorer encounters a set of magical gates that only open for prime numbers. Each gate requires a sequence of operations to transform the starting number into a prime to proceed to the next chamber. Raaneth can perform the following operations to ...
0.618191
Taco_35740
C
[ "is_prime", "min_operations_to_prime" ]
2
[ [ "min_operations_to_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0aaeb01f124a8f88f2f1804ab6c9c55250be0c51
294032edf07033606ab57dd769af0d77b1baf6fa
v1.0
complete
Taco
Taco_34753_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def mirror_tree(root: Optional[TreeNode]) -> Optional[TreeNode]: """ Convert a binary tree to its mirror image. Args: root: TreeNode - The root of the given ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def mirror_tree(root): if root is None: return None # Swap left and right subtrees root.left, root.right = root.right, root.left # Mirror th...
from solution import mirror_tree, pre_order_traversal, build_tree_from_string, handle_tests def test_single_node(): root = build_tree_from_string("1") mirrored_root = mirror_tree(root) assert pre_order_traversal(mirrored_root) == [1] def test_simple_tree(): root = build_tree_from_string("1(2)(3)") ...
[]
[ 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": "from typing import Optional\n\nclass TreeNode:\n def __init__(self, val: int = 0, left: 'TreeNode' = None, right: 'TreeNode' = None):\n self.val = val\n ...
trial_gpt4o_1
{ "original_instruction": "You are given a binary tree. Implement a function that converts this binary tree into its mirror image. The mirror of a binary tree is another binary tree with left and right children of all non-leaf nodes interchanged.\n\nWrite a function `mirror_tree(root)` where:\n- `root` is the root of...
0.532599
Taco_34753
C
[ "mirror_tree", "pre_order_traversal", "build_tree_from_string", "handle_tests" ]
4
[ [ "handle_tests", "build_tree_from_string" ], [ "handle_tests", "mirror_tree" ], [ "handle_tests", "pre_order_traversal" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
75128b9295c9b8de41eccc971f60e10d238f1126
93d423f0be743b6963e31a79d95b68e8da7decc9
v1.0
complete
Taco
Taco_35274_C
def next_train_schedule(routes, queries): """ This function finds the next train schedule based on the provided routes and queries. :param routes: Dictionary with key as (start, end) tuple and value as list of departure times. :param queries: List of (start, end, departure time) tuples. :return...
def next_train_schedule(routes, queries): """ This function finds the next train schedule based on the provided routes and queries. :param routes: Dictionary with key as (start, end) tuple and value as list of departure times. :param queries: List of (start, end, departure time) tuples. :return...
def test_process_input(): input_data = """3 A B 5 5 15 25 35 55 B C 4 60 120 180 240 A C 3 100 200 300 3 A B 10 A C 50 B C 80""" expected_routes = { ('A', 'B'): [5, 15, 25, 35, 55], ('B', 'C'): [60, 120, 180, 240], ('A', 'C'): [100, 200, 300], } expected_queries = [('A', 'B', 10)...
[ { "docstring": "This function finds the next train schedule based on the provided routes and queries.\n\n:param routes: Dictionary with key as (start, end) tuple and value as list of departure times.\n:param queries: List of (start, end, departure time) tuples.\n:return: List of earliest possible departure time...
[ 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_next_train(N, routes, Q, queries):\n timetable = {}\n \n for i in range(N):\n start, end, T = routes[i][:3]\n departure_times = rou...
trial_gpt4o_2
{ "original_instruction": "You are given a railway timetable containing train schedules for various routes. Each route is identified by its start and end stations, along with an array of departure times for the train from the start station. \n\nYou are tasked with writing a program that answers queries about the earl...
0.592549
Taco_35274
C
[ "next_train_schedule", "process_input", "find_next_trains" ]
3
[ [ "find_next_trains", "next_train_schedule" ], [ "find_next_trains", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
033a62aa30c619fa5d54e92d038c2723d22c7129
1dd99b7998f4d5bbc411ef828b7d170e9ab9c00d
v1.0
complete
Taco
Taco_35836_C
def min_operations_to_single_digit(n: int) -> int: """ Calculate the minimum number of operations required to reduce n to a single-digit number. >>> min_operations_to_single_digit(38) 2 >>> min_operations_to_single_digit(5) 0 >>> min_operations_to_single_digit(1000000) 1 """
def sum_of_digits(x): return sum(int(digit) for digit in str(x)) def min_operations_to_single_digit(n): if n < 10: return 0 operations = 0 while n >= 10: n = sum_of_digits(n) operations += 1 return operations
from solution import min_operations_to_single_digit def test_single_digit_number(): assert min_operations_to_single_digit(5) == 0 def test_double_digit_number(): assert min_operations_to_single_digit(38) == 2 def test_large_number_all_zeros(): assert min_operations_to_single_digit(1000000) == 1 def test...
[ { "docstring": null, "function_declaration": "def sum_of_digits(x):", "function_name": "sum_of_digits", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def min_operations_to_single_digit(n):", "function_name": "min_operations_to_single_digit", "parameter_...
[ 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 sum_of_digits(n):\n \"\"\"\n Returns the sum of digits of a given non-negative integer n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\n...
trial_gpt4o_2
{ "original_instruction": "You are given an integer $n$. We define a function $f(x)$ which returns the sum of digits of a non-negative integer $x$. Your task is to find the minimum number of operations required to reduce $n$ to a single-digit number. In one operation, you can replace $n$ with $f(n)$.\n\nFor example, ...
0.669055
Taco_35836
C
[ "sum_of_digits", "min_operations_to_single_digit" ]
2
[ [ "min_operations_to_single_digit", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
615c1b36fbe288413e8dfc96e2a4059f7315db56
80b70660f0c683bb290ee8685840ebd46b2740e7
v1.0
complete
Taco
Taco_35876_C
def find_kth_smallest(N: int, sequence: List[int], K: int) -> int: """ Find the Kth smallest element in the sequence using the Quickselect algorithm. >>> find_kth_smallest(6, [7, 10, 4, 3, 20, 15], 3) 7 >>> find_kth_smallest(5, [7, 10, 4, 20, 15], 4) 15 """
def partition(arr, low, high): pivot = arr[high] i = low for j in range(low, high): if arr[j] <= pivot: arr[i], arr[j] = arr[j], arr[i] i += 1 arr[i], arr[high] = arr[high], arr[i] return i def quickselect(arr, low, high, k): if low == high: return arr[lo...
from solution import find_kth_smallest def test_find_kth_smallest(): assert find_kth_smallest(6, [7, 10, 4, 3, 20, 15], 3) == 7 assert find_kth_smallest(5, [7, 10, 4, 20, 15], 4) == 15 assert find_kth_smallest(6, [1, 2, 3, 4, 5, 6], 6) == 6 assert find_kth_smallest(6, [6, 5, 4, 3, 2, 1], 1) == 1 as...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quickselect(arr, low, high, k):", "function_name": "quickselect", "parameter_list...
[ 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 partition(arr, low, high):\n pivot = arr[high]\n i = low\n for j in range(low, high):\n if arr[j] <= pivot:\n arr[i], arr[j] = arr[j...
trial_gpt4o_2
{ "original_instruction": "You are given a sequence of N integers, and an integer K. Your task is to find the Kth smallest element in the sequence using the Quickselect algorithm.\n\nExample:\nInput:\nN = 6\nsequence = [7, 10, 4, 3, 20, 15]\nK = 3\nOutput:\n7\nExplanation:\nThe 3rd smallest element in the array [7, 1...
0.671004
Taco_35876
C
[ "partition", "quickselect", "find_kth_smallest" ]
3
[ [ "find_kth_smallest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9bfe68be2a85ca11269c9fa93bfc6eae1f12469f
16cf5becb8e612376ab6ddd8a4487f96d86a7a00
v1.0
complete
Taco
Taco_35813_C
def merge_and_sort(list1, list2): """ Merges two lists and returns a sorted list without using built-in sort functions. >>> merge_and_sort([1, 4, 5], [2, 3, 6]) [1, 2, 3, 4, 5, 6] >>> merge_and_sort([-1, 2, 4], [1, 0, -3, 5]) [-3, -1, 0, 1, 2, 4, 5] >>> merge_and_sort([1, 3, 5], [1, 3, 5]) ...
def merge_and_sort(list1, list2): """ Merges two lists and returns a sorted list without using built-in sort functions. """ # Merge the two lists merged_list = list1 + list2 # Implement Merge Sort return merge_sort(merged_list) def merge_sort(arr): """ Sorts the given list using Mer...
from solution import merge_and_sort def test_merge_and_sort_basic(): assert merge_and_sort([1, 4, 5], [2, 3, 6]) == [1, 2, 3, 4, 5, 6] def test_merge_and_sort_with_negative(): assert merge_and_sort([-1, 2, 4], [1, 0, -3, 5]) == [-3, -1, 0, 1, 2, 4, 5] def test_merge_and_sort_identical_elements(): assert ...
[ { "docstring": "Merges two lists and returns a sorted list without using built-in sort functions.", "function_declaration": "def merge_and_sort(list1, list2):", "function_name": "merge_and_sort", "parameter_list": "(list1, list2)" }, { "docstring": "Sorts the given list using Merge Sort algo...
[ 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 merge_and_sort(list1, list2):\n \"\"\"\n Merges two lists and returns a sorted list in non-decreasing order.\n Does not use built-in sorted() or any b...
trial_gpt4o_2
{ "original_instruction": "Create a function `merge_and_sort` that takes two lists of integers as inputs and returns a single list that combines the elements of both input lists sorted in non-decreasing order. You are not allowed to use the built-in `sorted()` function or any other built-in sort functions.\n\n### Inp...
0.622271
Taco_35813
C
[ "merge_and_sort", "merge_sort" ]
2
[ [ "merge_and_sort", "merge_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
89f921f6c3ecd5bc7c152ab7949e9aaeee6c755d
b0dc220aa3369963abaacc7e541e410c948c50ba
v1.0
complete
Taco
Taco_35873_C
from typing import List def largestNumber(arr: List[int]) -> str: """ Given a list of non-negative integers, arrange them in such a way that they form the largest possible number. >>> largestNumber([54, 546, 548, 60]) '6054854654' >>> largestNumber([1, 34, 3, 98, 9, 76, 45, 4]) '99876...
from functools import cmp_to_key def compare(x, y): # Comparator function to decide the order if x + y > y + x: return -1 else: return 1 def largestNumber(arr): """ Given a list of non-negative integers, arranges them in such a way that they form the largest possible number. ""...
from solution import largestNumber def test_example1(): arr = [54, 546, 548, 60] assert largestNumber(arr) == '6054854654' def test_example2(): arr = [1, 34, 3, 98, 9, 76, 45, 4] assert largestNumber(arr) == '998764543431' def test_single_element(): arr = [1] assert largestNumber(arr) == ...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Given a list of non-negative integers, arranges them in such a way that they form the largest possible number.", "function_declaration": "def large...
[ 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": "from functools import cmp_to_key\n\ndef compare(a, b):\n \"\"\"\n Custom comparator function to decide the order of numbers.\n \"\"\"\n if a + b > b + ...
trial_gpt4o_2
{ "original_instruction": "Given a list of non-negative integers, arrange them in such a way that they form the largest possible number.\nExample 1:\nInput:\nN = 3\narr = [54, 546, 548, 60]\nOutput:\n6054854654\nExplanation: \nBy arranging the elements in such a way to form the largest possible number, we get 6054854...
0.760575
Taco_35873
C
[ "compare", "largestNumber" ]
2
[ [ "largestNumber", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2b6ff01041ce0ca1a03c29df246a66d1a1e28106
1f71b6ca8b90bd11f4b1bbbcd8717409a738a55a
v1.0
complete
Taco
Taco_35409_C
def irrigation_system(M: int, N: int, pipes: List[Tuple[int, int, int]], Q: int, irrigation_plans: List[Tuple[int, int, int]]) -> List[str]: """ Determine if the irrigation plan can be executed given the current capacity of the pipes. Parameters: M (int): Number of farms. N (int): Number of pip...
from collections import defaultdict import heapq def dijkstra_capacity(graph, start, end, required_capacity): """Find the maximum possible capacity from start to end using a modified Dijkstra's algorithm.""" max_capacity = {node: -1 for node in graph} max_capacity[start] = float('inf') priority_queue =...
from solution import irrigation_system def test_irrigation_system(): M, N = 4, 5 pipes = [ (1, 2, 30), (1, 3, 40), (2, 3, 10), (2, 4, 20), (3, 4, 50), ] Q = 3 irrigation_plans = [ (1, 4, 30), (1, 3, 35), (2, 4, 25), ] assert ir...
[ { "docstring": "Find the maximum possible capacity from start to end using a modified Dijkstra's algorithm.", "function_declaration": "def dijkstra_capacity(graph, start, end, required_capacity):", "function_name": "dijkstra_capacity", "parameter_list": "(graph, start, end, required_capacity)" }, ...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef can_irrigate(m, n, pipes, q, plans):\n graph = {}\n for u, v, capacity in pipes:\n if u not in graph:\n graph[u] = []\n...
trial_gpt4o_9
{ "original_instruction": "The kingdom of CodeLand is constructing a new irrigation system. There are M farms connected by a network of N pipes. Each pipe can transport water in both directions and has a certain capacity, indicating the maximum amount of water it can transport per second.\n\nYou are given a list of Q...
0.604293
Taco_35409
C
[ "dijkstra_capacity", "irrigation_system" ]
2
[ [ "irrigation_system", "dijkstra_capacity" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e1dfc755321709525a5d801130dec686995c783f
8cc1fc079c979e30052a72717f9010b291020446
v1.0
complete
Taco
Taco_35787_C
def count_hurdle_jumps(test_cases): """ Given multiple test cases of Kevin's hurdle race, determine the number of jumps Kevin makes before he can no longer continue. >>> count_hurdle_jumps([[1, 2, 3, 4, 5], [2, 1, 2, 1]]) [1, 2] """ pass def parse_input(input_string): """ Parse the input string...
def count_hurdle_jumps(test_cases): results = [] for hurdles in test_cases: jumps = 0 n = len(hurdles) if n == 0: results.append(jumps) continue min_hurdle = min(hurdles) current_index = hurdles.index(min_hurdle) while current_in...
def test_parse_input(): input_string = "2\n5 1 2 3 4 5\n4 2 1 2 1\n" expected = [ [1, 2, 3, 4, 5], [2, 1, 2, 1] ] assert parse_input(input_string) == expected def test_count_hurdle_jumps(): test_cases = [ [1, 2, 3, 4, 5], [2, 1, 2, 1] ] expected = [1, 2] ...
[ { "docstring": null, "function_declaration": "def count_hurdle_jumps(test_cases):", "function_name": "count_hurdle_jumps", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "parameter...
[ 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 find_jumps(n, hurdles):\n \"\"\"\n Returns the number of jumps Kevin makes before he can no longer continue.\n \"\"\"\n if n == 0:\n return ...
trial_gpt4o_4
{ "original_instruction": "Kevin is participating in an obstacle race and has to jump over hurdles placed along a straight path. There are N hurdles in a row, and each hurdle has a specific height given in an array of size N. Kevin can jump one hurdle at a time, but he has a unique jumping style: he always jumps over...
0.584637
Taco_35787
C
[ "count_hurdle_jumps", "parse_input", "process" ]
3
[ [ "process", "count_hurdle_jumps" ], [ "process", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
5d3e623337b689c3cf30dde0fa84da819cd74768
9ee9d8cd48e071359807bd0cf6c2035957444fdc
v1.0
complete
Taco
Taco_35729_C
from typing import List, Tuple def largest_concatenated_number(test_cases: List[Tuple[int, List[int]]]) -> List[str]: """ Merge the given integers into the largest possible concatenated number as a string. Ensure no leading zeros are present. >>> largest_concatenated_number([(2, [3, 30]), (3, [9, 92, ...
from functools import cmp_to_key def compare(x, y): if x + y > y + x: return -1 else: return 1 def largest_concatenated_number(test_cases): results = [] for case in test_cases: N, numbers = case str_nums = sorted(map(str, numbers), key=cmp_to_key(compare)) resul...
from solution import largest_concatenated_number, parse_input def test_largest_concatenated_number_case1(): input_text = "2\n2\n3\n30\n3\n9\n92\n5" test_cases = parse_input(input_text) result = largest_concatenated_number(test_cases) assert result == ["330", "9925"] def test_single_test_case(): in...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_concatenated_number(test_cases):", "function_name": "largest_concatenated_number", "parameter_lis...
[ 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": "from functools import cmp_to_key\n\ndef compare_numbers(a, b):\n if a + b > b + a:\n return -1\n else:\n return 1\n\ndef largest_concatenated_n...
trial_gpt4o_1
{ "original_instruction": "You are given N integers. You need to merge these integers into a single integer by concatenating their string representations such that the resulting number is the largest possible. You should return the final concatenated number as a string, ensuring no leading zeros are present.\n\nInput...
0.627269
Taco_35729
C
[ "compare", "largest_concatenated_number", "parse_input" ]
3
[ [ "largest_concatenated_number", "compare" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
67a3665dd64f17916fbb752ffe55393471b9100e
29e33a07a2dacdc8c51c08619a43cf79a6ae72d7
v1.0
complete
Taco
Taco_35246_C
def optimal_ruins_visiting_order(m: int, n: int, ruins: dict, start: tuple) -> str: """ Determines the optimal order to visit all ruins to minimize the total travel time. m, n: Dimensions of the grid. ruins: Dictionary with coordinates of ruins as keys and treasure weights as values. start: ...
from itertools import permutations def compute_travel_time(path, ruins, start): """ Compute the travel time for a given path starting from `start`. """ def manhattan_dist(p1, p2): return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]) total_time, current_pos, collected_weight = 0, start, 0 ...
import pytest from solution import optimal_ruins_visiting_order def test_case_1(): m, n = 5, 5 ruins = {(2, 3): 10, (4, 4): 20, (1, 1): 5, (3, 2): 15, (4, 1): 25} start = (3, 3) result = optimal_ruins_visiting_order(m, n, ruins, start).split() assert set((int(result[i]), int(result[i+1])) for i in ...
[ { "docstring": "Compute the travel time for a given path starting from `start`.", "function_declaration": "def compute_travel_time(path, ruins, start):", "function_name": "compute_travel_time", "parameter_list": "(path, ruins, start)" }, { "docstring": "Determines the optimal order to visit ...
[ 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": "import itertools\n\ndef calculate_distance(start, end):\n \"\"\"\n Calculate Manhattan distance between two grid points.\n \"\"\"\n return abs(start[0]...
trial_gpt4o_8
{ "original_instruction": "You are an avid explorer and have come across a hidden valley with multiple ancient ruins. Each ruin has treasures you can collect, but the path to each ruin is treacherous with traps that slow your progress.\n\nYour goal is to collect all treasures from each ruin while minimizing the overa...
0.580886
Taco_35246
C
[ "compute_travel_time", "optimal_ruins_visiting_order", "main" ]
3
[ [ "optimal_ruins_visiting_order", "compute_travel_time" ] ]
1
[]
false
[]
false
pytest
true
[]
true
188bd00e2cb421e367a3cce3d8f7740768c9542f
35c67cb574253a3cecdee96e43f2fe46e707a05e
v1.0
complete
Taco
Taco_35800_C
from typing import List, Tuple def min_buses(s: Tuple[int, int], d: Tuple[int, int], lines: List[Tuple[Tuple[int, int], Tuple[int, int]]]) -> int: """Determine the minimum number of bus lines needed to travel from starting point S to destination point D. Args: s: Coordinates of the starting point (sx, s...
from collections import deque from typing import List, Tuple def is_intersect(p1, p2, p3, p4) -> bool: """ Returns True if line segments p1p2 and p3p4 intersect. Points are represented as tuples (x, y) """ def orientation(p, q, r): val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1]...
def test_min_buses(): assert min_buses((0, 0), (10, 10), [((0, 0), (5, 5)), ((5, 5), (10, 10)), ((5, 0), (10, 5)), ((0, 10), (10, 0))]) == 2 assert min_buses((0, 0), (10, 10), [((0, 0), (1, 1)), ((2, 2), (3, 3))]) == -1 assert min_buses((0, 0), (5, 5), [((0, 0), (5, 5)), ((2, 2), (3, 3))]) == 1 assert m...
[ { "docstring": "Returns True if line segments p1p2 and p3p4 intersect.\nPoints are represented as tuples (x, y)", "function_declaration": "def is_intersect(p1, p2, p3, p4):", "function_name": "is_intersect", "parameter_list": "(p1, p2, p3, p4)" }, { "docstring": null, "function_declarati...
[ 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 min_bus_lines(sx, sy, dx, dy, bus_lines):\n from collections import deque, defaultdict\n def intersect(x1, y1, x2, y2, x3, y3, x4, y4):\n def on_s...
trial_gpt4o_1
{ "original_instruction": "The ancient city of Bytown has a unique transportation system consisting of $n$ bus lines. Each bus line is described by two points $(x_i, y_i)$ and $(u_i, v_i)$, which represent two ends of the bus line in a 2D plane. Your task is to determine the minimum number of bus lines you need to ta...
0.650482
Taco_35800
C
[ "is_intersect", "build_graph", "min_buses" ]
3
[ [ "build_graph", "is_intersect" ], [ "min_buses", "build_graph" ], [ "min_buses", "is_intersect" ] ]
3
[]
false
[]
false
pytest
false
[]
true
05226d83081a8606885e09a144d5cf0abe2e06d7
368fd5f2522e4fe37ef9c244120ec1a9370cb5af
v1.0
complete
Taco
Taco_35616_C
from typing import List, Tuple def min_travel_time(n: int, m: int, k: int, streets: List[Tuple[int, int, int]], flood_prone: List[Tuple[int, int]], s: int, d: int) -> int: """ Find the minimum travel time from the start intersection to the destination intersection avoiding any flooded streets. >>> min_tra...
import heapq def dijkstra(graph, source, destination, banned_edges): n = len(graph) visited = [False] * n min_time = [float('inf')] * n min_time[source] = 0 heap = [(0, source)] while heap: curr_time, u = heapq.heappop(heap) if visited[u]: continue ...
def test_min_travel_time_basic(): n = 5 m = 7 k = 2 streets = [(1, 2, 4), (1, 3, 2), (2, 4, 5), (3, 4, 8), (3, 5, 10), (4, 5, 2), (5, 4, 9)] flood_prone = [(2, 3), (4, 5)] s, d = 1, 5 assert min_travel_time(n, m, k, streets, flood_prone, s, d) == 12 def test_min_travel_time_no_path(): n...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, source, destination, banned_edges):", "function_name": "dijkstra", "parameter_list": "(graph, source, destination, banned_edges)" }, { "docstring": null, "function_declaration": "def min_travel_time(n, m, k, streets, flood...
[ 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": "import heapq\n\ndef find_minimum_travel_time(n, m, k, streets, flooded_streets, start, destination):\n # Creating an adjacency list for the graph\n adjacency...
trial_gpt4o_1
{ "original_instruction": "A city has $n$ intersections connected by one-way streets. Each street has a travel time associated with it. Unfortunately, due to heavy rainfall, certain streets may become flooded and need to be avoided. Given the travel time of streets and the pairs of intersections where streets might b...
0.66379
Taco_35616
C
[ "dijkstra", "min_travel_time" ]
2
[ [ "min_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
9cd1b29e3494704907e5c2436e022a8056b877b9
7099e8756fd4ad04f364d09b15d78708124d4766
v1.0
complete
Taco
Taco_35608_C
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reverse_alternate_k_nodes(head: ListNode, k: int) -> ListNode: """ Given a linked list, reverse every alternate K nodes and return its modified form. Args: head (ListNode): The head of the lin...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reverse_alternate_k_nodes(head: ListNode, k: int) -> ListNode: def reverse(head, k): prev, curr = None, head while k and curr: nxt = curr.next curr.next = prev ...
from solution import ListNode, reverse_alternate_k_nodes def list_to_linked_list(elements): dummy = ListNode(0) curr = dummy for element in elements: curr.next = ListNode(element) curr = curr.next return dummy.next def linked_list_to_list(head): elements = [] while head: ...
[]
[ 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 ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef reverse_alternate_k_nodes(head: ListNode, k: in...
trial_gpt4o_0
{ "original_instruction": "Given a linked list, the task is to reverse every alternate K nodes (where K is an integer) in the linked list and return its modified form.\nExample 1:\nInput:\nhead = [1, 2, 3, 4, 5, 6, 7, 8, 9]\nK = 3\nOutput: [3, 2, 1, 4, 5, 6, 9, 8, 7]\nExplanation: \nThe linked list elements are in th...
0.588925
Taco_35608
C
[ "reverse_alternate_k_nodes", "reverse_skip_k_nodes" ]
2
[ [ "reverse_alternate_k_nodes", "reverse_skip_k_nodes" ], [ "reverse_skip_k_nodes", "reverse_alternate_k_nodes" ] ]
2
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
fc76a4002847872af32eb76ed6e140962029bf28
53a10fbbefccd5165d11dba95958e05d7a128a83
v1.0
complete
Taco
Taco_35948_C
def detect_cycle_in_graph(V: int, E: int, edges: List[Tuple[int, int]]) -> str: """ Detect if there is at least one cycle in a directed graph. The graph is represented using an adjacency list where each node has a list of directed edges to other nodes. Args: V (int): The number of vertices in the g...
def has_cycle(V, edges): from collections import defaultdict # Create adjacency list graph = defaultdict(list) for u, v in edges: graph[u].append(v) visited = [False] * V rec_stack = [False] * V def dfs(v): visited[v] = True rec_stack[v] = True ...
from solution import detect_cycle_in_graph def test_sample_input_1(): V = 4 E = 4 edges = [(0, 1), (1, 2), (2, 3), (3, 1)] assert detect_cycle_in_graph(V, E, edges) == "YES" def test_sample_input_2(): V = 4 E = 3 edges = [(0, 1), (1, 2), (2, 3)] assert detect_cycle_in_graph(V, E, edges...
[ { "docstring": null, "function_declaration": "def has_cycle(V, edges):", "function_name": "has_cycle", "parameter_list": "(V, edges)" }, { "docstring": null, "function_declaration": "def detect_cycle_in_graph(V, E, edges):", "function_name": "detect_cycle_in_graph", "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 has_cycle(V, edges):\n from collections import defaultdict\n \n # Create adjacency list\n graph = defaultdict(list)\n for u, v in edges:\n ...
trial_gpt4o_0
{ "original_instruction": "Detecting Cycles in a Directed Graph\n\nAlice is working on optimizing routes for a package delivery service. She needs to ensure that there are no cycles in the system of routes, to avoid scenarios where packages could end up in a never-ending loop. Alice has tasked you with writing a prog...
0.643271
Taco_35948
C
[ "has_cycle", "detect_cycle_in_graph" ]
2
[ [ "detect_cycle_in_graph", "has_cycle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
53957efa6237ef0e254bf99f35bfce82620b47bb
928e7d7d99ab60973e35a90774164736159f69f3
v1.0
complete
Taco
Taco_35623_C
def min_construction_cost(n: int, m: int, roads: List[Tuple[int, int, int, int]]) -> int: """ Determine the minimum total construction cost required to achieve a connected road network for the village. The village is structured as a grid of n×n blocks. Each road segment connects two blocks and has a c...
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): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[r...
def test_min_construction_cost(): assert min_construction_cost(4, 5, [ (1, 2, 1, 10), (2, 3, 2, 15), (3, 4, 3, 10), (1, 3, 2, 20), (2, 4, 3, 30) ]) == 35 assert min_construction_cost(3, 3, [ (1, 2, 1, 10), (2, 3, 2, 5), (1, 3, 3, 20) ]) ==...
[ { "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)" }, ...
[ 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(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_0
{ "original_instruction": "In a remote village, the inhabitants decided to construct a road network connecting their village with a nearby city. The village can be thought of as a grid of n×n blocks, and there are m proposed road segments they can build to connect some pairs of blocks. Each road segment connects two ...
0.636178
Taco_35623
C
[ "find", "union", "min_construction_cost" ]
3
[ [ "min_construction_cost", "find" ], [ "min_construction_cost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
a0ac2e7458b0deae46e659e2781f128f2232023f
9390d07433e1911440078fe42be2a0e14eabb680
v1.0
complete
Taco
Taco_35685_C
class TreeNode: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right class DLLNode: def __init__(self, value): self.value = value self.prev = None self.next = None def tree_to_dll_from_input(input_data): ""...
class TreeNode: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right class DLLNode: def __init__(self, value): self.value = value self.prev = None self.next = None def tree_to_dll(root): def inorder(node, p...
def test_tree_to_dll_1(): input_data = """5 10 5 15 5 -1 7 7 -1 -1 15 12 20 12 -1 -1 20 -1 -1""" expected_output = [5, 7, 10, 12, 15, 20] assert tree_to_dll_from_input(input_data) == expected_output def test_tree_to_dll_2(): input_data = """3 1 -1 2 2 -1 3 3 -1 -1""" expected_output = [1, 2, 3] ...
[]
[ 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, value, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\nclass D...
trial_gpt4o_0
{ "original_instruction": "Define a transformation to convert a given binary tree into a doubly linked list. Each node in the doubly linked list must contain the same value as the corresponding node in the binary tree. The doubly linked list should be arranged in such a way that it follows the in-order traversal sequ...
0.47644
Taco_35685
C
[ "tree_to_dll", "build_tree", "tree_to_dll_from_input" ]
3
[ [ "tree_to_dll_from_input", "build_tree" ], [ "tree_to_dll_from_input", "tree_to_dll" ] ]
2
[]
false
[ "TreeNode", "DLLNode" ]
true
pytest
false
[]
true
43040efa15470582bae34ccf2f90494374b11225
c60a653b20420e9cdeda78e8abd4e4d0c91dc9ca
v1.0
complete
Taco
Taco_35814_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def insert_level_order(arr, root, i, n): if i < n: temp = TreeNode(arr[i]) root = temp root.left = insert_level_order(arr, root.left, 2 * i + 1, n) root.righ...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def insert_level_order(arr, root, i, n): if i < n: temp = TreeNode(arr[i]) root = temp root.left = insert_level_order(arr, root.left, 2 * i + 1, n) root.righ...
from solution import closest_value_in_bst def test_case_1(): n = 7 values = [4, 2, 6, 1, 3, 5, 7] x = 4 assert closest_value_in_bst(n, values, x) == 4 def test_case_2(): n = 7 values = [10, 5, 15, 2, 7, 12, 17] x = 13 assert closest_value_in_bst(n, values, x) == 12 def test_case_3(): ...
[]
[ 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, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef insert_level_order(arr, roo...
trial_gpt4o_2
{ "original_instruction": "You are given a balanced binary search tree (BST) with n nodes and a target value x. The tree consists of nodes with unique integer values. Your task is to find the node in the BST that has the minimum absolute difference with the given target value x. If there are multiple nodes with the s...
0.577051
Taco_35814
C
[ "insert_level_order", "find_closest_value", "closest_value_in_bst" ]
3
[ [ "closest_value_in_bst", "find_closest_value" ], [ "closest_value_in_bst", "insert_level_order" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
993e123f71f1ac4b8cfdfb81cb503b487f1e99cd
ff14d9ab79425043f7a3de881b9c500bb6a62bb8
v1.0
complete
Taco
Taco_35995_C
from typing import List def max_stars_per_case(stars: List[int]) -> int: """ Returns the maximum number of stars that can be collected by following the non-adjacent stages rule. >>> max_stars_per_case([1, 2, 9, 4]) == 10 >>> max_stars_per_case([3, 2, 5, 10, 7]) == 15 >>> max_stars_per_case([]) == ...
def max_stars_per_case(stars): """ Returns the maximum number of stars that can be collected by following the non-adjacent stages rule. """ N = len(stars) if N == 0: return 0 elif N == 1: return stars[0] elif N == 2: return max(stars[0], stars[1]) dp = [...
from solution import max_stars_per_case, max_stars def test_max_stars_per_case(): assert max_stars_per_case([1, 2, 9, 4]) == 10 assert max_stars_per_case([3, 2, 5, 10, 7]) == 15 assert max_stars_per_case([]) == 0 assert max_stars_per_case([0]) == 0 assert max_stars_per_case([5]) == 5 assert max...
[ { "docstring": "Returns the maximum number of stars that can be collected \nby following the non-adjacent stages rule.", "function_declaration": "def max_stars_per_case(stars):", "function_name": "max_stars_per_case", "parameter_list": "(stars)" }, { "docstring": "Returns the maximum number ...
[ 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 max_stars(T, test_cases):\n def max_non_adjacent_sum(stars):\n incl = 0\n excl = 0\n for star in stars:\n new_excl = max(exc...
trial_gpt4o_1
{ "original_instruction": "Junior Programmer wants to collect as many stars as possible. They are given an array representing the number of stars collected at each stage in a game. However, they can only collect stars from non-adjacent stages to avoid penalties. Determine the maximum number of stars Junior Programmer...
0.553008
Taco_35995
C
[ "max_stars_per_case", "max_stars", "process_input" ]
3
[ [ "max_stars", "max_stars_per_case" ], [ "process_input", "max_stars" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
d9c256a867964963771bf25fbd09403255337798
4f6f5caaeefeb162caf55fe2c2051e648527bbf5
v1.0
complete
Taco
Taco_36264_C
def find_first_missing_positive(n, nums): """ Finds the first missing positive integer from the list. >>> find_first_missing_positive(5, [3, 4, -1, 1, 2]) 5 >>> find_first_missing_positive(3, [1, 2, 0]) 3 >>> find_first_missing_positive(4, [7, 8, 9, 11, 12]) 1 >>> find_first_missing...
def first_missing_positive(nums): """ Finds the first missing positive integer from the list. """ n = len(nums) # Step 1: Mark non-positive and out of range elements for i in range(n): if nums[i] <= 0 or nums[i] > n: nums[i] = n + 1 # Step 2: Use the index as a ...
def test_find_first_missing_positive(): assert find_first_missing_positive(5, [3, 4, -1, 1, 2]) == 5 assert find_first_missing_positive(3, [1, 2, 0]) == 3 assert find_first_missing_positive(4, [7, 8, 9, 11, 12]) == 1 assert find_first_missing_positive(4, [1, 2, 3, 4]) == 5 assert find_first_missing_...
[ { "docstring": "Finds the first missing positive integer from the list.", "function_declaration": "def first_missing_positive(nums):", "function_name": "first_missing_positive", "parameter_list": "(nums)" }, { "docstring": "Wrapper function to get the required format of input and output.", ...
[ 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 first_missing_positive(N, arr):\n \"\"\"\n Finds the smallest missing positive integer in a given list of integers.\n \n Parameters:\n N (int): ...
trial_gpt4o_2
{ "original_instruction": "In a simulated computer science competition, participants were asked to identify the first missing positive integer in a given list of integers. Little Sarah found this intriguing and decided to practice more on this problem.\n\nThe task is to implement a function to find the smallest posit...
0.783704
Taco_36264
C
[ "first_missing_positive", "find_first_missing_positive" ]
2
[ [ "find_first_missing_positive", "first_missing_positive" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c2142010bae6604a8c7d2e4651e336a5bb6c3407
7cfd89ec765cf72087af934150ece83badf80a64
v1.0
complete
Taco
Taco_36232_C
def find_smallest_prime_factors(numbers: List[int]) -> List[int]: """ Given a list of positive integers, returns a new list where each element is the smallest prime factor of the corresponding element in the input list. >>> find_smallest_prime_factors([30, 45, 13, 100, 27]) [2, 3, 13, 2, 3] >>> ...
def smallest_prime_factor(n): """ Function that returns the smallest prime factor of n """ if n <= 1: return None if n % 2 == 0: return 2 factor = 3 while factor * factor <= n: if n % factor == 0: return factor factor += 2 return n def find_sm...
from solution import find_smallest_prime_factors def test_find_smallest_prime_factors(): assert find_smallest_prime_factors([30, 45, 13, 100, 27]) == [2, 3, 13, 2, 3] assert find_smallest_prime_factors([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] assert find_smallest_prime_factors([6, 15, 21, 25, 49]) == [2, 3, 3...
[ { "docstring": "Function that returns the smallest prime factor of n", "function_declaration": "def smallest_prime_factor(n):", "function_name": "smallest_prime_factor", "parameter_list": "(n)" }, { "docstring": "Given a list of positive integers, returns a new list where each element \nis 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": "def smallest_prime_factor(n):\n \"\"\"\n Returns the smallest prime factor of the given number n.\n \"\"\"\n if n <= 1:\n return None\n if n ...
trial_gpt4o_2
{ "original_instruction": "Julia is working on a task related to the concept of prime factorization. She needs to implement a function that finds the smallest prime factor for each number in a given list. A prime factor of a given integer n is any prime number that divides n without leaving a remainder. The smallest ...
0.796758
Taco_36232
C
[ "smallest_prime_factor", "find_smallest_prime_factors" ]
2
[ [ "find_smallest_prime_factors", "smallest_prime_factor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
232d71fe707e922ca056744fa30d0ecf3b4a9ce6
5e1741c3895319d8358894c3378d5eb91d7609f7
v1.0
complete
Taco
Taco_36180_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(9) False >>> is_prime(11) True """ def sum_of_primes_in_range(A: int, B: ...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import is_prime, sum_of_primes_in_range, solve_prime_sum 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(11) def test_sum_of_primes_in_range(): assert sum_of...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers between A and B (inclusive).", "function_declaration": "def sum_of_pri...
[ 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_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n Returns True if 'n' is a prime number, otherwise False.\n \"\"\"\n if n...
trial_gpt4o_4
{ "original_instruction": "The Queen of a distant kingdom is passionate about prime numbers. She calls her Royal Mathematician and gives him a challenging task. She wants him to take two integers, A and B, and find out the sum of all prime numbers between A and B (inclusive). The task must be completed accurately so ...
0.714512
Taco_36180
C
[ "is_prime", "sum_of_primes_in_range", "solve_prime_sum" ]
3
[ [ "solve_prime_sum", "sum_of_primes_in_range" ], [ "sum_of_primes_in_range", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
87175c4c41b3c28648af38b7ce8b501ac56a59f0
070c86f7e9e726c0d54296df8cdf5915212b595a
v1.0
complete
Taco
Taco_35918_C
def get_genre_popularity(user_preferences): """ This function takes in a list of user preferences where each user preference is a list containing genres they like. It returns the genre popularity sorted by popularity and then lexicographically in case of ties. """ pass def parse_input(input_s...
def get_genre_popularity(user_preferences): """ This function takes in a list of user preferences where each user preference is a list containing genres they like. It returns the genre popularity sorted by popularity and then lexicographically in case of ties. """ from collections import defau...
import pytest from solution import get_genre_popularity, parse_input, recommendation_system def test_get_genre_popularity(): user_preferences = [ ["3", "action", "comedy", "drama"], ["2", "action", "horror"], ["4", "comedy", "drama", "thriller", "action"], ["1", "thriller"], ...
[ { "docstring": "This function takes in a list of user preferences where each user preference \nis a list containing genres they like. It returns the genre popularity sorted \nby popularity and then lexicographically in case of ties.", "function_declaration": "def get_genre_popularity(user_preferences):", ...
[ 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 popular_genres(n, user_genres):\n from collections import defaultdict\n \n genre_count = defaultdict(int)\n \n for genres in user_genres:\n ...
trial_gpt4o_2
{ "original_instruction": "Problem\nYou are tasked with developing a streaming service's recommendation system. The service maintains a list of movie genres and every user has a list of their preferred genres. Your job is to identify which genres are the most popular among the users.\n\nSample Input\nThe first input ...
0.61794
Taco_35918
C
[ "get_genre_popularity", "parse_input", "recommendation_system" ]
3
[ [ "recommendation_system", "get_genre_popularity" ], [ "recommendation_system", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
6cd3c31f281a0b031a06fcbf7dbd7804169f740c
58bf4cac9883e6096f48052aca10f667e809dd7c
v1.0
complete
Taco
Taco_36351_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number; otherwise, returns False. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(11) True """ pass def find_prime_pair(X: int) -> str: """ Returns a pair of prime numbers (p1, p2) such that p1 + p2 = X, or "Not possible...
def is_prime(n): """ Returns True if n is a prime number; otherwise, returns 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 F...
from solution import is_prime, find_prime_pair def test_is_prime(): # Testing edge cases assert is_prime(0) == False assert is_prime(1) == False # Testing small prime numbers assert is_prime(2) == True assert is_prime(3) == True # Testing small non-prime numbers assert is_prime(4) == Fa...
[ { "docstring": "Returns True if n is a prime number; otherwise, returns False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a pair of prime numbers (p1, p2) such that p1 + p2 = X or \"Not possible\" if no such p...
[ 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_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_4
{ "original_instruction": "Write a program that takes an integer X as input and determines whether it can be expressed as the sum of two prime numbers. If it can, print one such pair of prime numbers. If there are multiple pairs, print any one of them. If no such pair exists, print \"Not possible\".\n\nSAMPLE INPUT\n...
0.745272
Taco_36351
C
[ "is_prime", "find_prime_pair" ]
2
[ [ "find_prime_pair", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
87eb3c949ad88a44222dbf752b4c00ded42bed42
2e86641097ac70e263abd36fd5a741f367940746
v1.0
complete
Taco
Taco_36240_C
def minimum_number_of_trips(n: int, x: int, roads: List[Tuple[int, int, int]]) -> int: """ Determine the minimum number of trips needed to deliver supplies to all cities. >>> minimum_number_of_trips(5, 10, [(1, 2, 5), (1, 3, 3), (3, 4, 7), (4, 5, 2)]) 2 >>> minimum_number_of_trips(6, 15, [(1, 2, 4), (2,...
from collections import defaultdict, deque def min_trips_to_deliver_supplies(n, x, roads): graph = defaultdict(list) for u, v, t in roads: graph[u].append((v, t)) graph[v].append((u, t)) distance_from_capital = [0] * (n + 1) visited = [False] * (n + 1) def bfs(source)...
import pytest from solution import minimum_number_of_trips def test_example_1(): n = 5 x = 10 roads = [(1, 2, 5), (1, 3, 3), (3, 4, 7), (4, 5, 2)] assert minimum_number_of_trips(n, x, roads) == 2 def test_example_2(): n = 6 x = 15 roads = [(1, 2, 4), (2, 3, 6), (2, 4, 5), (1, 5, 3), (5, 6,...
[ { "docstring": null, "function_declaration": "def min_trips_to_deliver_supplies(n, x, roads):", "function_name": "min_trips_to_deliver_supplies", "parameter_list": "(n, x, roads)" }, { "docstring": null, "function_declaration": "def minimum_number_of_trips(n, x, roads):", "function_n...
[ 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 minimum_trips(n, x, roads):\n from collections import defaultdict\n\n # build the graph\n graph = defaultdict(list)\n for u, v, t i...
trial_gpt4o_1
{ "original_instruction": "In a certain country, there are n cities connected by n-1 bidirectional roads such that there is a unique path between any two cities (i.e., the cities form a tree). Each road has a certain travel time associated with it. The capital of the country is city 1.\n\nA pandemic has broken out, a...
0.653738
Taco_36240
C
[ "min_trips_to_deliver_supplies", "minimum_number_of_trips" ]
2
[ [ "minimum_number_of_trips", "min_trips_to_deliver_supplies" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7cefe3e8b7f6a2a1204b93b74c466329b1e9d502
f1ecba8f1b903be8aba5aa7d0f09242035dbaecb
v1.0
complete
Taco
Taco_36215_C
def format_org_chart(n: int, employee_manager_pairs: List[Tuple[str, str]]) -> str: """ Create a hierarchical organizational chart displaying the employee-manager relationships. Args: n: Number of employees (1 ≤ n ≤ 1000) employee_manager_pairs: List of tuples where each tuple contains two strings: Empl...
def create_org_chart(n, employee_manager_pairs): from collections import defaultdict # Dictionary to hold the hierarchy hierarchy = defaultdict(list) # Variable to hold the CEO ceo = None # Build the hierarchy and determine the CEO for employee, manager in employee_manager_pairs: ...
from solution import format_org_chart def test_example_case(): n = 8 pairs = [ ("Alice", "None"), ("Bob", "Alice"), ("Charlie", "Alice"), ("David", "Bob"), ("Eve", "Bob"), ("Frank", "Charlie"), ("Grace", "Charlie"), ("Heidi", "David"), ] o...
[ { "docstring": null, "function_declaration": "def create_org_chart(n, employee_manager_pairs):", "function_name": "create_org_chart", "parameter_list": "(n, employee_manager_pairs)" }, { "docstring": null, "function_declaration": "def format_org_chart(n, employee_manager_pairs):", "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 build_org_chart(n, employee_manager_pairs):\n from collections import defaultdict\n\n # Build the hierarchy tree\n hierarchy = defaultdict(list)\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of employees in a company. Each employee has a manager, except the CEO who has no manager. The company wants to create an organizational chart displaying the hierarchy.\n\nGiven:\n1. `n` - Number of employees (1 ≤ n ≤ 1000)\n2. A list of `n` lines where each line contai...
0.599559
Taco_36215
C
[ "create_org_chart", "format_org_chart" ]
2
[ [ "format_org_chart", "create_org_chart" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9d9fc2962a058a8bf090bbb17b402da6cde22b44
127bf088309d1d4a358ac1162a38066606b92375
v1.0
complete
Taco
Taco_36576_C
def minimum_repair_cost(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int: """ Calculate the minimum repair cost required to connect all castles in the kingdom of Avalon. >>> minimum_repair_cost(4, 4, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 1, 6)]) 12 >>> minimum_repair_cost(4, 2, [(1, 2, 3), (3, ...
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] > ...
from solution import minimum_repair_cost def test_example_case(): assert minimum_repair_cost(4, 4, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 1, 6)]) == 12 def test_disconnected_graph(): assert minimum_repair_cost(4, 2, [(1, 2, 3), (3, 4, 4)]) == "IMPOSSIBLE" def test_single_node(): assert minimum_repair_...
[ { "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, 0, 1, 1, 0, 0 ]
2
hard
0.2
{ "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_6
{ "original_instruction": "In the kingdom of Avalon, there are numerous castles connected by roads. Some of these roads are in dire need of repair. The king has a list of all the roads and their respective repair costs. The king wants to connect all the castles in such a way that the total repair cost is minimized.\n...
0.568088
Taco_36576
C
[ "find", "union", "kruskal", "minimum_repair_cost" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_repair_cost", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
67f0a76a7183ffe00fb53fb1d9e514946ee0090e
07a277ed563a7658f392958e83cdaf3593c820fe
v1.0
complete
Taco
Taco_36286_C
from typing import List, Tuple def is_palindrome(num: int) -> bool: """ Check if a number is a palindrome. A number is a palindrome if it reads the same forwards and backwards. >>> is_palindrome(121) True >>> is_palindrome(123) False >>> is_palindrome(1) True >>> is_palindrome(22) True ...
def is_palindrome(num): """ Check if a number is a palindrome. A number is a palindrome if it reads the same forwards and backwards. """ return str(num) == str(num)[::-1] def count_palindromes(l, r): """ Count the number of palindromic numbers between l and r inclusive. """ count = ...
def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True assert is_palindrome(12321) == True def test_count_palindromes(): assert count_palindromes(1, 10) == 9 assert count_palindromes(100...
[ { "docstring": "Check if a number is a palindrome.\nA number is a palindrome if it reads the same forwards and backwards.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Count the number of palindromic number...
[ 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 is_palindromic_number(n):\n \"\"\"\n Checks if a number is palindromic.\n \"\"\"\n str_n = str(n)\n return str_n == str_n[::-1]\n\ndef count_pal...
trial_gpt4o_2
{ "original_instruction": "In a distant land called Arrangia, numbers follow a distinctive pattern. The people of Arrangia believe in symmetry and balance, and hence, their favorite numbers are the ones which remain the same when reversed (also known as palindromic numbers). The king of Arrangia, in a bid to promote ...
0.768166
Taco_36286
C
[ "is_palindrome", "count_palindromes", "palindromic_numbers" ]
3
[ [ "count_palindromes", "is_palindrome" ], [ "palindromic_numbers", "count_palindromes" ] ]
2
[]
false
[]
false
pytest
false
[]
true
224f2b3a96b316919d747534180f3fb8a17a1708
a243336f671ec3dbae04c5b918ad88d967c8c5c5
v1.0
complete
Taco
Taco_36918_C
def smallest_prime_factor(n: int) -> int: """ Returns the smallest prime factor of n. >>> smallest_prime_factor(75) 3 >>> smallest_prime_factor(29) 29 >>> smallest_prime_factor(50) 2 """ def nth_multiple_of_smallest_prime_factor(N: int, M: int) -> int: """ Returns the N-th multi...
def smallest_prime_factor(n): """ Returns the smallest prime factor of n. """ if n % 2 == 0: return 2 for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return i return n def nth_multiple_of_smallest_prime_factor(N, M): """ Returns the N-th multiple of t...
from solution import smallest_prime_factor, nth_multiple_of_smallest_prime_factor def test_smallest_prime_factor(): assert smallest_prime_factor(75) == 3 assert smallest_prime_factor(29) == 29 assert smallest_prime_factor(50) == 2 assert smallest_prime_factor(1_000_000) == 2 assert smallest_prime_f...
[ { "docstring": "Returns the smallest prime factor of n.", "function_declaration": "def smallest_prime_factor(n):", "function_name": "smallest_prime_factor", "parameter_list": "(n)" }, { "docstring": "Returns the N-th multiple of the smallest prime factor of M.", "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 smallest_prime_factor(M):\n \"\"\"\n Returns the smallest prime factor of M.\n \"\"\"\n if M % 2 == 0:\n return 2\n for i in range(3, int...
trial_gpt4o_2
{ "original_instruction": "Given two positive integers N and M, you need to find the N-th multiple of the smallest prime factor (excluding 1) of M.\n\nThe smallest prime factor of a number is the smallest number greater than 1 that divides it without leaving a remainder. For example, the smallest prime factor of 10 i...
0.716329
Taco_36918
C
[ "smallest_prime_factor", "nth_multiple_of_smallest_prime_factor" ]
2
[ [ "nth_multiple_of_smallest_prime_factor", "smallest_prime_factor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b2e9a3dae1b88b6d3ce6baf61581ea3dddc08375
150d325098cb4a20fa5093c03b704f3218f01bf3
v1.0
complete
Taco
Taco_36815_C
from typing import List def can_rearrange_palindrome(test_cases: List[str]) -> List[str]: """ Determine if any rearrangement of digits can form a palindrome. >>> can_rearrange_palindrome(["12321", "12345", "54345"]) ["YES", "NO", "YES"] """ def answer_queries(n: int, numbers: List[str]) -> List[str]: ...
def can_rearrange_palindrome(test_cases): results = [] for number in test_cases: digit_count = [0] * 10 for digit in number: digit_count[int(digit)] += 1 odd_count = sum(1 for count in digit_count if count % 2 == 1) if odd_count > 1: ...
from solution import answer_queries def test_single_digit(): assert answer_queries(1, ["5"]) == ["YES"] def test_even_digit_counts(): assert answer_queries(1, ["1221"]) == ["YES"] def test_odd_digit_counts(): assert answer_queries(1, ["12321"]) == ["YES"] def test_no_possible_palindrome(): assert an...
[ { "docstring": null, "function_declaration": "def can_rearrange_palindrome(test_cases):", "function_name": "can_rearrange_palindrome", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def answer_queries(n, numbers):", "function_name": "answer_queries"...
[ 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 can_form_palindrome(n, numbers):\n results = []\n \n # helper function to determine if the number can form a palindrome\n def can_rearrange_to_pali...
trial_gpt4o_2
{ "original_instruction": "Dexter is fascinated by palindromes and has devised a unique game involving them. He provides a number and asks you to determine if any rearrangement of its digits can form a palindrome. If it's possible to form at least one palindrome by rearranging the digits, print \"YES\". Otherwise, pr...
0.687698
Taco_36815
C
[ "can_rearrange_palindrome", "answer_queries" ]
2
[ [ "answer_queries", "can_rearrange_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d0d3979f1c49f7cfae80228ee8a13a08ae605908
a5f4f017e28a7a400f6652e0dbd9b512b90cf4c6
v1.0
complete
Taco
Taco_36771_C
from typing import List def subarray_with_max_distinct(T: int, test_cases: List[List[int]]) -> List[List[int]]: """ Given an array of integers, find the longest subarray with the maximum number of distinct elements. If there are multiple such subarrays with the same length, return the one that appears first. ...
def find_longest_subarray_with_max_distinct_elements(arr): """ Finds the longest subarray with the maximum number of distinct elements. If there are multiple such subarrays with the same length, it returns the one that appears first. """ start = 0 max_len = 0 max_subarray = [] eleme...
from solution import subarray_with_max_distinct def test_single_test_case(): T = 1 test_cases = [ [1, 2, 1, 3, 4, 2, 3] ] expected = [ [1, 2, 1, 3, 4] ] assert subarray_with_max_distinct(T, test_cases) == expected def test_multiple_possible_subarrays(): T = 1 test_cases...
[ { "docstring": "Finds the longest subarray with the maximum number of distinct elements.\nIf there are multiple such subarrays with the same length, \nit returns the one that appears first.", "function_declaration": "def find_longest_subarray_with_max_distinct_elements(arr):", "function_name": "find_lon...
[ 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 longest_subarray_max_distinct(arr):\n \"\"\"\n Finds the longest subarray with the maximum number of distinct elements.\n \"\"\"\n l = 0\n longe...
trial_gpt4o_4
{ "original_instruction": "Given an array of integers, find the longest subarray with the maximum number of distinct elements. The goal is to return the subarray itself and not its length. If there are multiple such subarrays with the same length, return the one that appears first.\n\nINPUT:\nThe first line contains ...
0.69602
Taco_36771
C
[ "find_longest_subarray_with_max_distinct_elements", "solve", "subarray_with_max_distinct" ]
3
[ [ "solve", "find_longest_subarray_with_max_distinct_elements" ], [ "subarray_with_max_distinct", "solve" ] ]
2
[]
false
[]
false
pytest
true
[]
true
73d26c61933c7810c76eb3a3bed458c4860c43de
3fc053304973e7caf44df352665dd5bdeb0b876c
v1.0
complete
Taco
Taco_36170_C
def is_palindrome_brute_force(s: str, L: int, R: int) -> bool: """ Checks if the substring s[L:R+1] is a palindrome using brute force. >>> is_palindrome_brute_force("bananas", 0, 2) == False >>> is_palindrome_brute_force("bananas", 2, 4) == True >>> is_palindrome_brute_force("bananas", 1, 5) == True...
def is_palindrome_brute_force(s, L, R): """ Checks if the substring s[L:R+1] is a palindrome using brute force. """ substring = s[L:R+1] return substring == substring[::-1] def preprocess_dp(s): """ Preprocesses the string to find all palindromic substrings using dynamic programming. Re...
def test_is_palindrome_brute_force(): assert is_palindrome_brute_force("bananas", 0, 2) == False assert is_palindrome_brute_force("bananas", 2, 4) == True assert is_palindrome_brute_force("bananas", 1, 5) == True assert is_palindrome_brute_force("racecar", 0, 6) == True assert is_palindrome_brute_fo...
[ { "docstring": "Checks if the substring s[L:R+1] is a palindrome using brute force.", "function_declaration": "def is_palindrome_brute_force(s, L, R):", "function_name": "is_palindrome_brute_force", "parameter_list": "(s, L, R)" }, { "docstring": "Preprocesses the string to find all palindro...
[ 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 is_palindrome_brute_force(s, l, r):\n \"\"\"\n Function to check if a substring s[l:r+1] is a palindrome using brute force.\n \"\"\"\n substring = ...
trial_gpt4o_2
{ "original_instruction": "## Problem Description\n\nYou will be given a string and a series of queries. Each query will specify the starting and ending positions within the string, and you have to determine if the substring within that range forms a palindrome.\n\n-----Brute-Force:-----\nFor each query, extract the ...
0.738937
Taco_36170
C
[ "is_palindrome_brute_force", "preprocess_dp", "is_palindrome_dp", "solve_palindrome_queries" ]
4
[ [ "solve_palindrome_queries", "is_palindrome_brute_force" ], [ "solve_palindrome_queries", "is_palindrome_dp" ], [ "solve_palindrome_queries", "preprocess_dp" ] ]
3
[]
false
[]
false
pytest
false
[]
true
2e1d52832d8094c9705ec3335ae0575a64c26480
4ddd95c2cdedc2e7efe5be178fc45e20cbf289d6
v1.0
complete
Taco
Taco_36328_C
import math from typing import List, Tuple def gcd(a: int, b: int) -> int: """ Computes the Greatest Common Divisor of a and b using the Euclidean algorithm. """ def lcm(a: int, b: int) -> int: """ Computes the Least Common Multiple of a and b. """ def num_digits(n: int) -> int: """ ...
import math def gcd(a, b): """ Computes the Greatest Common Divisor of a and b using the Euclidean algorithm. """ return math.gcd(a, b) def lcm(a, b): """ Computes the Least Common Multiple of a and b. """ return abs(a * b) // gcd(a, b) def num_digits(n): """ Computes the numb...
import pytest from solution import gcd, lcm, num_digits, absolute_difference_gcd_lcm_digits, process_test_cases def test_gcd(): assert gcd(12, 15) == 3 assert gcd(7, 9) == 1 assert gcd(100000000000, 1000000000000) == 100000000000 def test_lcm(): assert lcm(12, 15) == 60 assert lcm(7, 9) == 63 ...
[ { "docstring": "Computes the Greatest Common Divisor of a and b using the Euclidean algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Computes the Least Common Multiple of a and b.", "function_declaration": "def l...
[ 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 math\n\ndef calculate_digit_diff(T, test_cases):\n results = []\n for i in range(T):\n A, B = test_cases[i]\n gcd_val = math.gcd(A, B)\n...
trial_gpt4o_9
{ "original_instruction": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.\n\nAlice loves playing with numbers. Today, she has decided to play a game with GCD (Greatest Common Divisor) and LCM (Least Common Multiple). Given two positive integers, she will compute both their GCD and LCM. ...
0.653678
Taco_36328
C
[ "gcd", "lcm", "num_digits", "absolute_difference_gcd_lcm_digits", "process_test_cases" ]
5
[ [ "absolute_difference_gcd_lcm_digits", "gcd" ], [ "absolute_difference_gcd_lcm_digits", "lcm" ], [ "absolute_difference_gcd_lcm_digits", "num_digits" ], [ "lcm", "gcd" ], [ "process_test_cases", "absolute_difference_gcd_lcm_digits" ] ]
5
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
80177cbc30f831ca15a1acab48239a09822fa276
951b9afcbfc8a02ffcb84951ad563da0d3643b00
v1.0
complete
Taco
Taco_36608_C
def check_collinearity(N: int, points: List[Tuple[int, int]]) -> str: """ Determines if there exists a straight line in the plane such that all the given points lie on that line. :param N: Number of points :param points: List of tuples representing the coordinates of points :return: "YES" if al...
def are_points_collinear(points): """ Determines if all points lie on a single straight line. :param points: List of tuples representing points (x, y) :return: "YES" if all points are collinear, "NO" otherwise """ if len(points) <= 2: return "YES" def slope(p1, p2): if ...
from solution import check_collinearity def test_single_point(): assert check_collinearity(1, [(0, 0)]) == "YES" def test_two_points(): assert check_collinearity(2, [(0, 0), (1, 1)]) == "YES" def test_three_collinear_points(): assert check_collinearity(3, [(1, 2), (2, 3), (3, 4)]) == "YES" def test_...
[ { "docstring": "Determines if all points lie on a single straight line.\n\n:param points: List of tuples representing points (x, y)\n:return: \"YES\" if all points are collinear, \"NO\" otherwise", "function_declaration": "def are_points_collinear(points):", "function_name": "are_points_collinear", ...
[ 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 are_points_collinear(points):\n \"\"\"\n Returns \"YES\" if all the given points lie on the same straight line, otherwise \"NO\".\n \"\"\"\n def sl...
trial_gpt4o_2
{ "original_instruction": "You are given $N$ points in a 2D plane. You need to determine if there exists a straight line in this plane such that all the given points lie on that line.\n\nInput Format\n\nThe first line contains an integer $N$. \nThe next $N$ lines each contain two integers $x$ and $y$ which specify t...
0.627673
Taco_36608
C
[ "are_points_collinear", "check_collinearity" ]
2
[ [ "check_collinearity", "are_points_collinear" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13b6518b5c1575425d78a007c8a4700ae1e8e243
75846a4599662144006580d7a0258a84ad2bcf2d
v1.0
complete
Taco
Taco_36964_C
def lcm(a, b): """ Compute the least common multiple of two numbers a and b. >>> lcm(4, 5) 20 >>> lcm(7, 3) 21 >>> lcm(10, 6) 30 """ pass def smallest_divisible_number(numbers): """ Return the smallest positive integer that is evenly divisible by all the integers in the list. >>...
from math import gcd from functools import reduce def lcm(a, b): """ Compute the least common multiple of two numbers a and b. """ return a * b // gcd(a, b) def smallest_divisible_number(numbers): """ Return the smallest positive integer that is evenly divisible by all the integers in the list...
from solution import lcm, smallest_divisible_number def test_lcm(): assert lcm(4, 5) == 20 assert lcm(7, 3) == 21 assert lcm(10, 6) == 30 def test_smallest_divisible_number(): assert smallest_divisible_number([4, 5]) == 20 assert smallest_divisible_number([1, 2, 3]) == 6 assert smallest_divisi...
[ { "docstring": "Compute the least common multiple of two numbers a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Return the smallest positive integer that is evenly divisible by all the integers in the list.", "fu...
[ 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": "import math\nfrom functools import reduce\n\ndef lcm(a, b):\n \"\"\"\n Returns the least common multiple of a and b.\n \"\"\"\n return abs(a * b) // ma...
trial_gpt4o_1
{ "original_instruction": "Write a function that finds the smallest number that is divisible by each of a list of given numbers. The function should take a list of integers as input and return the smallest positive integer that is evenly divisible by all the integers in the list.\n\nFor instance, the smallest number ...
0.733643
Taco_36964
C
[ "lcm", "smallest_divisible_number" ]
2
[ [ "smallest_divisible_number", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
80ee91426c0856718cdc55f0f51f670849a4a50c
c6ccde9c3f8b412716f2d002fc1f16e8b80596cc
v1.0
complete
Taco
Taco_36674_C
def perform_gamma_operations(T: int, cases: List[Tuple[int, int, int, str]]) -> List[str]: """ Perform the gamma operations on the given binary numbers according to the constraints. Parameters: T (int): Number of test cases. cases (List[Tuple[int, int, int, str]]): List of tuples, each cont...
def gamma_operation(B): return ''.join('1' if bit == '0' else '0' for bit in B) def perform_gamma_operations(T, cases): result = [] for i in range(T): N, L, M, B = cases[i] B = int(B, 2) # Convert the binary string to decimal number for _ in range(N): gamma_B =...
from solution import perform_gamma_operations def test_case_1(): T = 2 cases = [(1, 10, 5, '0110'), (2, 15, 1, '0011')] result = perform_gamma_operations(T, cases) assert result == ["Case #1: 1001", "Case #2: 0011"] def test_case_2(): T = 1 cases = [(5, 20, 0, '0101')] result = perform_gam...
[ { "docstring": null, "function_declaration": "def gamma_operation(B):", "function_name": "gamma_operation", "parameter_list": "(B)" }, { "docstring": null, "function_declaration": "def perform_gamma_operations(T, cases):", "function_name": "perform_gamma_operations", "parameter_l...
[ 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 gamma_operation(binary_str):\n # Flip the bits: '0' to '1' and '1' to '0'\n return ''.join('1' if bit == '0' else '0' for bit in binary_str)\n\ndef solve...
trial_gpt4o_2
{ "original_instruction": "Cindria is an advanced planet where the inhabitants have evolved a unique way to communicate numbers via a series of lights. Each light can be turned on or off to represent a binary number. However, due to their rapid technological advancement, they've started using a modified version of bi...
0.482867
Taco_36674
C
[ "gamma_operation", "perform_gamma_operations" ]
2
[ [ "perform_gamma_operations", "gamma_operation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
67ba65f7f747950daefd82d24ec747e8a3b6542b
7ef5e9aeade9ad7b5100420083970c63ce58b9fb
v1.0
complete
Taco
Taco_37272_C
def has_prime_pair_sum(t: int) -> str: """ Determines whether there exist two prime numbers p and q such that p + q = t. >>> has_prime_pair_sum(10) "YES" >>> has_prime_pair_sum(11) "NO" >>> has_prime_pair_sum(14) "YES" >>> has_prime_pair_sum(28) "YES" >>> has_prime_pair_...
def sieve_of_eratosthenes(max_num): """ Generates a list of booleans where True denotes that the index is a prime number. """ sieve = [True] * (max_num + 1) sieve[0] = sieve[1] = False # 0 and 1 are not primes p = 2 while p * p <= max_num: if sieve[p]: for i in range(p *...
from solution import has_prime_pair_sum def test_prime_pair_sum_yes(): assert has_prime_pair_sum(10) == "YES" assert has_prime_pair_sum(14) == "YES" assert has_prime_pair_sum(28) == "YES" assert has_prime_pair_sum(100) == "YES" def test_prime_pair_sum_no(): assert has_prime_pair_sum(11) == "NO" ...
[ { "docstring": "Generates a list of booleans where True denotes that the index is a prime number.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Returns 'YES' if there exist two prime...
[ 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 is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ...
trial_gpt4o_1
{ "original_instruction": "Max is learning about prime numbers and he is fascinated by prime pairs. A prime pair is defined as two prime numbers $(p, q)$ where $p < q$. He is particularly interested in finding prime pairs whose sum is a specific number $t$.\n\nA prime number is a natural number greater than $1$ that ...
0.65819
Taco_37272
C
[ "sieve_of_eratosthenes", "has_prime_pair_sum" ]
2
[ [ "has_prime_pair_sum", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a671037b5a32c35d8223f01e7a917339a1686032
b8b2010e15996ebe57ea98104f505159b24aaffc
v1.0
complete
Taco
Taco_37268_C
def smooth_number(n: int, k: int) -> str: """ Determine if the integer n is a Smooth Number for a given threshold k. A Smooth Number is an integer n that has all its prime factors less than or equal to k. Example: >>> smooth_number(42, 7) "YES" >>> smooth_number(44, 7) "NO" """
def is_smooth_number(n, k): def prime_factors(num): i = 2 factors = set() while i * i <= num: if num % i: i += 1 else: num //= i factors.add(i) if num > 1: factors.add(num) return factors ...
from solution import smooth_number def test_smooth_number_sample(): assert smooth_number(42, 7) == "YES" assert smooth_number(44, 7) == "NO" def test_smooth_number_large_k(): assert smooth_number(999999, 100) == "YES" def test_smooth_number_small_prime(): assert smooth_number(2, 2) == "YES" asser...
[ { "docstring": null, "function_declaration": "def is_smooth_number(n, k):", "function_name": "is_smooth_number", "parameter_list": "(n, k)" }, { "docstring": null, "function_declaration": "def smooth_number(n, k):", "function_name": "smooth_number", "parameter_list": "(n, k)" }...
[ 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_smooth_number(n, k):\n \"\"\"\n Determines if the integer n is a Smooth Number for a given threshold k.\n \n Args:\n n (int): The integer to ...
trial_gpt4o_3
{ "original_instruction": "A Smooth Number is an integer n that has all its prime factors less than or equal to a given threshold k. For example, if k = 7, then 42 is a Smooth Number because its prime factors (2, 3, and 7) are all ≤ 7, whereas 44 is not because it has a prime factor 11 which is > 7. \n\nWrite a progr...
0.568926
Taco_37268
C
[ "is_smooth_number", "smooth_number" ]
2
[ [ "smooth_number", "is_smooth_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83ad2ea966d3b5d5333a8c3bfe6ea8dc104993ba
cfc6cf2c526dc1e90762ad4b3c53b20072e65664
v1.0
complete
Taco
Taco_36829_C
def transform_word(word: str, k: int) -> str: """ Rotates each character in the word by k positions forward in the alphabet. >>> transform_word("abcd", 3) == "defg" >>> transform_word("xyz", 2) == "zab" """ pass def process_test_cases(test_cases: List[Tuple[str, int]]) -> List[Tuple[str, str]]:...
def transform_word(word, k): """ Rotates each character in the word by k positions forward in the alphabet. """ transformed = ''.join(chr((ord(char) - ord('a') + k) % 26 + ord('a')) for char in word) return transformed def process_test_cases(test_cases): results = [] for word, k in test_cas...
import pytest from solution import transform_word, process_test_cases, transform_and_evaluate def test_transform_word(): assert transform_word('abcd', 3) == 'defg' assert transform_word('xyz', 2) == 'zab' assert transform_word('a', 1) == 'b' assert transform_word('z', 1) == 'a' def test_process_test_...
[ { "docstring": "Rotates each character in the word by k positions forward in the alphabet.", "function_declaration": "def transform_word(word, k):", "function_name": "transform_word", "parameter_list": "(word, k)" }, { "docstring": null, "function_declaration": "def process_test_cases(te...
[ 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 rotate_character(c, k):\n \"\"\"\n Rotate single character `c` by `k` positions in the alphabet.\n \"\"\"\n return chr(((ord(c) - ord('a') + k) % 2...
trial_gpt4o_1
{ "original_instruction": "**Problem Statement:** \nIn a distant land, there is an ancient custom of arranging words in a special sequence based on a unique transformation. Each letter in the word is rotated \"k\" positions forward in the alphabet, with letters wrapping around as necessary. For example, if the lette...
0.647763
Taco_36829
C
[ "transform_word", "process_test_cases", "transform_and_evaluate" ]
3
[ [ "process_test_cases", "transform_word" ], [ "transform_and_evaluate", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
b958983d155a2888e3f054783d64577f49c74c9b
b157310705fbcb44f605e2d6d06885d506c09f5e
v1.0
complete
Taco
Taco_36760_C
from typing import List def is_prime(n: int) -> bool: """ Checks if n is a prime number. >>> is_prime(2) is True >>> is_prime(3) is True >>> is_prime(4) is False >>> is_prime(5) is True >>> is_prime(1) is False >>> is_prime(11) is True """ def filter_primes(numbers: List[int]) ...
def is_prime(n): """ Checks if n is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(numbers): ...
from solution import filter_primes, is_prime def test_is_prime(): assert is_prime(2) is True assert is_prime(3) is True assert is_prime(4) is False assert is_prime(5) is True assert is_prime(1) is False assert is_prime(0) is False assert is_prime(-1) is False assert is_prime(11) is True...
[ { "docstring": "Checks if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a new list containing only the prime numbers.", "function_declaration": "def filter_pr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list, preserving their original order. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\nIf the input list is e...
0.778112
Taco_36760
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63f4ea3ef1dec2ddd6008c2765f5400654a52d6d
673eb64be749432ab683d2df2a6f58955f371f06
v1.0
complete
Taco
Taco_36865_C
def determine_rating(score: int) -> str: """ Returns the rating based on the performance score. >>> determine_rating(35) 'POOR' >>> determine_rating(89) 'EXCELLENT' >>> determine_rating(42) 'AVERAGE' >>> determine_rating(77) 'GOOD' """ pass def performance_ratings(n: int, sc...
def determine_rating(score): """ Returns the rating based on the performance score. """ if score < 40: return "POOR" elif score < 60: return "AVERAGE" elif score < 80: return "GOOD" else: return "EXCELLENT" def performance_ratings(n, scores): """ Give...
def test_determine_rating(): assert determine_rating(35) == "POOR" assert determine_rating(89) == "EXCELLENT" assert determine_rating(42) == "AVERAGE" assert determine_rating(77) == "GOOD" assert determine_rating(63) == "GOOD" assert determine_rating(40) == "AVERAGE" assert determine_rating(...
[ { "docstring": "Returns the rating based on the performance score.", "function_declaration": "def determine_rating(score):", "function_name": "determine_rating", "parameter_list": "(score)" }, { "docstring": "Given the number of employees and their scores, returns their ratings.", "funct...
[ 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 employee_rating(num_employees, scores):\n \"\"\"\n Returns the rating of employees based on their performance scores.\n \n Parameters:\n num_emp...
trial_gpt4o_2
{ "original_instruction": "In a company, each employee is assigned a performance score from 0 to 100. Based on this score, the employee is rated as follows:\n- POOR: If the score is less than 40.\n- AVERAGE: If the score is greater than or equal to 40 but less than 60.\n- GOOD: If the score is greater than or equal t...
0.69424
Taco_36865
C
[ "determine_rating", "performance_ratings" ]
2
[ [ "performance_ratings", "determine_rating" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7562f236634eea8979346af563415690372387d9
b930fa014fcc8f2bb3ccbd2159eb6fd3d5bc313b
v1.0
complete
Taco
Taco_36994_C
from typing import List def is_prime(n: int) -> bool: """ Check if the given number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def smallest_prime_greater_than(x: int) -> int: """ Find the smallest prime number greater than the given number. >>> smallest_prime_greater_tha...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def smallest_prime_greater_than(x): num = ...
from solution import is_prime, smallest_prime_greater_than, find_smallest_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(25) == False def test_smallest_prime_greater_than(): assert smalle...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def smallest_prime_greater_than(x):", "function_name": "smallest_prime_greater_than", "parameter_list": "(x)" }...
[ 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 sympy import nextprime\n\ndef smallest_prime_greater_than_x(T, cases):\n \"\"\"\n For each number X in cases, find the smallest prime number greater tha...
trial_gpt4o_2
{ "original_instruction": "Robin loves playing around with numbers. One day, he came across an interesting problem involving prime numbers and wanted to solve it. He needs your help to find the smallest prime number that is larger than a given number.\nGiven an integer $X$, your task is to help Robin find the smalles...
0.727385
Taco_36994
C
[ "is_prime", "smallest_prime_greater_than", "find_smallest_primes" ]
3
[ [ "find_smallest_primes", "smallest_prime_greater_than" ], [ "smallest_prime_greater_than", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4dd65a2276acbc1056400977baf938d57f6a40ab
33a3bad2c36488ee4e096888f8b6d519d3ce98c4
v1.0
complete
Taco
Taco_37028_C
def count_unique_permutations(string: str) -> int: """ Calculate the number of unique strings that can be created from the given string by performing character swapping any number of times. >>> count_unique_permutations("abc") 6 >>> count_unique_permutations("aaa") 1 >>> count_unique_permutation...
def count_unique_permutations(string): from math import factorial from collections import Counter # Calculate the frequency of each character freq = Counter(string) # Calculate the total number of permutations as factorial of the length of the string total_permutations = factorial(len(stri...
def test_count_unique_permutations(): assert count_unique_permutations("abc") == 6 assert count_unique_permutations("aaa") == 1 assert count_unique_permutations("aba") == 3 assert count_unique_permutations("aabb") == 6 assert count_unique_permutations("abcd") == 24 assert count_unique_permutatio...
[ { "docstring": null, "function_declaration": "def count_unique_permutations(string):", "function_name": "count_unique_permutations", "parameter_list": "(string)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": ...
[ 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": "from math import factorial\nfrom collections import Counter\n\ndef unique_permutations(s):\n \"\"\"\n Returns the number of unique permutations that can be f...
trial_gpt4o_1
{ "original_instruction": "Jane loves playing with strings. She has a special operation that she can perform on any string called \"character swapping\". The operation involves choosing any two distinct indices in the string and swapping the characters at those indices. Jane wonders how many different strings she can...
0.670324
Taco_37028
C
[ "count_unique_permutations", "solve", "process_input_output" ]
3
[ [ "process_input_output", "solve" ], [ "solve", "count_unique_permutations" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
false
[]
true
d772477884468b38d8c327e8fa582f914ca2c766
f59df857b5e39f98466a9809a80c0b4559309030
v1.0
complete
Taco
Taco_37281_C
def is_bit_palindrome(num: int) -> bool: """ Check if the binary representation of num is a palindrome. >>> is_bit_palindrome(1) True # '1' >>> is_bit_palindrome(2) False # '10' >>> is_bit_palindrome(3) True # '11' >>> is_bit_palindrome(4) False # '100' >>> is_bit_palindrome(5) True # '...
def is_bit_palindrome(num): """ Check if the binary representation of num is a palindrome """ binary_rep = bin(num)[2:] # Convert to binary and remove '0b' prefix return binary_rep == binary_rep[::-1] def count_bit_palindromes(n): """ Count bit palindromes between 1 and n inclusive. ""...
from solution import is_bit_palindrome, count_bit_palindromes def test_is_bit_palindrome(): assert is_bit_palindrome(1) == True # '1' assert is_bit_palindrome(2) == False # '10' assert is_bit_palindrome(3) == True # '11' assert is_bit_palindrome(4) == False # '100' assert is_bit_palindrome(5) =...
[ { "docstring": "Check if the binary representation of num is a palindrome", "function_declaration": "def is_bit_palindrome(num):", "function_name": "is_bit_palindrome", "parameter_list": "(num)" }, { "docstring": "Count bit palindromes between 1 and n inclusive.", "function_declaration":...
[ 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 count_bit_palindromes(n):\n \"\"\"\n Returns the number of bit palindromes between 1 and n inclusive.\n \"\"\"\n def is_bit_palindrome(num):\n ...
trial_gpt4o_9
{ "original_instruction": "In a far away galaxy, there exists a planet called Bitland where people are fascinated by binary numbers. Bitlandians love converting numbers to their binary forms and playing with their bits. One day, a Bitlandian scientist discovered a new interesting property called \"bit palindrome\".\n...
0.709547
Taco_37281
C
[ "is_bit_palindrome", "count_bit_palindromes" ]
2
[ [ "count_bit_palindromes", "is_bit_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
46ec6b290e63826296dac1751e7643fddc48385c
49782b0f5e1a800c2dd7637d02ccdd11e147d165
v1.0
complete
Taco
Taco_36810_C
def find_permutation(n: int, query_function) -> list: """ Finds the permutation by querying up to 2n positions. Arguments: n -- the length of the permutation. query_function -- a function that takes an index i (1 <= i <= n) and returns the value at that position in the permutation. Returns...
def find_permutation(n, query_function): """ Finds the permutation by querying up to 2n positions. Arguments: n -- the length of the permutation. query_function -- a function that takes an index i (1 <= i <= n) and returns the value at that position in the permutation. Returns: A l...
def test_find_permutation(): # Mock query_function to simulate querying the hidden permutation directly. hidden_permutations = { 4: [2, 1, 4, 3], 6: [1, 3, 5, 2, 6, 4], 2: [2, 1] } def query_function_for_test(t, n, hidden_perm): queries = [] def query_functio...
[ { "docstring": "Finds the permutation by querying up to 2n positions.\n\nArguments:\nn -- the length of the permutation.\nquery_function -- a function that takes an index i (1 <= i <= n) and returns the value at that position in the permutation.\n\nReturns:\nA list of integers representing the permutation.", ...
[ 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 discover_permutation(n, query_func):\n permutation = [0] * n\n for i in range(1, n + 1):\n permutation[i - 1] = query_func(i)\n return permutat...
trial_gpt4o_1
{ "original_instruction": "You are tasked with finding a secret permutation of integers from 1 to n, where n is even. The task requires making queries to determine the hidden permutation. You can make up to 2n queries. \n\nAt each query, you can provide an index i (1 ≤ i ≤ n), and you will receive the value at that p...
0.568581
Taco_36810
C
[ "find_permutation", "solve_case" ]
2
[ [ "solve_case", "find_permutation" ] ]
1
[]
false
[]
false
pytest
false
[]
true
f2c4e8ef0307b58c2875982f935576b377b31da9
4d46fe81d75f0f2d45bd6d31886dcccfc249a779
v1.0
complete
Taco
Taco_36894_C
def shift_string(s: str, k: int) -> str: """ Shifts each character in the string `s` by `k` positions in the alphabet. Wraps around to 'a' if the shift goes past 'z'. >>> shift_string("abc", 2) "cde" >>> shift_string("xyz", 3) "abc" """ def encrypt_strings(test_cases: List[Tuple[str, int]])...
def shift_string(s, k): """ Shifts each character in the string `s` by `k` positions in the alphabet. """ result = [] for char in s: if 'a' <= char <= 'z': # Ensuring the character is a lowercase letter shifted = ord(char) + k if shifted > ord('z'): s...
import pytest from solution import shift_string, encrypt_strings, process_input_output def test_shift_string(): assert shift_string("abc", 2) == "cde" assert shift_string("xyz", 3) == "abc" assert shift_string("hello", 5) == "mjqqt" assert shift_string("zebra", 1) == "afcsb" assert shift_string("az...
[ { "docstring": "Shifts each character in the string `s` by `k` positions in the alphabet.", "function_declaration": "def shift_string(s, k):", "function_name": "shift_string", "parameter_list": "(s, k)" }, { "docstring": "Encrypts each string in `test_cases` by shifting characters according ...
[ 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 encrypt_string(s, k):\n \"\"\"\n Encrypts the string s by shifting each character by k positions in the alphabet.\n \n Parameters:\n s (str): Th...
trial_gpt4o_1
{ "original_instruction": "A company wants to secure its information by encrypting data using a special technique. They need a program that takes a string and shifts each character by a fixed number of positions in the alphabet. If the shift goes past 'z', it wraps around to 'a'.\n\n-----Input:-----\n- First-line wil...
0.768077
Taco_36894
C
[ "shift_string", "encrypt_strings", "process_input_output" ]
3
[ [ "encrypt_strings", "shift_string" ], [ "process_input_output", "encrypt_strings" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
7cfcb29e939fbf0956829a72a46c7c52f619daaf
c73035ee887ed4bc367eb049929cd6ff86657ed7
v1.0
complete
Taco
Taco_37011_C
from typing import List, Union def sum_of_digits(n: int) -> int: """Calculate the sum of the digits of an integer n""" return sum(int(digit) for digit in str(n)) def is_harshad(number: int) -> bool: """Check if a number is a Harshad number""" return number % sum_of_digits(number) == 0 def find_harsha...
def sum_of_digits(n): return sum(int(digit) for digit in str(n)) def is_harshad(number): return number % sum_of_digits(number) == 0 def find_harshad_numbers(a, b): harshad_numbers = [] for num in range(a, b + 1): if is_harshad(num): harshad_numbers.append(num) if harshad_number...
from solution import find_harshad_numbers def test_example_case(): assert find_harshad_numbers(10, 20) == [10, 12, 18, 20] def test_no_harshad_number(): assert find_harshad_numbers(11, 11) == ["NO"] def test_single_harshad_number(): assert find_harshad_numbers(18, 18) == [18] def test_all_single_digit_n...
[ { "docstring": null, "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_harshad(number):", "function_name": "is_harshad", "parameter_list": "(number)" }, { "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 get_digit_sum(n):\n \"\"\"\n Helper function to calculate the sum of digits of a number.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\nd...
trial_gpt4o_1
{ "original_instruction": "Chef has recently started learning about number theory and came across the concept of Harshad numbers (or Niven numbers). A Harshad number is an integer that is divisible by the sum of its digits. Chef gets curious and decides to find all Harshad numbers within a given range [A, B] inclusiv...
0.691689
Taco_37011
C
[ "sum_of_digits", "is_harshad", "find_harshad_numbers", "main" ]
4
[ [ "find_harshad_numbers", "is_harshad" ], [ "is_harshad", "sum_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
50e94f309c7e0ac368e899d4b373a50c9cd1aaec
40d272d1504dc446ad0c8478c543f12e850420a2
v1.0
complete
Taco
Taco_36844_C
def add_song(playlist, x, pos): """ Adds song ID x to the playlist at position pos. """ # Implement the function here def remove_song(playlist, x): """ Removes a song with ID x from the playlist. """ # Implement the function here def find_median(playlist): """ Finds the median ...
from bisect import insort def add_song(playlist, x, pos): """ Adds song ID x to the playlist at position pos. """ playlist.insert(pos, x) def remove_song(playlist, x): """ Removes a song with ID x from the playlist. """ playlist.remove(x) def find_median(playlist): """ Finds t...
def test_add_song(): playlist = [1, 3, 5] add_song(playlist, 4, 2) assert playlist == [1, 3, 4, 5] def test_remove_song(): playlist = [2, 6, 7, 9] remove_song(playlist, 7) assert playlist == [2, 6, 9] def test_find_median_odd(): playlist = [1, 3, 4, 7, 9] assert find_median(playlist) =...
[ { "docstring": "Adds song ID x to the playlist at position pos.", "function_declaration": "def add_song(playlist, x, pos):", "function_name": "add_song", "parameter_list": "(playlist, x, pos)" }, { "docstring": "Removes a song with ID x from the playlist.", "function_declaration": "def r...
[ 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 add_song(playlist, song_id, position):\n \"\"\"\n Add song_id to the playlist at the specified position.\n \"\"\"\n playlist.insert(position, song_...
trial_gpt4o_2
{ "original_instruction": "You have been hired to design a playlist system for a music streaming application. You need to handle user requests to perform operations on their playlists. Each playlist contains a list of songs identified by their unique IDs.\n\nYour task is to implement the following operations:\n\n1. A...
0.547041
Taco_36844
C
[ "add_song", "remove_song", "find_median", "process_queries" ]
4
[ [ "process_queries", "add_song" ], [ "process_queries", "find_median" ], [ "process_queries", "remove_song" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
f1482e4c3fd14cf3efab3aec56a09c3156cff71d
a16dc42975af446f7ce44b78d676e1bf2e5ea18e
v1.0
complete
Taco
Taco_37211_C
def min_efficiency_sum(M: int, T: int, X: int, efficiencies: List[List[int]]) -> int: """ Select exactly one employee from each team such that the sum of the selected employees' efficiency scores is minimized but not less than a given threshold X. M: Number of employees in each team T: Number of teams...
from itertools import product def min_efficiency_sum(M, T, X, efficiencies): # Generate all possible combinations of choosing one employee from each team combinations = list(product(*efficiencies)) min_sum = float('inf') for combination in combinations: combination_sum = sum(combination) ...
from solution import min_efficiency_sum def test_example(): M, T, X = 3, 2, 5 efficiencies = [ [3, 2, 4], [1, 5, 2] ] assert min_efficiency_sum(M, T, X, efficiencies) == 5 def test_not_possible(): M, T, X = 3, 2, 10 efficiencies = [ [3, 2, 4], [1, 5, 2] ] ...
[ { "docstring": null, "function_declaration": "def min_efficiency_sum(M, T, X, efficiencies):", "function_name": "min_efficiency_sum", "parameter_list": "(M, T, X, efficiencies)" }, { "docstring": null, "function_declaration": "def read_input_and_solve():", "function_name": "read_inpu...
[ 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": "from itertools import product\n\ndef min_efficiency_sum(M, T, X, efficiencies):\n # Generate all possible combinations of selecting one employee from each team\...
trial_gpt4o_1
{ "original_instruction": "There are $M$ employees in a company, each assigned to one of $T$ different teams. For each team $j$ ($1 \\le j \\le T$), each employee $i$ in team $j$ has an efficiency score $e_{i,j}$, which is a positive integer. The management wants to select exactly one employee from each team such tha...
0.64198
Taco_37211
C
[ "min_efficiency_sum", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "min_efficiency_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9e0683be87092061998aa3fc5768c3c4a70575d3
1eb0af73651cc9f013d2a8877cac27d45bd8caea
v1.0
complete
Taco
Taco_36950_C
import math from typing import List, Tuple def nearest_tree_distance(trees: List[Tuple[int, int]], queries: List[Tuple[int, int]]) -> List[float]: """ Given the positions of N trees and Q queries with house coordinates, calculates the minimum Euclidean distance from each house to the nearest tree. :pa...
import math def nearest_tree_distance(trees, queries): results = [] for (A, B) in queries: min_dist = float('inf') for (X, Y) in trees: dist = math.sqrt((X - A) ** 2 + (Y - B) ** 2) if dist < min_dist: min_dist = dist results.append(min_dist)...
import math from solution import nearest_tree_distance, format_distances def test_nearest_tree_distance_1(): trees = [(1, 2), (4, 6), (7, 8)] queries = [(2, 3), (5, 5)] results = nearest_tree_distance(trees, queries) expected = [math.sqrt(2), math.sqrt(2)] assert results == expected def test_neare...
[ { "docstring": null, "function_declaration": "def nearest_tree_distance(trees, queries):", "function_name": "nearest_tree_distance", "parameter_list": "(trees, queries)" }, { "docstring": null, "function_declaration": "def format_distances(distances):", "function_name": "format_dista...
[ 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": "import math\nimport sys\n\ndef minimum_distance_to_trees(trees, queries):\n results = []\n for (a, b) in queries:\n min_distance = float('inf')\n ...
trial_gpt4o_4
{ "original_instruction": "In a forest, there are N trees positioned on an infinite grid. Each tree's location is represented as (X_i, Y_i). You are given Q queries. Each query consists of two integers (A, B) which represent the position of a house in the forest.\n\nFor each query, find the Euclidean distance to the ...
0.653403
Taco_36950
C
[ "nearest_tree_distance", "format_distances", "process_input" ]
3
[ [ "process_input", "format_distances" ], [ "process_input", "nearest_tree_distance" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
3d16c8a4f5d38fa456c66e5b11c08f12ca893200
d8d8beb7dd1b8ca1e313862be1a4bfe22ee469c6
v1.0
complete
Taco
Taco_37345_C
def get_factors(n): """ Returns a list of all factors of the given integer n. >>> get_factors(1) == {1} >>> get_factors(12) == {1, 2, 3, 4, 6, 12} >>> get_factors(18) == {1, 2, 3, 6, 9, 18} """ pass def max_rooms_dimensions(H, W): """ Returns the dimensions of the apartment block th...
def get_factors(n): """ Returns a list of all factors of the given integer n. """ factors = set() for i in range(1, int(n**0.5) + 1): if n % i == 0: factors.add(i) factors.add(n // i) return factors def max_rooms_dimensions(H, W): """ Returns the dimensio...
from solution import get_factors, max_rooms_dimensions def test_get_factors(): assert get_factors(1) == {1} assert get_factors(12) == {1, 2, 3, 4, 6, 12} assert get_factors(18) == {1, 2, 3, 6, 9, 18} def test_max_rooms_dimensions(): assert max_rooms_dimensions(12, 18) == (12, 18) assert max_rooms_...
[ { "docstring": "Returns a list of all factors of the given integer n.", "function_declaration": "def get_factors(n):", "function_name": "get_factors", "parameter_list": "(n)" }, { "docstring": "Returns the dimensions of the apartment block that maximize the number of rooms.", "function_d...
[ 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": "import math\n\ndef max_apartment_block(H, W):\n \"\"\"\n Returns the dimensions of the apartment block that maximize the number of rooms\n by finding the ...
trial_gpt4o_2
{ "original_instruction": "In a certain city, there is a unique way to build apartment blocks. Each apartment block is planned as a rectangular grid of rooms. The height (number of floors) and width (number of rooms per floor) have their own constraints. The height of the apartment block must be a divisible factor of...
0.597305
Taco_37345
C
[ "get_factors", "max_rooms_dimensions" ]
2
[ [ "max_rooms_dimensions", "get_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
055012c0777de768b282f2ef8009abfae2a4c1c6
a37bf5ee52b2c788afbf27aa01e74fbbfe4ce963