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_29764_C
def is_palindrome(s: str) -> bool: """ Determines if the given string is a palindrome ignoring spaces, punctuation, and capitalization. >>> is_palindrome("A man a plan a canal Panama") True >>> is_palindrome("racecar") True >>> is_palindrome("Hello World") False """ def check_palindrom...
def is_palindrome(s): """ Determines if the given string is a palindrome ignoring spaces, punctuation, and capitalization. """ import re cleaned = re.sub(r'[^A-Za-z0-9]', '', s).lower() return cleaned == cleaned[::-1] def check_palindromes(n, strings): results = [] for s in strings: ...
from solution import is_palindrome, check_palindromes def test_is_palindrome(): assert is_palindrome("A man a plan a canal Panama") == True assert is_palindrome("racecar") == True assert is_palindrome("Hello World") == False assert is_palindrome("No 'x' in Nixon") == True assert is_palindrome("Was ...
[ { "docstring": "Determines if the given string is a palindrome ignoring spaces, punctuation, and capitalization.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def check_palindr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Determines if the given string is a palindrome.\n \n Parameters:\n s (str): The input string to check\n \n Re...
trial_gpt4o_2
{ "original_instruction": "Write a program that determines if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). Print \"YES\" if the string is a palindrome, \"NO\" if not....
0.86334
Taco_29764
C
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3d3a61257d4d550109086b574fad554d414f197f
9e8d037840f817d3c998a70754c8b6ca160bdd50
v1.0
complete
Taco
Taco_29729_C
from typing import List def count_treasure_chests(p: int, participants: List[int], c: int, chests: List[int]) -> List[int]: """ Determine how many treasure chests each participant can potentially open based on the sum of any combination of digits in their assigned number. Args: p (int): Number of...
def get_combinations(digits): from itertools import combinations unique_sums = set() for i in range(1, len(digits) + 1): for combo in combinations(digits, i): unique_sums.add(sum(combo)) return unique_sums def count_treasure_chests(p, participants, c, chests): ...
from solution import count_treasure_chests def test_count_treasure_chests_sample(): P = 2 participants = [123, 456] C = 3 chests = [6, 15, 24] assert count_treasure_chests(P, participants, C, chests) == [1, 2] def test_count_treasure_chests_no_chests(): P = 1 participants = [123] C = 0...
[ { "docstring": null, "function_declaration": "def get_combinations(digits):", "function_name": "get_combinations", "parameter_list": "(digits)" }, { "docstring": null, "function_declaration": "def count_treasure_chests(p, participants, c, chests):", "function_name": "count_treasure_c...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_treasure_to_open(participant_numbers, lock_numbers):\n def get_digit_combinations_sums(number):\n from itertools import combinations\n ...
trial_gpt4o_9
{ "original_instruction": "Harry is hosting a Halloween party and is organizing a treasure hunt for his friends. He has hidden multiple treasure chests around his house and each chest has a lock that can only be opened with a unique key. To add a twist to the game, each participant has a unique number and they can on...
0.54762
Taco_29729
C
[ "get_combinations", "count_treasure_chests" ]
2
[ [ "count_treasure_chests", "get_combinations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9dbc71957f2d5bb24603816c12ab18ada5ee598c
51e82d8686c2091047beae829c5e80f8cae75cf5
v1.0
complete
Taco
Taco_29375_C
def preprocess_items(items): """ Preprocess the items to create prefix sums. >>> preprocess_items([2, 3, 7, 1, 6]) [0, 2, 5, 12, 13, 19] """ pass def query_sum(prefix_sums, i, j): """ Query the sum of items from shelf i to shelf j (inclusive). >>> query_sum([0, 2, 5, 12, 13, 19], 0,...
def preprocess_items(items): """ Preprocess the items to create prefix sums. """ prefix_sums = [0] * (len(items) + 1) for i in range(len(items)): prefix_sums[i + 1] = prefix_sums[i] + items[i] return prefix_sums def query_sum(prefix_sums, i, j): """ Query the sum of items from s...
import pytest from solution import preprocess_items, query_sum, handle_queries def test_preprocess_items(): items = [2, 3, 7, 1, 6] expected_prefix_sums = [0, 2, 5, 12, 13, 19] assert preprocess_items(items) == expected_prefix_sums def test_query_sum(): prefix_sums = [0, 2, 5, 12, 13, 19] assert q...
[ { "docstring": "Preprocess the items to create prefix sums.", "function_declaration": "def preprocess_items(items):", "function_name": "preprocess_items", "parameter_list": "(items)" }, { "docstring": "Query the sum of items from shelf i to shelf j (inclusive).", "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 preprocess_items(n, items):\n \"\"\"\n Preprocess the item counts on shelves to prepare for efficient range sum queries.\n Args:\n - n (int): The n...
trial_gpt4o_2
{ "original_instruction": "You have been hired to develop an inventory management system for a warehouse. The warehouse has a series of shelves arranged in a linear fashion, each shelf containing a certain number of items. The shelves are numbered from 0 to N-1.\n\nThe warehouse managers have a specific way they want...
0.554896
Taco_29375
C
[ "preprocess_items", "query_sum", "handle_queries" ]
3
[ [ "handle_queries", "preprocess_items" ], [ "handle_queries", "query_sum" ] ]
2
[ "handle_queries" ]
false
[]
false
pytest
true
[]
true
b56a8c6e487489be21fe0eccb723c30bc5067022
b4693803624c6d09e2954d363b3f53f85953a25f
v1.0
complete
Taco
Taco_29611_C
def can_reach_endless_obstacle(grid, N, M, K): """ Determines if it is possible for Lily to reach the bottom-right corner of the grid with the ability to destroy up to K obstacles. Parameters: grid (List[List[int]]): The grid layout with cells containing either 0 (empty) or 1 (obstacle). N (int): The n...
from collections import deque def can_reach_endless_obstacle(grid, N, M, K): # Directions for right and down moves directions = [(0, 1), (1, 0)] # Queue elements: (row, col, obstacles destroyed) queue = deque([(0, 0, 0)]) visited = set((0, 0, 0)) # Store tuples of (x, y, obstacles destroyed) ...
from solution import parse_input_and_solve def test_sample_input(): input_data = '''3 3 3 1 0 1 0 1 0 1 0 0 0 4 4 2 0 1 1 0 0 1 1 0 1 0 0 1 0 0 1 0 2 2 0 1 0 0 1''' expected_output = '''YES YES NO''' assert parse_input_and_solve(input_data) == expected_output def test_single_path_no_obstacles(): input...
[ { "docstring": null, "function_declaration": "def can_reach_endless_obstacle(grid, N, M, K):", "function_name": "can_reach_endless_obstacle", "parameter_list": "(grid, N, M, K)" }, { "docstring": null, "function_declaration": "def solve_obstacle_cases(test_cases):", "function_name": ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef can_reach_destination(grid, N, M, K):\n directions = [(1, 0), (0, 1)] # down, right\n queue = deque([(0, 0, K)]) # (ro...
trial_gpt4o_2
{ "original_instruction": "In a futuristic world, Lily finds herself in a city with a grid layout of size N×M, where each cell in the grid contains either 0 (representing an empty space) or 1 (representing an obstacle). Lily needs to navigate from the top-left corner (cell (1, 1)) to the bottom-right corner (cell (N,...
0.665875
Taco_29611
C
[ "can_reach_endless_obstacle", "solve_obstacle_cases", "parse_input_and_solve" ]
3
[ [ "parse_input_and_solve", "solve_obstacle_cases" ], [ "solve_obstacle_cases", "can_reach_endless_obstacle" ] ]
2
[ "parse_input_and_solve" ]
false
[]
false
pytest
true
[]
true
039a8d57a9e7e7face5a9fd5676f1e81369e5b44
35510b98dc3beeecc931284beee6bf09281509d2
v1.0
complete
Taco
Taco_29662_C
def find_connected_components(N, edges): """ Finds the connected components of an undirected graph. Args: N (int): number of nodes in the graph. edges (List[Tuple[int, int]]): list of edges in the graph. Returns: List[List[int]]: a list of connected components, where each component is represent...
def find_connected_components(N, edges): from collections import defaultdict, deque graph = defaultdict(list) for u, v in edges: graph[u-1].append(v-1) graph[v-1].append(u-1) visited = [False] * N components = [] def bfs(start): component = [] queue = deque([st...
def test_find_connected_components(): N = 5 edges = [(1, 2), (1, 3), (3, 4), (4, 5)] expected = [[0, 1, 2, 3, 4]] assert find_connected_components(N, edges) == expected def test_max_weight_in_components(): weights = [1, 2, 3, 4, 5] components = [[0, 1, 2, 3, 4]] expected = {0: 5, 1: 5, 2: 5...
[ { "docstring": null, "function_declaration": "def find_connected_components(N, edges):", "function_name": "find_connected_components", "parameter_list": "(N, edges)" }, { "docstring": null, "function_declaration": "def max_weight_in_components(weights, components):", "function_name":...
[ 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_max_weight_in_connected_component(n, m, weights, edges, queries):\n from collections import defaultdict, deque\n \n # Step 1: Build adjacency lis...
trial_gpt4o_1
{ "original_instruction": "You are given an undirected graph with $N$ nodes and $M$ edges. Each node has a weight assigned to it. For each query, you need to find the maximum weighted node in the connected component of a given node.\n\n-----Input-----\n- The first line of the input contains two space-separated intege...
0.676027
Taco_29662
C
[ "find_connected_components", "max_weight_in_components", "process_queries", "solve_graph_problem" ]
4
[ [ "process_queries", "max_weight_in_components" ], [ "solve_graph_problem", "find_connected_components" ], [ "solve_graph_problem", "process_queries" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
acaf844c8ef6a7de4b9f8b2f7f3b77b268d0c2c2
7f5ce6eb833e66203d5118c9d6f6edb9575c6df8
v1.0
complete
Taco
Taco_29930_C
def persistence(arr: List[int]) -> List[int]: """ Your task is to write a function that takes an integer array and returns the "persistence" of that number. The persistence of a number is the number of times you must multiply the digits in the number until you reach a single digit. If the array is empty, return...
from typing import List def digit_product(n: int) -> int: result = 1 while n > 0: result *= n % 10 n //= 10 return result def persistence(arr: List[int]) -> List[int]: if not arr: return [] def calculate_persistence(n: int) -> int: count = 0 while n >= ...
from solution import persistence def test_persistence_single_digits(): assert persistence([4, 5, 6]) == [0, 0, 0] def test_persistence_multiple_digits(): assert persistence([39, 999, 25]) == [3, 4, 2] def test_persistence_mixed_numbers(): assert persistence([39, 999, 4, 0]) == [3, 4, 0, 0] def test_pers...
[ { "docstring": null, "function_declaration": "def digit_product(n):", "function_name": "digit_product", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def persistence(arr):", "function_name": "persistence", "parameter_list": "(arr)" }, { "docstri...
[ 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 typing import List\n\ndef digit_product(n: int) -> int:\n result = 1\n while n > 0:\n result *= n % 10\n n //= 10\n return result\n\nde...
trial_gpt4o_0
{ "original_instruction": "Your task is to write a function that takes an integer array and returns the \"persistence\" of that number. The persistence of a number is the number of times you must multiply the digits in the number until you reach a single digit.\n\nFor example, the persistence of 39 is three because 3...
0.531253
Taco_29930
C
[ "digit_product", "persistence" ]
2
[ [ "persistence", "digit_product" ] ]
1
[]
false
[]
false
pytest
true
[]
true
85c49ffe7619cc07b45dcfbc47af1d66f5af8b5f
2d439cb6e86eac8451132b120856a703fda98510
v1.0
complete
Taco
Taco_29922_C
def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False """ pass def longest_increasing_prime_subsequence(arr: List[int]) -> int: """ Find the length of the longest strictly increasing subsequence of prime numbers. >>> longes...
from bisect import bisect_left def is_prime(n): """Check if a number is a prime number.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False limit = int(n**0.5) + 1 for i in range(3, limit, 2): if n % i == 0: return False ...
from solution import is_prime, longest_increasing_prime_subsequence, process_test_cases def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find the length of the longest strictly increasing subsequence of prime numbers.", "function_declaration": "def longe...
[ 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 bisect\n\ndef is_prime(n):\n \"\"\"\n Check if a number is a prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of N integers. Your task is to find the length of the longest subsequence which is strictly increasing and consists of prime numbers only.\n\nNote: A subsequence is derived from the list by deleting some or no elements without changing the order of the remaining element...
0.670377
Taco_29922
C
[ "is_prime", "longest_increasing_prime_subsequence", "process_test_cases", "example_usage" ]
4
[ [ "example_usage", "process_test_cases" ], [ "longest_increasing_prime_subsequence", "is_prime" ], [ "process_test_cases", "longest_increasing_prime_subsequence" ] ]
3
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
fab2965afb6ecfe10257c189fe20766747c16a51
f3778accc0995391ec6914ba1c858cf6147df5f2
v1.0
complete
Taco
Taco_29319_C
from typing import List, Tuple from collections import defaultdict from bisect import bisect_left, bisect_right def preprocess_transactions(transactions: List[Tuple[int, int]]) -> dict: """ Process the list of transactions and return a dictionary where keys are user_ids and values are lists of transaction_ids. ...
from collections import defaultdict from bisect import bisect_left, bisect_right def preprocess_transactions(transactions): user_transactions = defaultdict(list) for user_id, trans_id in transactions: user_transactions[user_id].append(trans_id) for user_id in user_transactions: user_tr...
def test_preprocess_transactions(): transactions = [(1, 5), (2, 15), (1, 25), (2, 35), (3, 50)] expected = { 1: [5, 25], 2: [15, 35], 3: [50] } assert preprocess_transactions(transactions) == expected def test_count_transactions_in_range(): user_transactions = { 1: [...
[ { "docstring": null, "function_declaration": "def preprocess_transactions(transactions):", "function_name": "preprocess_transactions", "parameter_list": "(transactions)" }, { "docstring": null, "function_declaration": "def count_transactions_in_range(user_transactions, l, r):", "func...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef transactions_in_range(num_transactions, num_queries, max_id, transactions, queries):\n \"\"\"\n Returns the number...
trial_gpt4o_2
{ "original_instruction": "A large online retailer uses a high-traffic database to maintain records of user transactions. To support reporting and data analysis, they need to frequently count the number of transactions each user has made within a given range of transaction IDs.\n\nYou are provided with a list of tran...
0.561954
Taco_29319
C
[ "preprocess_transactions", "count_transactions_in_range", "process_queries" ]
3
[ [ "process_queries", "count_transactions_in_range" ], [ "process_queries", "preprocess_transactions" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
3f9d1748a3e1da41cd26293a3b0e95b9aa8ef36c
13ec4eb201270f6ac4e036486f0d900ddf65a3e7
v1.0
complete
Taco
Taco_29651_C
from typing import List def is_prime(n: int) -> bool: """ Return True if n is a prime number else False """ pass def closest_fibonacci(n: int) -> int: """ Return the closest Fibonacci number to n """ pass def replace_primes_with_fibonacci(n: int, values: List[int]) -> List[int]: """ Replace prime...
def is_prime(n): """Return True if n is a prime number else False""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def closest_fibonacci(n): ...
from solution import is_prime, closest_fibonacci, replace_primes_with_fibonacci def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(10) == False assert is_prime(17) == True def test_closest_fibonacci(): assert closest_fibonacci...
[ { "docstring": "Return True if n is a prime number else False", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return the closest Fibonacci number to n", "function_declaration": "def closest_fibonacci(n):", "functio...
[ 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\n\ndef is_prime(number):\n if number <= 1:\n return False\n if number <= 3:\n return True\n if number % 2 == 0 or number % 3 == ...
trial_gpt4o_4
{ "original_instruction": "You are given a list of `N` integers. Your task is to return a list of the same integers but with each prime number replaced by the closest Fibonacci number. If there are two Fibonacci numbers equally close to a prime number, replace it with the smaller one. \n\nFor the purpose of this ques...
0.82927
Taco_29651
C
[ "is_prime", "closest_fibonacci", "replace_primes_with_fibonacci" ]
3
[ [ "replace_primes_with_fibonacci", "closest_fibonacci" ], [ "replace_primes_with_fibonacci", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6126aba12a7aa85c9009e39fb2358367a5c264ff
e5a50727b9691c0ae9f9a2a4d91870c54375def4
v1.0
complete
Taco
Taco_29544_C
def is_prime(n: int) -> bool: """ Checks if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False """ def filter_primes(arr: List[int]) -> List[int]: """ Takes an array of integers and returns an array co...
def is_prime(n): """ Checks if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import filter_primes def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 10, 12]) == [] def test_filter_primes_with_primes(): assert filter_primes([3, 4, 7, 10, 11, 13]) == [3, 7, 11, 13] def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11, 13, 17, 19]) ...
[ { "docstring": "Checks if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes an array of integers and returns an array containing only the prime numbers\nfrom the input array in the order the...
[ 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 determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ret...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes an array of integers and returns an array containing only the prime numbers from the input array in the order they appeared.\n\nExample: `input: [3, 4, 7, 10, 11, 13]` => `output: [3, 7, 11, 13]`\n\nNote: An empty array should return an empty array.", "prompt_i...
0.752105
Taco_29544
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4a1d4cb2b0f58e2b31d59035243cf85bfabcfb50
c2bd8ef252326097fcdb656b978206ec79532926
v1.0
complete
Taco
Taco_29881_C
def check_collinear(p1, p2, p3): """ Check if three points are collinear. """ x1, y1 = p1 x2, y2 = p2 x3, y3 = p3 return (y2 - y1) * (x3 - x2) == (y3 - y2) * (x2 - x1) def find_circle(points): n = len(points) for i in range(n): for j in range(i+1, n): for k in ra...
from math import isclose def check_collinear(p1, p2, p3): """ Check if three points are collinear. """ x1, y1 = p1 x2, y2 = p2 x3, y3 = p3 return (y2 - y1) * (x3 - x2) == (y3 - y2) * (x2 - x1) def find_circle(points): n = len(points) for i in range(n): for j in range(i+1, n...
from solution import circle_from_points def test_circle_from_points_sample1(): assert circle_from_points(4, ["0 0", "1 0", "0 1", "1 1"]) == "yes" def test_circle_from_points_sample2(): assert circle_from_points(3, ["0 0", "1 2", "3 6"]) == "no" def test_circle_from_points_exactly_three_points_non_collinear(...
[ { "docstring": "Check if three points are collinear.", "function_declaration": "def check_collinear(p1, p2, p3):", "function_name": "check_collinear", "parameter_list": "(p1, p2, p3)" }, { "docstring": null, "function_declaration": "def find_circle(points):", "function_name": "find_c...
[ 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 itertools import combinations\nfrom math import isclose\n\ndef calculate_circle_center(x1, y1, x2, y2, x3, y3):\n \"\"\"\n Calculate the center of the c...
trial_gpt4o_2
{ "original_instruction": "You are given a list of points in a 2D plane, each represented by their x and y coordinates. Your task is to determine if there exists a circle that contains at least three of these points on its circumference.\n\nNote:\n1. The circle is said to contain a point if the point lies exactly on ...
0.630861
Taco_29881
C
[ "check_collinear", "find_circle", "circle_from_points" ]
3
[ [ "circle_from_points", "find_circle" ], [ "find_circle", "check_collinear" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5bd7f7d3201fb440f030556e7e08cf219da4b95b
3664b76d6afae807b6d9cda9583b138472752fff
v1.0
complete
Taco
Taco_29998_C
def longest_increasing_subsequence_with_limit(n: int, k: int, sequence: List[int]) -> int: """ Given a sequence of n integers and a limit k, find the length of the longest increasing subsequence where the difference between consecutive elements in the subsequence is at most k. >>> longest_increasing_subsequ...
def longest_increasing_subsequence_with_limit(n, k, sequence): # Initialize DP array where dp[i] represents the length of the LIS ending at index i dp = [1] * n # Populate the DP array for i in range(1, n): for j in range(i): if sequence[i] > sequence[j] and sequence[i] - sequen...
from solution import lis_within_limit def test_case_1(): input_str = "5 3\n1 3 5 10 12" assert lis_within_limit(input_str) == 3 def test_case_2(): input_str = "6 2\n1 2 3 4 5 6" assert lis_within_limit(input_str) == 6 def test_case_3(): input_str = "6 1\n10 20 30 40 50 60" assert lis_within_l...
[ { "docstring": null, "function_declaration": "def longest_increasing_subsequence_with_limit(n, k, sequence):", "function_name": "longest_increasing_subsequence_with_limit", "parameter_list": "(n, k, sequence)" }, { "docstring": null, "function_declaration": "def lis_within_limit(input_st...
[ 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 longest_increasing_subsequence_with_diff_k(n, k, a):\n dp = [1] * n # dp[i] will store the length of the LIS ending at i with the given condition\n\n fo...
trial_gpt4o_1
{ "original_instruction": "Given a sequence of n integers a1, a2, ..., an, find the length of the longest increasing subsequence (LIS) where the difference between consecutive elements in the subsequence is at most k.\n\nConstraints\n\n* 1 ≤ n ≤ 1000\n* 1 ≤ ai ≤ 10^9 (1 ≤ i ≤ n)\n* 1 ≤ k ≤ 10^9\n\nInput\n\nThe input ...
0.736977
Taco_29998
C
[ "longest_increasing_subsequence_with_limit", "lis_within_limit" ]
2
[ [ "lis_within_limit", "longest_increasing_subsequence_with_limit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0933f114b3041acf1dd15eef96e05d0766e56268
dbc5cd391eaf5e48350fa6df19bf238765ea2c61
v1.0
complete
Taco
Taco_29750_C
def min_removals_to_decreasing_wall(n, heights): """ This function finds the minimum number of bricks to be removed to ensure the wall is consistently decreasing in height from left to right. Parameters: n (int): The number of sections in the wall. heights (List[int]): A list of heights ...
def min_removals_to_decreasing_wall(n, heights): """ This function finds the minimum number of bricks to be removed to ensure the wall is consistently decreasing in height from left to right. Parameters: n (int): The number of sections in the wall. heights (List[int]): A list of heights o...
def test_min_removals_to_decreasing_wall(): assert min_removals_to_decreasing_wall(6, [5, 3, 8, 6, 2, 9]) == 3 assert min_removals_to_decreasing_wall(5, [3, 1, 4, 2, 5]) == 3 assert min_removals_to_decreasing_wall(7, [9, 8, 7, 6, 5, 4, 3]) == 0 assert min_removals_to_decreasing_wall(4, [1, 2, 3, 4]) == ...
[ { "docstring": "This function finds the minimum number of bricks to be removed \nto ensure the wall is consistently decreasing in height from \nleft to right.\n\nParameters:\nn (int): The number of sections in the wall.\nheights (List[int]): A list of heights of sections of the wall.\n\nReturns:\nint: The minim...
[ 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 min_bricks_to_remove(heights):\n \"\"\"\n Returns the minimum number of bricks that need to be removed so that the remaining wall is consistently\n de...
trial_gpt4o_1
{ "original_instruction": "Given an array of integers representing heights of adjacent sections of a wall, design an algorithm to find the minimum number of bricks that need to be removed so that the remaining wall is consistently decreasing in height from left to right.\n\nThe wall is represented by an array where e...
0.657322
Taco_29750
C
[ "min_removals_to_decreasing_wall", "lower_bound" ]
2
[ [ "min_removals_to_decreasing_wall", "lower_bound" ] ]
1
[]
false
[]
false
pytest
false
[]
true
f181bce839d3272b2831e8651ba6fe34f6b6c4b3
9299dda8de978e2b1a020e226b2b8d2b70f895eb
v1.0
complete
Taco
Taco_29826_C
def maxCoins_from_input(n: int, nums: List[int]) -> int: """ Maximize points by bursting balloons. Args: n (int): The number of balloons. nums (List[int]): List of integers representing the numbers on the balloons. Returns: int: The maximum points that can be collected by bursting...
def maxCoins(nums): """ Maximize points by bursting balloons. """ nums = [1] + nums + [1] n = len(nums) dp = [[0] * n for _ in range(n)] for length in range(2, n): for left in range(0, n - length): right = left + length for k in range(left + 1, right): ...
from solution import maxCoins_from_input def test_maxCoins_example(): assert maxCoins_from_input(4, [3, 1, 5, 8]) == 167 def test_maxCoins_one_balloon(): assert maxCoins_from_input(1, [3]) == 3 def test_maxCoins_two_balloons(): assert maxCoins_from_input(2, [3, 1]) == 6 def test_maxCoins_all_same(): ...
[ { "docstring": "Maximize points by bursting balloons.", "function_declaration": "def maxCoins(nums):", "function_name": "maxCoins", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def maxCoins_from_input(n, nums):", "function_name": "maxCoins_from_input", ...
[ 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 maxCoins(nums):\n \"\"\"\n Returns the maximum coins/burst points that can be collected by bursting the balloons wisely.\n \"\"\"\n n = len(nums)\n...
trial_gpt4o_4
{ "original_instruction": "You are given a sequence of balloons, each balloon has a number written on it. You are allowed to burst the balloons. When you burst a balloon, the i-th balloon, you gain points equal to `nums[i-1] * nums[i] * nums[i+1]`. After the burst, the left and right balloons then become adjacent. Yo...
0.597905
Taco_29826
C
[ "maxCoins", "maxCoins_from_input" ]
2
[ [ "maxCoins_from_input", "maxCoins" ] ]
1
[]
false
[]
false
pytest
true
[]
true
349bc221f22377cc91b29bab3473455cecc1d8fe
e98c31c686dd6924183bf196239429ec6cd35562
v1.0
complete
Taco
Taco_30275_C
def twinPrimes(n): """ Returns all twin primes up to n (inclusive). >>> twinPrimes(20) [(3, 5), (5, 7), (11, 13), (17, 19)] >>> twinPrimes(1) [] >>> twinPrimes(50) [(3, 5), (5, 7), (11, 13), (17, 19), (29, 31), (41, 43)] """
def is_prime(num): """ Helper function to check if a number is a prime number. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import twinPrimes def test_twinPrimes_example(): assert twinPrimes(20) == [(3, 5), (5, 7), (11, 13), (17, 19)] def test_twinPrimes_small_numbers(): assert twinPrimes(1) == [] assert twinPrimes(2) == [] assert twinPrimes(3) == [] assert twinPrimes(10) == [(3, 5), (5, 7)] def test_twi...
[ { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns all twin primes up to n (inclusive).", "function_declaration": "def twinPrimes(n):", ...
[ 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 is_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n re...
trial_gpt4o_8
{ "original_instruction": "A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. A twin prime is a pair of prime numbers that differ by 2. For example, (3, 5), (11, 13), and (17, 19) are twin primes.\n\n## Task:\nWrite a function ```twinPrimes(n)``` which returns all...
0.599758
Taco_30275
C
[ "is_prime", "twinPrimes" ]
2
[ [ "twinPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
565d1feb3f44e4a0832869bcc68335c48fe14dc0
0439c5beb7e50786be57559de3bfe7395591573a
v1.0
complete
Taco
Taco_30397_C
def rearrange_array(arr, k): """ Rearranges the array such that the element at position i moves to position (i + k) % n. Modifies the array in place and returns it. >>> rearrange_array([1, 2, 3, 4, 5], 2) [4, 5, 1, 2, 3] >>> rearrange_array([10, 20, 30, 40, 50, 60, 70], 3) [40, 50, 60, 70, 1...
def rearrange_array(arr, k): """ Rearranges the array such that the element at position i moves to position (i + k) % n. Modifies the array in place and returns it. """ n = len(arr) k = k % n # To handle cases where k > n reverse(arr, 0, n - 1) reverse(arr, 0, k - 1) reverse(arr, k,...
from solution import rearrange_array def test_rearrange_basic(): assert rearrange_array([1, 2, 3, 4, 5], 2) == [4, 5, 1, 2, 3] def test_rearrange_single_element(): assert rearrange_array([1], 0) == [1] assert rearrange_array([1], 1) == [1] def test_rearrange_shift_more_than_length(): assert rearrange...
[ { "docstring": "Rearranges the array such that the element at position i moves to position (i + k) % n.\nModifies the array in place and returns it.", "function_declaration": "def rearrange_array(arr, k):", "function_name": "rearrange_array", "parameter_list": "(arr, k)" }, { "docstring": nu...
[ 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 rearrange_array(arr, k):\n \"\"\"\n Rearranges the array so that each element at position i moves to position (i+k) % n.\n \n Parameters:\n - ar...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes an array of integers and an integer k, and rearranges the array in such a way that the element at position i moves to position (i+k) % n, where n is the length of the array. The function should modify the array in place and return the modified array.\n\nNote: You...
0.671697
Taco_30397
C
[ "rearrange_array", "reverse" ]
2
[ [ "rearrange_array", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0a41e0cb4efbcef660824e78af70a0625d57a53
29232b1a9dde01debc6ae046dfaab4fa653b6145
v1.0
complete
Taco
Taco_30002_C
def find_two_sum_indices(n: int, target: int, nums: List[int]) -> List[int]: """ Find the indices of the two numbers such that they add up to target. >>> find_two_sum_indices(5, 9, [2, 7, 11, 15, 4]) [0, 1] >>> find_two_sum_indices(4, 6, [3, 2, 4, 7]) [1, 2] """
def two_sum(nums, target): """ Returns the indices of the two numbers such that they add up to target. """ index_map = {} # Stores number and its index for index, num in enumerate(nums): complement = target - num if complement in index_map: return sorted([index_map[compl...
from solution import two_sum, find_two_sum_indices def test_example_1(): assert find_two_sum_indices(5, 9, [2, 7, 11, 15, 4]) == [0, 1] def test_example_2(): assert find_two_sum_indices(4, 6, [3, 2, 4, 7]) == [1, 2] def test_no_solution(): assert find_two_sum_indices(4, 10, [1, 2, 3, 4]) == [] # None ex...
[ { "docstring": "Returns the indices of the two numbers such that they add up to target.", "function_declaration": "def two_sum(nums, target):", "function_name": "two_sum", "parameter_list": "(nums, target)" }, { "docstring": null, "function_declaration": "def find_two_sum_indices(n, targ...
[ 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 two_sum_indices(nums, target):\n \"\"\"\n Finds the indices of the two numbers in `nums` that add up to `target`.\n \n Args:\n nums : List of in...
trial_gpt4o_2
{ "original_instruction": "You are given an integer array `nums` of length `n` (1 ≤ n ≤ 100,000) and an integer `target`. Your task is to find the indices of the two numbers such that they add up to `target`. Assume that each input would have exactly one solution, and you may not use the same element twice.\n\nThe an...
0.62923
Taco_30002
C
[ "two_sum", "find_two_sum_indices" ]
2
[ [ "find_two_sum_indices", "two_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b9ca54ce8fb86fa6b6f37674426f209225be4fcf
8c4e69f3a8a46749e8c071cc7ab71d3750d6f14d
v1.0
complete
Taco
Taco_30117_C
def min_additional_edges(n, m, edges): """ Determine the minimum number of additional resources (edges) required to make the entire orchard connected. Args: n (int): The number of trees. m (int): The number of existing resources. edges (List[Tuple[int, int]]): The existing resources between tre...
def dfs(node, visited, graph): stack = [node] while stack: current = stack.pop() for neighbor in graph[current]: if not visited[neighbor]: visited[neighbor] = True stack.append(neighbor) def min_additional_edges(n, m, edges): graph = [[] for _ in ...
def test_min_additional_edges(): test_cases = [ (4, 2, [(1, 2), (2, 3)]), (3, 3, [(1, 2), (2, 3), (3, 1)]), (5, 1, [(4, 5)]) ] expected = [1, 0, 3] assert process_test_cases(test_cases) == expected def test_min_additional_edges_single_component(): test_cases = [ ...
[ { "docstring": null, "function_declaration": "def dfs(node, visited, graph):", "function_name": "dfs", "parameter_list": "(node, visited, graph)" }, { "docstring": null, "function_declaration": "def min_additional_edges(n, m, edges):", "function_name": "min_additional_edges", "pa...
[ 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(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n rootX = fi...
trial_gpt4o_2
{ "original_instruction": "Hana is the owner of a large orchard with various types of fruit trees. She has hired several gardeners to take care of the trees. Each gardener is assigned to a specific section of the orchard and has access to a distinct set of trees for maintenance. However, the gardeners need to periodi...
0.592572
Taco_30117
C
[ "dfs", "min_additional_edges", "process_test_cases" ]
3
[ [ "min_additional_edges", "dfs" ], [ "process_test_cases", "min_additional_edges" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
false
[]
true
92f7cdfe3ef042ffcdafe407b14da5c1bce9b5cc
17c0c92bf1346609a3d006d39e643536bbf770ab
v1.0
complete
Taco
Taco_29735_C
import math from typing import List, Tuple def calculate_distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float: """ Calculate the Euclidean distance between two points in a 2D plane. >>> calculate_distance((0, 0), (0, 1)) 1.0 >>> calculate_distance((0, 0), (1, 1)) math.sqrt(2) """ ...
import math def calculate_distance(p1, p2): """ Helper function to calculate the Euclidean distance between two points. """ return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2) def polygon_perimeter(points): """ Function to calculate the perimeter of a polygon given its vertices. """ ...
from solution import calculate_distance, polygon_perimeter, process_input def test_calculate_distance(): assert calculate_distance((0, 0), (0, 1)) == 1.0 assert calculate_distance((0, 0), (1, 1)) == math.sqrt(2) assert calculate_distance((1, 0), (0, 1)) == math.sqrt(2) def test_polygon_perimeter_square():...
[ { "docstring": "Helper function to calculate the Euclidean distance between two points.", "function_declaration": "def calculate_distance(p1, p2):", "function_name": "calculate_distance", "parameter_list": "(p1, p2)" }, { "docstring": "Function to calculate the perimeter of a polygon given i...
[ 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 euclidean_distance(p1, p2):\n \"\"\"\n Returns the Euclidean distance between two points p1 and p2.\n \"\"\"\n return math.sqrt((p1[...
trial_gpt4o_1
{ "original_instruction": "Write a program to find the perimeter of a polygon given its vertices in a 2D plane. The polygon is defined by a list of points \\((x_i, y_i)\\) for \\(i = 0\\) to \\(n-1\\). The points are listed in a counter-clockwise order and the last point should be connected to the first point to clos...
0.556273
Taco_29735
C
[ "calculate_distance", "polygon_perimeter", "process_input" ]
3
[ [ "polygon_perimeter", "calculate_distance" ], [ "process_input", "polygon_perimeter" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
7812e86b140c8bf0a70df42096e0a6eed96a60cd
bd6a0ffd9ed1d9aec73099ae594a9efd90357997
v1.0
complete
Taco
Taco_29723_C
def knapsack(C: int, N: int, items: List[Tuple[int, int]]) -> int: """ Solves the knapsack problem and returns the maximum value that can be carried in the backpack without exceeding its capacity. Parameters: - C: int, capacity of the backpack - N: int, number of items - items: list of tupl...
def knapsack(C, N, items): """ Solves the knapsack problem. Parameters: - C: int, capacity of the backpack - N: int, number of items - items: list of tuples, each tuple (Wi, Vi) indicates weight and value of an item Returns: - int, the maximum value that can be carried in the backp...
def test_knapsack_base_case(): assert knapsack(4, 3, [(1, 3), (4, 5), (3, 4)]) == 7 def test_knapsack_single_item_fits_perfectly(): assert knapsack(5, 1, [(5, 10)]) == 10 def test_knapsack_single_item_too_large(): assert knapsack(5, 1, [(6, 10)]) == 0 def test_knapsack_multiple_items(): assert knapsa...
[ { "docstring": "Solves the knapsack problem.\n\nParameters:\n- C: int, capacity of the backpack\n- N: int, number of items\n- items: list of tuples, each tuple (Wi, Vi) indicates weight and value of an item\n\nReturns:\n- int, the maximum value that can be carried in the backpack without exceeding its capacity"...
[ 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 knapsack(C, N, items):\n \"\"\"\n Solves the knapsack problem.\n \n Parameters:\n - C: int, capacity of the backpack\n - N: int, number of it...
trial_gpt4o_0
{ "original_instruction": "Problem Statement\n\nAlex is planning a vacation trip and wants to ensure his luggage is packed efficiently. He has a backpack with a specific capacity and a list of items, each with a weight and a value. Alex wants to maximize the total value of the items he can carry without exceeding the...
0.559014
Taco_29723
C
[ "knapsack", "solve_knapsack_from_input" ]
2
[ [ "solve_knapsack_from_input", "knapsack" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5cce395593de8beeb89edfda4673426dae1e6440
6b57c58ce49f7890c6e06446ea618a9c82337453
v1.0
complete
Taco
Taco_30031_C
from typing import List, Tuple def labyrinth_solver(input_str: str) -> List[int]: """ Determine the optimal path for maximizing collected treasures while minimizing health loss in a labyrinth. Args: input_str (str): The input string containing the number of chambers, initial health, chambers' details,...
import heapq def optimal_path(n, h, chambers_info, connections): # Parse inputs treasures = {chamber: treasures for chamber, treasures, _ in chambers_info} traps = {chamber: traps for chamber, _, traps in chambers_info} adj = {i: [] for i in range(1, n + 1)} for a, b, c in connections: adj[...
def test_labyrinth_solver(): input_str = "5 1000\n1 10 0\n2 20 5\n3 30 10\n4 40 15\n5 50 20\n1 2 200\n2 3 150\n2 4 300\n2 5 500\n3 4 100\n4 5 250" expected_output = [1, 2, 3, 4, 5] assert labyrinth_solver(input_str) == expected_output def test_labyrinth_solver_multiple_paths(): input_str = "4 1000\n1 1...
[ { "docstring": null, "function_declaration": "def optimal_path(n, h, chambers_info, connections):", "function_name": "optimal_path", "parameter_list": "(n, h, chambers_info, connections)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": ...
[ 0, 0, 0, 0, 0, 0, 1, 0, 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 labyrinth_optimal_path(chambers, connections, initial_health):\n n = len(chambers)\n graph = {i: [] for i in range(1, n + 1)}\n \n ...
trial_gpt4o_7
{ "original_instruction": "A group of adventurers finds themselves at the entrance of an ancient labyrinth. The labyrinth consists of a series of chambers connected by tunnels. Each chamber has a certain number of treasures and some traps which can reduce the party's health if not carefully navigated. The goal of the...
0.607118
Taco_30031
C
[ "optimal_path", "parse_input", "labyrinth_solver" ]
3
[ [ "labyrinth_solver", "optimal_path" ], [ "labyrinth_solver", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
b94b4dcfd36de9edb502913a92e12c89d13b93ef
9b23a414d5c0f95cd58c40b77528228c74aeaf68
v1.0
complete
Taco
Taco_30431_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(preorder): """ Build a binary search tree from a preorder traversal list. """ def helper(preorder_iter): val = next(preorder_iter) ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(preorder): """ Build a binary search tree from a preorder traversal list. """ def helper(preorder_iter): val = next(preorder_iter) ...
import pytest from solution import build_tree, kth_smallest, find_kth_smallest def test_kth_smallest(): # Test Case 1 tree1 = build_tree("5 3 2 null null 4 null null 8 7 null null 9 null null".split()) assert kth_smallest(tree1, 3) == 4 # Test Case 2 tree2 = build_tree("3 1 null null 4 null nu...
[]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_6
{ "original_instruction": "Given a binary tree, your task is to find the ‘k’th smallest element in this tree. The binary tree nodes contain integer values and follow the standard properties of a binary search tree (i.e., the left subtree of a node contains only nodes with keys less than the node's key, and the right ...
0.549509
Taco_30431
C
[ "build_tree", "kth_smallest", "find_kth_smallest" ]
3
[ [ "find_kth_smallest", "build_tree" ], [ "find_kth_smallest", "kth_smallest" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
21e4298f895fe0f80b16f026ec41feda9aed8c52
7a79ac0996baa8adc3a5b4d0bd71ce2893922dfc
v1.0
complete
Taco
Taco_30160_C
def list_of_numbers_to_words(lst: List[int]) -> List[str]: """ Convert a list of integers to a list of their English words representation. Args: lst: List of integers (0 <= number < 100) Returns: List of strings representing each integer in words. Examples: >>> list_of_numbers_t...
def number_to_words(number): """ Convert a number less than 100 to its English words representation. """ if 0 <= number <= 19: return ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourtee...
from solution import list_of_numbers_to_words def test_single_digit_numbers(): assert list_of_numbers_to_words([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \ ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] def test_teens(): assert list_of_numbers_to_words([10, 11, 12, 13, 14,...
[ { "docstring": "Convert a number less than 100 to its English words representation.", "function_declaration": "def number_to_words(number):", "function_name": "number_to_words", "parameter_list": "(number)" }, { "docstring": "Convert a list of integers to a list of their English words repres...
[ 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 number_to_words(number):\n \"\"\"Convert a number to its word representation\"\"\"\n if not 0 <= number < 100:\n raise ValueError(\"Number out of ...
trial_gpt4o_2
{ "original_instruction": "## Task\nWrite a function that takes a list of integers and returns a list of strings. For each integer in the input list, the corresponding string in the output list should describe the number in words. Assume the input list only contains non-negative integers less than 100.\n\n## Examples...
0.575718
Taco_30160
C
[ "number_to_words", "list_of_numbers_to_words" ]
2
[ [ "list_of_numbers_to_words", "number_to_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f63d89e87716623d3d3c1ef3527ecbb7491c8298
760343b410b48bba31899b331e1e4afef43cb8c1
v1.0
complete
Taco
Taco_30340_C
def merge_sort(arr): """Perform the merge sort algorithm to sort an array of integers in non-decreasing order. >>> merge_sort([64, 34, 25, 12, 22]) [12, 22, 25, 34, 64] >>> merge_sort([]) [] >>> merge_sort([1]) [1] """ def sort_books(test_cases): """Sort the given book index cases u...
def merge_sort(arr): if len(arr) > 1: mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] merge_sort(left_half) merge_sort(right_half) i = j = k = 0 while i < len(left_half) and j < len(right_half): if left_half[i] < right_half[j]: ...
import pytest from solution import merge_sort, sort_books, format_input_output def test_merge_sort_single_case(): input_array = [64, 34, 25, 12, 22] merge_sort(input_array) assert input_array == [12, 22, 25, 34, 64] def test_merge_sort_empty_array(): input_array = [] merge_sort(input_array) as...
[ { "docstring": null, "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def sort_books(test_cases):", "function_name": "sort_books", "parameter_list": "(test_cases)" }, { ...
[ 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 merge_sort(arr):\n if len(arr) <= 1:\n return arr\n \n mid = len(arr) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])...
trial_gpt4o_1
{ "original_instruction": "In a distant kingdom, there's a wise king with a peculiar problem. He has a large bookshelf, and he wants to sort all the books on it in non-decreasing order according to their numeric indexes. However, due to his love for programming challenges, he wants to accomplish this with a specific ...
0.569518
Taco_30340
C
[ "merge_sort", "sort_books", "format_input_output" ]
3
[ [ "format_input_output", "sort_books" ], [ "sort_books", "merge_sort" ] ]
2
[ "format_input_output" ]
false
[]
false
pytest
true
[]
true
b8260328b17575b8ee420aff8269c88a58d85512
d3ef150c1b1157ee82e49ea307d2917610ce7c4b
v1.0
complete
Taco
Taco_30519_C
import math from typing import List def lcm(a: int, b: int) -> int: """ Computes the least common multiple of two numbers. >>> lcm(2, 3) 6 >>> lcm(4, 5) 20 """ pass def smallest_multiple(n: int) -> int: """ Returns the smallest positive integer that is evenly divisible by all numbers f...
import math def lcm(a, b): """ Returns the least common multiple of a and b. """ return abs(a * b) // math.gcd(a, b) def smallest_multiple(n): """ Returns the smallest positive integer that is evenly divisible by all numbers from 1 to n. """ if n == 1: return 1 result = 1 ...
from solution import smallest_multiple def test_smallest_multiple_1(): assert smallest_multiple(1) == 1 def test_smallest_multiple_2(): assert smallest_multiple(2) == 2 def test_smallest_multiple_3(): assert smallest_multiple(3) == 6 def test_smallest_multiple_4(): assert smallest_multiple(4) == 12 ...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest positive integer that is evenly divisible by all numbers from 1 to n.", "function_declarati...
[ 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 math import gcd\n\ndef lcm(a, b):\n \"\"\"\n Returns the least common multiple (LCM) of two numbers.\n \"\"\"\n return a * b // gcd(a, b)\n\ndef s...
trial_gpt4o_2
{ "original_instruction": "Write a program to find the smallest positive integer that is evenly divisible by all numbers from 1 to a given number `n`. In other words, find the Least Common Multiple (LCM) of all numbers from 1 to `n`. For example:\n\n```\nFor n = 5\nNumbers: 1, 2, 3, 4, 5\nSmallest positive integer di...
0.652838
Taco_30519
C
[ "lcm", "smallest_multiple" ]
2
[ [ "smallest_multiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d980b0d5091481dad6bf0f9fa3cbff45247616cb
52e5da3e60b66471a2e60ff4c514ecbccfab3866
v1.0
complete
Taco
Taco_30017_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ ... def prime_factors(n: int) -> List[int]: """ Return the prime factors of a number. >>> prime_factors(4) [2, 2] >>> prime_factors(15) [3, 5] """ ... de...
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 prime_factors(n): factors = [] whi...
from solution import is_prime, prime_factors, choose_best_prime_factors, who_wins_game def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert is_prime(13) assert not is_prime(15) def test_prime_factors(): assert prime_factors(4) == [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, 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 if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_4
{ "original_instruction": "Two friends, Maya and Jacob, love playing number games. They recently discovered a new game based on prime factorization and decided to challenge each other. The game starts with an array of positive integers, and the players take turns. During a turn, a player must choose an element from t...
0.674486
Taco_30017
C
[ "is_prime", "prime_factors", "choose_best_prime_factors", "who_wins_game" ]
4
[ [ "choose_best_prime_factors", "is_prime" ], [ "choose_best_prime_factors", "prime_factors" ], [ "who_wins_game", "choose_best_prime_factors" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8eb4959f7229d500572dae69348ce6a70d4d1ed3
a6ffb3311055ca40c7b45f094fa4b33fb6a5608d
v1.0
complete
Taco
Taco_30900_C
def max_fertile_square(n: int, m: int, field: List[str]) -> int: """ Determine the size of the largest square plot of fertile land. >>> max_fertile_square(5, 6, ["101010", "111111", "111110", "111110", "111000"]) 9 >>> max_fertile_square(4, 4, ["1010", "1111", "1011", "1011"]) 4 """
def max_fertile_square(n, m, field): if n == 0 or m == 0: return 0 dp = [[0] * m for _ in range(n)] max_side = 0 for i in range(n): for j in range(m): if field[i][j] == '1': if i == 0 or j == 0: dp[i][j] = 1 else: ...
from solution import max_fertile_square def test_example1(): n = 5 m = 6 field = [ "101010", "111111", "111110", "111110", "111000" ] assert max_fertile_square(n, m, field) == 9 def test_example2(): n = 4 m = 4 field = [ "1010", "...
[ { "docstring": null, "function_declaration": "def max_fertile_square(n, m, field):", "function_name": "max_fertile_square", "parameter_list": "(n, m, field)" }, { "docstring": null, "function_declaration": "def max_fertile_square_from_input():", "function_name": "max_fertile_square_f...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def max_fertile_square(n, m, field):\n if n == 0 or m == 0:\n return 0\n \n dp = [[0] * m for _ in range(n)]\n max_side...
trial_gpt4o_1
{ "original_instruction": "Farmer John has a rectangular field, represented as a grid of size n x m (1 ≤ n, m ≤ 500). Each cell in the grid can either be fertile land or barren land. Bessie the cow loves to graze on fertile land and avoid barren land.\n\nFarmer John wants to help Bessie by determining the maximum siz...
0.573188
Taco_30900
C
[ "max_fertile_square", "max_fertile_square_from_input" ]
2
[ [ "max_fertile_square_from_input", "max_fertile_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3f7409879764cb318484bedf45daa6d3ab36dc64
74f46754775d98387c1c45efb4744b5d8f86fe1f
v1.0
complete
Taco
Taco_30821_C
from typing import List def filter_repeated_digits(numbers: List[int]) -> List[int]: """ Takes a list of integers and returns a list containing all the integers that have at least one of their digits repeated. >>> filter_repeated_digits([123, 112, 456, 998, 789]) [112, 998] >>> filter_repeate...
def has_repeated_digits(n): """ Helper function to determine if the given integer has any repeated digits. """ digits = {} n = abs(n) # Handle negative numbers by taking the absolute value while n > 0: digit = n % 10 if digit in digits: return True digits[dig...
from solution import filter_repeated_digits def test_filter_repeated_digits_example_1(): assert filter_repeated_digits([123, 112, 456, 998, 789]) == [112, 998] def test_filter_repeated_digits_example_2(): assert filter_repeated_digits([9876543210, 1234567890, 111222333, 444555666, 12321]) == [111222333, 44455...
[ { "docstring": "Helper function to determine if the given integer has any repeated digits.", "function_declaration": "def has_repeated_digits(n):", "function_name": "has_repeated_digits", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a list containing all th...
[ 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 repeated_digits(nums):\n \"\"\"\n Returns a list of integers that contain at least one repeated digit. The order\n of the integers in the output list ...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes a list of integers and returns a list containing all the integers that have at least one of their digits repeated. The order of the integers in the output list should be the same as their order in the input list.\n\n### Input:\n- A list of integers.\n\n### Output...
0.733463
Taco_30821
C
[ "has_repeated_digits", "filter_repeated_digits" ]
2
[ [ "filter_repeated_digits", "has_repeated_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0d7d98d89062c31e165cbd2828abcf813f4229e
ad91f894deae72767e43fc9cf080378a1b8bbd91
v1.0
complete
Taco
Taco_30491_C
import math from typing import List def is_prime(n: int) -> bool: """ Determines if a number n is prime. Returns True if n is a prime number, otherwise False. """ pass def check_primes(numbers: List[int]) -> List[str]: """ Takes a list of integers and returns a list of strings indicati...
import math def is_prime(n): """ Determines if a number n is prime. Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False limit = math.isqrt(n) for i in range(3, limit + 1, 2): ...
from solution import is_prime, check_primes def test_is_prime(): assert is_prime(2) == True, "2 is a prime number" assert is_prime(3) == True, "3 is a prime number" assert is_prime(4) == False, "4 is not a prime number" assert is_prime(29) == True, "29 is a prime number" assert is_prime(1) == False...
[ { "docstring": "Determines if a number n is prime.\nReturns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a list of strings\nindicating w...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ...
trial_gpt4o_1
{ "original_instruction": "A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Determining if a number is prime is a common problem in programming and number theory.\n\nIn this exercise, you are required to write a function that takes a list of integers and returns...
0.823669
Taco_30491
C
[ "is_prime", "check_primes" ]
2
[ [ "check_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9a06a7729645316841d3f27b35905817c03fd1eb
a9357bb40769cc9c617c49a0b9e7fc6fd18da489
v1.0
complete
Taco
Taco_29976_C
def caesar_encrypt(message: str, shift: int) -> str: """ Encrypts the message using Caesar Cipher technique by shifting each letter by the given shift value. >>> caesar_encrypt("Hello, World!", 3) "Khoor, Zruog!" >>> caesar_encrypt("Attack at dawn!", 5) "Fyyfhp fy ifbs!" """ pass def caesar...
def caesar_encrypt(message: str, shift: int) -> str: def shift_char(c, shift): if 'a' <= c <= 'z': return chr((ord(c) - ord('a') + shift) % 26 + ord('a')) elif 'A' <= c <= 'Z': return chr((ord(c) - ord('A') + shift) % 26 + ord('A')) else: return c ...
from solution import caesar_encrypt, caesar_decrypt def test_caesar_encrypt(): assert caesar_encrypt("Hello, World!", 3) == "Khoor, Zruog!" assert caesar_encrypt("Attack at dawn!", 5) == "Fyyfhp fy ifbs!" assert caesar_encrypt("Python", 13) == "Clguba" assert caesar_encrypt("abcdefghijklmnopqrstuvwxyz"...
[ { "docstring": null, "function_declaration": "def caesar_encrypt(message, shift):", "function_name": "caesar_encrypt", "parameter_list": "(message, shift)" }, { "docstring": null, "function_declaration": "def caesar_decrypt(encrypted_message, shift):", "function_name": "caesar_decryp...
[ 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 caesar_encrypt(message: str, shift: int) -> str:\n encrypted_message = []\n \n for char in message:\n if char.isalpha():\n shift_amo...
trial_gpt4o_2
{ "original_instruction": "Encrypting and Decrypting Messages with Caesar Cipher\n\nCaesar Cipher is one of the simplest and most widely known encryption techniques. In this method, each letter in the plaintext is shifted a certain number of places down or up the alphabet.\n\nLet's implement both encryption and decry...
0.704287
Taco_29976
C
[ "caesar_encrypt", "caesar_decrypt" ]
2
[ [ "caesar_decrypt", "caesar_encrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
24571a7f691bbf65e28884eb17581263e3ba46f3
e7c0d6ff5399e27028cbaf7848cb436f8ac32374
v1.0
complete
Taco
Taco_30544_C
from typing import List def total_quicksort_comparisons(n: int, arr: List[int]) -> int: """ Calculate the total number of comparisons QuickSort makes to sort the array using the first element as the pivot. >>> total_quicksort_comparisons(4, [4, 3, 2, 1]) 6 >>> total_quicksort_comparisons(5, [1, 2,...
def quicksort_comparisons(arr, low, high): if low < high: pivotIndex = partition(arr, low, high) left_comparisons = quicksort_comparisons(arr, low, pivotIndex - 1) right_comparisons = quicksort_comparisons(arr, pivotIndex + 1, high) total_comparisons = (high - low) + left_comparisons...
def test_total_quicksort_comparisons(): assert total_quicksort_comparisons(4, [4, 3, 2, 1]) == 6 assert total_quicksort_comparisons(5, [1, 2, 3, 4, 5]) == 10 assert total_quicksort_comparisons(1, [1]) == 0 assert total_quicksort_comparisons(3, [3, 2, 1]) == 3 assert total_quicksort_comparisons(6, [6...
[ { "docstring": null, "function_declaration": "def quicksort_comparisons(arr, low, high):", "function_name": "quicksort_comparisons", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", ...
[ 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 quicksort_comparison_count(arr):\n \"\"\"\n Returns the total number of comparisons QuickSort makes when sorting the array using the first element as the...
trial_gpt4o_5
{ "original_instruction": "Alicia is learning about sorting algorithms and came across the QuickSort algorithm. She understands the basic idea but wants to explore how QuickSort operates with different pivot selection strategies. One common strategy is to always pick the first element as the pivot. Alicia wants to de...
0.612187
Taco_30544
C
[ "quicksort_comparisons", "partition", "total_quicksort_comparisons" ]
3
[ [ "quicksort_comparisons", "partition" ], [ "total_quicksort_comparisons", "quicksort_comparisons" ] ]
2
[]
false
[]
false
pytest
false
[]
true
f8b4942cc941369e10869046b825cc2b2d652616
6cf8f62cacfba1d0f1fd68182168c639735d79fa
v1.0
complete
Taco
Taco_30654_C
def buildMaxHeap(arr: list, n: int) -> list: """ Build a max-heap from the given array. >>> buildMaxHeap([4, 1, 3, 9, 7], 5) [9, 7, 3, 1, 4] >>> buildMaxHeap([2, 10, 8, 5, 6, 1], 6) [10, 6, 8, 5, 2, 1] """ # Implement max-heap construction here def buildMinHeap(arr: list, n: int) -> li...
def heapify_max(arr, n, i): largest = i left = 2 * i + 1 right = 2 * i + 2 if left < n and arr[left] > arr[largest]: largest = left if right < n and arr[right] > arr[largest]: largest = right if largest != i: arr[i], arr[largest] = arr[largest], arr[i] ...
from solution import buildMaxHeap, buildMinHeap, extractMax, extractMin def test_buildMaxHeap(): arr = [4, 1, 3, 9, 7] n = len(arr) max_heap = buildMaxHeap(arr, n) assert max_heap == [9, 7, 3, 1, 4] def test_extractMax(): arr = [4, 1, 3, 9, 7] n = len(arr) buildMaxHeap(arr, n) assert e...
[ { "docstring": null, "function_declaration": "def heapify_max(arr, n, i):", "function_name": "heapify_max", "parameter_list": "(arr, n, i)" }, { "docstring": null, "function_declaration": "def buildMaxHeap(arr, n):", "function_name": "buildMaxHeap", "parameter_list": "(arr, n)" ...
[ 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 heapify_max(arr, n, i):\n \"\"\"Ensure the max-heap property starting from node i.\"\"\"\n largest = i # Initialize largest as root\n left = 2 * i + ...
trial_gpt4o_1
{ "original_instruction": "A binary heap is a complete binary tree which satisfies the heap property. The heap can be of two types:\n- Max-Heap: In this type of heap, each parent node is greater than or equal to its child nodes.\n- Min-Heap: In this type of heap, each parent node is less than or equal to its child no...
0.690152
Taco_30654
C
[ "heapify_max", "buildMaxHeap", "extractMax", "heapify_min", "buildMinHeap", "extractMin" ]
6
[ [ "buildMaxHeap", "heapify_max" ], [ "buildMinHeap", "heapify_min" ], [ "extractMax", "heapify_max" ], [ "extractMin", "heapify_min" ] ]
4
[]
false
[]
false
pytest
true
[]
true
c551a1e0dbfa844433f6be8ce4e8637673c8f911
55ee462bcc270dac15559790f1ba413707f503b5
v1.0
complete
Taco
Taco_30961_C
def is_palindrome(num: int) -> bool: """ Check if a number is a palindrome. >>> is_palindrome(121) == True >>> is_palindrome(123) == False >>> is_palindrome(0) == True >>> is_palindrome(11) == True >>> is_palindrome(10) == False """ def smallest_palindrome_greater_than(n: int) -> int: ...
def is_palindrome(num): return str(num) == str(num)[::-1] def smallest_palindrome_greater_than(n): m = n + 1 while not is_palindrome(m): m += 1 return m
from solution import is_palindrome, smallest_palindrome_greater_than def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(0) == True assert is_palindrome(11) == True assert is_palindrome(10) == False def test_smallest_palindrome_greate...
[ { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def smallest_palindrome_greater_than(n):", "function_name": "smallest_palindrome_greater_than", "pa...
[ 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 smallest_palindrome_greater_than(n):\n \"\"\"\n Returns the smallest palindromic number greater than n.\n \"\"\"\n def is_palindrome(num):\n ...
trial_gpt4o_2
{ "original_instruction": "Problem\n\nJames is obsessed with palindromic numbers. A palindromic number is a number that remains the same when its digits are reversed. Given an integer `n`, he wants to find out the smallest palindrome greater than `n`.\n\nConstraints\n\n* 0 ≤ n ≤ 10^6\n\nInput\n\nThe input is given in...
0.735714
Taco_30961
C
[ "is_palindrome", "smallest_palindrome_greater_than" ]
2
[ [ "smallest_palindrome_greater_than", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
546cd9c3e7f5c84f8e4b0f474b6d99bd84dbbe2d
bd3797b49a2068695c7edd5abb38e6df8ffaf8b6
v1.0
complete
Taco
Taco_29638_C
def solve(n: int, m: int, roads: List[Tuple[int, int, int]], q: int, queries: List[int]) -> List[int]: """ Solve the shortest path problem in a directed graph with given queries. Args: n : int : Number of cities m : int : Number of roads roads : List[Tuple[int, int, int]] : Each tuple cont...
from heapq import heappop, heappush import sys def dijkstra(n, edges, start): graph = [[] for _ in range(n + 1)] for u, v, w in edges: graph[u].append((w, v)) distances = [float('inf')] * (n + 1) distances[start] = 0 priority_queue = [(0, start)] # (distance, node) while prio...
def test_example_1(): n, m = 5, 6 roads = [ (1, 2, 2), (1, 3, 4), (2, 4, 7), (3, 4, 1), (4, 5, 3), (3, 5, 1) ] q = 3 queries = [4, 5, 2] expected_output = [5, 5, 2] assert solve(n, m, roads, q, queries) == expected_output def test_example_2():...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start):", "function_name": "dijkstra", "parameter_list": "(n, edges, start)" }, { "docstring": null, "function_declaration": "def solve(n, m, roads, q, queries):", "function_name": "solve", "parameter_list": "(n...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from heapq import heappop, heappush\nimport sys\n\ndef dijkstra(n, edges, start):\n graph = [[] for _ in range(n + 1)]\n for u, v, w in edges:\n graph...
trial_gpt4o_0
{ "original_instruction": "A company is trying to optimize the routing of their delivery trucks between various cities. Each city is connected by one-way roads, and the company wants to determine the shortest path for their trucks to deliver goods from the central warehouse to several destination cities. The problem ...
0.719503
Taco_29638
C
[ "dijkstra", "solve" ]
2
[ [ "solve", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
dcc480fdf0c36e1321151c9dcaa34070d64ee6d7
b85bacb774fe105f38b05388cbea0786cf1d5ec3
v1.0
complete
Taco
Taco_31038_C
def is_prime(n: int) -> bool: """Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False """ # Your code here def product_of_unique_primes(arr: List[int]) -> int: """ Return the product of all unique prime numbers in the gi...
def is_prime(n): """Check if a number is prime.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def product_of_unique_primes(arr): """...
from solution import is_prime, product_of_unique_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_product_of_unique_primes(): assert product_of_unique_primes([4, 7, 8,...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return the product of all unique prime numbers in the given array.\nIf no prime numbers are found, return 1.", "function_decla...
[ 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 Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers, return the product of all the unique prime numbers present in the array. \n\nIf no prime numbers are present in the array, return 1. \n\nFor example:\n- Input: [4, 7, 8, 15, 7, 19]\n- Output: 133 (since 7 and 19 are the unique prime numbers and 7 * 19 = 133)\n\n-...
0.70428
Taco_31038
C
[ "is_prime", "product_of_unique_primes" ]
2
[ [ "product_of_unique_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7816fc555c550331e1e835c126d0329c50956fb0
8ceed4d7e66056276f783568fa50461883ac743d
v1.0
complete
Taco
Taco_30477_C
def find_max_overlap(events): """ Finds the maximum number of overlapping events. Parameters: events (List[Tuple[int, int]]): A list of tuples representing events with start and end times. Returns: int: The maximum number of overlapping events. """ pass def max_overlapping_events(T, test_c...
def find_max_overlap(events): events.sort(key=lambda x: (x[0], x[1])) start_times = sorted([event[0] for event in events]) end_times = sorted([event[1] for event in events]) max_overlap = 0 current_overlap = 0 i, j = 0, 0 n = len(events) while i < n and j < n: if start...
import pytest from solution import max_overlapping_events, parse_input def test_max_overlap(): input_data = "2\n3\n1 4\n2 5\n6 8\n4\n1 10\n2 5\n3 6\n7 11" T, test_cases = parse_input(input_data) assert max_overlapping_events(T, test_cases) == [2, 3] def test_single_event(): input_data = "1\n1\n0 5" ...
[ { "docstring": null, "function_declaration": "def find_max_overlap(events):", "function_name": "find_max_overlap", "parameter_list": "(events)" }, { "docstring": null, "function_declaration": "def max_overlapping_events(T, test_cases):", "function_name": "max_overlapping_events", ...
[ 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_overlapping_events(test_cases):\n results = []\n for events in test_cases:\n times = []\n for start, end in events:\n times....
trial_gpt4o_1
{ "original_instruction": "Alex works as an event coordinator and is organizing a series of events across multiple venues. Each event is represented by its start and end times. Some events may overlap in time, and Alex needs to find out the maximum number of overlapping events happening at any moment. Your task is to...
0.58563
Taco_30477
C
[ "find_max_overlap", "max_overlapping_events", "parse_input" ]
3
[ [ "max_overlapping_events", "find_max_overlap" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
dc3f232f1c30a3446707522e68063e9bd33f02b0
2f3123ef6f18d1a50ba529c1bdb11bd570fdab2e
v1.0
complete
Taco
Taco_30976_C
from typing import List class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reverse_k_nodes(n: int, lst: List[int], k: int) -> List[int]: """ Given a linked list, reverse every k nodes of the linked list. Args: n : int : size of the linked lis...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reverseKGroup(head, k): def reverseLinkedList(head, k): new_head, ptr = None, head while k: next_node = ptr.next ptr.next = new_head new_head = ptr ...
import pytest from solution import reverse_k_nodes def test_example1(): assert reverse_k_nodes(8, [1, 2, 3, 4, 5, 6, 7, 8], 3) == [3, 2, 1, 6, 5, 4, 7, 8] def test_single_element_list(): assert reverse_k_nodes(1, [10], 1) == [10] def test_all_nodes_reversed(): assert reverse_k_nodes(4, [1, 2, 3, 4], 4) =...
[]
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef reverse_k_group(head: ListNode, k: int) -> List...
trial_gpt4o_2
{ "original_instruction": "Given a linked list, reverse every k nodes of the linked list.\n\nInput\nFirst line of input contains one integer n, which denotes the size of the linked list.\n\nSecond line contains n space separated integers representing the elements of the linked list.\n\nThird line contains one integer...
0.584128
Taco_30976
C
[ "reverseKGroup", "list_to_linked_list", "linked_list_to_list", "reverse_k_nodes" ]
4
[ [ "reverse_k_nodes", "linked_list_to_list" ], [ "reverse_k_nodes", "list_to_linked_list" ], [ "reverse_k_nodes", "reverseKGroup" ] ]
3
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
4976c0cc47544c6f51881c62f3928a0dcffd1ad6
2f1e4b3b7a6d8bc6993e25539f08c36ece979f25
v1.0
complete
Taco
Taco_30968_C
def is_prime(num: int) -> bool: """Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False """ pass def is_fermat_number(n: int) -> bool: """Check if a number is a Fermat number. >>> is_fermat_number(3) True >>> is_fermat_number(23...
def is_prime(num): """Check if a number is prime.""" if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 retur...
import pytest from solution import is_prime, is_fermat_number, classify_number, process_numbers 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(6) assert is_prime(7) def test_is_fermat_number(): assert is_fermat_n...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Check if a number is a Fermat number.", "function_declaration": "def is_fermat_number(n):", "function_name": "is_ferma...
[ 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 Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ...
trial_gpt4o_3
{ "original_instruction": "In 18th century, Leonhard Euler formulated that numbers of the form $2^{2^n} + 1$ are prime numbers, which were later known as Fermat primes. A Fermat number is defined as follows:\n\n$F_n = 2^{2^n} + 1$\n\nEuler conjectured that all Fermat numbers are prime, but it was later proven false. ...
0.734109
Taco_30968
C
[ "is_prime", "is_fermat_number", "classify_number", "process_numbers" ]
4
[ [ "classify_number", "is_fermat_number" ], [ "classify_number", "is_prime" ], [ "process_numbers", "classify_number" ] ]
3
[]
false
[]
false
pytest
true
[]
true
41130c842c6ccfb6e0eca74be7d9a1fdae2900eb
a53533c4c0ffd10f9b689d6ff3711ab8b575084f
v1.0
complete
Taco
Taco_30856_C
from collections import defaultdict from typing import List, Tuple def minimal_capacity(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """ Given a directed graph with n nodes and m edges representing a water supply system, find the minimal capacity of an edge that, if removed, would lead to the max...
from collections import defaultdict, deque def bfs(capacity, source, sink, parent): visited = set() queue = deque([source]) visited.add(source) while queue: u = queue.popleft() for v in capacity[u]: if v not in visited and capacity[u][v] > 0: queue.appen...
import pytest from solution import minimal_capacity def test_case_1(): n = 4 m = 5 edges = [ (1, 2, 10), (2, 3, 5), (2, 4, 15), (3, 4, 10), (4, 3, 10) ] assert minimal_capacity(n, m, edges) == 5 def test_case_2(): n = 3 m = 3 edges = [ (1...
[ { "docstring": null, "function_declaration": "def bfs(capacity, source, sink, parent):", "function_name": "bfs", "parameter_list": "(capacity, source, sink, parent)" }, { "docstring": null, "function_declaration": "def edmonds_karp(n, capacity, source, sink):", "function_name": "edmo...
[ 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 networkx as nx\n\ndef minimal_capacity_removal(n, m, edges):\n \"\"\"\n Returns the minimal capacity of an edge that, if removed, would result in the ...
trial_gpt4o_1
{ "original_instruction": "The land of Eldoria has a complex underground water system that supplies water to various villages. The water system can be represented as a graph where each node is a village and each edge is a pipeline connecting two villages. Each pipeline has a certain capacity that represents the maxim...
0.67337
Taco_30856
C
[ "bfs", "edmonds_karp", "minimal_capacity" ]
3
[ [ "edmonds_karp", "bfs" ], [ "minimal_capacity", "edmonds_karp" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ca4a86522e6391b28e294d0c372f99d965fbe3c5
8a39c5aea459f012aaaf636cadc7adaca7b46ecb
v1.0
complete
Taco
Taco_31185_C
def is_prime(num): """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(10) False """ # Implementation here def is_doubly_prime(n: int) -> str: """ Function to...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5)+1, 2): if num % i == 0: return False return True def is_...
from solution import is_prime, is_doubly_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False def test_is_doubly_prime(): assert is_doubly_prime(5) == "yes" assert is_doubly_prim...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to determine if a number is doubly prime.", "function_declaration": "def is_doubly_prime(n):",...
[ 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(num):\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n retu...
trial_gpt4o_4
{ "original_instruction": "An organization is considering numbers to be classified as \"doubly prime.\" A number is doubly prime if both the number itself and the number minus two are prime.\n\nFor example, 5 is a doubly prime number because both 5 and 3 are prime, but 4 is not a doubly prime because neither 4 nor 2 ...
0.844237
Taco_31185
C
[ "is_prime", "is_doubly_prime" ]
2
[ [ "is_doubly_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c32531b4ce10d5047903f397f27201ac09c3cf22
2fe22e4f063a1c4a12cb0748c760baff93b6df7d
v1.0
complete
Taco
Taco_31252_C
def find_subsequence_score(T, test_cases): """ Determines if there exists a contiguous subsequence of a given word that has a score equal to the given integer K. The function processes multiple test cases. For each test case, the function returns "YES" if a contiguous subsequence with the given sc...
def calculate_char_value(c): return ord(c) - ord('a') + 1 def find_subsequence_score(T, test_cases): results = [] for i in range(T): N, word, K = test_cases[i] prefix_sum = [0] * (N + 1) for j in range(N): prefix_sum[j + 1] = prefix_sum[j] + calculate_char_value...
def test_sample_input_1(): T = 2 test_cases = [(3, "abc", 6), (5, "zyxwv", 15)] expected_output = ["YES", "NO"] assert find_subsequence_score(T, test_cases) == expected_output def test_single_character_word(): T = 1 test_cases = [(1, "a", 1)] expected_output = ["YES"] assert find_subseq...
[ { "docstring": null, "function_declaration": "def calculate_char_value(c):", "function_name": "calculate_char_value", "parameter_list": "(c)" }, { "docstring": null, "function_declaration": "def find_subsequence_score(T, test_cases):", "function_name": "find_subsequence_score", "...
[ 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 character_position_score(char):\n \"\"\"\n Returns the alphabetical score of a lowercase character.\n \"\"\"\n return ord(char) - ord('a') + 1\n\nd...
trial_gpt4o_2
{ "original_instruction": "In an alphabetical string, a character's value is its position in the alphabet, a = 1, b = 2, ..., z = 26. Given a word, calculate the score of this word by summing up the values of all its characters. \nFor example, for the word \"abc\", its score would be 1 + 2 + 3 = 6. \n\nIn this task, ...
0.600456
Taco_31252
C
[ "calculate_char_value", "find_subsequence_score" ]
2
[ [ "find_subsequence_score", "calculate_char_value" ] ]
1
[]
false
[]
false
pytest
false
[]
true
eef8f8415153c2f1359b2c1e259f3ea4661d4e94
518de612f03821d961cbe71a9ff1eb1de551443a
v1.0
complete
Taco
Taco_29622_C
class Book: def __init__(self, id, title, author, year, genres): self.id = id self.title = title self.author = author self.year = year self.genres = genres class Library: def __init__(self): self.books = {} def add_book(self, id, title, author, year, genres)...
class Book: def __init__(self, id, title, author, year, genres): self.id = id self.title = title self.author = author self.year = year self.genres = genres class Library: def __init__(self): self.books = {} def add_book(self, id, title, author, year, genres)...
import pytest from solution import process_commands def test_add_and_search_by_title(): commands = [ "5", "ADD 1 The_Great_Gatsby F._Scott_Fitzgerald 1925 Fiction,Classic", "ADD 2 To_Kill_a_Mockingbird Harper_Lee 1960 Fiction,Classic", "SEARCH TITLE Gatsby", "REMOVE 1", ...
[]
[ 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": "class Book:\n def __init__(self, book_id, title, author, year, genres):\n self.book_id = book_id\n self.title = title\n self.author = autho...
trial_gpt4o_4
{ "original_instruction": "You are working on a software development project that involves managing a library of books. Each book has a unique identifier (ID), a title, an author, a publication year, and a list of genres it belongs to. You are tasked with creating a program that reads a list of books and provides var...
0.462921
Taco_29622
C
[ "format_book", "process_commands", "run_command" ]
3
[ [ "process_commands", "format_book" ], [ "run_command", "process_commands" ] ]
2
[]
false
[ "Book", "Library" ]
true
pytest
true
[]
true
c0c99338f1ba84b9cba5dc546e80923d3c71a69c
384f8d915272f0b884e23721c571315e2ff97b5b
v1.0
complete
Taco
Taco_30858_C
import math from typing import List, Tuple def point_in_circle(px: int, py: int, cx: int, cy: int, r: int) -> bool: """ Determines if the point (px, py) is inside the circle centered at (cx, cy) with radius r. Args: px (int): x-coordinate of the point. py (int): y-coordinate of the point. cx (...
import math def point_in_circle(px, py, cx, cy, r): """ Determines if the point (px, py) is inside the circle centered at (cx, cy) with radius r. """ distance = math.sqrt((px - cx) ** 2 + (py - cy) ** 2) return distance <= r def circles_containing_point(datasets): """ Given a list of datas...
from solution import point_in_circle, circles_containing_point def test_point_in_circle(): assert point_in_circle(5, 5, 1, 1, 3) == False assert point_in_circle(5, 5, 4, 4, 2) == True assert point_in_circle(5, 5, 6, 6, 1) == False assert point_in_circle(7, 9, 8, 10, 5) == True assert point_in_circl...
[ { "docstring": "Determines if the point (px, py) is inside the circle centered at (cx, cy) with radius r.", "function_declaration": "def point_in_circle(px, py, cx, cy, r):", "function_name": "point_in_circle", "parameter_list": "(px, py, cx, cy, r)" }, { "docstring": "Given a list of datase...
[ 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 point_in_circles(px, py, circles):\n count = 0\n for (cx, cy, r) in circles:\n if math.sqrt((px - cx) ** 2 + (py - cy) ** 2) <= r:\...
trial_gpt4o_2
{ "original_instruction": "Problem Statement\n\nYou are working on a software that processes geometric shapes. One of the shapes you need to handle is circles. Given a point in 2D space and a list of circles, determine which circles contain the point within their area.\n\nA circle can be described by its center coord...
0.58516
Taco_30858
C
[ "point_in_circle", "circles_containing_point" ]
2
[ [ "circles_containing_point", "point_in_circle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b17f07744baa00be614a7e1cd1abb110c1559142
297c8a964f38d618051ad4acd482e8703aaf8500
v1.0
complete
Taco
Taco_30904_C
from typing import List, Tuple def sum_unique_integers_in_rows(grid: List[List[int]]) -> List[int]: """ Given a grid (list of lists of integers), returns a list of sums of unique integers for each row. >>> sum_unique_integers_in_rows([[1, 2, 3], [4, 4, 4], [1, 2, 2]]) [6, 4, 3] >>> sum_unique_integ...
def sum_unique_integers_in_rows(grid): """ Given a grid (list of lists of integers), returns a list of sums of unique integers for each row. """ result = [] for row in grid: unique_integers = set(row) row_sum = sum(unique_integers) result.append(row_sum) return result d...
def test_sum_unique_integers_in_rows(): assert sum_unique_integers_in_rows([[1, 2, 3], [4, 4, 4], [1, 2, 2]]) == [6, 4, 3] assert sum_unique_integers_in_rows([[2, 3], [3, 3], [1, 2]]) == [5, 3, 3] assert sum_unique_integers_in_rows([[5], [5, 5, 5], [1, 1, 1, 1]]) == [5, 5, 1] assert sum_unique_integers_...
[ { "docstring": "Given a grid (list of lists of integers), returns a list of sums of unique integers for each row.", "function_declaration": "def sum_unique_integers_in_rows(grid):", "function_name": "sum_unique_integers_in_rows", "parameter_list": "(grid)" }, { "docstring": "Processes multip...
[ 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 sum_unique_integers_in_rows(grids):\n result = []\n \n for grid in grids:\n r, c = grid[0]\n data = grid[1:]\n \n for row ...
trial_gpt4o_4
{ "original_instruction": "You are a software engineer at a company that stores a vast amount of data across multiple databases. Each database is represented as a grid where each cell contains numerical data. The company wants an efficient way to identify and sum up only the unique integers that appear in each row of...
0.642348
Taco_30904
C
[ "sum_unique_integers_in_rows", "process_grids" ]
2
[ [ "process_grids", "sum_unique_integers_in_rows" ] ]
1
[]
false
[]
false
pytest
false
[]
true
923ddb2a7988af125f83448c22e9f568304df898
64d81657ffb2bb0e3d57274dfef7978d02df212b
v1.0
complete
Taco
Taco_30401_C
def sieve_of_eratosthenes(max_num): """ Generates a list to determine if numbers up to max_num are prime. """ pass def count_twin_primes(L, R): """ Counts the twin prime pairs in the range [L, R] """ pass # Unit tests def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(1...
def sieve_of_eratosthenes(max_num): """ Generates a list to determine if numbers up to max_num are prime. """ is_prime = [True] * (max_num + 1) is_prime[0] = is_prime[1] = False p = 2 while (p * p <= max_num): if (is_prime[p] == True): for i in range(p * p, max_num + 1, p...
def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(10) == [False, False, True, True, False, True, False, True, False, False, False] def test_count_twin_primes_example1(): assert count_twin_primes(3, 13) == 3 def test_count_twin_primes_example2(): assert count_twin_primes(10, 19) == 2 def test...
[ { "docstring": "Generates a list to determine if numbers up to max_num are prime.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Counts the twin prime pairs in the range [L, R]", ...
[ 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 sieve_of_eratosthenes(max_num):\n \"\"\"\n Generates a list to determine if numbers up to max_num are prime.\n \"\"\"\n is_prime = [True] * (max_nu...
trial_gpt4o_0
{ "original_instruction": "Chef is experimenting with prime numbers and their interesting properties. Today, he is fascinated by the concept of twin primes. A pair of prime numbers (p1, p2) is called twin primes if p2 = p1 + 2. He seeks your help to determine the number of twin prime pairs (p1, p2) such that both p1 ...
0.573225
Taco_30401
C
[ "sieve_of_eratosthenes", "count_twin_primes" ]
2
[ [ "count_twin_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
bf327234cafdac3baaad193d238051736e874242
62df11222069ccec88f89a251cc8889a85061760
v1.0
complete
Taco
Taco_31387_C
def restore_binary_tree(N: int, inorder: List[int], preorder: List[int]) -> List[int]: """ Restore the binary tree from in-order and pre-order traversals and return the post-order traversal. Args: N (int): Number of nodes in the binary tree. inorder (List[int]): In-order traversal of the binary tree. ...
def build_tree(inorder, preorder): if not inorder or not preorder: return None root_val = preorder.pop(0) root_index = inorder.index(root_val) root = TreeNode(root_val) root.left = build_tree(inorder[:root_index], preorder) root.right = build_tree(inorder[root_index + 1:], preo...
from solution import restore_binary_tree def test_restore_binary_tree_one_node(): N = 1 inorder = [1] preorder = [1] assert restore_binary_tree(N, inorder, preorder) == [1] def test_restore_binary_tree_example(): N = 5 inorder = [4, 2, 5, 1, 3] preorder = [1, 2, 4, 5, 3] assert restore...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(inorder, preorde...
trial_gpt4o_2
{ "original_instruction": "Binary Tree Restoration\n\nAlex is given the task of restoring a binary tree from its in-order and pre-order traversals. As an expert coder, you have been asked to assist Alex in writing a program to reconstruct the binary tree from these traversals and then output the post-order traversal ...
0.530527
Taco_31387
C
[ "build_tree", "postorder_traversal", "restore_binary_tree" ]
3
[ [ "restore_binary_tree", "build_tree" ], [ "restore_binary_tree", "postorder_traversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
154c062c11f3f273df34149959f87a26310a73c1
8c92bcfd9ed74d91d2c7e8e5faa1180aedeacccd
v1.0
complete
Taco
Taco_31129_C
import heapq from typing import List, Tuple def dijkstra(n: int, edges: List[List[Tuple[int, int]]], start: int) -> List[int]: # Implementation of the Dijkstra algorithm to find shortest path from start node pass def minimum_magical_difficulty(n: int, m: int, edges_list: List[Tuple[int, int, int]]) -> int: ...
import heapq def dijkstra(n, edges, start): distances = [float('inf')] * n distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq.heappop(priority_queue) if current_distance > distances[current_node]: con...
def test_first_example(): n = 5 m = 6 edges_list = [ (1, 2, 2), (1, 3, 2), (2, 4, 2), (3, 4, 2), (4, 5, 2), (2, 3, 1) ] assert minimum_magical_difficulty(n, m, edges_list) == 6 def test_second_example(): n = 4 m = 4 edges_list = [ ...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start):", "function_name": "dijkstra", "parameter_list": "(n, edges, start)" }, { "docstring": null, "function_declaration": "def minimum_magical_difficulty(n, m, edges_list):", "function_name": "minimum_magical_dif...
[ 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 minimum_magical_difficulty(n, m, edges):\n from collections import defaultdict\n import heapq\n\n graph = defaultdict(list)\n for u...
trial_gpt4o_1
{ "original_instruction": "In an ancient kingdom, there exists a mysterious ritual that involves magic stones and pathways. The kingdom is represented as a series of numbered stones, and pathways between them. There is a unique stone from which the magic must begin, and one special stone where the ritual is completed...
0.618921
Taco_31129
C
[ "dijkstra", "minimum_magical_difficulty" ]
2
[ [ "minimum_magical_difficulty", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
84eea47b2ea74f472e8771e5bfcccaf5de6030d5
1cc54dc25b4b10bae0a5a7d30782db0c78378d45
v1.0
complete
Taco
Taco_31345_C
def findNthNumber(N: int) -> int: """ Given an integer N, generate a sequence of numbers such that the next number in the sequence is the sum of the squares of the digits of the current number. Returns the N-th number in this sequence starting with 1. >>> findNthNumber(3) 1 >>> findNthNumber(5)...
def sum_of_squares_of_digits(n): """ Returns the sum of the squares of the digits of 'n'. """ return sum(int(digit) ** 2 for digit in str(n)) def findNthNumber(N): """ Returns the N-th number in the sequence starting with 1 where the next number in the sequence is the sum of the squares of ...
from solution import findNthNumber def test_findNthNumber_case1(): assert findNthNumber(3) == 1 def test_findNthNumber_case2(): assert findNthNumber(5) == 1 def test_findNthNumber_case3(): assert findNthNumber(10) == 1 def test_findNthNumber_case4(): assert findNthNumber(1) == 1 def test_findNthNum...
[ { "docstring": "Returns the sum of the squares of the digits of 'n'.", "function_declaration": "def sum_of_squares_of_digits(n):", "function_name": "sum_of_squares_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the N-th number in the sequence starting with 1\nwhere the next n...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_squares_of_digits(num):\n \"\"\"\n Helper function to compute the sum of the squares of the digits of a given number.\n \"\"\"\n return sum(...
trial_gpt4o_2
{ "original_instruction": "Given an integer `N`, generate a sequence of numbers such that the next number in the sequence is the sum of the squares of the digits of the current number. Return the N-th number in this sequence starting with 1.\n\nExample 1:\nInput: N = 3\nOutput: 10\nExplanation: Starting from 1, the s...
0.679883
Taco_31345
C
[ "sum_of_squares_of_digits", "findNthNumber" ]
2
[ [ "findNthNumber", "sum_of_squares_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d797f779dec9f6dd8fc1c07cb555865041a2e263
ac7de1d1d032ed8a714188c23fbbda42cd2767a7
v1.0
complete
Taco
Taco_31524_C
def can_form_palindrome(s: str) -> bool: """ Determines if it's possible to rearrange the characters in the string `s` to form a palindrome. >>> can_form_palindrome("civic") True >>> can_form_palindrome("ivicc") True >>> can_form_palindrome("google") False >>> can_form_palindrome("aabbcc") True ...
def can_form_palindrome(s): """ Determines if it's possible to rearrange the characters in the string `s` to form a palindrome. """ from collections import Counter char_counts = Counter(s) odd_count = sum(1 for count in char_counts.values() if count % 2 != 0) return odd_count <= 1 ...
from solution import can_form_palindrome, solve def test_can_form_palindrome(): assert can_form_palindrome("civic") == True, "Test Case 1 Failed" assert can_form_palindrome("ivicc") == True, "Test Case 2 Failed" assert can_form_palindrome("google") == False, "Test Case 3 Failed" assert can_form_palindr...
[ { "docstring": "Determines if it's possible to rearrange the characters in the string `s` to form a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def so...
[ 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 can_form_palindrome(s):\n \"\"\"\n Determines if the characters in string s can be rearranged to form a palindrome.\n \"\"\"\n from collections imp...
trial_gpt4o_2
{ "original_instruction": "Given a string s, determine if it is possible to rearrange the characters in the string to form a palindrome. \n\nInput\nThe first line of input contains an integer T, denoting the number of test cases.\nEach of the next T lines contains one string s.\n\nOutput\nPrint T lines, either \"POSS...
0.785961
Taco_31524
C
[ "can_form_palindrome", "solve" ]
2
[ [ "solve", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
534c774cc4770c492bf1e7f948ea58f53c1b04ec
b2e641fee548ca67f2de173536f0b9c7c3b7455a
v1.0
complete
Taco
Taco_30739_C
def encode_rle(s: str) -> str: """ Encode a string using Run-Length Encoding (RLE). >>> encode_rle("AAAABBBCCDAA") '4A3B2C1D2A' >>> encode_rle("AAAAAAAAAAAAAA") '14A' """ pass def decode_rle(s: str) -> str: """ Decode a Run-Length Encoded (RLE) string. >>> decode_rle("4A3B2C1D2A") ...
def encode_rle(s): if not s: return "" encoded = [] prev_char = s[0] count = 1 for char in s[1:]: if char == prev_char: count += 1 else: encoded.append(f"{count}{prev_char}") prev_char = char count = 1 encoded...
def test_encode_rle(): assert encode_rle("AAAABBBCCDAA") == "4A3B2C1D2A" assert encode_rle("AAAAAAAAAAAAAA") == "14A" assert encode_rle("AABBA") == "2A2B1A" assert encode_rle("ABB") == "1A2B" assert encode_rle("") == "" def test_decode_rle(): assert decode_rle("4A3B2C1D2A") == "AAAABBBCCDAA" ...
[ { "docstring": null, "function_declaration": "def encode_rle(s):", "function_name": "encode_rle", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def decode_rle(s):", "function_name": "decode_rle", "parameter_list": "(s)" }, { "docstring": null, ...
[ 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 rle_encode(input_str):\n \"\"\"\n Encodes the input string using Run-Length Encoding (RLE).\n \"\"\"\n if not input_str:\n return \"\"\n ...
trial_gpt4o_2
{ "original_instruction": "You are working on a data compression algorithm and need to implement a simple version of the Run-Length Encoding (RLE) algorithm. \n\nRun-Length Encoding is a very basic form of data compression in which consecutive occurrences of the same data value are stored as a single data value and c...
0.684248
Taco_30739
C
[ "encode_rle", "decode_rle", "run_rle" ]
3
[ [ "run_rle", "decode_rle" ], [ "run_rle", "encode_rle" ] ]
2
[]
false
[]
false
pytest
false
[]
true
92bef76b90dbf6f5d372cd2a52e801686610af70
e9be488386e5ea7d953992c3a0cfdf66d5e0de7d
v1.0
complete
Taco
Taco_31408_C
from typing import List def transform_to_k_distance_apart(n: int, k: int, permutation: List[int]) -> List[int]: """ Transforms the given permutation into a new permutation where for every pair of elements (i, j), where i < j and j - i = k (k-distance apart), the value of the element at position j is strict...
def transform_to_k_distance_apart(n, k, permutation): """ Transforms the given permutation into a new permutation where for every pair of elements (i, j), where i < j and j - i = k (k-distance apart), the value of the element at position j is strictly greater than the value of the element at position i....
def test_transform_to_k_distance_apart_case_1(): assert transform_to_k_distance_apart_from_input("5 2\n1 3 2 5 4") == "1 3 2 5 4" def test_transform_to_k_distance_apart_case_2(): assert transform_to_k_distance_apart_from_input("4 3\n4 2 3 1") == "-1" def test_transform_to_k_distance_apart_case_3(): assert...
[ { "docstring": "Transforms the given permutation into a new permutation where for every pair of elements (i, j),\nwhere i < j and j - i = k (k-distance apart), the value of the element at position j is strictly\ngreater than the value of the element at position i. If it is not possible, returns -1.", "funct...
[ 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 k_distance_apart(n, k, perm):\n \"\"\"\n Takes an integer n (length of permutation), an integer k (distance requirement),\n and a list perm (the permu...
trial_gpt4o_1
{ "original_instruction": "#### Permutation to K-Distance Apart\n\nYou are given a permutation of integers from 1 to n inclusive. Your task is to transform the given permutation into a new permutation where for every pair of elements (i, j), where i < j and j - i = k (k-distance apart), the value of the element at po...
0.668616
Taco_31408
C
[ "transform_to_k_distance_apart", "parse_input", "transform_to_k_distance_apart_from_input" ]
3
[ [ "transform_to_k_distance_apart_from_input", "parse_input" ], [ "transform_to_k_distance_apart_from_input", "transform_to_k_distance_apart" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
5b574ce0fef018ac36fa01a127f41fe076ad4214
1950ac557b4f6b26b06a575158a8329f277663f6
v1.0
complete
Taco
Taco_31019_C
from typing import List def filter_primes(nums: List[int]) -> List[int]: """ Returns a list of prime numbers from the input list of integers. >>> filter_primes([2, 4, 5, 6, 9, 11, 13]) [2, 5, 11, 13] >>> filter_primes([-3, 0, 1, 4, 7, 8]) [7] """
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: retur...
from solution import filter_primes def test_filter_primes_mix_numbers(): assert filter_primes([2, 4, 5, 6, 9, 11, 13]) == [2, 5, 11, 13] def test_filter_primes_negative_and_zero(): assert filter_primes([-3, 0, 1, 4, 7, 8]) == [7] def test_filter_primes_all_non_primes(): assert filter_primes([0, 4, 6, 8, ...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list of integers.", "function_declaration": "def filt...
[ 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 prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 ...
trial_gpt4o_2
{ "original_instruction": "Your task is to write a function that takes in a list of integers and returns a new list containing only the prime numbers from the input list. Prime numbers are numbers greater than 1 that have no divisors other than 1 and themselves.\n\n### Detailed Requirements\n\n1. **Function Name**: f...
0.679388
Taco_31019
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3eb550ddb8654e296e4c166a986138a816c43dcb
8d29399e3db4f8537dfcc4d239f58393a3d4528b
v1.0
complete
Taco
Taco_31846_C
def is_palindrome_permutation(s: str) -> bool: """ Determines if the given string s is a valid palindrome permutation. :param s: A string of lowercase English letters. :return: True if the string is a valid palindrome permutation, otherwise False. >>> is_palindrome_permutation("civic") Tru...
def is_palindrome_permutation(s): """ Determines if the given string s is a valid palindrome permutation. :param s: A string of lowercase English letters. :return: True if the string is a valid palindrome permutation, otherwise False. """ from collections import Counter # Count the...
from solution import is_palindrome_permutation, solve def test_is_palindrome_permutation(): assert is_palindrome_permutation("civic") == True assert is_palindrome_permutation("ivicc") == True assert is_palindrome_permutation("hello") == False assert is_palindrome_permutation("a") == True assert is_...
[ { "docstring": "Determines if the given string s is a valid palindrome permutation.\n\n:param s: A string of lowercase English letters.\n:return: True if the string is a valid palindrome permutation, otherwise False.", "function_declaration": "def is_palindrome_permutation(s):", "function_name": "is_pal...
[ 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_permutation(s):\n \"\"\"\n Determines if the input string can be permuted to form a palindrome.\n \"\"\"\n from collections import Co...
trial_gpt4o_2
{ "original_instruction": "Write a program that determines if a string is a valid palindrome permutation. \n\nA palindrome permutation is defined as a string that, when any permutation is formed from it, can be a palindrome. A palindrome is a word that reads the same backward as forward.\n\n-----Input:-----\n- The fi...
0.718913
Taco_31846
C
[ "is_palindrome_permutation", "solve" ]
2
[ [ "solve", "is_palindrome_permutation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c4613de81e88a7e7edf33044185354bc67d07c5b
fbd804334811b5996838fe3e16220e17210343f9
v1.0
complete
Taco
Taco_30960_C
def max_total_significance(N: int, M: int, heights: List[List[int]]) -> int: """ Determine the maximum total significance value David can achieve in one trip. >>> max_total_significance(3, 3, [ [1, 2, 1], [3, 4, 3], [1, 8, 1] ]) 8 >>> max_total_significance(3, 3, [ [1...
def is_peak(grid, x, y): """ Check if a cell (x, y) is a peak in the grid. """ n = len(grid) m = len(grid[0]) current_height = grid[x][y] directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] for dx, dy in directions: nx, ny = x + dx, y + dy if 0 <= nx < n and 0 <= ny < m ...
import pytest from solution import max_total_significance def test_basic_example(): heights = [ [1, 2, 1], [3, 4, 3], [1, 8, 1] ] assert max_total_significance(3, 3, heights) == 8 def test_single_peak(): heights = [ [1, 3, 1], [2, 4, 2], [1, 1, 1] ] ...
[ { "docstring": "Check if a cell (x, y) is a peak in the grid.", "function_declaration": "def is_peak(grid, x, y):", "function_name": "is_peak", "parameter_list": "(grid, x, y)" }, { "docstring": "Find all peaks in the grid.", "function_declaration": "def find_all_peaks(grid):", "func...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_peaks(grid, n, m):\n peaks = []\n for i in range(n):\n for j in range(m):\n is_peak = True\n for di, dj in [(-1, 0), (1...
trial_gpt4o_9
{ "original_instruction": "David loves to go on hiking adventures and he always takes his drone with him to capture beautiful landscapes. The drone has a limited battery capacity, and David wants to maximize the number of peaks (highest points in their respective areas) it can record in one trip. Each peak has a sign...
0.569365
Taco_30960
C
[ "is_peak", "find_all_peaks", "max_total_significance" ]
3
[ [ "find_all_peaks", "is_peak" ], [ "max_total_significance", "find_all_peaks" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7c5ad6155de45e2ad4c3a8982585e4d9e503fd7f
24a96af48646e0bd0763f5fa45b5a04e34ce3f4d
v1.0
complete
Taco
Taco_31288_C
def find_start_end_positions(grid): """ Find the positions of 'S' and 'E' in the grid. """ # Implementation here def is_valid_move(grid, direction, r, c): """ Check if a move in the given direction is valid. """ # Implementation here def find_path(grid, start, end): """ Use DFS...
def find_start_end_positions(grid): """ Find the positions of 'S' and 'E' in the grid. """ start = end = None for i, row in enumerate(grid): for j, char in enumerate(row): if char == 'S': start = (i, j) elif char == 'E': end = (i, j) ...
def test_case_1(): grid = [["#","#","#","#","#"], ["#","S",".",".","#"], ["#",".","#","E","#"], ["#",".","#","#","#"], ["#","#","#","#","#"]] assert is_valid_maze_path(grid) == True def test_case_2(): grid = [["#","#","#","#","#"], ["#","S",".","#...
[ { "docstring": "Find the positions of 'S' and 'E' in the grid.", "function_declaration": "def find_start_end_positions(grid):", "function_name": "find_start_end_positions", "parameter_list": "(grid)" }, { "docstring": "Check if a move in the given direction is valid.", "function_declarat...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def has_valid_path(grid):\n from collections import deque\n\n directions = {\n 'up': (-1, 0),\n 'down': (1, 0),\n 'left': (0, -1),\n ...
trial_gpt4o_5
{ "original_instruction": "Given an m x n grid of characters representing a maze, your task is to determine if there is a valid path from the player's starting position 'S' to an exit 'E'. The maze contains walls represented by '#', free spaces represented by '.', and possibly some one-way doors represented by '^', '...
0.649271
Taco_31288
C
[ "find_start_end_positions", "is_valid_move", "find_path", "is_valid_maze_path" ]
4
[ [ "find_path", "is_valid_move" ], [ "is_valid_maze_path", "find_path" ], [ "is_valid_maze_path", "find_start_end_positions" ] ]
3
[]
false
[]
false
pytest
false
[]
true
7579a44314a2f435801177d043114b9d5d6bbf5e
3a559cd6d96b7276481a81210a1395279d79248a
v1.0
complete
Taco
Taco_32036_C
from typing import List, Tuple def minimum_barriers(n: int, m: int, rivers: List[Tuple[int, int]]) -> List[int]: """ Determine the minimum number of barriers required to isolate each lake in the village. >>> minimum_barriers(4, 4, [(1, 2), (2, 3), (3, 4), (1, 3)]) [1, 1, 1, 0] >>> minimum_barriers(5, 5...
from collections import defaultdict, deque def find_minimum_barriers(n, m, rivers): def topological_sort(): in_degree = [0] * (n + 1) for u, v in rivers: graph[u].append(v) in_degree[v] += 1 zero_in_degree = deque([i for i in range(1, n + 1) if in_degree[i] ...
def test_minimum_barriers(): assert minimum_barriers(4, 4, [(1, 2), (2, 3), (3, 4), (1, 3)]) == [1, 1, 1, 0] assert minimum_barriers(5, 5, [(1, 2), (2, 3), (3, 4), (4, 5), (1, 4)]) == [1, 1, 1, 1, 0] assert minimum_barriers(3, 2, [(1, 2), (2, 3)]) == [1, 1, 0] assert minimum_barriers(6, 6, [(1, 2), (2, ...
[ { "docstring": null, "function_declaration": "def find_minimum_barriers(n, m, rivers):", "function_name": "find_minimum_barriers", "parameter_list": "(n, m, rivers)" }, { "docstring": null, "function_declaration": "def minimum_barriers(n, m, rivers):", "function_name": "minimum_barri...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef min_barriers(n, m, rivers):\n def topo_sort(vertices, edges):\n graph = defaultdict(list)\n in_d...
trial_gpt4o_9
{ "original_instruction": "In a small village, there is a unique river network consisting of several rivers and lakes. The rivers are in the form of directed edges connecting pairs of lakes. Each lake is assigned a numerical index from $1$ to $n$, and the lakes and rivers form a directed acyclic graph (DAG). \n\nThe ...
0.589986
Taco_32036
C
[ "find_minimum_barriers", "minimum_barriers" ]
2
[ [ "minimum_barriers", "find_minimum_barriers" ] ]
1
[]
false
[]
false
pytest
false
[]
true
82b4bc029dd5794070ce8d2731625ff06a8ca895
bef9279f5f9832f86e9e8e91d5b8e9e892879596
v1.0
complete
Taco
Taco_31514_C
def check_library(n: int, existing_data: List[str], k: int, new_books_data: List[str]) -> str: """ Determine if it is possible to add new book categories to the library without violating the rules. >>> check_library(4, ["10 9 8 7", "5 4 3", "12 11", "20 15 10 5"], 3, ["6", "2", "13"]) 'YES' >>> check_li...
def can_add_books(existing_categories, new_books): existing_numbers = set() # Extract all category and subcategory numbers from existing categories for category in existing_categories: for number in category: existing_numbers.add(number) # Check each new book's category number ...
def test_example_1(): n = 4 existing_data = [ "10 9 8 7", "5 4 3", "12 11", "20 15 10 5" ] k = 3 new_books_data = ["6", "2", "13"] assert check_library(n, existing_data, k, new_books_data) == "YES" def test_example_2(): n = 3 existing_data = [ ...
[ { "docstring": null, "function_declaration": "def can_add_books(existing_categories, new_books):", "function_name": "can_add_books", "parameter_list": "(existing_categories, new_books)" }, { "docstring": null, "function_declaration": "def check_library(n, existing_data, k, new_books_data...
[ 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 can_add_books(existing_categories, new_books):\n existing_set = set()\n for category in existing_categories:\n existing_set.update(category)\n\n ...
trial_gpt4o_2
{ "original_instruction": "The Grand Library is a vast collection of rare and ancient books. The library uses a unique system of categories and subcategories to organize its books. Each category is represented by a unique number, and each subcategory is a strictly descending sequence of numbers connected to a parent ...
0.474048
Taco_31514
C
[ "can_add_books", "check_library" ]
2
[ [ "check_library", "can_add_books" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a4e8adfc3a131e81a6cae70696636636e393dbbd
94acd046dc874e9baeb5deead8a7ab76db3f0221
v1.0
complete
Taco
Taco_31856_C
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 += 6 r...
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 += 6 re...
import pytest from solution import solve_game, div_game_winner def test_prime_factors(): assert prime_factors(18) == [2, 3, 3] assert prime_factors(10) == [2, 5] assert prime_factors(17) == [17] def test_div_game_winner(): assert div_game_winner(18) == "YES" assert div_game_winner(10) == "NO" ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to get the prime factors of a number.", "function_declaration": "def prime_factors(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": "def compute_prime_factors(n):\n \"\"\"Compute the prime factors of a number n.\"\"\"\n i = 2\n factors = set()\n while i * i <= n:\n if n % i:\n...
trial_gpt4o_1
{ "original_instruction": "Paul and Jenny are playing a number transformation game. Initially, a positive integer N is written on a blackboard. The players take turns, starting with Paul. On his or her turn, a player can replace N with N divided by any of its prime factors. The first player to reduce the number to 1 ...
0.672166
Taco_31856
C
[ "is_prime", "prime_factors", "div_game_winner", "solve_game" ]
4
[ [ "div_game_winner", "prime_factors" ], [ "solve_game", "div_game_winner" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9e28828ebc851551b7e4501acafdc79f69f27491
22f6507589b694214ef235ac7f39deadbb912a8a
v1.0
complete
Taco
Taco_31323_C
from typing import List, Tuple from collections import defaultdict, deque def max_communication_efficiency(n: int, connections: List[Tuple[int, int]]) -> int: """ Calculate the maximum communication efficiency between departments. The function takes the number of departments and a list of direct communications...
import sys from collections import defaultdict, deque def find_furthest_node_and_distance(n, edges): # Create a graph using adjacency list graph = defaultdict(list) for a, b in edges: graph[a].append(b) graph[b].append(a) # Function to perform BFS and return the furthest node and i...
from solution import max_communication_efficiency def test_example_case(): assert max_communication_efficiency(5, [(1, 2), (1, 3), (3, 4), (3, 5)]) == 3 def test_line_structure(): assert max_communication_efficiency(4, [(1, 2), (2, 3), (3, 4)]) == 3 def test_star_structure(): assert max_communication_eff...
[ { "docstring": null, "function_declaration": "def find_furthest_node_and_distance(n, edges):", "function_name": "find_furthest_node_and_distance", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def max_communication_efficiency(n, connections):", "func...
[ 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 collections import deque\n\ndef bfs_furthest_node(graph, start):\n \"\"\"\n Performs BFS to find the furthest node and its distance from the start node....
trial_gpt4o_1
{ "original_instruction": "A large company wants to conduct an internal survey to analyze the communication efficiency between different departments. The company has n departments numbered from 1 to n. Each department communicates directly with specific other departments, and this communication is bidirectional. The ...
0.546258
Taco_31323
C
[ "find_furthest_node_and_distance", "max_communication_efficiency" ]
2
[ [ "max_communication_efficiency", "find_furthest_node_and_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
080f96c839e8e0a99f898dca6c21f27ba17e1de6
9fb03f234c6b86c7e0c5e62cce745b69e1ab9a0b
v1.0
complete
Taco
Taco_31975_C
def has_path_sum(root, target_sum): """ Given a binary tree and a target sum, determines if there is a path from root to any leaf such that the sum of the node values equals the target sum. """ pass def create_tree(node_values): """ Creates a binary tree from a list of node values given in...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def has_path_sum(root, target_sum): """ Given a binary tree and a target sum, determines if there is a path from root to any leaf such that the sum of the node values equals the target su...
def test_solution_case1(): n = 5 S = 6 node_values = [1, 2, 3, 4, 5] # Expected output: YES solution(n, S, node_values) def test_solution_case2(): n = 3 S = 5 node_values = [1, 2, 3] # Expected output: NO solution(n, S, node_values) def test_solution_case3(): n = 7 ...
[]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.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=0):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(node_values):\...
trial_gpt4o_7
{ "original_instruction": "You are given a binary tree with $n$ nodes. Each node has an integer value associated with it. Your task is to determine whether the tree contains a path from the root to any leaf such that the sum of the values of the nodes along this path is equal to a given target sum $S$.\n\n-----Input-...
0.606777
Taco_31975
C
[ "has_path_sum", "create_tree", "solution" ]
3
[ [ "solution", "create_tree" ], [ "solution", "has_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
a7b1bf6794dd27d76e5b9afcfb3cd322893b7b02
c74c38ed2e5760e88e8cf3bb8c4daf27a107ab91
v1.0
complete
Taco
Taco_31802_C
def bfs_distance(start_node, adj_list, N): """ Perform a breadth-first search to find the shortest path from start_node to all other nodes. Returns the maximum distance found. """ pass def find_diameter(N, edges): """ Given the number of rooms N and edges, find the diameter of the maze. ...
from collections import deque def bfs_distance(start_node, adj_list, N): """ Perform a breadth-first search to find the shortest path from start_node to all other nodes. Returns the maximum distance found. """ distances = [-1] * (N + 1) distances[start_node] = 0 queue = deque([start_node]) ...
def test_sample_cases(): input_data = "2\n5 5\n1 2\n1 3\n2 4\n3 4\n4 5\n4 4\n1 2\n2 3\n3 4\n4 1" expected_output = "3\n2" assert main(input_data) == expected_output def test_singe_case(): input_data = "1\n3 2\n1 2\n2 3" expected_output = "2" assert main(input_data) == expected_output def test_...
[ { "docstring": "Perform a breadth-first search to find the shortest path from start_node\nto all other nodes. Returns the maximum distance found.", "function_declaration": "def bfs_distance(start_node, adj_list, N):", "function_name": "bfs_distance", "parameter_list": "(start_node, adj_list, N)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef bfs(graph, start, n):\n distances = [-1] * n\n distances[start] = 0\n queue = deque([start])\n \n while queue:\...
trial_gpt4o_1
{ "original_instruction": "Alex is designing a complex maze game that has numerous rooms interconnected by corridors. Each room is marked with a number from 1 to N, and each corridor connects two distinct rooms. Alex must ensure that it's possible to travel from any room to any other room. However, he also wants to m...
0.565983
Taco_31802
C
[ "bfs_distance", "find_diameter", "process_input", "main" ]
4
[ [ "find_diameter", "bfs_distance" ], [ "process_input", "find_diameter" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
1f49f4d501beb639577751b19296685ede2d4598
1e9db513de4cbb8412302c9d19fcea434b34b806
v1.0
complete
Taco
Taco_31600_C
def is_interesting(n: int) -> bool: """ Returns True if the number n does not contain the digit '7' """ pass def find_nearest_interesting(k: int) -> int: """ Given a positive integer k ($1 \le k \le 10000$), return the nearest larger or equal interesting number to k. An interesting number d...
def is_interesting(n): """ Returns True if the number n does not contain the digit '7' """ return '7' not in str(n) def find_nearest_interesting(k): """ Returns the nearest larger or equal interesting number to k """ while not is_interesting(k): k += 1 return k
from solution import find_nearest_interesting def test_nearest_interesting_from_70(): assert find_nearest_interesting(70) == 80 def test_nearest_interesting_from_123(): assert find_nearest_interesting(123) == 123 def test_nearest_interesting_from_678(): assert find_nearest_interesting(678) == 680 def te...
[ { "docstring": "Returns True if the number n does not contain the digit '7'", "function_declaration": "def is_interesting(n):", "function_name": "is_interesting", "parameter_list": "(n)" }, { "docstring": "Returns the nearest larger or equal interesting number to k", "function_declaratio...
[ 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_interesting_number(k):\n \"\"\"\n Finds the smallest integer n >= k such that n does not contain the digit '7'.\n \n :param k: integer, the st...
trial_gpt4o_2
{ "original_instruction": "Polycarp is fascinated by numbers and their properties. One day, he discovered a new kind of interesting number. He defines a positive integer as interesting if it does not contain the digit '7' in its decimal representation. For instance, numbers like 48, 56, and 123 are interesting, but n...
0.629504
Taco_31600
C
[ "is_interesting", "find_nearest_interesting" ]
2
[ [ "find_nearest_interesting", "is_interesting" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7e2385c7a380e48cd5d5367ec302de96f1fed042
2f00c2eaffe803ccfc98f1e83129d798b570c62b
v1.0
complete
Taco
Taco_30846_C
def minimumMoves(x1: int, y1: int, x2: int, y2: int) -> int: """ Determine the minimum number of moves required for a knight to move from its starting position (x1, y1) to a target position (x2, y2) on a standard 8x8 chessboard. A knight moves in an "L" shape: two squares in a horizontal or vertical dir...
from collections import deque def is_valid_position(x, y): """ Check if the position (x, y) is within the bounds of a standard 8x8 chessboard. """ return 1 <= x <= 8 and 1 <= y <= 8 def minimumMoves(x1: int, y1: int, x2: int, y2: int) -> int: """ Calculates the minimum number of moves required...
from solution import minimumMoves def test_minimumMoves_start_equals_target(): assert minimumMoves(1, 1, 1, 1) == 0 assert minimumMoves(4, 4, 4, 4) == 0 def test_minimumMoves_simple_case(): assert minimumMoves(1, 1, 2, 3) == 1 assert minimumMoves(1, 1, 3, 2) == 1 def test_minimumMoves_general_cases()...
[ { "docstring": "Check if the position (x, y) is within the bounds of a standard 8x8 chessboard.", "function_declaration": "def is_valid_position(x, y):", "function_name": "is_valid_position", "parameter_list": "(x, y)" }, { "docstring": "Calculates the minimum number of moves required for a ...
[ 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 collections import deque\n\ndef minimumMoves(x1: int, y1: int, x2: int, y2: int) -> int:\n \"\"\"\n Determines the minimum number of moves required for ...
trial_gpt4o_2
{ "original_instruction": "# Objective\n\nWrite a function `minimumMoves` to determine the minimum number of moves required for a knight to move from its starting position `(x1, y1)` to a target position `(x2, y2)` on a standard 8x8 chessboard. A knight moves in an \"L\" shape: two squares in a horizontal or vertical...
0.706731
Taco_30846
C
[ "is_valid_position", "minimumMoves" ]
2
[ [ "minimumMoves", "is_valid_position" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6abda628af8dcbd89fca5c61122cfa081bd912c4
ef0d3207ee62e2d83b0505a90628ff7b81750113
v1.0
complete
Taco
Taco_31828_C
def find_smallest_number(X: int, S: int) -> int: """ Finds the smallest number greater than or equal to X that has a sum of digits equal to S. >>> find_smallest_number(100, 5) == 104 >>> find_smallest_number(10, 9) == 18 >>> find_smallest_number(1, 1) == 1 >>> find_smallest_number(15, 6) == 15 >...
def sum_of_digits(n): """ Returns the sum of digits of a given number n. """ return sum(int(digit) for digit in str(n)) def find_smallest_number(X, S): """ Finds the smallest number greater than or equal to X that has a sum of digits equal to S. """ current_number = X while True: ...
from solution import find_smallest_number def test_sample_inputs(): assert find_smallest_number(100, 5) == 104 assert find_smallest_number(10, 9) == 18 def test_edge_cases(): # Edge case where X is the smallest possible value assert find_smallest_number(1, 1) == 1 # Edge case where X itself has th...
[ { "docstring": "Returns the sum of digits of a given number n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Finds the smallest number greater than or equal to X that has a sum of digits equal to S.", "func...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_smallest_number_with_sum(X, S):\n \"\"\"\n Finds the smallest number greater than or equal to X that has a sum of digits equal to S.\n \"\"\"\n ...
trial_gpt4o_9
{ "original_instruction": "Anna loves playing with numbers. She especially enjoys working with numbers that have interesting properties. Recently, she has been fascinated by numbers whose sum of digits is equal to a specific value, S. She wants to find the smallest number that is greater than or equal to a given numb...
0.725823
Taco_31828
C
[ "sum_of_digits", "find_smallest_number" ]
2
[ [ "find_smallest_number", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
11e064998bed9cc651725082c338d5661621c951
fd5f63dbef5a0c02fe53ca6a17f0aec16ac74dad
v1.0
complete
Taco
Taco_32110_C
def explore_city(n: int, m: int, grid_lines: List[str]) -> str: """ Determine whether the tourist can reach the destination 'E' starting from 'S'. Arguments: n -- the number of rows in the grid m -- the number of columns in the grid grid_lines -- a list of strings representing the city grid Re...
def can_reach_destination(grid, n, m): from collections import deque # Finding the start 'S' and end 'E' points start = None end = None for i in range(n): for j in range(m): if grid[i][j] == 'S': start = (i, j) elif grid[i][j] == 'E': ...
def test_example_1(): n = 4 m = 4 grid_lines = [ ".S..", "..#.", "..#E", "...." ] assert explore_city(n, m, grid_lines) == "YES" def test_example_2(): n = 3 m = 3 grid_lines = [ "S##", ".#.", ".##E" ] assert explore_city(n,...
[ { "docstring": null, "function_declaration": "def can_reach_destination(grid, n, m):", "function_name": "can_reach_destination", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def explore_city(n, m, grid_lines):", "function_name": "explore_city", ...
[ 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 can_reach_destination(n, m, grid):\n from collections import deque\n \n # Find the starting position 'S'\n for r in range(n):\n for c in ran...
trial_gpt4o_1
{ "original_instruction": "A tourist is exploring a new city and needs help navigating the city streets. The city is represented as a grid of characters where '.' represents an open path the tourist can walk on, '#' represents a building the tourist cannot go through, 'S' represents the starting point of the tourist,...
0.552077
Taco_32110
C
[ "can_reach_destination", "explore_city" ]
2
[ [ "explore_city", "can_reach_destination" ] ]
1
[]
false
[]
false
pytest
false
[]
true
975a787aa290010265a7995d0ab773c457681b4f
93194f80aafcb1eeb6832dad2df4de453dea35f9
v1.0
complete
Taco
Taco_32048_C
from typing import List, Tuple def can_have_substring(sentence: str, a: str, b: str) -> bool: """ Function to determine if the cryptic sentence can be decrypted to contain the given substring. >>> can_have_substring("he_lo_wor_d", "h", "e") == True >>> can_have_substring("_hell_cat_", "h", "e") == True ...
def can_have_substring(sentence, a, b): """ Function to determine if the cryptic sentence can be decrypted to contain the given substring. """ target = a + b n = len(sentence) len_target = len(target) for i in range(n - len_target + 1): if all(x == y or x == '_' for x, y in zip(...
from solution import check_sentences def test_can_have_substring(): assert can_have_substring("he_lo_wor_d", "h", "e") == True assert can_have_substring("_hell_cat_", "h", "e") == True assert can_have_substring("_prog_am_ing", "p", "r") == True assert can_have_substring("_prog_am_ing", "a", "g") == Fal...
[ { "docstring": "Function to determine if the cryptic sentence can be decrypted to contain the given substring.", "function_declaration": "def can_have_substring(sentence, a, b):", "function_name": "can_have_substring", "parameter_list": "(sentence, a, b)" }, { "docstring": "Function to proce...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_have_substring(sentence, a, b):\n # Create the substring we are looking for\n target = a + b\n \n # Iterate through each position in the senten...
trial_gpt4o_8
{ "original_instruction": "You are given $N$ cryptic sentences. Each sentence is constructed out of lowercase Latin letters and underscores, where an underscore represents a \"hidden\" letter that must be replaced to form a complete word.\n\nThere are $Q$ queries. Each query is in the format L R a b, and you should o...
0.592434
Taco_32048
C
[ "can_have_substring", "check_sentences" ]
2
[ [ "check_sentences", "can_have_substring" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0ac49dea36384ac91fae9850e74c113fe0488e33
47a8cad8e243f3d7d6e1cceb851feed8dd25f5dc
v1.0
complete
Taco
Taco_30901_C
def is_mountain_sequence(sequence): """ Determine whether a sequence of integers is a mountain sequence. A sequence is considered a "mountain" if and only if: 1. There exists a peak element such that elements before the peak are in strictly increasing order. 2. Elements after the peak are in strictly de...
def is_mountain_sequence(sequence): n = len(sequence) if n < 3: return "NO" peak_index = 0 # Get to the peak while peak_index + 1 < n and sequence[peak_index] < sequence[peak_index + 1]: peak_index += 1 if peak_index == 0 or peak_index == n - 1: return "NO" ...
from solution import is_mountain_sequence, check_sequences def test_is_mountain_sequence(): assert is_mountain_sequence([1, 2, 3, 4, 3, 2, 1]) == "YES" assert is_mountain_sequence([1, 2, 3, 2, 1]) == "YES" assert is_mountain_sequence([1, 2, 3, 4, 5]) == "NO" assert is_mountain_sequence([5, 4, 3, 2, 1])...
[ { "docstring": null, "function_declaration": "def is_mountain_sequence(sequence):", "function_name": "is_mountain_sequence", "parameter_list": "(sequence)" }, { "docstring": null, "function_declaration": "def check_sequences(num_sequences, sequences):", "function_name": "check_sequen...
[ 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_mountain_sequence(sequence):\n n = len(sequence)\n if n < 3:\n return \"NO\"\n \n peak_index = 0\n # Get to the peak\n while peak_i...
trial_gpt4o_0
{ "original_instruction": "You have been given a sequence of integers, and you are to determine whether it is a \"mountain\" sequence. A sequence is considered a \"mountain\" if and only if:\n\n1. There exists a peak element such that elements before the peak are in strictly increasing order.\n2. Elements after the p...
0.623675
Taco_30901
C
[ "is_mountain_sequence", "check_sequences" ]
2
[ [ "check_sequences", "is_mountain_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b17e761811b1e9e15e4dcf4ef29369154ed27777
b8760f0631438439f6b188130d06d371a4809cb2
v1.0
complete
Taco
Taco_32160_C
def generate_diamond(n): """ Generates a diamond shape for a given size n and returns it as a list of strings. Each string in the list represents a single line in the diamond. >>> generate_diamond(1) ['*'] >>> generate_diamond(3) [' *', ' * *', '* *', ' * *', ' *'] >>> generate_diamo...
def generate_diamond(n): """ Generates a diamond shape for a given size n and returns it as a list of strings. Each string in the list represents a single line in the diamond. """ lines = [] # Upper part including the middle line for i in range(n): line = ' ' * (n - i - 1) + '*'...
from solution import parse_input, generate_diamonds, generate_diamond def test_generate_diamond_size_1(): expected_output = [ "*" ] assert generate_diamond(1) == expected_output def test_generate_diamond_size_3(): expected_output = [ " *", " * *", "* *", " * ...
[ { "docstring": "Generates a diamond shape for a given size n and returns it as a list of strings.\nEach string in the list represents a single line in the diamond.", "function_declaration": "def generate_diamond(n):", "function_name": "generate_diamond", "parameter_list": "(n)" }, { "docstri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_diamond(n):\n \"\"\"\n Generates a diamond pattern of given size n.\n \"\"\"\n diamond = []\n max_width = 2 * n - 1\n \n # Top ha...
trial_gpt4o_2
{ "original_instruction": "Write a program to generate a diamond-shaped pattern of a given size using asterisks (*) and spaces.\n\n* The diamond has a width of (2n-1) characters, where n is the height of the top half of the diamond excluding the center line.\n* The first half of the diamond incrementally widens, whil...
0.533895
Taco_32160
C
[ "generate_diamond", "generate_diamonds", "parse_input" ]
3
[ [ "generate_diamonds", "generate_diamond" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
1651e00d3555c55bb57fceae18e1f4a268d805ac
d421ac581e241f0fe33262efbbc50347904a056b
v1.0
complete
Taco
Taco_31309_C
from typing import List, Tuple, Union def shortest_delivery_route(n: int, e: int, roads: List[Tuple[int, int, int]], start: int, end: int) -> Union[Tuple[int, List[int]], str]: """ Determine the shortest possible delivery route from a starting intersection to a destination intersection. >>> shortest_delivery_r...
import heapq def dijkstra(graph, start, end, n): pq = [(0, start)] distances = {vertex: float('infinity') for vertex in range(1, n + 1)} distances[start] = 0 previous_nodes = {vertex: None for vertex in range(1, n + 1)} visited = set() while pq: current_distance, current_vertex = heapq...
def test_shortest_delivery_route(): n = 4 e = 4 roads = [(1, 2, 10), (2, 3, 20), (3, 4, 10), (4, 1, 40)] start = 1 end = 3 assert shortest_delivery_route(n, e, roads, start, end) == (30, [1, 2, 3]) def test_shortest_delivery_route_impossible(): n = 4 e = 3 roads = [(1, 2, 5), (2, 3,...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, start, end, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, end, n)" }, { "docstring": null, "function_declaration": "def shortest_delivery_route(n, e, roads, start, end):", "function_name": "short...
[ 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 heapq\n\ndef dijkstra(graph, start, end, n):\n pq = [(0, start, [start])]\n visited = set()\n while pq:\n (distance, current_vertex, path) =...
trial_gpt4o_4
{ "original_instruction": "A famous restaurant chain wants to optimize its delivery routes to ensure meals are delivered as quickly as possible. They provide a map of the city, which is composed of a number of intersections connected by streets. Each street has a certain length in meters.\n\nThe problem is to determi...
0.648838
Taco_31309
C
[ "dijkstra", "shortest_delivery_route" ]
2
[ [ "shortest_delivery_route", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
34ec6c723e7ce28a9e2959a52ff9256a69888ff0
e3f6c661dbccc8a8d1234c4bb62fe1459620d9d8
v1.0
complete
Taco
Taco_31580_C
def is_balanced_deck(cards): """ Determine if the given deck of cards is balanced. >>> is_balanced_deck([1, 3, 2, 2]) == True >>> is_balanced_deck([1, 2, 3, 6, 1, 2]) == False """ pass def check_decks(test_cases): """ Check multiple decks of cards to see if they are balanced. >>> check_deck...
def is_balanced_deck(cards): N = len(cards) // 2 first_half_sum = sum(cards[:N]) second_half_sum = sum(cards[N:]) return first_half_sum == second_half_sum def check_decks(test_cases): results = [] for N, cards in test_cases: if is_balanced_deck(cards): results.append("YES") ...
from solution import is_balanced_deck, check_decks, process_input def test_is_balanced_deck(): assert is_balanced_deck([1, 3, 2, 2]) == True assert is_balanced_deck([1, 2, 3, 6, 1, 2]) == False def test_check_decks(): assert check_decks([(2, [1, 3, 2, 2]), (3, [1, 2, 3, 6, 1, 2])]) == ["YES", "NO"] def t...
[ { "docstring": null, "function_declaration": "def is_balanced_deck(cards):", "function_name": "is_balanced_deck", "parameter_list": "(cards)" }, { "docstring": null, "function_declaration": "def check_decks(test_cases):", "function_name": "check_decks", "parameter_list": "(test_c...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_balanced_deck(cards):\n N = len(cards) // 2\n first_half_sum = sum(cards[:N])\n second_half_sum = sum(cards[N:])\n return first_half_sum == seco...
trial_gpt4o_0
{ "original_instruction": "Doctor offers to play a game with you using an unusual deck of 2N cards. Each card has a positive integer printed on it. The deck is called \"balanced\" if the sum of integers on the first N cards is equal to the sum of the integers on the last N cards. \n\nFor example, if N = 2 and the int...
0.576379
Taco_31580
C
[ "is_balanced_deck", "check_decks", "process_input" ]
3
[ [ "check_decks", "is_balanced_deck" ], [ "process_input", "check_decks" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
8bd5f2f4a7566d74f48be4897d48359b66850624
377c26615c50cbb29e05b0de09228347853bbac9
v1.0
complete
Taco
Taco_32350_C
def is_perfect_square(x): """ Helper function to determine if a number is a perfect square. """ # Code to determine if x is a perfect square. def smallest_sum_perfect_square_subarray(arr): """ Function to find the smallest possible sum of a contiguous subarray whose product is a perfect sq...
def is_perfect_square(x): """ Helper function to determine if a number is a perfect square. """ return int(x ** 0.5) ** 2 == x def smallest_sum_perfect_square_subarray(arr): """ Function to find the smallest possible sum of a contiguous subarray whose product is a perfect square. """ ...
from solution import process_test_cases, smallest_sum_perfect_square_subarray def test_smallest_sum_perfect_square_subarray_case_1(): arr = [2, 4, 3, 9, 6] assert smallest_sum_perfect_square_subarray(arr) == 4 def test_smallest_sum_perfect_square_subarray_case_2(): arr = [1, 7, 1, 2] assert smallest_s...
[ { "docstring": "Helper function to determine if a number is a perfect square.", "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": "Function to find the smallest possible sum of a contiguous subarray whose \npr...
[ 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 math\n\ndef is_perfect_square(x):\n \"\"\"\n Check if a given number x is a perfect square.\n \"\"\"\n root = int(math.sqrt(x))\n return x ==...
trial_gpt4o_1
{ "original_instruction": "In a given array, find the smallest possible sum of contiguous subarray whose product is a perfect square.\n\n-----Input:-----\n- The first line contains an integer $T$ denoting the number of test cases.\n- The first line of each test case contains a single integer $N$ denoting the number o...
0.648437
Taco_32350
C
[ "is_perfect_square", "smallest_sum_perfect_square_subarray", "process_test_cases" ]
3
[ [ "process_test_cases", "smallest_sum_perfect_square_subarray" ], [ "smallest_sum_perfect_square_subarray", "is_perfect_square" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
35b7ccbec7c3d3e079293779506c2623c25bde20
6769c6fa29321efbdf6bcbb2e2cf4b650f980df5
v1.0
complete
Taco
Taco_32135_C
def min_max_path_after_incantations(n: int, roads: List[Tuple[int, int, int]], k: int, queries: List[Tuple[int, int]]) -> List[int]: """ In a magical kingdom, determine the minimum possible maximum weight for each path after performing up to K incantations. Args: n (int): Number of cities roads (List[T...
from heapq import heappop, heappush from math import inf def floyd_warshall(n, graph): dist = [[inf] * n for _ in range(n)] for i in range(n): for j in range(n): if i == j: dist[i][j] = 0 elif graph[i][j] != inf: dist[i][j] = graph[i][j] ...
from solution import min_max_path_after_incantations def test_example_case(): n = 5 m = 10 k = 5 roads = [ (1, 2, 10), (1, 3, 20), (1, 4, 15), (1, 5, 30), (2, 3, 25), (2, 4, 30), (2, 5, 10), (3, 4, 35), (3, 5, 40), (4, 5, 2...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, graph):", "function_name": "floyd_warshall", "parameter_list": "(n, graph)" }, { "docstring": null, "function_declaration": "def min_max_path_after_incantations(n, roads, k, queries):", "function_name": "min_max_path...
[ 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 heapq\n\ndef halve_road_weights(edges, K):\n # Create a priority queue of all edges with their initial weights\n pq = []\n for (u, v), weight in ed...
trial_gpt4o_4
{ "original_instruction": "In a magical kingdom, there are N cities and M bidirectional roads connecting these cities. The roads form a fully connected graph, meaning there's a direct road between every pair of cities. A powerful wizard has cast a strange spell on the kingdom's road network, causing each road to have...
0.73317
Taco_32135
C
[ "floyd_warshall", "min_max_path_after_incantations" ]
2
[ [ "min_max_path_after_incantations", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fd4be32552f62d9230713145a70fdd0ccb7ab5f0
4eed7af9e03d92304b968647b9e7947427fe1c81
v1.0
complete
Taco
Taco_30994_C
import math from typing import List, Tuple def calculate_volume(radius: int) -> float: """Calculate the volume of a sphere given its radius.""" pass def combined_force_field_volume(test_cases: List[List[Tuple[int, int, int, int]]]) -> List[float]: """Calculate the combined volume of force fields needed fo...
import math def calculate_volume(radius): """Calculate the volume of a sphere given its radius.""" return (4/3) * math.pi * (radius ** 3) def combined_force_field_volume(test_cases): """Calculate the combined volume of force fields needed for each test case.""" results = [] for case in test_cases:...
from solution import combined_force_field_volume, parse_input, calculate_volume def test_combined_force_field_volume_single_station(): test_cases = [ [[0, 0, 0, 1]] ] expected_results = [calculate_volume(1)] assert combined_force_field_volume(test_cases) == expected_results def test_combined_f...
[ { "docstring": "Calculate the volume of a sphere given its radius.", "function_declaration": "def calculate_volume(radius):", "function_name": "calculate_volume", "parameter_list": "(radius)" }, { "docstring": "Calculate the combined volume of force fields needed for each test case.", "f...
[ 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 math\n\ndef calculate_volume(radius):\n \"\"\"Calculate the volume of a sphere given its radius.\"\"\"\n return (4/3) * math.pi * (radius ** 3)\n\ndef...
trial_gpt4o_0
{ "original_instruction": "Problem E: Protect the Galaxy Research Stations\n\nThe United Galactic Federation has stationed a series of research stations in outer space for deep space exploration. Each research station is a sphere with a specific radius. Some of these stations are at risk of colliding due to unpredict...
0.516541
Taco_30994
C
[ "calculate_volume", "combined_force_field_volume", "parse_input" ]
3
[ [ "combined_force_field_volume", "calculate_volume" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
a3ab4de7c818b50804c1098eeb5a904976acb6cf
9c269737c72d68c6eb3bf735ab71a27bf7de9a46
v1.0
complete
Taco
Taco_32580_C
def isPrimePower(n: int) -> bool: """ Determines if the number is a prime power. A prime power is a number that can be expressed in the form p^k where p is a prime number and k is an integer greater than or equal to 1. >>> isPrimePower(16) True >>> isPrimePower(18) False >>> isPrimePower(2) ...
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 isPrimePower(n): if n <= 1: re...
from solution import isPrimePower def test_example_cases(): assert isPrimePower(16) == True assert isPrimePower(18) == False def test_prime_numbers(): assert isPrimePower(2) == True assert isPrimePower(3) == True assert isPrimePower(5) == True assert isPrimePower(7) == True def test_non_prime...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def isPrimePower(n):", "function_name": "isPrimePower", "parameter_list": "(n)" } ]
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_0
{ "original_instruction": "Given an integer n, write a function that determines if the number is a prime power. A prime power is a number that can be expressed in the form \\( p^k \\) where p is a prime number and k is an integer greater than or equal to 1. \n\nExample 1:\nInput:\nn = 16\nOutput: True\nExplanation: 1...
0.739464
Taco_32580
C
[ "is_prime", "isPrimePower" ]
2
[ [ "isPrimePower", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dbbfe2f9f9948dc15352ad3f3f5bf6bc35bca582
dec0d5d44f71ba3846e68665f115afa51e23006c
v1.0
complete
Taco
Taco_32387_C
def form_largest_number(n: int, num_list: List[int]) -> str: """Forms the largest possible number from the input list of non-negative integers following the constraint that the final number should not contain any leading zeros, except for the number zero itself. >>> form_largest_number(5, [10, 2, 9, 39, 17...
from functools import cmp_to_key def largest_number(nums): """ Forms the largest possible number from the input list of non-negative integers. """ def compare(x, y): # Custom comparator to decide the order based on concatenated result if x + y > y + x: return -1 ...
from solution import form_largest_number def test_sample_input(): assert form_largest_number(5, [10, 2, 9, 39, 17]) == "93921710" def test_all_zeros(): assert form_largest_number(3, [0, 0, 0]) == "0" def test_single_number(): assert form_largest_number(1, [5]) == "5" def test_leading_zero_case(): as...
[ { "docstring": "Forms the largest possible number from the input list of non-negative integers.", "function_declaration": "def largest_number(nums):", "function_name": "largest_number", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def form_largest_number(n,...
[ 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 functools import cmp_to_key\n\ndef compare(x, y):\n # Custom comparator to decide the order based on concatenation\n if x + y > y + x:\n return -...
trial_gpt4o_2
{ "original_instruction": "In a software development contest, there was a problem of forming the largest number by rearranging a given set of non-negative integers. However, there was a constraint: a new rule was introduced that the final number should not contain any leading zeros, except for the number zero itself....
0.712126
Taco_32387
C
[ "largest_number", "form_largest_number" ]
2
[ [ "form_largest_number", "largest_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8d83b22c12e9eaf2e5e6d89d2c2595bd67ff8e23
5e4130f38e80cdcd728bb9c1680da217108f40da
v1.0
complete
Taco
Taco_31755_C
from typing import List, Dict def optimizeTravel(cities: List[str], distances: Dict[str, Dict[str, int]]) -> List[str]: """ Helps in optimizing the travel distance for visiting multiple cities. Parameters: cities (List[str]): An array of strings, where each string represents the name of a city. ...
from itertools import permutations def calculate_route_distance(route, distances): total_distance = 0 for i in range(len(route) - 1): total_distance += distances[route[i]][route[i+1]] # Add distance to return to starting city total_distance += distances[route[-1]][route[0]] return total_dis...
from solution import optimizeTravel def test_optimize_travel(): cities = ["A", "B", "C", "D"] distances = { "A": {"B": 10, "C": 15, "D": 20}, "B": {"A": 10, "C": 35, "D": 25}, "C": {"A": 15, "B": 35, "D": 30}, "D": {"A": 20, "B": 25, "C": 30} } result = optimizeTravel(c...
[ { "docstring": null, "function_declaration": "def calculate_route_distance(route, distances):", "function_name": "calculate_route_distance", "parameter_list": "(route, distances)" }, { "docstring": null, "function_declaration": "def optimizeTravel(cities, distances):", "function_name...
[ 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 permutations\n\ndef calculate_total_distance(path, distances):\n total_distance = 0\n number_of_cities = len(path)\n for i in range(...
trial_gpt4o_2
{ "original_instruction": "## Travel Distance Optimizer\n\nYou are required to write a function called **`optimizeTravel`** that helps in optimizing the travel distance for visiting multiple cities. The function takes two parameters:\n\n1. **`cities`**: An array of strings, where each string represents the name of a ...
0.685525
Taco_31755
C
[ "calculate_route_distance", "optimizeTravel" ]
2
[ [ "optimizeTravel", "calculate_route_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d28517f776d41cb0cb55aa98148882bbe8f7d417
2dd0b99f1bf8b55c60ed9d86ea9708578b6cd19b
v1.0
complete
Taco
Taco_32209_C
def minimal_cost_to_connect_servers(n: int, m: int, edges: List[Tuple[int, int, int]], queries: List[Tuple[int, int]]) -> List[int]: """ Determines the minimal cost to connect all servers for each query. :param n: Number of servers :param m: Number of links :param edges: List of tuples where e...
from heapq import heappop, heappush def find(parents, i): if parents[i] == i: return i parents[i] = find(parents, parents[i]) return parents[i] def union(parents, ranks, u, v): root_u = find(parents, u) root_v = find(parents, v) if root_u != root_v: if ranks[root_u] > rank...
from solution import minimal_cost_to_connect_servers def test_example_1(): n = 4 m = 3 edges = [ (1, 2, 1), (2, 3, 2), (3, 4, 4) ] queries = [ (1, 3), (4, 1) ] result = minimal_cost_to_connect_servers(n, m, edges, queries) assert result == [6, 3] ...
[ { "docstring": null, "function_declaration": "def find(parents, i):", "function_name": "find", "parameter_list": "(parents, i)" }, { "docstring": null, "function_declaration": "def union(parents, ranks, u, v):", "function_name": "union", "parameter_list": "(parents, ranks, u, v)"...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n\n def find(self, u):\n if self.parent[u...
trial_gpt4o_2
{ "original_instruction": "A company wants to minimize the cost of transferring data between its distributed servers. There are n servers located in different geographical regions, and each server has a data volume that needs to be transferred. The servers are connected via m direct bidirectional links, each with an ...
0.647577
Taco_32209
C
[ "find", "union", "kruskal", "minimal_cost_to_connect_servers" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimal_cost_to_connect_servers", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
3206983b015b64d21de255717873d11ca002f552
10a618f17876a4ebebf57606a81af62c77bb719c
v1.0
complete
Taco
Taco_31176_C
def build_matrix(N: int) -> list: """ Constructs a NxN matrix based on specific rules. Args: N (int): The size of the matrix. Returns: list: The constructed NxN matrix. """ def format_matrix(matrix: list) -> str: """ Formats the matrix into a single line string. Args: ma...
def build_matrix(N): matrix = [[0] * N for _ in range(N)] for i in range(N): for j in range(N): if i == j: matrix[i][j] = i * i elif j > i: matrix[i][j] = i * j else: matrix[i][j] = i * j return matrix def...
from solution import build_matrix, format_matrix, solve def test_example_1(): test_cases = [3] expected_output = ["0 0 0 0 1 2 0 2 4"] assert solve(test_cases) == expected_output def test_example_2(): test_cases = [4] expected_output = ["0 0 0 0 0 1 2 3 0 2 4 6 0 3 6 9"] assert solve(test_case...
[ { "docstring": null, "function_declaration": "def build_matrix(N):", "function_name": "build_matrix", "parameter_list": "(N)" }, { "docstring": null, "function_declaration": "def format_matrix(matrix):", "function_name": "format_matrix", "parameter_list": "(matrix)" }, { ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def build_matrix(N):\n matrix = [[0] * N for _ in range(N)]\n \n for i in range(N):\n for j in range(N):\n if i == j:\n m...
trial_gpt4o_0
{ "original_instruction": "In a distant galaxy, inhabitants use a unique numeric system based on unusual multiplication rules. They have a special 2-dimensional grid where numbers multiply differently based on their position.\n\nThe planet's grid is represented by an N x N matrix where matrix[i][j] represents the mul...
0.524692
Taco_31176
C
[ "build_matrix", "format_matrix", "solve" ]
3
[ [ "solve", "build_matrix" ], [ "solve", "format_matrix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c4e5c824c36514126a23d0b1fb2d2d0c00a2290a
89d4a7f8e8f439c430a43208e9e3fbc198f50e65
v1.0
complete
Taco
Taco_32162_C
def longest_path(N: int, M: int, edges: List[Tuple[int, int, int]]) -> Union[int, str]: """ Determine the weight of the longest path in an undirected graph. If the graph contains a cycle, return "INF". Args: N: Number of nodes in the graph. M: Number of edges in the graph. edges: List of tu...
def has_cycle_util(graph, visited, rec_stack, node): visited[node] = True rec_stack[node] = True for neighbor, weight in graph[node]: if not visited[neighbor]: if has_cycle_util(graph, visited, rec_stack, neighbor): return True elif rec_stack[neighbor]: ...
from solution import parse_and_solve def test_example_input(): input_data = """5 6 1 2 10 2 3 10 3 4 10 4 5 10 1 5 30 3 1 20""" assert parse_and_solve(input_data) == "INF" def test_no_cycle(): input_data = """4 4 1 2 5 2 3 5 3 4 5 1 4 15""" assert parse_and_solve(input_data) == 15 def test_single_nod...
[ { "docstring": null, "function_declaration": "def has_cycle_util(graph, visited, rec_stack, node):", "function_name": "has_cycle_util", "parameter_list": "(graph, visited, rec_stack, node)" }, { "docstring": null, "function_declaration": "def has_cycle(graph, N):", "function_name": "...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef longest_path(N, M, edges):\n graph = defaultdict(list)\n for u, v, w in edges:\n graph[u].append((v,...
trial_gpt4o_2
{ "original_instruction": "You are given an undirected graph with $N$ nodes and $M$ edges. Each edge has a weight associated with it. The task is to determine the longest path in the graph such that the sum of weights of the edges in the path is maximized.\n\n-----Input-----\n- The first line of the input contains tw...
0.629763
Taco_32162
C
[ "has_cycle_util", "has_cycle", "longest_path", "find_longest_path", "parse_and_solve" ]
5
[ [ "find_longest_path", "longest_path" ], [ "has_cycle", "has_cycle_util" ], [ "longest_path", "has_cycle" ], [ "parse_and_solve", "find_longest_path" ] ]
4
[]
false
[]
false
pytest
true
[]
true
e0cb6d5a8eeb10c401e20bfb24fc2e1c209027f7
aa37b114345277e3933c6766a0c3beaad16cb5ff
v1.0
complete
Taco
Taco_31953_C
def nthPerfectNum(n: int) -> int: """ Given an integer n, find the nth Perfect Number. A perfect number is a positive integer that is equal to the sum of its proper divisors, excluding itself. >>> nthPerfectNum(1) 6 >>> nthPerfectNum(2) 28 >>> nthPerfectNum(3) 496 >>> nthPerfec...
def is_perfect(num): """ Helper function to determine if a number is a perfect number. """ if num <= 1: return False sum_divisors = 1 # Starting with 1 since 1 is a proper divisor for all numbers > 1 for i in range(2, int(num**0.5) + 1): if num % i == 0: sum_div...
from solution import nthPerfectNum, is_perfect def test_is_perfect(): assert is_perfect(6) == True # 6 is a perfect number assert is_perfect(28) == True # 28 is a perfect number assert is_perfect(12) == False # 12 is not a perfect number assert is_perfect(496) == True # 496 is a perfect number ...
[ { "docstring": "Helper function to determine if a number is a perfect number.", "function_declaration": "def is_perfect(num):", "function_name": "is_perfect", "parameter_list": "(num)" }, { "docstring": "Returns the nth Perfect Number.", "function_declaration": "def nthPerfectNum(n):", ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_perfect_number(num):\n \"\"\"\n Checks if a given number is a perfect number.\n \"\"\"\n if num < 2:\n return False\n \n divisors_s...
trial_gpt4o_9
{ "original_instruction": "Given an integer n, find the nth Perfect Number.\nA perfect number is a positive integer that is equal to the sum of its proper divisors, excluding itself. Proper divisors of a number are all the divisors excluding the number itself.\n\nExample 1:\nInput:\nn = 1\nOutput:\n6\nExplanation:\nT...
0.652112
Taco_31953
C
[ "is_perfect", "nthPerfectNum" ]
2
[ [ "nthPerfectNum", "is_perfect" ] ]
1
[]
false
[]
false
pytest
true
[]
true
965863280a1f98d53ee18a19c4d659d3b91dca0d
e66cf1c050339e178cb0e67f650cc259caca08a8
v1.0
complete
Taco
Taco_32370_C
from typing import List def generate_permutations(lst: List[int]) -> List[tuple]: """ Generates all possible permutations of the given list. >>> generate_permutations([1]) [(1,)] >>> generate_permutations([4, 5]) [(4, 5), (5, 4)] >>> generate_permutations([1, 2, 3]) [(1, 2, 3), (1, 3, 2...
from itertools import permutations def generate_permutations(lst): """ Generates all possible permutations of the given list. """ all_permutations = list(permutations(lst)) return all_permutations def format_permutations(lst): """ Returns all permutations in a formatted output (list of str...
from solution import generate_permutations, format_permutations def test_generate_single_element(): assert generate_permutations([1]) == [(1,)] def test_generate_two_elements(): result = generate_permutations([4, 5]) expected = [(4, 5), (5, 4)] assert sorted(result) == sorted(expected) def test_gener...
[ { "docstring": "Generates all possible permutations of the given list.", "function_declaration": "def generate_permutations(lst):", "function_name": "generate_permutations", "parameter_list": "(lst)" }, { "docstring": "Returns all permutations in a formatted output (list of strings).", "...
[ 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": "import itertools\n\ndef find_permutations(n, array):\n \"\"\"\n Returns all permutations of a given array.\n\n :param n: Number of elements in the array\n...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers, we want to find all possible permutations of this array. A permutation of an array is a rearrangement of its elements into a new sequence.\n\nInput\n\nThe first line of input contains an integer n (1 ≤ n ≤ 7) — the number of elements in the array. The second line...
0.651193
Taco_32370
C
[ "generate_permutations", "format_permutations" ]
2
[ [ "format_permutations", "generate_permutations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
646559d09762eba4041e5f15bb8724a7edb8a29a
f13f2fe30706646db5f8077d4db58011db0f9ecb
v1.0
complete
Taco
Taco_32667_C
def max_subarray_sum(arr): """ Returns the maximum sum of the contiguous subarray using Kadane's Algorithm. >>> max_subarray_sum([5, -1, 5]) == 9 >>> max_subarray_sum([1, 2, 3, 4]) == 10 >>> max_subarray_sum([-1, -2, -3, -4]) == -1 >>> max_subarray_sum([4, -1, 2, 1]) == 6 """ pass def m...
def max_subarray_sum(arr): """ Returns the maximum sum of the contiguous subarray using Kadane's Algorithm. """ max_current = max_global = arr[0] for num in arr[1:]: max_current = max(num, max_current + num) if max_current > max_global: max_global = max_current ...
from solution import max_subarray_sum, max_subarray_sum_from_input def test_max_subarray_sum_simple(): assert max_subarray_sum([5, -1, 5]) == 9 assert max_subarray_sum([1, 2, 3, 4]) == 10 assert max_subarray_sum([-1, -2, -3, -4]) == -1 assert max_subarray_sum([4, -1, 2, 1]) == 6 def test_max_subarray_...
[ { "docstring": "Returns the maximum sum of the contiguous subarray using Kadane's Algorithm.", "function_declaration": "def max_subarray_sum(arr):", "function_name": "max_subarray_sum", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def max_subarray_sum_from_i...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_subarray_sum(arr):\n \"\"\"\n Returns the maximum sum of a contiguous subarray using Kadane's algorithm.\n \"\"\"\n max_current = max_global = ...
trial_gpt4o_1
{ "original_instruction": "For an array of integers $B = \\\\{b_0, b_1, ..., b_{n-1}\\\\}$, find the subarray that has the maximum sum and print that sum.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $-10,000 \\leq b_i \\leq 10,000$\n\nInput\n\nAn array is given in the following format.\n\n$n$\n$b_0 \\; b_1 \\; ,...
0.749416
Taco_32667
C
[ "max_subarray_sum", "max_subarray_sum_from_input" ]
2
[ [ "max_subarray_sum_from_input", "max_subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
731192fa5ac8b24608c8323b6303ef7d757b6c3c
3bbbb20f7d44dd8a6f3ecbc3fba051f713252e0e
v1.0
complete
Taco
Taco_31800_C
from typing import List def unreachable_buildings(h: int, w: int, city_map: List[str]) -> int: """ Determine the number of buildings that cannot be reached by any fire station signal. Args: h (int): The height of the grid. w (int): The width of the grid. city_map (List[str]): The city grid, re...
def bfs_reachable_buildings(grid, h, w): from collections import deque fire_stations = [] buildings = set() for i in range(h): for j in range(w): if grid[i][j] == 'F': fire_stations.append((i, j)) elif grid[i][j] == 'B': buildings...
def test_sample_1(): h = 4 w = 5 city_map = [ "BBSSB", "BFFSB", "BBSSB", "BSSFB" ] assert unreachable_buildings(h, w, city_map) == 2 def test_sample_2(): h = 3 w = 3 city_map = [ "BSB", "BFB", "BSB" ] assert unreachable_bui...
[ { "docstring": null, "function_declaration": "def bfs_reachable_buildings(grid, h, w):", "function_name": "bfs_reachable_buildings", "parameter_list": "(grid, h, w)" }, { "docstring": null, "function_declaration": "def unreachable_buildings(h, w, city_map):", "function_name": "unreac...
[ 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 unreachable_buildings(h, w, grid):\n from collections import deque\n \n directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]\n queue = deque()\n visi...
trial_gpt4o_4
{ "original_instruction": "**Emergency Signal Relay**\n\nYou are given a city grid where each cell is either a building `B`, a street `S`, or a fire station `F`. The signal from a fire station can be relayed through streets to reach buildings, but cannot pass through other buildings. To ensure efficient emergency ser...
0.542442
Taco_31800
C
[ "bfs_reachable_buildings", "unreachable_buildings" ]
2
[ [ "unreachable_buildings", "bfs_reachable_buildings" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ae65ddabb07de0f71663f3aa1d91f1c1b576dc1e
27daa2612140ba25721157e19dbd545c59507c56
v1.0
complete
Taco
Taco_31924_C
def preprocess_graph(N, edges): """ Preprocess the graph to facilitate answering shortest path queries. Parameters: N (int): The number of nodes. edges (List[Tuple[int, int, int]]): A list of edges where each edge is represented by a tuple (U, V, D). Returns: List[List[Tuple[int, int]]...
import heapq def preprocess_graph(N, edges): graph = [[] for _ in range(N + 1)] for u, v, d in edges: graph[u].append((d, v)) graph[v].append((d, u)) return graph def dijkstra(graph, start, N): distances = [float('inf')] * (N + 1) distances[start] = 0 priority_queue = [(0, star...
def test_shortest_paths(): N = 5 M = 6 edges = [ (1, 2, 10), (1, 3, 5), (2, 3, 2), (3, 4, 1), (4, 5, 7), (2, 5, 10), ] Q = 3 queries = [ (1, 5), (2, 4), (1, 4), ] expected_output = [13, 3, 6] assert shortest_path...
[ { "docstring": null, "function_declaration": "def preprocess_graph(N, edges):", "function_name": "preprocess_graph", "parameter_list": "(N, edges)" }, { "docstring": null, "function_declaration": "def dijkstra(graph, start, N):", "function_name": "dijkstra", "parameter_list": "(g...
[ 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\nimport sys\n\ndef preprocess_network(n, edges):\n graph = [[] for _ in range(n + 1)]\n for u, v, d in edges:\n graph[u].append((v, d))\n...
trial_gpt4o_1
{ "original_instruction": "Alex is working on a project that involves managing a network of computers represented by an undirected graph $\\mathbf{G}$ with $N$ nodes and $M$ edges. Each edge connects two nodes $U_i$ and $V_i$ and has an associated transmission delay $D_i$.\n\nAlex needs to find the shortest path betw...
0.600245
Taco_31924
C
[ "preprocess_graph", "dijkstra", "shortest_paths" ]
3
[ [ "shortest_paths", "dijkstra" ], [ "shortest_paths", "preprocess_graph" ] ]
2
[]
false
[]
false
pytest
false
[]
true
e44949235637916e009755dbe4d909255bab1320
4e8f0c172858eb9036db09440dbe13ade6cf457f
v1.0
complete
Taco
Taco_32228_C
from typing import List, Tuple def fibonacci_sequence(n: int) -> List[int]: """ Generates a list of first n Fibonacci numbers. >>> fibonacci_sequence(1) [1] >>> fibonacci_sequence(3) [1, 1, 2] """ def fruit_basket_weights(n: int) -> Tuple[int, int]: """ Calculates the minimum and maxim...
def fibonacci_sequence(n): """ Generates a list of first n Fibonacci numbers. """ fibonacci = [1, 1] for i in range(2, n): fibonacci.append(fibonacci[-1] + fibonacci[-2]) return fibonacci[:n] def fruit_basket_weights(n): """ Calculates the minimum and maximum weight of the fruit...
from solution import fibonacci_sequence, fruit_basket_weights def test_fibonacci_sequence(): assert fibonacci_sequence(1) == [1] assert fibonacci_sequence(2) == [1, 1] assert fibonacci_sequence(3) == [1, 1, 2] assert fibonacci_sequence(5) == [1, 1, 2, 3, 5] assert fibonacci_sequence(7) == [1, 1, 2,...
[ { "docstring": "Generates a list of first n Fibonacci numbers.", "function_declaration": "def fibonacci_sequence(n):", "function_name": "fibonacci_sequence", "parameter_list": "(n)" }, { "docstring": "Calculates the minimum and maximum weight of the fruit basket.", "function_declaration"...
[ 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 fib(n):\n \"\"\"\n Calculate the n-th Fibonacci number.\n \"\"\"\n if n == 1 or n == 2:\n return 1\n a, b = 1, 1\n for _ in range(3, n...
trial_gpt4o_3
{ "original_instruction": "In a distant kingdom, there is a magical orchard where fruits grow in special numbers based on the Fibonacci sequence. The n-th type of fruit has a weight defined by the n-th Fibonacci number.\n\nThe king wants to create a fruit basket containing at least one type of each fruit. However, th...
0.611378
Taco_32228
C
[ "fibonacci_sequence", "fruit_basket_weights" ]
2
[ [ "fruit_basket_weights", "fibonacci_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
497e9c4689f917af562980fab71b002c81544d1e
4e57b74350f2af2ee6244bb23cd8d46fedffe64b
v1.0
complete
Taco
Taco_32711_C
def is_palindrome(num): """ Checks whether a number is a palindrome. """ pass def possible_palindromic_bibs(A, B, K): """ Determines if it is possible to assign K distinct palindromic bib numbers within the range [A, B]. Returns "POSSIBLE" if feasible, otherwise "IMPOSSIBLE". ...
def is_palindrome(num): """ Checks whether a number is a palindrome. """ return str(num) == str(num)[::-1] def possible_palindromic_bibs(A, B, K): """ Determines if it is possible to assign K distinct palindromic bib numbers within the range [A, B]. Returns "POSSIBLE" if feasible,...
from solution import is_palindrome, possible_palindromic_bibs, main 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(10) == False def test_possible_palindromic_bibs()...
[ { "docstring": "Checks whether a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Determines if it is possible to assign K distinct palindromic bib numbers \nwithin the range [A, B].\n\...
[ 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(n):\n \"\"\"\n Checks if a given number n is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef count_palindromes_in_range...
trial_gpt4o_2
{ "original_instruction": "Alex is organizing a marathon event, and to manage the event efficiently, each runner will be assigned a unique bib number. The bib numbers have a special property: they need to be palindromes. A palindromic number is a number that remains the same when its digits are reversed.\n\nGiven a r...
0.691325
Taco_32711
C
[ "is_palindrome", "possible_palindromic_bibs", "main" ]
3
[ [ "possible_palindromic_bibs", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
056468bf3b57141b4276337a1c42c010489fd217
60d1db11690c7479f6e928e3b19e895edf7eda0f
v1.0
complete
Taco
Taco_32009_C
def find_invalid_access_times(start_time: str, end_time: str, n: int, log_entries: List[str]) -> str: """ Determine which keycards were used outside the allowed hours. >>> find_invalid_access_times("08:00", "18:00", 5, ["07:30 enter", "08:00 enter", "12:00 exit", "18:01 exit", "20:00 enter"]) "07:30 enter\n...
def is_within_allowed_hours(time, start_time, end_time): return start_time <= time <= end_time def find_invalid_access_times(start_time, end_time, n, log_entries): invalid_entries = [] for entry in log_entries: entry_time, action = entry.split() if not is_within_allowed_hours(entry_time, s...
from solution import find_invalid_access_times def test_all_access_times_valid(): start_time = "09:00" end_time = "17:00" n = 3 log_entries = ["09:00 enter", "12:00 exit", "17:00 exit"] assert find_invalid_access_times(start_time, end_time, n, log_entries) == "ALL ACCESS TIMES VALID" def test_some...
[ { "docstring": null, "function_declaration": "def is_within_allowed_hours(time, start_time, end_time):", "function_name": "is_within_allowed_hours", "parameter_list": "(time, start_time, end_time)" }, { "docstring": null, "function_declaration": "def find_invalid_access_times(start_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": "from typing import List, Tuple\n\n\ndef parse_time(time_str: str) -> Tuple[int, int]:\n \"\"\"\n Parse a time string in HH:MM format and return a tuple of (h...
trial_gpt4o_2
{ "original_instruction": "Ryan is designing a security system for his office building. He wants to add a keycard system that only grants access during certain hours based on a log of keycard entries and exits. Each entry in the log is represented by a time in 24-hour format (HH:MM), and an action (either \"enter\" o...
0.481286
Taco_32009
C
[ "is_within_allowed_hours", "find_invalid_access_times" ]
2
[ [ "find_invalid_access_times", "is_within_allowed_hours" ] ]
1
[]
false
[]
false
pytest
true
[]
true
56d0d0779dad4843687080dcd2226db46b9573af
d622b71f279cd4a50056221416774c537bb9a872
v1.0
complete
Taco
Taco_31835_C
from typing import List, Tuple def process_queries(N: int, edges: List[Tuple[int, int]], queries: List[Tuple[int, int]]) -> List[int]: """ Given an undirected tree with N vertices labeled from 1 to N. Find the K-th ancestor of a given node in the tree for each query. :param N: int - Number of vertice...
from collections import defaultdict, deque def preprocess_tree(N, edges): """ Preprocess the tree to build the parent and depth information. """ graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) parent = [-1] * (N + 1) depth = [-1] * (N + 1)...
from solution import process_queries def test_basic_case(): N = 7 edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)] queries = [(4, 1), (5, 2), (6, 1), (6, 3)] assert process_queries(N, edges, queries) == [2, 1, 3, -1] def test_no_kth_ancestor(): N = 5 edges = [(1, 2), (1, 3), (2, 4), (3...
[ { "docstring": "Preprocess the tree to build the parent and depth information.", "function_declaration": "def preprocess_tree(N, edges):", "function_name": "preprocess_tree", "parameter_list": "(N, edges)" }, { "docstring": "Find the k-th ancestor of node x.", "function_declaration": "de...
[ 0, 0, 0, 0, 1, 0, 0, 0, 1 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef preprocess_ancestors(n, edges):\n # Building the tree\n tree = defaultdict(list)\n \n for u, v in edg...
trial_gpt4o_5
{ "original_instruction": "A tree is a connected acyclic graph. In a tree, any two vertices are connected by exactly one path. \n\nGiven an undirected tree with \\( N \\) vertices labeled from \\( 1 \\) to \\( N \\). You need to find the K-th ancestor of a given node in the tree.\n\nInput Format\n\nThe first line con...
0.61023
Taco_31835
C
[ "preprocess_tree", "find_kth_ancestor", "process_queries" ]
3
[ [ "process_queries", "find_kth_ancestor" ], [ "process_queries", "preprocess_tree" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
fb55528d1b76173e9d1dc1e71e5d985729c9d8f3
444bd383e2bc82c24b5aecbdc7cdd20f2ceb974e
v1.0
complete
Taco
Taco_32808_C
from typing import List, Tuple def min_max_weight_kruskal(n: int, edges: List[Tuple[int, int, int]]) -> int: """ Determine the minimum possible value of the longest road in the optimal network. Parameters: n (int): The number of cities. edges (List[Tuple[int, int, int]]): A list of edges where eac...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) # path compression 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...
from solution import min_max_weight_kruskal def test_case_1(): n = 4 m = 5 edges = [ (1, 2, 5), (2, 3, 10), (3, 4, 1), (4, 1, 3), (1, 3, 2) ] result = min_max_weight_kruskal(n, edges) assert result == 5 def test_case_2(): n = 3 m = 3 edges = ...
[ { "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, 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_minimum_maximum_road(n, m, roads):\n parent = list(range(n + 1))\n rank = [0] * (n + 1)\n\n def find(x):\n if parent[x] != x:\n ...
trial_gpt4o_1
{ "original_instruction": "In an ancient kingdom, there is a need to deliver crucial messages between cities using a system of couriers. The kingdom is represented as a graph with `n` cities and `m` potential roads between them. Each road has a specified weight that represents the time taken to traverse it. However, ...
0.651575
Taco_32808
C
[ "find", "union", "min_max_weight_kruskal" ]
3
[ [ "min_max_weight_kruskal", "find" ], [ "min_max_weight_kruskal", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
73694c1caa7ad9c501221bfca8e08bf135ffd8b1
dbf4e31aeac114b82c346c26858c5b46fe721ad7
v1.0
complete
Taco
Taco_32415_C
import re def evaluate_expression(expression: str) -> str: """ Evaluate a single arithmetic expression and return the result rounded to two decimal places. >>> evaluate_expression("5+3*2") '11.00' >>> evaluate_expression("4/2-1") '1.00' >>> evaluate_expression("7*(3+2)") '35.00' >>> eva...
import re def evaluate_expression(expression): try: # Evaluate the expression and round the result to 2 decimal places result = eval(expression) return f"{result:.2f}" except Exception as e: return str(e) def process_expressions(expressions): results = [] for expression...
from solution import evaluate_expression, process_expressions def test_evaluate_single_expression(): assert evaluate_expression("5+3*2") == "11.00" assert evaluate_expression("4/2-1") == "1.00" assert evaluate_expression("7*(3+2)") == "35.00" assert evaluate_expression("9/3*3+2") == "11.00" assert ...
[ { "docstring": null, "function_declaration": "def evaluate_expression(expression):", "function_name": "evaluate_expression", "parameter_list": "(expression)" }, { "docstring": null, "function_declaration": "def process_expressions(expressions):", "function_name": "process_expressions...
[ 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 evaluate_expression(expression):\n \"\"\"\n Evaluates a given arithmetic expression string and returns the result rounded to two decimal precision.\n ...
trial_gpt4o_3
{ "original_instruction": "Problem Description\n\nYou are given the task of evaluating a series of mathematical expressions passed in a specific format, and turning them into their correct arithmetic results. Implement a program that can solve basic arithmetic expressions, ensuring to follow the order of operations (...
0.61387
Taco_32415
C
[ "evaluate_expression", "process_expressions" ]
2
[ [ "process_expressions", "evaluate_expression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
924ec4538ef1edaae4db7353df315336a9cc4377
f6ae4887d946eb1da9f05187bcc947ebaadab523
v1.0
complete
Taco
Taco_31962_C
def minimum_travel_time(N: int, M: int, roads: List[Tuple[int, int, int]], Q: int, queries: List[Tuple[int, int]]) -> List[int]: """ Calculate the minimum travel time between given pairs of buildings. Args: N (int): Number of buildings. M (int): Number of roads. roads (List[Tuple[int, int, int]]): ...
import sys def floyd_warshall(n, dist): # Initialize the distance array for k in range(n): for i in range(n): for j in range(n): if dist[i][k] != sys.maxsize and dist[k][j] != sys.maxsize: dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) return d...
from solution import minimum_travel_time def test_minimum_travel_time(): N = 5 M = 6 roads = [ (1, 2, 3), (1, 3, 1), (2, 3, 1), (3, 4, 6), (3, 5, 4), (4, 5, 2), ] Q = 3 queries = [ (1, 4), (2, 5), (1, 5), ] expected...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, dist):", "function_name": "floyd_warshall", "parameter_list": "(n, dist)" }, { "docstring": null, "function_declaration": "def minimum_travel_time(N, M, roads, Q, queries):", "function_name": "minimum_travel_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 floyd_warshall(n, edges):\n # Initialize the distance matrix\n dist = [[float('inf')] * n for _ in range(n)]\n \n # Set the distance from a node to...
trial_gpt4o_2
{ "original_instruction": "Consider a city where there are N office buildings connected by bi-directional roads. Each road connects exactly two buildings and has a travel time associated with it. People can go from one building to another through any number of intermediate buildings via these roads, and there might b...
0.762186
Taco_31962
C
[ "floyd_warshall", "minimum_travel_time" ]
2
[ [ "minimum_travel_time", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7f54b815310f25bc367222915b2ad0c4f503f927
14bd4af27c7e9daf4315f6145646ec76a4c3e412
v1.0
complete
Taco
Taco_32924_C
def detect_cycle(N: int, M: int, edges: List[Tuple[int, int]]) -> str: """ Detect if there are any cyclic dependencies between the vertices in the directed graph. Input: - N: Number of vertices - M: Number of edges - edges: List of M tuples representing directed edges (u_i, v_i) Output: - '...
from collections import defaultdict, deque def detect_cycle_in_directed_graph(N, M, edges): def has_cycle(): indegree = [0] * (N + 1) graph = defaultdict(list) for u, v in edges: graph[u].append(v) indegree[v] += 1 queue = deque() ...
from solution import detect_cycle def test_cycle_in_graph(): assert detect_cycle(3, 3, [(1, 2), (2, 3), (3, 1)]) == "CYCLE" def test_no_cycle_in_graph(): assert detect_cycle(4, 3, [(1, 2), (2, 3), (3, 4)]) == "NO CYCLE" def test_another_cycle(): assert detect_cycle(4, 4, [(1, 2), (2, 3), (3, 4), (4, 2)])...
[ { "docstring": null, "function_declaration": "def detect_cycle_in_directed_graph(N, M, edges):", "function_name": "detect_cycle_in_directed_graph", "parameter_list": "(N, M, edges)" }, { "docstring": null, "function_declaration": "def detect_cycle(N, M, edges):", "function_name": "de...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef detect_cycle(n, m, edges):\n def dfs(node):\n if node in visiting: # Cycle detected\n return True\...
trial_gpt4o_1
{ "original_instruction": "Detect Cyclic Dependencies in a Directed Graph\n\n**Problem**\n\nYou are given a directed graph represented by N vertices and M edges. Each edge is directed from vertex u_i to vertex v_i. Your task is to detect if there are any cyclic dependencies between the vertices in this graph.\n\n**In...
0.650705
Taco_32924
C
[ "detect_cycle_in_directed_graph", "detect_cycle" ]
2
[ [ "detect_cycle", "detect_cycle_in_directed_graph" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5672d3d101474f55f51a421a1e415a4b91f93f7
b1b73536c111cdbff555725451d05bf5f1c76846
v1.0
complete
Taco
Taco_32920_C
from typing import List def min_max_difference_in_rotated_array(arr: List[int], k: int) -> int: """ Rotates the array to the right by k positions and returns the difference between the maximum and minimum element in the rotated array. Parameters: arr (List[int]): The input array. k (int): The ...
from typing import List def rotate_array(arr: List[int], k: int) -> List[int]: """ Rotates the array to the right by k positions. Parameters: arr (List[int]): The input array. k (int): The number of positions to rotate the array. Returns: List[int]: The rotated array. """ n = len(...
from solution import min_max_difference_in_rotated_array def test_min_max_difference_in_rotated_array(): assert min_max_difference_in_rotated_array([3, 8, 9, 7, 6], 3) == 6 assert min_max_difference_in_rotated_array([1, 2, 3, 4, 5, 6], 2) == 5 assert min_max_difference_in_rotated_array([7, 4, 2, 9, 0], 1) ...
[ { "docstring": "Rotates the array to the right by k positions.\n\nParameters:\narr (List[int]): The input array.\nk (int): The number of positions to rotate the array.\n\nReturns:\nList[int]: The rotated array.", "function_declaration": "def rotate_array(arr, k):", "function_name": "rotate_array", "...
[ 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 typing import List\n\ndef min_max_difference_in_rotated_array(arr: List[int], k: int) -> int:\n \"\"\"\n Rotates the array to the right by k positions a...
trial_gpt4o_2
{ "original_instruction": "#Min and Max Element Difference in a Rotated Array\n\nYou need to write a function that takes an array of integers and a rotation value as parameters. The function should rotate the array to the right by the given number of positions. Then, it should return the difference between the maximu...
0.714629
Taco_32920
C
[ "rotate_array", "min_max_difference_in_rotated_array" ]
2
[ [ "min_max_difference_in_rotated_array", "rotate_array" ] ]
1
[]
false
[]
false
pytest
true
[]
true
03e83f6552694c2682d67fb7d84ef38102e489f1
9a92815955526830ebc5ddc98f81997f2cd69dee
v1.0
complete
Taco
Taco_32947_C
from typing import List, Tuple def solution(n: int, m: int, edges: List[Tuple[int, int]]) -> int: """ Given an undirected graph with `n` nodes and `m` edges, determine if there exists a valid path from the first node to the last node. If a valid path exists, return the length of the shortest path, otherwi...
from collections import deque, defaultdict def bfs_shortest_path(n, edges): # Create graph from edges graph = defaultdict(list) for u, v in edges: graph[u-1].append(v-1) graph[v-1].append(u-1) # BFS to find the shortest path from node 0 to node n-1 queue = deque([0]) distances ...
def test_solution(): assert solution(5, 6, [(1, 2), (2, 3), (3, 4), (4, 5), (2, 4), (1, 5)]) == 1 assert solution(4, 4, [(1, 2), (2, 3), (3, 4), (1, 3)]) == 2 assert solution(3, 2, [(1, 2), (2, 3)]) == 2 assert solution(3, 1, [(1, 2)]) == -1 assert solution(2, 1, [(1, 2)]) == 1 assert solution(6...
[ { "docstring": null, "function_declaration": "def bfs_shortest_path(n, edges):", "function_name": "bfs_shortest_path", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def solution(n, m, edges):", "function_name": "solution", "parameter_list": "(n, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef bfs_shortest_path(n, edges):\n # Create graph from edges\n graph = defaultdict(list)\n for u, v in edges...
trial_gpt4o_0
{ "original_instruction": "Given an undirected graph with `n` nodes and `m` edges, determine if there exists a valid path from the first node to the last node. If a valid path exists, print the length of the shortest path. If no such path exists, print -1.\n\nConstraints\n\n* 2 \\leq n \\leq 10^5\n* 1 \\leq m \\leq 2...
0.689801
Taco_32947
C
[ "bfs_shortest_path", "solution" ]
2
[ [ "solution", "bfs_shortest_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
fbd92423ce09b5b101d648fab7b466221a0a76bb
24dfaa023f621e3be9749d9b32b82d1afb1cbadf
v1.0
complete
Taco
Taco_33091_C
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def insert(root, data): if root is None: return Node(data) if data < root.data: root.left = insert(root.left, data) else: root.right = insert(root.right, data) r...
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def insert(root, data): if root is None: return Node(data) if data < root.data: root.left = insert(root.left, data) else: root.right = insert(root.right, data) r...
def test_exists_pair_with_sum_yes(): values = [4, 2, 6, 1, 3, 5, 7] k = 9 root = build_bst_from_list(values) assert exists_pair_with_sum(root, k) == True def test_exists_pair_with_sum_no(): values = [4, 2, 6, 1, 3, 5, 7] k = 14 root = build_bst_from_list(values) assert exists_pair_with_...
[]
[ 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 Node:\n def __init__(self, data):\n self.data = data\n self.left = None\n self.right = None\n\ndef insert(root, data):\n if root i...
trial_gpt4o_0
{ "original_instruction": "You are given a balanced binary search tree (BST) and an integer $k$. Your task is to determine whether there exist two different nodes in the BST whose values sum up to $k$. \n\nConsider the following definition for a binary search tree node:\n\n```python\nclass Node:\n def __init__(sel...
0.541414
Taco_33091
C
[ "insert", "find_pair_with_sum", "exists_pair_with_sum", "build_bst_from_list" ]
4
[ [ "build_bst_from_list", "insert" ], [ "exists_pair_with_sum", "find_pair_with_sum" ] ]
2
[]
false
[ "Node" ]
true
pytest
false
[]
true
677d4fe9e4ee83327b3b403115923f50cf23a345
2df6282ba4b35dffc0cd54582df9487d4e390c4a
v1.0
complete
Taco
Taco_33067_C
class TreeNode: def __init__(self): self.data = 0 self.children = [] def add_data(tree, u, d): tree[u].data += d def get_subtree_sum(tree, u): def dfs(node): total = node.data for child in node.children: total += dfs(tree[child]) return total return ...
class TreeNode: def __init__(self): self.data = 0 self.children = [] def add_data(tree, u, d): tree[u].data += d def get_subtree_sum(tree, u): def dfs(node): total = node.data for child in node.children: total += dfs(tree[child]) return total return ...
from solution import solve def test_solve_example(): n, q = 5, 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] queries = [(1, 2, 5), (1, 3, 10), (2, 2), (2, 1), (2, 3)] assert solve(n, q, edges, queries) == [5, 15, 10] def test_solve_no_data_operations(): n, q = 3, 2 edges = [(1, 2), (1, 3)] qu...
[]
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\nclass TreeDataStorage:\n def __init__(self, n):\n self.n = n\n self.tree = defaultdict(list)\n ...
trial_gpt4o_4
{ "original_instruction": "Tara has a tree-structured data storage system. This tree is rooted at node 1 and has n nodes in total. Each node contains a certain amount of data. Tara needs to perform various operations on this tree. These operations are as follows:\n\n1. Add Data: For a given node u, add a specific amo...
0.63786
Taco_33067
C
[ "add_data", "get_subtree_sum", "solve" ]
3
[ [ "solve", "add_data" ], [ "solve", "get_subtree_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
898826ad67f925566bedc23420e58c121bec6927
e7c3ed13f33ec3bae3e57faf39177ac7da025c37
v1.0
complete
Taco
Taco_33194_C
from typing import List, Tuple def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) def minimum_spanning_tree(N: int, M: int, roads: List[Tuple[int, int, int]]) -> int: """ Given ...
from typing import List, Tuple def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = rootX ...
def test_example_case(): N = 4 M = 5 roads = [(1, 2, 1), (1, 3, 3), (2, 3, 2), (3, 4, 4), (4, 2, 5)] assert minimum_spanning_tree(N, M, roads) == 7 def test_disconnected_graph(): N = 4 M = 2 roads = [(1, 2, 1), (3, 4, 2)] assert minimum_spanning_tree(N, M, roads) == -1 def test_single_...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimum_spanning_tree(N: int, M: int, roads):\n \"\"\"\n Returns the total length of the Minimum Spanning Tree (MST) connecting all N villages.\n If i...
trial_gpt4o_2
{ "original_instruction": "In an ancient kingdom, there are N villages connected by M bidirectional roads, where each road connects exactly two different villages. The roads can have different lengths. The kingdom wants to minimize the total road length required to connect all villages so that there is a path between...
0.646483
Taco_33194
C
[ "find", "union", "minimum_spanning_tree" ]
3
[ [ "minimum_spanning_tree", "find" ], [ "minimum_spanning_tree", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
10d59edb613ded0926e35dca33cd4bcde72a3050
f5e4891cf6bd5ec354123d1d5db80b8c31da1bda
v1.0
complete
Taco
Taco_33351_C
def count_sharp_knives(knives, required_sharpness): """ Returns a list of counts of knives suitable for each ingredient's required sharpness values. Parameters: knives (list): a list of integers representing the sharpness values of the knives. required_sharpness (list): a list of integers represent...
def count_sharp_knives(knives, required_sharpness): """ Returns a list of counts of knives suitable for each ingredient's required sharpness. Parameters: knives (list): a list of integers representing the sharpness values of the knives. required_sharpness (list): a list of integers representing...
from solution import count_sharp_knives def test_example_1(): knives = [10, 15, 20] required_sharpness = [12, 17] assert count_sharp_knives(knives, required_sharpness) == [2, 1] def test_example_2(): knives = [5, 9, 12, 16, 25] required_sharpness = [10, 20, 8, 5] assert count_sharp_knives(kniv...
[ { "docstring": "Returns a list of counts of knives suitable for each ingredient's required sharpness.\n\nParameters:\nknives (list): a list of integers representing the sharpness values of the knives.\nrequired_sharpness (list): a list of integers representing the required sharpness for each ingredient.\n\nRetu...
[ 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 suitable_knives(knives, ingredients):\n \"\"\"\n For each ingredient's required sharpness, count how many knives in the set \n have a sharpness value ...
trial_gpt4o_4
{ "original_instruction": "Sarah is preparing for a cooking competition and is practicing some advanced knife skills. She has a set of various knives, each with a different sharpness value. Given that a recipe involves cutting certain ingredients, she needs to ensure that each cut made is as smooth as possible. A smo...
0.596081
Taco_33351
C
[ "count_sharp_knives", "binary_search" ]
2
[ [ "count_sharp_knives", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d5424e66a8f52fb7c56373c91746f32623a70f97
2e02ed4dd5fa11bc161fcfdbe1a30a20891dd789
v1.0
complete
Taco
Taco_32816_C
def sieve_of_eratosthenes(limit): """ Generate a list of booleans representing primality of numbers from 0 to limit. True means the number is prime, False means it is not. """ pass def count_primes_in_intervals(intervals): """ For each interval in the intervals list, count the prime numbers...
def sieve_of_eratosthenes(limit): """ Generate a list of booleans representing primality of numbers from 0 to limit. True means the number is prime, False means it is not. """ is_prime = [True] * (limit + 1) is_prime[0] = is_prime[1] = False # 0 and 1 are not prime numbers p = 2 wh...
def test_sieve_of_eratosthenes(): primes_up_to_10 = sieve_of_eratosthenes(10) assert primes_up_to_10 == [False, False, True, True, False, True, False, True, False, False, False] def test_count_primes_in_intervals(): intervals = [(2, 10), (11, 20), (20, 30)] assert count_primes_in_intervals(intervals) =...
[ { "docstring": "Generate a list of booleans representing primality of numbers from 0 to limit.\nTrue means the number is prime, False means it is not.", "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "do...
[ 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 count_primes_in_range(a, b):\n \"\"\"\n Returns the number of prime numbers in the interval [a, b] (inclusive).\n \"\"\"\n def is_prime(n):\n ...
trial_gpt4o_2
{ "original_instruction": "A mysterious scroll has been found in an ancient library, and it contains encrypted messages believed to reveal the hidden location of a mythical treasure. The encryption method used is based on a unique set of rules involving prime numbers.\n\nYour task is to write a program that decodes t...
0.64581
Taco_32816
C
[ "sieve_of_eratosthenes", "count_primes_in_intervals", "decode_messages" ]
3
[ [ "count_primes_in_intervals", "sieve_of_eratosthenes" ], [ "decode_messages", "count_primes_in_intervals" ] ]
2
[]
false
[]
false
pytest
false
[]
true
41d24a92691e8a3505715550515a7f90b3ba1af9
2f1ae650e91c0eb7e7fb5a50a2adefde94fb2201
v1.0
complete
Taco
Taco_32411_C
def is_valid_serial(serial): """ Checks if a given serial number is valid. A valid serial number must: 1. Contain at least two different digits. 2. Have no consecutive identical digits. """ pass def check_serials(serials): """ This function processes a list of serial numbers and che...
def is_valid_serial(serial): """ Checks if a given serial number is valid. A valid serial number must: 1. Contain at least two different digits. 2. Have no consecutive identical digits. """ if len(set(serial)) < 2: return "Invalid" for i in range(1, len(serial)): if seria...
def test_single_valid_serial(): assert is_valid_serial("12345") == "Valid" def test_single_invalid_serial_identical_digits(): assert is_valid_serial("11111") == "Invalid" def test_single_invalid_serial_consecutive_identical(): assert is_valid_serial("112233") == "Invalid" def test_single_valid_serial_wit...
[ { "docstring": "Checks if a given serial number is valid.\nA valid serial number must:\n1. Contain at least two different digits.\n2. Have no consecutive identical digits.", "function_declaration": "def is_valid_serial(serial):", "function_name": "is_valid_serial", "parameter_list": "(serial)" }, ...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_serial(serial):\n \"\"\"\n Checks if the given serial number is valid according to the rules.\n A valid serial number must:\n 1. Contain a...
trial_gpt4o_5
{ "original_instruction": "A factory produces a series of electronic devices each having a unique serial number. The serial number consists of digits only. The factory wants to ensure that each serial number is valid according to specific rules before the devices are shipped. A valid serial number must have the follo...
0.556872
Taco_32411
C
[ "is_valid_serial", "check_serials" ]
2
[ [ "check_serials", "is_valid_serial" ] ]
1
[]
false
[]
false
pytest
false
[]
true
27d9dd26a2e5b8ce472f6b17eb5d9dff0a6a7544
7b4f92a21dad1b8fffaf75cc89a34f0b28ffd96e