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_37407_C
class TransientError(Exception): pass def send_request() -> str: # Simulates sending a request to a service. from random import randint if randint(0, 1) == 0: raise TransientError("Transient error occurred") else: return "Success" def send_with_retry(max_retries: int) -> str: "...
class TransientError(Exception): pass def send_request() -> str: # Simulates sending a request to a service. from random import randint if randint(0, 1) == 0: raise TransientError("Transient error occurred") else: return "Success" def send_with_retry(max_retries: int) -> str: "...
from solution import TransientError, send_request, send_with_retry def test_send_with_retry_success_first_try(monkeypatch): def mock_send_request(): return "Success" monkeypatch.setattr('solution.send_request', mock_send_request) assert send_with_retry(3) == "Success" def test_send_with_retry_succ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TransientError(Exception):\n pass\n\ndef send_request() -> str:\n # Simulates sending a request to a service.\n from random import randint\n if r...
trial_gpt4o_0
{ "original_instruction": "You are a developer working on a complex multi-tier application that communicates with several back-end services. One of your tasks is to ensure the reliability and efficiency of communication with these services by implementing a retry mechanism. The retry mechanism should attempt to resen...
0.462859
Taco_37407
C
[ "send_request", "send_with_retry" ]
2
[ [ "send_with_retry", "send_request" ] ]
1
[]
false
[ "TransientError" ]
true
pytest
true
[]
true
8fa19fa711ef90b620ccc1bdafd10db7da30bb99
847f696f4d198f1d83942595c2178fbe27ed6039
v1.0
complete
Taco
Taco_36825_C
from typing import List, Optional class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(level_order: List[Optional[int]]) -> Optional[TreeNode]: """ Builds a binary tree from the level-order traversal list. ...
from typing import List, Optional class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(level_order: List[Optional[int]]) -> Optional[TreeNode]: if not level_order or level_order[0] is None: return No...
import pytest from solution import max_path_sum def test_max_path_sum_example_1(): assert max_path_sum(6, [1, 2, 3, None, 5, None, None]) == 8 def test_max_path_sum_example_2(): assert max_path_sum(3, [1, 2, 3]) == 4 def test_max_path_sum_single_node(): assert max_path_sum(1, [1]) == 1 def test_max_path...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree_from_list(level):\n if ...
trial_gpt4o_2
{ "original_instruction": "You are given a binary tree where each node contains an integer value. The binary tree is represented as a list of integers in level-order traversal where `null` represents the absence of a node. Your task is to find the maximum sum of values in any path from the root node to a leaf node.\n...
0.531782
Taco_36825
C
[ "build_tree", "max_sum_root_to_leaf", "max_path_sum" ]
3
[ [ "max_path_sum", "build_tree" ], [ "max_path_sum", "max_sum_root_to_leaf" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
d068ca276d8ad409ef3447a05815c295f459f41d
8051fe08defdf782ffc3e34f6b925534ecf7991d
v1.0
complete
Taco
Taco_37117_C
from typing import List def is_arithmetic_progression(arr: List[int]) -> bool: """Check if the given list of integers forms an arithmetic progression.""" ... def is_geometric_progression(arr: List[int]) -> bool: """Check if the given list of integers forms a geometric progression.""" ... def can_form...
def is_arithmetic_progression(arr): if len(arr) < 2: return True arr.sort() d = arr[1] - arr[0] for i in range(2, len(arr)): if arr[i] - arr[i-1] != d: return False return True def is_geometric_progression(arr): if len(arr) < 2: return True arr.sort() ...
def test_no_initial_books(): assert can_form_shelf([]) == True def test_single_initial_book(): assert can_form_shelf([1]) == True def test_arithmetic_progression(): assert can_form_shelf([3, 1, 2, 4]) == True def test_invalid_arithmetic_progression(): assert can_form_shelf([1, 2, 3, 5]) == False def...
[ { "docstring": null, "function_declaration": "def is_arithmetic_progression(arr):", "function_name": "is_arithmetic_progression", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def is_geometric_progression(arr):", "function_name": "is_geometric_progression...
[ 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_arithmetic_progression(arr):\n if len(arr) < 2:\n return True\n arr.sort()\n d = arr[1] - arr[0]\n for i in range(2, len(arr)):\n ...
trial_gpt4o_0
{ "original_instruction": "Twilight Sparkle is organizing a book fair in Equestria. She has decided to group the books into different categories, and each category will have a separate shelf. Each shelf can hold books based on a specific criterion of book height. The criterion is as follows: A shelf can hold books wh...
0.537369
Taco_37117
C
[ "is_arithmetic_progression", "is_geometric_progression", "can_form_shelf", "main" ]
4
[ [ "can_form_shelf", "is_arithmetic_progression" ], [ "can_form_shelf", "is_geometric_progression" ] ]
2
[]
false
[]
false
pytest
false
[]
true
9f1507592a91a5969350c1af4b81cb0e972df0ee
72510e03a410b2160ef9b02d693823bff552c69a
v1.0
complete
Taco
Taco_37348_C
import math from typing import List def calculate_std_dev(arr: List[int]) -> float: """ Calculate the standard deviation of a list of integers. """ n = len(arr) mean = sum(arr) / n variance = sum((x - mean) ** 2 for x in arr) / n return math.sqrt(variance) def min_std_dev_after_removal(arr: Li...
import math def calculate_std_dev(arr): n = len(arr) mean = sum(arr) / n variance = sum((x - mean) ** 2 for x in arr) / n return math.sqrt(variance) def min_std_dev_after_removal(arr): n = len(arr) if n <= 1: return 0 original_std_dev = calculate_std_dev(arr) min_std_dev =...
from solution import min_std_dev_after_removal def test_min_std_dev_example_1(): assert min_std_dev_after_removal([1, 2, 3, 4, 5]) == 1.118034 def test_min_std_dev_example_2(): assert min_std_dev_after_removal([10, 10, 10, 10]) == 0.000000 def test_min_std_dev_example_3(): assert min_std_dev_after_remova...
[ { "docstring": null, "function_declaration": "def calculate_std_dev(arr):", "function_name": "calculate_std_dev", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def min_std_dev_after_removal(arr):", "function_name": "min_std_dev_after_removal", "parame...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef minimum_std_dev(n, arr):\n def std_dev(remaining):\n mean = sum(remaining) / len(remaining)\n variance = sum((x - mean) ** 2 fo...
trial_gpt4o_9
{ "original_instruction": "Given an array of integers, you are going to remove exactly one element from the array so that the standard deviation of the remaining elements becomes as small as possible.\n\nThe standard deviation of a dataset is a measure of how much the elements in the dataset deviate from the mean. Fo...
0.668445
Taco_37348
C
[ "calculate_std_dev", "min_std_dev_after_removal" ]
2
[ [ "min_std_dev_after_removal", "calculate_std_dev" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a38948c7a315721771e9b36062c41ca65180735
faecc4b22b943c98af5d249180633893b4ef3c1c
v1.0
complete
Taco
Taco_37576_C
def count_twin_primes(n: int) -> int: """ Counts the number of twin prime pairs (p1, p2) such that p2 - p1 = 2 and p2 <= n. >>> count_twin_primes(10) 2 >>> count_twin_primes(5) 1 >>> count_twin_primes(2) 0 >>> count_twin_primes(20) 4 >>> count_twin_primes(100) 8 ...
def sieve_of_eratosthenes(n): """ Generates a list of booleans indicating whether each number <= n is prime. """ primes = [True] * (n + 1) p = 2 while (p * p <= n): if primes[p]: for i in range(p * p, n + 1, p): primes[i] = False p += 1 primes[0], ...
from solution import count_twin_primes def test_twin_primes_below_10(): assert count_twin_primes(10) == 2 def test_twin_primes_below_5(): assert count_twin_primes(5) == 1 def test_twin_primes_below_2(): assert count_twin_primes(2) == 0 def test_twin_primes_below_20(): assert count_twin_primes(20) ==...
[ { "docstring": "Generates a list of booleans indicating whether each number <= n is prime.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Counts the number of twin prime pairs (p1, p2) such that ...
[ 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 count_twin_primes(n):\n \"\"\"\n Function to count the number of twin prime pairs where both elements are less than or equal to n.\n \"\"\"\n if n ...
trial_gpt4o_1
{ "original_instruction": "Alex loves numbers and he recently learned about prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Alex is now curious about pairs of prime numbers that have a certain interesting property: the difference between them is ...
0.661257
Taco_37576
C
[ "sieve_of_eratosthenes", "count_twin_primes" ]
2
[ [ "count_twin_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ce7f4827cec3f40d1c288dff891d86b585ada564
822b58ae8f80bdad190ce1982e18201399a25b25
v1.0
complete
Taco
Taco_37664_C
def reverse_number(n: int) -> int: """ Reverse the digits of the given number. """ return int(str(n)[::-1]) def make_symmetrical(n: int) -> tuple[int, int]: """ Determine the number of steps it takes to make the given integer symmetrical by repeatedly adding the reverse of the number to itself. ...
def reverse_number(n): return int(str(n)[::-1]) def make_symmetrical(n): steps = 0 while n != reverse_number(n): n += reverse_number(n) steps += 1 return steps, n
from solution import make_symmetrical def test_already_symmetrical(): assert make_symmetrical(1331) == (0, 1331) def test_single_step(): assert make_symmetrical(56) == (1, 121) def test_multiple_steps(): assert make_symmetrical(87) == (4, 4884) def test_single_step_large(): assert make_symmetrical(1...
[ { "docstring": null, "function_declaration": "def reverse_number(n):", "function_name": "reverse_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def make_symmetrical(n):", "function_name": "make_symmetrical", "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": "def reverse_number(n):\n return int(str(n)[::-1])\n\ndef make_symmetrical(n):\n steps = 0\n while n != reverse_number(n):\n n += reverse_number(n)\...
trial_gpt4o_0
{ "original_instruction": "Tom is fascinated by symmetrical numbers. A symmetrical number is one that remains the same when its digits are reversed. Given an integer, Tom wants to determine the number of steps it takes to make it symmetrical by repeatedly adding the reverse of the number to itself.\n\nFor example:\n-...
0.663635
Taco_37664
C
[ "reverse_number", "make_symmetrical" ]
2
[ [ "make_symmetrical", "reverse_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
17415482f14bf2e19ad22841f0b88770d263970e
550b839b7af0fd2211197058445cec378927831d
v1.0
complete
Taco
Taco_37413_C
def shortest_word_ladder_length(words, start, end): """Returns the length of the shortest word ladder from start to end. If no such ladder exists, returns -1. >>> shortest_word_ladder_length(["hot", "dot", "dog", "lot", "log"], "hot", "dog") 3 >>> shortest_word_ladder_length(["hot", "dot", "dog", "lot",...
from collections import deque def is_adjacent(word1, word2): """ Returns True if word1 and word2 differ by exactly one character. """ difference_count = 0 for c1, c2 in zip(word1, word2): if c1 != c2: difference_count += 1 if difference_count > 1: return Fals...
def test_shortest_word_ladder_length(): words = ["hot", "dot", "dog", "lot", "log"] assert shortest_word_ladder_length(words, "hot", "dog") == 3 def test_no_ladder_exists(): words = ["hot", "dot", "dog", "lot", "log"] assert shortest_word_ladder_length(words, "hot", "logx") == -1 def test_single_step_...
[ { "docstring": "Returns True if word1 and word2 differ by exactly one character.", "function_declaration": "def is_adjacent(word1, word2):", "function_name": "is_adjacent", "parameter_list": "(word1, word2)" }, { "docstring": "Returns the length of the shortest word ladder from start to end....
[ 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 collections import deque\n\ndef shortest_word_ladder_length(N, words, start, end):\n def word_differs_by_one(w1, w2):\n count = sum(1 for a, b in zi...
trial_gpt4o_2
{ "original_instruction": "Alice loves solving puzzles, and her latest obsession is word puzzles. She got a list of N words and wants to create a word ladder puzzle out of them. A word ladder is a sequence of words where each word in the sequence differs from the previous word by exactly one character (e.g., CAT -> C...
0.571222
Taco_37413
C
[ "is_adjacent", "shortest_word_ladder_length" ]
2
[ [ "shortest_word_ladder_length", "is_adjacent" ] ]
1
[]
false
[]
false
pytest
false
[]
true
faa8dc12a88bd881dfe6fe319807959484a4b375
fec1369b0da338eb1f6b4f4ec3df10dd4f0c589b
v1.0
complete
Taco
Taco_37594_C
class TreeNode: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def is_bst(node, min_value, max_value): """ Check if the given binary tree is a valid BST. >>> root = TreeNode(10, TreeNode(5), TreeNode(15)) >>> is_bst(root,...
class TreeNode: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def is_bst(node, min_value, max_value): if node is None: return True if node.value <= min_value or node.value >= max_value: return False retur...
from solution import TreeNode, is_bst, to_tree_structure, minimal_bst_correction def test_is_bst(): # Valid BST example root = TreeNode(10, TreeNode(5), TreeNode(15)) assert is_bst(root, float('-inf'), float('inf')) == True # Invalid BST example invalid_root = TreeNode(10, TreeNode(5, right=TreeNo...
[]
[ 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": "def is_valid_bst(tree_data):\n def is_bst(node_index, min_val, max_val):\n if node_index == -1:\n return True\n value, left_child, righ...
trial_gpt4o_3
{ "original_instruction": "You are given a binary search tree (BST) with `N` nodes. Each node has a unique integer value. Your task is to determine if the tree forms a valid BST and, if not, determine the minimal changes required to make it a valid BST by either deleting or modifying nodes.\n\nA valid BST is defined ...
0.601665
Taco_37594
C
[ "is_bst", "to_tree_structure", "minimal_bst_correction" ]
3
[ [ "minimal_bst_correction", "is_bst" ], [ "minimal_bst_correction", "to_tree_structure" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
6aac62170fb3c577456b5f660b18b19a844c1649
33b6aa1059543920d301af5d4366e32ed42c16cb
v1.0
complete
Taco
Taco_37198_C
def calculate_race_times(n, k, times): """ Calculates the total time taken by each team to complete the race. Parameters: - n (int): Number of teams - k (int): Number of members in each team - times (list): A list of lists where each inner list contains the completion times of the te...
def calculate_race_times(n, k, times): """ Calculates the total time taken by each team to complete the race. Parameters: - n (int): Number of teams - k (int): Number of members in each team - times (list): A list of lists where each inner list contains the completion times of the te...
from solution import relay_race, calculate_race_times def test_single_team_single_member(): assert relay_race(1, 1, [[5]]) == [5] def test_multiple_teams_single_member(): assert relay_race(3, 1, [[5], [10], [7]]) == [5, 10, 7] def test_multiple_teams_multiple_members(): assert relay_race(3, 4, [[5, 4, 7,...
[ { "docstring": "Calculates the total time taken by each team to complete the race.\n\nParameters:\n- n (int): Number of teams\n- k (int): Number of members in each team\n- times (list): A list of lists where each inner list contains the \n completion times of the team members of a team\n\nReturns:\n- list: A l...
[ 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 calculate_team_total_times(n, k, team_times):\n \"\"\"\n Calculate the total race time for each team.\n \n Args:\n n : int : Number of teams\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of n teams participating in a relay race, where each team has k members that need to complete their segment of the race one after another. The order in which team members complete their segments is predefined for each team. Given the completion times of each member of e...
0.567537
Taco_37198
C
[ "calculate_race_times", "relay_race" ]
2
[ [ "relay_race", "calculate_race_times" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e71b648f172f2ec0214a57e8c2efc7933287136b
02bd94334564861a685ed7c2597bb38a7c872566
v1.0
complete
Taco
Taco_37468_C
def shortest_path(num_warehouses: int, adj_matrix: List[List[int]], start: int, dest: int) -> int: """Find the shortest path between two specific warehouses using Dijkstra's algorithm. Args: num_warehouses (int): Number of warehouses. adj_matrix (List[List[int]]): Adjacency matrix representing ...
import heapq def dijkstra(adj_matrix, start, dest): n = len(adj_matrix) start -= 1 dest -= 1 # Distance from start to all other nodes distances = [float('inf')] * n distances[start] = 0 # Priority Queue to store (distance, node) pq = [(0, start)] while pq: cur...
def test_shortest_path(): assert shortest_path(4, [[0, 10, 15, 0], [10, 0, 0, 20], [15, 0, 0, 30], [0, 20, 30, 0]], 1, 4) == 30 assert shortest_path(4, [[0, 10, 20, 0], [10, 0, 0, 15], [20, 0, 0, 10], [0, 15, 10, 0]], 1, 4) == 25 assert shortest_path(3, [[0, 10, 0], [10, 0, 20], [0, 20, 0]], 1, 3) == 30 ...
[ { "docstring": null, "function_declaration": "def dijkstra(adj_matrix, start, dest):", "function_name": "dijkstra", "parameter_list": "(adj_matrix, start, dest)" }, { "docstring": null, "function_declaration": "def shortest_path(num_warehouses, adj_matrix, start, dest):", "function_n...
[ 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 dijkstra(adj_matrix, start, dest):\n n = len(adj_matrix)\n start -= 1\n dest -= 1\n \n # Distance from start to all other nodes\...
trial_gpt4o_0
{ "original_instruction": "A company is interested in optimizing their transportation routes by evaluating the shortest possible route between their warehouses. Their system can be represented using a weighted, undirected graph where nodes represent warehouses and edges represent the transportation routes, with weigh...
0.609946
Taco_37468
C
[ "dijkstra", "shortest_path" ]
2
[ [ "shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
f64190cf97d5c767168e95d0dcb9ceca3d4fa673
5d109e2b408403a6b9b06cc21f6e9f3f1b9e8a95
v1.0
complete
Taco
Taco_36914_C
from typing import List def bakery_sales_vs_orders(N: int, M: int, item_prices_list: List[str], logs: List[str]) -> str: """ Computes the difference in total sales revenue and predicted revenue for each item at the end of the day. Arguments: N : int - The number of log entries. M : int - The numb...
def sales_vs_orders_difference(N, M, item_prices, log): """ Calculate the difference between total sales revenue and predicted revenue for each item. Args: N: int - The number of log entries. M: int - The number of different items sold by the shop. item_prices: dict - A dictionary with item...
def test_sales_vs_orders_difference(): N = 5 M = 2 item_prices_list = ["croissant 5", "muffin 3"] logs = [ "+ croissant 20", "- croissant 10", "+ muffin 5", "- muffin 8", "+ croissant 30" ] expected_output = "croissant 200\nmuffin -9" actual_output = ...
[ { "docstring": "Calculate the difference between total sales revenue and predicted revenue for each item.\n\nArgs:\nN: int - The number of log entries.\nM: int - The number of different items sold by the shop.\nitem_prices: dict - A dictionary with item names as keys and their price per unit as values.\nlog: li...
[ 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 calculate_revenue_difference(log_entries, prices):\n sales_revenue = {}\n predicted_revenue = {}\n \n for item_name in prices:\n sales_reven...
trial_gpt4o_2
{ "original_instruction": "A bakery shop keeps track of their daily sales and orders in a log. Each entry in the log records a sale or an order of a particular item. The shop needs your help to compute the difference in total sales revenue and predicted revenue for each item at the end of the day.\n\nThe shop sells v...
0.644113
Taco_36914
C
[ "sales_vs_orders_difference", "format_output", "bakery_sales_vs_orders" ]
3
[ [ "bakery_sales_vs_orders", "format_output" ], [ "bakery_sales_vs_orders", "sales_vs_orders_difference" ] ]
2
[ "format_output" ]
false
[]
false
pytest
false
[]
true
54e7b4531ee1d51d374fe15b62208fbfdcfb3057
e91f01adef3d6bcb300163342385166f04040cdb
v1.0
complete
Taco
Taco_37802_C
def is_self_dividing(num: int) -> bool: """ Check if a number is self-dividing or not. >>> is_self_dividing(128) True >>> is_self_dividing(120) False >>> is_self_dividing(101) False >>> is_self_dividing(22) True """ pass def self_dividing_numbers(left: int, right: int) -> Li...
def is_self_dividing(num): """ Check if a number is self-dividing or not. """ original = num while num > 0: digit = num % 10 if digit == 0 or original % digit != 0: return False num //= 10 return True def self_dividing_numbers(left, right): """ Return...
from solution import self_dividing_numbers, is_self_dividing def test_self_dividing_numbers_basic(): assert self_dividing_numbers(1, 22) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22] def test_self_dividing_numbers_large_range(): # Not all elements will be checked exactly, we'll just ensure the function compl...
[ { "docstring": "Check if a number is self-dividing or not.", "function_declaration": "def is_self_dividing(num):", "function_name": "is_self_dividing", "parameter_list": "(num)" }, { "docstring": "Return a list of self-dividing numbers between left and right (inclusive).", "function_decl...
[ 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_self_dividing(number):\n \"\"\"\n Check if a number is self-dividing.\n \"\"\"\n original = number\n while number > 0:\n digit = numbe...
trial_gpt4o_2
{ "original_instruction": "```if:javascript\nA \"self-dividing number\" is a number that is divisible by every digit it contains. An integer `num` is self-dividing if:\n\n- `num % d == 0` for every digit `d` in its decimal representation.\n- `num` does not contain the digit zero.\n\nWrite a function `selfDividingNumb...
0.628235
Taco_37802
C
[ "is_self_dividing", "self_dividing_numbers" ]
2
[ [ "self_dividing_numbers", "is_self_dividing" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a5dfa540a4d6193f78b1ae5801653db0c1e2a6df
ae532289f00e5418d59fcc18cb007cbfcb0af99a
v1.0
complete
Taco
Taco_37866_C
def shift_character(c, shift): """ Shift a single character by the given number of positions in the alphabet. Wrap around if the end of the alphabet is reached. """ if 'a' <= c <= 'z': return chr((ord(c) - ord('a') + shift) % 26 + ord('a')) elif 'A' <= c <= 'Z': return chr((ord(c...
def shift_character(c, shift): """ Shift a single character by the given number of positions in the alphabet. Wrap around if the end of the alphabet is reached. """ if 'a' <= c <= 'z': return chr((ord(c) - ord('a') + shift) % 26 + ord('a')) elif 'A' <= c <= 'Z': return chr((ord(c...
from solution import process_test_cases def test_example_cases(): t = 3 test_cases = [ ("abc", 1), ("XYZ", 3), ("Hello, World!", 5) ] results = process_test_cases(t, test_cases) assert results == ["bcd", "ABC", "Mjqqt, Btwqi!"] def test_no_shift(): t = 2 test_cases ...
[ { "docstring": "Shift a single character by the given number of positions in the alphabet.\nWrap around if the end of the alphabet is reached.", "function_declaration": "def shift_character(c, shift):", "function_name": "shift_character", "parameter_list": "(c, shift)" }, { "docstring": "Tra...
[ 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 shift_character(c, shift):\n \"\"\"\n Shift a single character by the given number of positions in the alphabet.\n Wrap around if the end of the alpha...
trial_gpt4o_0
{ "original_instruction": "Emma is working on text transformation and needs to implement a function that will shift every alphabetical character in a given string by a specified number of places in the alphabet. She needs your help to write code for this.\n\nThe function should handle both uppercase and lowercase let...
0.717938
Taco_37866
C
[ "shift_character", "transform_string", "process_test_cases" ]
3
[ [ "process_test_cases", "transform_string" ], [ "transform_string", "shift_character" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
510277e019b06d7eb6789f985e0517b99fc495f6
f5a8b87fa7795113b4ab75a1ffe2343311f6767f
v1.0
complete
Taco
Taco_37620_C
def find_max_cluster(plants): """ Finds the maximum cluster of plants where no plant is taller than another plant that appeared earlier on either day. """ pass def longest_increasing_subsequence(seq): """ Finds the length of the longest increasing subsequence in a sequence. """ pass...
def find_max_cluster(plants): """ Finds the maximum cluster of plants where no plant is taller than another plant that appeared earlier on either day. """ # Sort the plants by their heights on the first day plants_sorted_day1 = sorted(plants, key=lambda x: x[0]) # Get only the heights of the...
def test_find_max_cluster_case1(): plants = [(1, 2), (2, 3), (3, 1)] assert find_max_cluster(plants) == 2 def test_find_max_cluster_case2(): plants = [(1, 3), (2, 2), (3, 4), (4, 1)] assert find_max_cluster(plants) == 2 def test_find_max_cluster_case3(): plants = [(1, 4), (2, 3), (3, 2), (4, 1)] ...
[ { "docstring": "Finds the maximum cluster of plants where no plant is taller\nthan another plant that appeared earlier on either day.", "function_declaration": "def find_max_cluster(plants):", "function_name": "find_max_cluster", "parameter_list": "(plants)" }, { "docstring": null, "func...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_cluster(n, heights):\n # Sort plants based on height on first day; if equal, sort based on second day height\n heights.sort(key=lambda x: (x[0], x[1]...
trial_gpt4o_9
{ "original_instruction": "A newly formed scientific expedition team has discovered a special type of plants in the dense forests of Amazon. These plants have an unusual property. Each plant has a unique height, and they grow in clusters. The team has decided to study the growth pattern of these plants over several d...
0.505273
Taco_37620
C
[ "find_max_cluster", "longest_increasing_subsequence", "main" ]
3
[ [ "find_max_cluster", "longest_increasing_subsequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4ecbd4399c6755fa6330064ccb16511e19fa8ce8
827bc553d2304a8a4b0781e2573020e69d8b150d
v1.0
complete
Taco
Taco_37942_C
def generatePrimeLists(n: int) -> List[List[int]]: """ Given an integer n, generate a list of lists where each inner list contains the first 'i' prime numbers, for i ranging from 1 to n. >>> generatePrimeLists(1) [[2]] >>> generatePrimeLists(2) [[2], [2, 3]] >>> generatePrimeLists(3) [[2], [2, 3], [2, 3...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def generate_prime_numbers(n): """ Helper function to generate the first n prim...
from solution import generatePrimeLists def test_generate_prime_lists_1(): assert generatePrimeLists(1) == [[2]] def test_generate_prime_lists_2(): assert generatePrimeLists(2) == [[2], [2, 3]] def test_generate_prime_lists_3(): assert generatePrimeLists(3) == [[2], [2, 3], [2, 3, 5]] def test_generate_...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Helper function to generate the first n prime numbers.", "function_declaration": "def generate_prime_nu...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num < 2:\n return False\n for i in range(2, int(nu...
trial_gpt4o_2
{ "original_instruction": "Given an integer n, write a program to generate a list of lists where each inner list contains the first 'i' prime numbers, for i ranging from 1 to n.\n\nExample 1:\nInput: 4\nOutput: [[2], [2, 3], [2, 3, 5], [2, 3, 5, 7]]\n\nYour Task:\nYou don't need to input anything. Complete the functi...
0.706887
Taco_37942
C
[ "is_prime", "generate_prime_numbers", "generatePrimeLists" ]
3
[ [ "generatePrimeLists", "generate_prime_numbers" ], [ "generate_prime_numbers", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e1982e9cbd0c35e405670618f7815fd73838e5c3
660d056ef9c6cc9bb1ab5d630b62a8b1a8bf269c
v1.0
complete
Taco
Taco_37902_C
from typing import List, Tuple def graph_connectivity(T: int, test_cases: List[dict]) -> List[str]: """ Determine if there exists a path between pairs of nodes in a graph for multiple test cases. T: int - number of test cases test_cases: List[dict] - a list of dictionaries where each dictionary r...
def find(x, parent): if parent[x] != x: parent[x] = find(parent[x], parent) return parent[x] def union(x, y, parent, rank): rootX = find(x, parent) rootY = find(y, parent) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[rootX...
def test_solution(): T = 1 test_cases = [ { "graph": (4, 4), "edges": [(1, 2), (2, 3), (3, 4), (4, 1)], "queries": (2, [(1, 3), (1, 4)]) } ] expected_output = ["YES", "YES"] assert graph_connectivity(T, test_cases) == expected_output def tes...
[ { "docstring": null, "function_declaration": "def find(x, parent):", "function_name": "find", "parameter_list": "(x, parent)" }, { "docstring": null, "function_declaration": "def union(x, y, parent, rank):", "function_name": "union", "parameter_list": "(x, y, parent, rank)" }, ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(x, parent):\n if parent[x] != x:\n parent[x] = find(parent[x], parent)\n return parent[x]\n\ndef union(x, y, parent, rank):\n rootX = find...
trial_gpt4o_0
{ "original_instruction": "Consider a graph with `n` nodes and `m` edges. Each node is numbered from 1 to `n`. You are given the edges of the graph, where each edge connects two nodes `u` and `v`. There are also `k` pairs of nodes, and for each pair, you need to determine if there exists a path between these two node...
0.649869
Taco_37902
C
[ "find", "union", "solve", "graph_connectivity" ]
4
[ [ "graph_connectivity", "solve" ], [ "solve", "find" ], [ "solve", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
e8b34090c4156f6419d2020f5078dd39d018bc25
252e42eaf5ee0bd991b209783b8356c616c497cc
v1.0
complete
Taco
Taco_37721_C
from typing import List, Tuple, Union def is_possible_to_arrange(n: int, dominoes: List[Tuple[int, int]]) -> Union[str, List[Tuple[int, int]]]: """ Determine if it is possible to arrange all the dominoes in a line according to the rule described. If it is possible, output the arrangement. If it is not possible, ou...
def arrange_dominoes(dominoes): from collections import defaultdict, deque # Create adjacency list and count degrees adj = defaultdict(list) degree = defaultdict(int) for a, b in dominoes: adj[a].append(b) adj[b].append(a) degree[a] += 1 degree[b] += 1 ...
def test_example_1(): assert is_possible_to_arrange(3, [(1, 2), (2, 3), (3, 4)]) == [(1, 2), (2, 3), (3, 4)] def test_example_2(): assert is_possible_to_arrange(3, [(1, 2), (3, 4), (5, 6)]) == "No" def test_example_3(): assert is_possible_to_arrange(4, [(1, 2), (2, 3), (4, 5), (3, 4)]) == [(1, 2), (2, 3),...
[ { "docstring": null, "function_declaration": "def arrange_dominoes(dominoes):", "function_name": "arrange_dominoes", "parameter_list": "(dominoes)" }, { "docstring": null, "function_declaration": "def is_possible_to_arrange(n, dominoes):", "function_name": "is_possible_to_arrange", ...
[ 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 arrange_dominoes(dominoes):\n from collections import defaultdict, deque\n \n # Create adjacency list and count degrees\n adj = defaultdict(list)\n...
trial_gpt4o_0
{ "original_instruction": "Anna loves playing with dominoes. She has a set of $n$ dominoes, and each domino is represented as a tuple of two integers $(a, b)$. Anna wants to arrange all the dominoes in a line such that if she places a domino with values $(a_i, b_i)$ next to domino with values $(a_j, b_j)$, then at le...
0.544971
Taco_37721
C
[ "arrange_dominoes", "is_possible_to_arrange" ]
2
[ [ "is_possible_to_arrange", "arrange_dominoes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
485f80bc5b2049c16fe4bfc4a02b6f943513a8cf
3fb8a5514c31e0f7e452e5aea61a6d8e8b56f4af
v1.0
complete
Taco
Taco_37905_C
def card_value(card: str) -> int: """ Returns the blackjack value of a given card. >>> card_value('2') 2 >>> card_value('10') 10 >>> card_value('Jack') 10 >>> card_value('Queen') 10 >>> card_value('King') 10 >>> card_value('Ace') 1 """ def blackjack_total(cards: List[str]) -> int: ...
def card_value(card): """ Returns the blackjack value of a given card. """ if card in ['Jack', 'Queen', 'King']: return 10 elif card == 'Ace': return 1 # Start with Ace as 1, calculate 11 later if possible else: return int(card) def blackjack_total(cards): """ Ca...
import pytest from solution import card_value, blackjack_total, process_input def test_card_value(): assert card_value('2') == 2 assert card_value('10') == 10 assert card_value('Jack') == 10 assert card_value('Queen') == 10 assert card_value('King') == 10 assert card_value('Ace') == 1 def test...
[ { "docstring": "Returns the blackjack value of a given card.", "function_declaration": "def card_value(card):", "function_name": "card_value", "parameter_list": "(card)" }, { "docstring": "Calculates the highest possible total value of the given set of cards \nin blackjack without exceeding ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_blackjack_total(cards):\n \"\"\"\n Calculate the total value of a set of cards in a simplified version of Blackjack.\n cards: list of str ->...
trial_gpt4o_2
{ "original_instruction": "Blackjack Card Total\n\nYou need to write a program to calculate the total value of a set of cards in a simplified version of Blackjack. \n\nIn this version, the cards have the following values:\n\n- Number cards (2 through 10) have their face value.\n- Face cards (Jack, Queen, King) are al...
0.64674
Taco_37905
C
[ "card_value", "blackjack_total", "process_input" ]
3
[ [ "blackjack_total", "card_value" ], [ "process_input", "blackjack_total" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
071fe4e122d5280af9fad8b57985dba3a58840f4
451801f9b9a6ea007d37eaef9cce9033dd125707
v1.0
complete
Taco
Taco_37694_C
def is_symmetric(matrix) -> str: """ Determines if the given matrix is symmetric. :param matrix: A 2D list representing the matrix :return: "YES" if the matrix is symmetric, otherwise "NO" """ pass def read_matrix_and_check_symmetry(): import sys input = sys.stdin.read data = i...
def is_symmetric(matrix): """ Determines if the given matrix is symmetric. :param matrix: A 2D list representing the matrix :return: "YES" if the matrix is symmetric, otherwise "NO" """ n = len(matrix) for i in range(n): for j in range(i, n): if matrix[i][j] != matri...
import pytest from solution import is_symmetric def test_symmetric_matrix(): matrix = [ [1, 2, 3], [2, 4, 5], [3, 5, 6] ] assert is_symmetric(matrix) == "YES" def test_non_symmetric_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert is...
[ { "docstring": "Determines if the given matrix is symmetric.\n\n:param matrix: A 2D list representing the matrix\n:return: \"YES\" if the matrix is symmetric, otherwise \"NO\"", "function_declaration": "def is_symmetric(matrix):", "function_name": "is_symmetric", "parameter_list": "(matrix)" }, ...
[ 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_symmetric(matrix):\n \"\"\"\n Checks if the given matrix is symmetric with respect to its main diagonal.\n \"\"\"\n n = len(matrix)\n for i i...
trial_gpt4o_2
{ "original_instruction": "Alice loves playing with square matrices and enjoys transposing them. Recently, she encountered a matrix and wanted to determine if it is symmetric with respect to its main diagonal (i.e., the matrix should be equal to its transpose). However, Alice needs your help to automate this process....
0.572889
Taco_37694
C
[ "is_symmetric", "read_matrix_and_check_symmetry" ]
2
[ [ "read_matrix_and_check_symmetry", "is_symmetric" ] ]
1
[]
false
[]
false
pytest
true
[]
true
466ff309b3cc235ce89bde75b105bcf4dfaf3e90
b0c6574ee8cffb763f854a26f791e97b92788ae0
v1.0
complete
Taco
Taco_38095_C
def is_prime(num): """ Check if a number is a prime number >>> is_prime(2) == True >>> is_prime(3) == True >>> is_prime(4) == False >>> is_prime(17) == True >>> is_prime(18) == False """ pass def find_prime_pair(n): """ Find a pair of prime numbers whose sum is equal to n >>> fi...
def is_prime(num): if num < 2: return False if num == 2: return True if num % 2 == 0: return False p = 3 while p * p <= num: if num % p == 0: return False p += 2 return True def find_prime_pair(n): for i in range(2, n // 2 + 1): # Only ne...
from solution import is_prime, find_prime_pair, process_datasets 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_find_prime_pair(): assert find_prime_pair(10) == (3, 7) ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def find_prime_pair(n):", "function_name": "find_prime_pair", "parameter_list": "(n)" }, { "docstring...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n 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_1
{ "original_instruction": "Write a program that takes an integer n and determines if it can be expressed as the sum of two prime numbers. If it is possible, output one such pair of prime numbers. If there are multiple pairs, output the pair where the smaller prime number is the smallest among all possible pairs. If n...
0.637601
Taco_38095
C
[ "is_prime", "find_prime_pair", "process_datasets" ]
3
[ [ "find_prime_pair", "is_prime" ], [ "process_datasets", "find_prime_pair" ] ]
2
[ "process_datasets" ]
false
[]
false
pytest
true
[]
true
1d51e63c5273a76f65e1e345f6cfbf72cc066042
b5685b06ec8e277fda9729dd5121027734e2b145
v1.0
complete
Taco
Taco_37937_C
import math from typing import List, Tuple from collections import defaultdict def calculate_distance(x1: int, y1: int, x2: int, y2: int) -> float: """ Calculate the Euclidean distance between two points (x1, y1) and (x2, y2). >>> calculate_distance(0, 0, 3, 4) 5.0 >>> calculate_distance(1, 1, 4, 5) 5.0 ...
import math from collections import defaultdict def calculate_distance(x1, y1, x2, y2): return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def find_bus_with_highest_distance(reports): bus_positions = defaultdict(list) bus_distances = defaultdict(float) for report in reports: bus_id, x, y = rep...
def test_calculate_distance(): assert math.isclose(calculate_distance(0, 0, 3, 4), 5.0) assert math.isclose(calculate_distance(1, 1, 4, 5), 5.0) assert math.isclose(calculate_distance(0, 0, 0, 5), 5.0) assert math.isclose(calculate_distance(0, 5, 5, 5), 5.0) assert math.isclose(calculate_distance(5,...
[ { "docstring": null, "function_declaration": "def calculate_distance(x1, y1, x2, y2):", "function_name": "calculate_distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def find_bus_with_highest_distance(reports):", "function_name": "find_b...
[ 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 math\nfrom collections import defaultdict\n\ndef calculate_distance(x1, y1, x2, y2):\n \"\"\"\n Calculate the Euclidean distance between two points (x...
trial_gpt4o_2
{ "original_instruction": "The city's public transportation system has recently started to track the movement of its buses. Each bus has a unique ID and reports its location (x, y) coordinates at regular intervals. A transportation manager wants to find the bus that has traveled the highest distance over a given peri...
0.60586
Taco_37937
C
[ "calculate_distance", "find_bus_with_highest_distance", "main" ]
3
[ [ "find_bus_with_highest_distance", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6cb7aa2e11436249aa015d9966df31e28b36bb8d
af7ee80d061488215d88869dfd61862f1a0068a0
v1.0
complete
Taco
Taco_38423_C
from typing import List def is_prime(n: int) -> bool: """ Determine if a number is prime. """ pass def filter_primes(nums: List[int]) -> List[int]: """ Returns a list of prime numbers from the given list of integers. >>> filter_primes([10, 15, 3, 7, 9, 11]) [3, 7, 11] >>> filter_primes([4,...
def is_prime(n): """ Helper function to determine if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_pr...
from solution import filter_primes def test_filter_primes_mixed_numbers(): assert filter_primes([10, 15, 3, 7, 9, 11]) == [3, 7, 11] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 10]) == [] def test_filter_primes_with_primes_only(): assert filter_primes([2, 3, 5, 7, 11, 13]) == [2, 3...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.", "function_declaration": "def filter_...
[ 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 given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes a list of integers and returns a new list containing all the elements of the original list that are prime numbers.\n\nA prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\nExamples:\n\n```python\nfilter_primes...
0.759276
Taco_38423
C
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
30b9b69bb0eb33b5d0a2ae73fc0f3c010fae8e62
7fffcf5b2adf84207a93fad8228c9f475e778ea8
v1.0
complete
Taco
Taco_38320_C
def is_prime(num: int) -> bool: """Helper function to determine if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def check_prime_rows_and_columns(matrix: List[List[int]]) -> str: """ Function to check if any row or column in the matrix consists only of prime num...
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2 or num == 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import check_prime_rows_and_columns def test_prime_row(): matrix = [ [2, 3, 5], [4, 6, 8], [7, 11, 13] ] assert check_prime_rows_and_columns(matrix) == "YES" def test_no_prime_row_or_column(): matrix = [ [4, 6, 8], [9, 10, 12], [15, 14, 16]...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to check if any row or column in the matrix consists only of prime numbers.", "function_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": "def is_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2 or num ...
trial_gpt4o_0
{ "original_instruction": "Aman is fascinated by prime numbers and often spends his free time exploring their properties. One day, he came up with an interesting problem involving matrices and prime numbers. He needs your help to solve it.\n\nYou are given an $N \\times N$ matrix filled with integers. Your task is to...
0.743083
Taco_38320
C
[ "is_prime", "check_prime_rows_and_columns" ]
2
[ [ "check_prime_rows_and_columns", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64fc32a90b47406e17b623185c84e0af3001e60c
a5ee92ccc9d6c7ec7e53c0b275ffc77ae5b25bce
v1.0
complete
Taco
Taco_38059_C
def sum_of_digits(n: int) -> int: """ Sum the digits of an integer, repeating the process until a single-digit number is obtained. >>> sum_of_digits(12) 3 >>> sum_of_digits(45) 9 >>> sum_of_digits(-23) 5 >>> sum_of_digits(908) 8 >>> sum_of_digits(320) 5 >>> sum_of_digits(...
def sum_of_digits(n): while n >= 10 or n <= -10: n = sum(int(digit) for digit in str(abs(n))) return n if n >= 0 else -n def transform_sequence(sequences): transformed = [] for sequence in sequences: transformed_seq = [sum_of_digits(num) for num in sequence] transformed.append(t...
def test_sum_of_digits(): assert sum_of_digits(12) == 3 assert sum_of_digits(45) == 9 assert sum_of_digits(-23) == 5 assert sum_of_digits(908) == 8 assert sum_of_digits(320) == 5 assert sum_of_digits(155) == 2 assert sum_of_digits(-9) == 9 assert sum_of_digits(81) == 9 assert sum_of_...
[ { "docstring": null, "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def transform_sequence(sequences):", "function_name": "transform_sequence", "parameter_list": "(sequenc...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def digit_sum(n):\n \"\"\"\n Helper function to find the sum of digits of a number until it becomes a single-digit number.\n \"\"...
trial_gpt4o_2
{ "original_instruction": "Paul loves playing with sequences of numbers. One day, he discovered a fascinating pattern in certain integer sequences and decided to test it by writing a program. However, Paul is not very comfortable with coding, so he asked for your help.\n\nGiven an integer sequence, your task is to tr...
0.69328
Taco_38059
C
[ "sum_of_digits", "transform_sequence", "parse_input_and_transform" ]
3
[ [ "parse_input_and_transform", "transform_sequence" ], [ "transform_sequence", "sum_of_digits" ] ]
2
[ "parse_input_and_transform" ]
false
[]
false
pytest
false
[]
true
29ceb6a1f0990d5485b9f21db26dc583b75314b0
fab1aa0cc99557ad11a9f170df2576c527fde4a7
v1.0
complete
Taco
Taco_37886_C
from collections import defaultdict, deque def preprocess(n, edges): """Preprocess the graph to calculate the distances between all pairs of cities.""" adj = defaultdict(list) for u, v in edges: adj[u].append(v) adj[v].append(u) def bfs(start): """Perform BFS to calculate s...
from collections import defaultdict, deque def preprocess(n, edges): """Preprocess the graph to calculate the distance between all pairs of cities.""" adj = defaultdict(list) for u, v in edges: adj[u].append(v) adj[v].append(u) def bfs(start): """Perform BFS to calculate sh...
def test_shortest_paths_case_1(): n = 5 edges = [(1, 2), (1, 3), (3, 4), (3, 5)] queries = [(2, 4), (4, 5), (1, 3)] expected = [3, 2, 1] assert shortest_paths(n, edges, queries) == expected def test_shortest_paths_case_2(): n = 3 edges = [(1, 2), (1, 3)] queries = [(1, 2), (1, 3), (2, 3...
[ { "docstring": "Preprocess the graph to calculate the distance between all pairs of cities.", "function_declaration": "def preprocess(n, edges):", "function_name": "preprocess", "parameter_list": "(n, edges)" }, { "docstring": "Respond to each query by calculating the shortest path using pre...
[ 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, defaultdict\n\ndef preprocess_tree(tree, n):\n parent = [-1] * (n + 1)\n depth = [-1] * (n + 1)\n def bfs(start):\n ...
trial_gpt4o_2
{ "original_instruction": "Given a list of `n` cities connected by `n-1` bi-directional roads, you are provided with `q` queries. Each query provides you with two cities and asks for the shortest path length between them in terms of the number of edges. Cities are numbered from `1` to `n`.\n\nFor example, if `n=5` an...
0.724508
Taco_37886
C
[ "preprocess", "shortest_paths" ]
2
[ [ "shortest_paths", "preprocess" ] ]
1
[]
false
[]
false
pytest
false
[]
true
58b65c3927691cbe66ed7ebde6e4a294f5e454d8
7bd10903f5908f209cdea0ff028e3ae9bb557e78
v1.0
complete
Taco
Taco_38063_C
def check_magic_square_possible(n: int, grid: List[List[int]]) -> str: """ Given an n x n grid filled with integers, where n is always odd, determine if it's possible to make the grid a magic square by rotating any rows or columns. A grid is considered a magic square if the sum of each row, column, and bot...
def is_magic_square_possible(grid): n = len(grid) def row_sum(row): return sum(grid[row]) def col_sum(col): return sum(grid[row][col] for row in range(n)) def diag1_sum(): return sum(grid[i][i] for i in range(n)) def diag2_sum(): return sum(grid[i][n-1-i] for ...
def test_magic_square_possible(): assert check_magic_square_possible(3, [ [8, 1, 6], [3, 5, 7], [4, 9, 2] ]) == "YES" assert check_magic_square_possible(3, [ [8, 1, 6], [3, 5, 9], [4, 9, 2] ]) == "NO" assert check_magic_square_possible(1, [ [...
[ { "docstring": null, "function_declaration": "def is_magic_square_possible(grid):", "function_name": "is_magic_square_possible", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def check_magic_square_possible(n, grid):", "function_name": "check_magic_squar...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magic_square_possible(grid):\n n = len(grid)\n \n def row_sum(row):\n return sum(grid[row])\n\n def col_sum(col):\n return sum(gri...
trial_gpt4o_0
{ "original_instruction": "Given an n x n grid filled with integers, where n is always odd, your task is to determine if it's possible to make the grid a magic square by rotating any rows or columns. A grid is considered a magic square if the sum of each row, column, and both diagonals are equal. You can rotate a row...
0.553733
Taco_38063
C
[ "is_magic_square_possible", "check_magic_square_possible" ]
2
[ [ "check_magic_square_possible", "is_magic_square_possible" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b3dc0fe3c9e32cdc85bff7a98e823ec0a018a0b3
e4fa3cf17f8f8178ac8122fbda57cad9f2cbfd9f
v1.0
complete
Taco
Taco_38364_C
from typing import List, Tuple def find_islands(N: int, edges: List[Tuple[int, int]]) -> int: """ Return the number of distinct islands in the graph. Parameters: - N (int): number of nodes - edges (list of tuples): list of edges where each edge is represented by a tuple (u, v) Returns: - ...
from collections import defaultdict def find_islands(N, edges): """ Return the number of distinct islands in the graph. Parameters: - N (int): number of nodes - edges (list of tuples): list of edges where each edge is represented by a tuple (u, v) Returns: - int: number of distinct island...
from solution import solve def test_case_1(): input_lines = [ "2", "5 3", "1 2", "2 3", "4 5", "4 0" ] expected_output = [2, 4] assert solve(input_lines) == expected_output def test_case_2_all_connected(): input_lines = [ "1", "5 4", ...
[ { "docstring": "Return the number of distinct islands in the graph.\n\nParameters:\n- N (int): number of nodes\n- edges (list of tuples): list of edges where each edge is represented by a tuple (u, v)\n\nReturns:\n- int: number of distinct islands", "function_declaration": "def find_islands(N, edges):", ...
[ 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_islands(N, M, edges):\n from collections import defaultdict, deque\n\n # Create an adjacency list for the graph\n graph = defaultdict(list)\n ...
trial_gpt4o_2
{ "original_instruction": "You are given an undirected graph with $N$ nodes and $M$ edges. Each node is numbered from $1$ to $N$. An \"island\" is defined as a subset of nodes such that all nodes in this subset are connected directly or indirectly through edges, and no node in this subset is directly connected to any...
0.609266
Taco_38364
C
[ "find_islands", "process_test_cases", "solve" ]
3
[ [ "process_test_cases", "find_islands" ], [ "solve", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
2511bd2184dc191788eef69d37b694de50ba6bca
61c3ac98312178185ab63acee11dcd1441351f66
v1.0
complete
Taco
Taco_38475_C
from collections import defaultdict from typing import List, Tuple def lca_tree(n: int, edges: List[Tuple[int, int]], q: int, queries: List[Tuple[int, int]]) -> List[int]: """ You are given a rooted tree with n nodes, where each node is uniquely numbered from 1 to n, and the root of the tree is always nod...
import sys from collections import defaultdict, deque from math import log2, ceil sys.setrecursionlimit(200000) def preprocess_LCA(n, tree, root=1): log_n = ceil(log2(n)) parent = [[-1] * (log_n + 1) for _ in range(n + 1)] level = [-1] * (n + 1) def bfs(start): q = deque([start]) leve...
from solution import lca_tree def test_example_case_1(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] q = 3 queries = [(4, 5), (4, 3), (3, 5)] assert lca_tree(n, edges, q, queries) == [2, 1, 1] def test_example_case_2(): n = 6 edges = [(1, 2), (1, 3), (3, 4), (3, 5), (5, 6)] q = 4 ...
[ { "docstring": null, "function_declaration": "def preprocess_LCA(n, tree, root=1):", "function_name": "preprocess_LCA", "parameter_list": "(n, tree, root=1)" }, { "docstring": null, "function_declaration": "def find_LCA(u, v, parent, level):", "function_name": "find_LCA", "parame...
[ 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 sys\nfrom collections import defaultdict, deque\nfrom math import log2, ceil\n\nsys.setrecursionlimit(200000)\n\ndef preprocess_LCA(n, tree, root=1):\n l...
trial_gpt4o_0
{ "original_instruction": "You are given a rooted tree with n nodes, where each node is uniquely numbered from 1 to n, and the root of the tree is always node 1. You need to perform q queries on this tree. Each query consists of providing two nodes u and v, and you need to determine the least common ancestor (LCA) of...
0.566482
Taco_38475
C
[ "preprocess_LCA", "find_LCA", "lca_tree" ]
3
[ [ "lca_tree", "find_LCA" ], [ "lca_tree", "preprocess_LCA" ] ]
2
[]
false
[]
false
pytest
true
[]
true
59e30962c88161c6f3098f7637a0eeccd5916038
72197ed6464136a33b3b05f16fbd43c096ecc309
v1.0
complete
Taco
Taco_38654_C
def manage_course_scheduling(data: str) -> str: """ Develop an application that helps a university manage their course scheduling in a way that minimizes faculty workload conflicts. Specifically, ensures that no faculty member is scheduled to teach more than one course at any given time. Args: data (str): ...
def can_schedule_courses(course_list): from collections import defaultdict def check_conflicts(schedule): for faculty, times in schedule.items(): times.sort() for i in range(1, len(times)): if times[i][0] < times[i-1][1]: return False ...
from solution import manage_course_scheduling def test_manage_course_scheduling_no_conflict(): input_data = """ 3 alice 9 12 bob 10 13 alice 12 14 0 """ expected_output = "Yes\nalice 9 12 12 14\nbob 10 13" assert manage_course_scheduling(input_data).strip() == expected_output.strip(...
[ { "docstring": null, "function_declaration": "def can_schedule_courses(course_list):", "function_name": "can_schedule_courses", "parameter_list": "(course_list)" }, { "docstring": null, "function_declaration": "def parse_input(data):", "function_name": "parse_input", "parameter_l...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_schedule_courses(courses):\n from collections import defaultdict\n\n def no_conflict(schedule):\n # Check if there are any overlapping interva...
trial_gpt4o_2
{ "original_instruction": "You are instructed to develop an application that helps a university manage their course scheduling in a way that minimizes faculty workload conflicts. Specifically, you need to ensure that no faculty member is scheduled to teach more than one course at any given time.\n\n### Problem Statem...
0.560296
Taco_38654
C
[ "can_schedule_courses", "parse_input", "manage_course_scheduling" ]
3
[ [ "manage_course_scheduling", "can_schedule_courses" ], [ "manage_course_scheduling", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
67f782c2d8b1bb7f91dc258957fa2a48dd729492
b26e74b67436b25946df550a5301b23c3ce82173
v1.0
complete
Taco
Taco_38082_C
def max_product_of_three(arr): """ Returns the maximum product of any three numbers in the array. If the array contains fewer than three elements, returns 'NO SOLUTION'. """ # Your code here def find_max_product_of_three(test_cases): """ Given multiple test cases, finds the maximum product ...
def max_product_of_three(arr): """ Returns the maximum product of any three numbers in the array. If the array contains fewer than three elements, returns 'NO SOLUTION'. """ n = len(arr) if n < 3: return 'NO SOLUTION' arr.sort() # The maximum product can be the product ...
def test_max_product_of_three(): assert max_product_of_three([10, 3, 5, 6, 20]) == 1200 assert max_product_of_three([-10, -10, 5, 2, 1, 0]) == 500 assert max_product_of_three([1, 2]) == 'NO SOLUTION' assert max_product_of_three([1, 2, 3]) == 6 assert max_product_of_three([]) == 'NO SOLUTION' ass...
[ { "docstring": "Returns the maximum product of any three numbers in the array.\nIf the array contains fewer than three elements, returns 'NO SOLUTION'.", "function_declaration": "def max_product_of_three(arr):", "function_name": "max_product_of_three", "parameter_list": "(arr)" }, { "docstri...
[ 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_product_of_three(arr):\n \"\"\"\n Returns the maximum product of any three numbers in the array.\n If the array contains fewer than three elements...
trial_gpt4o_1
{ "original_instruction": "Given an array of integers, you need to find the maximum product of any three numbers in the array. If the array contains fewer than three elements, print 'NO SOLUTION'.\n\nThe product of a group of integers is the result of multiplying them together.\n\nINPUT:\n\nThe first line of the inpu...
0.661307
Taco_38082
C
[ "max_product_of_three", "find_max_product_of_three", "parse_input", "print_output" ]
4
[ [ "find_max_product_of_three", "max_product_of_three" ] ]
1
[ "parse_input", "print_output" ]
false
[]
false
pytest
false
[]
true
986aec21cc844c9b5b1f3f8a45b3d877c0ddec63
84a06e22592fb44cb8a40948cbb62c643101778d
v1.0
complete
Taco
Taco_37928_C
def is_subset_sum(arr, n, T): """ Determines if there exists a subset of `arr` that sums exactly to `T`. Parameters: arr (list of int): The list of integers. n (int): The number of elements in the list. T (int): The target sum. Returns: str: "YES" if a subset with sum T exists,...
def is_subset_sum(arr, n, T): """ Determines if there exists a subset of `arr` that sums exactly to `T`. Parameters: arr (list of int): The list of integers. n (int): The number of elements in the list. T (int): The target sum. Returns: str: "YES" if a subset with sum T exists,...
from solution import array_subset_sum def test_sample_input_1(): input_text = "5\n1 2 3 4 5\n9" assert array_subset_sum(input_text) == "YES" def test_sample_input_2(): input_text = "3\n-1 1 0\n2" assert array_subset_sum(input_text) == "NO" def test_sample_input_3(): input_text = "4\n15 -7 -3 8\n8...
[ { "docstring": "Determines if there exists a subset of `arr` that sums exactly to `T`.\n\nParameters:\narr (list of int): The list of integers.\nn (int): The number of elements in the list.\nT (int): The target sum.\n\nReturns:\nstr: \"YES\" if a subset with sum T exists, otherwise \"NO\".", "function_decla...
[ 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_subset_sum_possible(n, arr, target):\n \"\"\"\n Determines if there exists a subset of elements in arr that sums exactly to target.\n \n Paramet...
trial_gpt4o_5
{ "original_instruction": "Array Subset Sum\n\nGiven an array of integers and a target sum, determine if there exists a subset within the array that sums exactly to the target sum.\n\nInput\n\nThe first line contains an integer, $n$, the number of elements in the array.\nThe second line contains $n$ integers separate...
0.634247
Taco_37928
C
[ "is_subset_sum", "array_subset_sum" ]
2
[ [ "array_subset_sum", "is_subset_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e6da53c5ca7a451ce81a481e524bfa8b752bf016
81844af8a38093a2c97656f86b19a2722707123f
v1.0
complete
Taco
Taco_38113_C
from typing import List, Tuple def minimum_cost_to_connect_all_computers(n: int, edges: List[Tuple[int, int, int]]) -> int: """ Compute the minimum cost needed to ensure full communication between all computers. Args: n (int): Number of nodes (computers). edges (List[Tuple[int, int, int]])...
def find_parent(parent, i): if parent[i] == i: return i else: return find_parent(parent, parent[i]) def union(parent, rank, x, y): xroot = find_parent(parent, x) yroot = find_parent(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[y...
def test_minimum_cost_example(): n = 4 edges = [ (1, 2, 3), (1, 3, 1), (2, 3, 7), (2, 4, 2), (3, 4, 5) ] assert minimum_cost_to_connect_all_computers(n, edges) == 6 def test_no_edges(): n = 4 edges = [] assert minimum_cost_to_connect_all_computers(n,...
[ { "docstring": null, "function_declaration": "def find_parent(parent, i):", "function_name": "find_parent", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank...
[ 1, 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 find_parent(parent, i):\n if parent[i] == i:\n return i\n else:\n return find_parent(parent, parent[i])\n\ndef union(parent, rank, x, y):\n...
trial_gpt4o_0
{ "original_instruction": "A company is trying to optimize its network of computers for better communication. Each computer is represented as a node in a graph, and a direct cable connection between two computers is represented as an undirected edge between two nodes. The network graph consists of N nodes labeled fro...
0.664535
Taco_38113
C
[ "find_parent", "union", "minimum_cost_to_connect_all_computers" ]
3
[ [ "minimum_cost_to_connect_all_computers", "find_parent" ], [ "minimum_cost_to_connect_all_computers", "union" ], [ "union", "find_parent" ] ]
3
[]
false
[]
false
pytest
false
[]
true
c3727151200eed0774c255fe6d73580be58f0b67
f9f49edbcc2545931fb762194b4dde36435f13cb
v1.0
complete
Taco
Taco_38438_C
def is_palindromic(n): """ Checks if a number is palindromic. >>> is_palindromic(121) True >>> is_palindromic(123) False >>> is_palindromic(898) True """ pass def is_prime(n): """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) Fal...
def is_palindromic(n): """ Checks if a number is palindromic. """ return str(n) == str(n)[::-1] def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 wh...
from solution import is_palindromic, is_prime, nth_palindromic_prime, get_palindromic_primes def test_is_palindromic(): assert is_palindromic(121) == True assert is_palindromic(123) == False assert is_palindromic(898) == True def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == Tr...
[ { "docstring": "Checks if a number is palindromic.", "function_declaration": "def is_palindromic(n):", "function_name": "is_palindromic", "parameter_list": "(n)" }, { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime",...
[ 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\n\ndef is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ret...
trial_gpt4o_2
{ "original_instruction": "Anita is fascinated by palindromic numbers. A number is a palindrome if it reads the same forwards and backwards, such as $121$ or $9889$. Anita is also interested in prime numbers. A prime number is a natural number greater than $1$ that has no positive divisors other than $1$ and itself.\...
0.741755
Taco_38438
C
[ "is_palindromic", "is_prime", "nth_palindromic_prime", "get_palindromic_primes" ]
4
[ [ "get_palindromic_primes", "nth_palindromic_prime" ], [ "nth_palindromic_prime", "is_palindromic" ], [ "nth_palindromic_prime", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
63055bccc566ed8d987cd7340b28dd9fe71f3d8e
811902576f0e67047937e3d94278cb79ddc9a192
v1.0
complete
Taco
Taco_38682_C
def knight_moves(T: int, test_cases: List[Dict]) -> List[int]: """ Calculate the minimum number of moves required for a knight to travel from a start position to a destination position on a chessboard. If it is not possible for the knight to reach the destination, return -1. Input The first paramet...
from collections import deque def is_valid(x, y, board): return 0 <= x < 8 and 0 <= y < 8 and board[x][y] == 0 def bfs_knight_moves(start, end, board): directions = [ (2, 1), (2, -1), (-2, 1), (-2, -1), (1, 2), (1, -2), (-1, 2), (-1, -2) ] queue = deque([(start[0], start[1], 0)]) ...
import pytest from solution import knight_moves def test_knight_moves_no_obstacle(): T = 1 test_cases = [ {'start': (0, 0), 'end': (7, 7), 'obstacles': []} ] result = knight_moves(T, test_cases) assert result == [6] def test_knight_moves_with_obstacle(): T = 1 test_cases = [ ...
[ { "docstring": null, "function_declaration": "def is_valid(x, y, board):", "function_name": "is_valid", "parameter_list": "(x, y, board)" }, { "docstring": null, "function_declaration": "def bfs_knight_moves(start, end, board):", "function_name": "bfs_knight_moves", "parameter_li...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_knight_moves(start, end, obstacles):\n directions = [\n (2, 1), (2, -1), (-2, 1), (-2, -1),\n (1, 2), (1,...
trial_gpt4o_4
{ "original_instruction": "Anna is passionate about puzzles and recently she came across a chessboard puzzle. Given a standard 8x8 chessboard with some squares marked with `X` to indicate obstacles, Anna needs to determine the minimum number of moves required for a knight to travel from a given start position to a gi...
0.675781
Taco_38682
C
[ "is_valid", "bfs_knight_moves", "knight_moves" ]
3
[ [ "bfs_knight_moves", "is_valid" ], [ "knight_moves", "bfs_knight_moves" ] ]
2
[]
false
[]
false
pytest
true
[]
true
71a4c92f672dfccaabc5c966ea29ad0385c51a52
1c1c79a3bc55cd400f78d40199a209a67d6146d6
v1.0
complete
Taco
Taco_38278_C
def time_difference(server_time: str, device_time: str) -> int: """ Calculate the time difference (in minutes) between the central server and a device. >>> time_difference("12:00", "11:45") 15 >>> time_difference("12:00", "13:05") -65 """ # Add your code here def adjust_time(device_time: st...
def time_difference(server_time, device_time): h1, m1 = map(int, server_time.split(":")) h2, m2 = map(int, device_time.split(":")) total_server_minutes = h1 * 60 + m1 total_device_minutes = h2 * 60 + m2 drift_minutes = total_server_minutes - total_device_minutes return drift_minutes def adjust_...
import pytest from solution import time_difference, adjust_time, synchronize_clocks def test_time_difference(): assert time_difference("12:00", "11:45") == 15 assert time_difference("12:00", "13:05") == -65 assert time_difference("12:00", "11:59") == 1 assert time_difference("23:30", "23:00") == 30 ...
[ { "docstring": null, "function_declaration": "def time_difference(server_time, device_time):", "function_name": "time_difference", "parameter_list": "(server_time, device_time)" }, { "docstring": null, "function_declaration": "def adjust_time(device_time, drift_minutes):", "function_...
[ 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 synchronize_clocks(n, server_time, device_times):\n \"\"\"\n Takes the number of devices, server time and a list of device times,\n returns the adjust...
trial_gpt4o_9
{ "original_instruction": "You are working for a company that manages a large number of networked devices in multiple locations. As part of your job, you need to synchronize the clocks of these devices with a central server to ensure that their local times are accurate and consistent. Each device has a clock that can...
0.55869
Taco_38278
C
[ "time_difference", "adjust_time", "synchronize_clocks" ]
3
[ [ "synchronize_clocks", "adjust_time" ], [ "synchronize_clocks", "time_difference" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a70aaa8ea4b5c06d1bab23018ca3370e53619b4a
485c1a7e120269e557eb7673938501a759bac2c6
v1.0
complete
Taco
Taco_37447_C
from typing import List, Tuple def count_isolated_black_regions(datasets: List[Tuple[Tuple[int, int], List[List[str]]]]) -> List[int]: """ Determine the number of isolated black regions in each dataset. >>> count_isolated_black_regions([((5, 5), [['X','W','W','W','X'], ['W','B','B','W','W'], ['W','B','W','W','...
def count_isolated_black_regions(datasets): def dfs(grid, x, y, m, n, visited): stack = [(x, y)] directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] while stack: cx, cy = stack.pop() for dx, dy in directions: nx, ny = cx + dx, cy + dy ...
def test_parse_input(): input_str = "2\n5 5\nX W W W X\nW B B W W\nW B W W W\nW W W X W\nX W W W X\n3 4\nX W W X\nW B W W\nX W B X\n" expected_datasets = [ ((5, 5), [ ['X','W','W','W','X'], ['W','B','B','W','W'], ['W','B','W','W','W'], ['W','W','W','X','W'...
[ { "docstring": null, "function_declaration": "def count_isolated_black_regions(datasets):", "function_name": "count_isolated_black_regions", "parameter_list": "(datasets)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_isolated_black_regions(datasets):\n def dfs(grid, x, y, m, n, visited):\n stack = [(x, y)]\n directions = [(0, 1), (1, 0), (0, -1), (-1,...
trial_gpt4o_0
{ "original_instruction": "You are given a set of images each represented as a 2D grid of characters. The grid consists of characters `B`, `W` and `X` where `B` represents a black pixel, `W` represents a white pixel, and `X` represents a boundary pixel which should not be changed. Your task is to determine the number...
0.534079
Taco_37447
C
[ "count_isolated_black_regions", "parse_input", "count_isolated_black_regions_from_input" ]
3
[ [ "count_isolated_black_regions_from_input", "count_isolated_black_regions" ], [ "count_isolated_black_regions_from_input", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
cbc4a1f6c486d286c5aa816d9394cdc019791fb8
a80a373e1dd8739e6de00ad9a9e5b12325a00518
v1.0
complete
Taco
Taco_38488_C
def can_travel_by_bridges(grid, N, M): """ Determines if it's possible to travel from the top-left corner to the bottom-right corner of the grid based on the game "Number Bridges" rules. :param grid: List of lists, representing the grid :param N: Number of rows :param M: Number of columns ...
from collections import deque def can_travel_by_bridges(grid, N, M): """ Determines if it's possible to travel from the top-left corner to the bottom-right corner of the grid based on the game "Number Bridges" rules. :param grid: List of lists, representing the grid :param N: Number of rows ...
def test_can_travel_by_bridges(): # Test case 1 grid1 = [ [3, 1, 2], [0, 2, 1], [1, 1, 3] ] assert can_travel_by_bridges(grid1, 3, 3) == "Impossible" # Test case 2 grid2 = [ [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 2, 2, 2, 2], [9, 8, 7, ...
[ { "docstring": "Determines if it's possible to travel from the top-left corner to the bottom-right corner\nof the grid based on the game \"Number Bridges\" rules.\n\n:param grid: List of lists, representing the grid\n:param N: Number of rows\n:param M: Number of columns\n:return: \"Possible\" or \"Impossible\""...
[ 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 is_possible_to_travel(grid, N, M):\n from collections import deque\n\n def valid(x, y):\n return 0 <= x < N and 0 <= y < M\n \n directions =...
trial_gpt4o_2
{ "original_instruction": "In a faraway kingdom, there exists an ancient game called \"Number Bridges\". This game involves a rectangular grid with dimensions N x M. Each cell in the grid contains a non-negative integer that represents the number of bridges that can be built from that cell.\n\nA player can move from ...
0.634797
Taco_38488
C
[ "can_travel_by_bridges", "number_bridges" ]
2
[ [ "number_bridges", "can_travel_by_bridges" ] ]
1
[]
false
[]
false
pytest
false
[]
true
25f4182dc62e7fa86a776bd246d67957ad0d43ed
0791ef452760edd05b22502d52ee15940b794cd7
v1.0
complete
Taco
Taco_38443_C
def find_peak_people(events) -> int: """ Determines the peak number of people on the path simultaneously at any moment during the day. :param events: List of tuples where each tuple contains an integer timestamp and a character ('A' or 'D') denoting an arrival or a departure. :return: Th...
def find_peak_people(events): events.sort() max_travelers = 0 current_travelers = 0 for event in events: if event[1] == 'A': current_travelers += 1 if current_travelers > max_travelers: max_travelers = current_travelers elif event[1] == 'D': ...
from solution import process_events def test_example1(): event_list = ["1 A", "5 A", "8 D", "10 A", "12 D", "15 D"] assert process_events(6, event_list) == 2 def test_example2(): event_list = ["2 A", "3 D", "4 A", "6 D"] assert process_events(4, event_list) == 1 def test_case_all_arrivals_then_depart...
[ { "docstring": null, "function_declaration": "def find_peak_people(events):", "function_name": "find_peak_people", "parameter_list": "(events)" }, { "docstring": null, "function_declaration": "def process_events(n, event_list):", "function_name": "process_events", "parameter_list...
[ 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 peak_travelers_on_path(n, events):\n events.sort()\n \n current_travelers = 0\n peak_travelers = 0\n \n for event in events:\n if even...
trial_gpt4o_2
{ "original_instruction": "In a small town, there is a popular path between two intersections A and B. Every day, numerous townspeople travel between these intersections. We need to track the number of people who traverse this path on each day of a given week.\n\nWe represent the town's path between intersections A a...
0.579594
Taco_38443
C
[ "find_peak_people", "process_events" ]
2
[ [ "process_events", "find_peak_people" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4188d1b57a7c2e0a994a398b4903b90682933981
cd141c9f5eb7d2efca9043ea506b5b420a99db65
v1.0
complete
Taco
Taco_38978_C
from collections import deque class TreeNode: def __init__(self, key): self.data = key self.left = None self.right = None def deepestLeafSum(root: TreeNode) -> int: """ Given a binary tree, return the sum of the values of the nodes at the deepest level. >>> deepestLeafSum(Tree...
from collections import deque class TreeNode: def __init__(self, key): self.data = key self.left = None self.right = None def deepestLeafSum(root): if not root: return 0 queue = deque([root]) current_sum = 0 while queue: current_sum = 0 lev...
def test_deepestLeafSum(): assert processTestCases([[1, 2, 3, 4, 5, -1, 6]]) == [15] assert processTestCases([[10, 20, 30, -1, 40]]) == [40] assert processTestCases([[1, 2, 3, -1, -1, 4, 5]]) == [9] assert processTestCases([[5, 3, 8, 1, 4, 7, 10, -1, 2]]) == [2] assert processTestCases([[7]]) == [7]...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, data):\n self.data = data\n self.left = None\n self.right = None\n\ndef deepestLeafSum(root):\n if not ...
trial_gpt4o_1
{ "original_instruction": "Given a binary tree, the task is to complete the function deepestLeafSum() which returns an integer denoting the sum of the values of the nodes at the deepest level of the binary tree.\n\nInput:\nThe first line of input contains an integer T denoting the number of test cases. Then T test ca...
0.569357
Taco_38978
C
[ "deepestLeafSum", "buildTree", "processTestCases" ]
3
[ [ "processTestCases", "buildTree" ], [ "processTestCases", "deepestLeafSum" ] ]
2
[ "processTestCases" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
7b9cfe618a43668a849255d48653cb28c9c8f22f
d6feb8e961eef68097a1e930fc9e51b65cd213cd
v1.0
complete
Taco
Taco_38786_C
def optimal_house(n: int, connections: List[str]) -> int: """ Find the optimal house for building the new playground in Toyland. The function takes the number of houses and a list of connections between them, and returns the house that minimizes the sum of distances to all other houses. >>> op...
def find_centroid(n, edges): from collections import defaultdict # Build the tree tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) # To store the size of each subtree size = [0] * (n + 1) # Function to compute size of subtree using DF...
from solution import optimal_house def test_example_1(): n = 5 connections = ["1 2", "1 3", "3 4", "3 5"] assert optimal_house(n, connections) == 3 def test_example_2(): n = 4 connections = ["1 2", "2 3", "3 4"] assert optimal_house(n, connections) == 2 def test_single_node(): n = 1 c...
[ { "docstring": null, "function_declaration": "def find_centroid(n, edges):", "function_name": "find_centroid", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def optimal_house(n, connections):", "function_name": "optimal_house", "parameter_list": ...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef find_optimal_playground(n, roads):\n if n == 1:\n return 1\n \n # Build the graph.\n graph = d...
trial_gpt4o_6
{ "original_instruction": "Toyland is a small town with n houses numbered from 1 to n, and it is designed as a tree (all houses are connected with n-1 bidirectional roads without cycles). The mayor of Toyland wants to build a new playground for children and is looking for the optimal location for it.\n\nThe optimal l...
0.597554
Taco_38786
C
[ "find_centroid", "optimal_house" ]
2
[ [ "optimal_house", "find_centroid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
26c8d500079eada78bb87403ef2098004917d207
04b5401c298b83ba62da3bc37a3999bc8efc7907
v1.0
complete
Taco
Taco_39116_C
def first_n_primes(n: int) -> List[int]: """ Returns a list of the first `n` prime numbers. >>> first_n_primes(1) [2] >>> first_n_primes(2) [2, 3] >>> first_n_primes(5) [2, 3, 5, 7, 11] >>> first_n_primes(10) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] >>> first_n_primes(0) [] >>> first_n_prime...
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: retu...
from solution import first_n_primes def test_first_n_primes_1(): assert first_n_primes(1) == [2] def test_first_n_primes_2(): assert first_n_primes(2) == [2, 3] def test_first_n_primes_5(): assert first_n_primes(5) == [2, 3, 5, 7, 11] def test_first_n_primes_10(): assert first_n_primes(10) == [2, 3,...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of the first `n` prime numbers.", "function_declaration": "def first_n_primes(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 is_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "```if:python,php\nYou need to write a function that takes an integer `n` and returns a list of the first `n` prime numbers. Prime numbers are those greater than 1 and only divisible by 1 and themselves. For example, the first 5 prime numbers are [2, 3, 5, 7, 11]. Also you can guess that the...
0.784835
Taco_39116
C
[ "is_prime", "first_n_primes" ]
2
[ [ "first_n_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f6dc670b60a60796cf628c1ee69d52b3efc19d10
49366b21017f32b6a7babcc9e6dd939dd6023c11
v1.0
complete
Taco
Taco_39155_C
from typing import List class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def buildTree(inorder: List[int], postorder: List[int]) -> List[int]: """ Reconstruct a binary tree from the given inorder and postorder tra...
from collections import deque class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def buildTreeFromInorderPostorder(inorder, postorder): if not inorder or not postorder: return None # Create a hashmap...
from solution import buildTree def test_example_1(): inorder = [9, 3, 15, 20, 7] postorder = [9, 15, 7, 20, 3] assert buildTree(inorder, postorder) == [3, 9, 20, 15, 7] def test_example_2(): inorder = [2, 1] postorder = [2, 1] assert buildTree(inorder, postorder) == [1, 2] def test_single_nod...
[]
[ 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\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n ...
trial_gpt4o_1
{ "original_instruction": "A binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child. Given the inorder and postorder traversals of a binary tree, write a function to reconstruct the binary tree and output its level-order traversal.\n\nExampl...
0.522855
Taco_39155
C
[ "buildTreeFromInorderPostorder", "levelOrderTraversal", "buildTree" ]
3
[ [ "buildTree", "buildTreeFromInorderPostorder" ], [ "buildTree", "levelOrderTraversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ca3dc67718f81c0f84da1fb3d17380a94db568b9
fd3d2a9ae51a94a16fd3ef75a9d6f9b9f36a0613
v1.0
complete
Taco
Taco_38828_C
from typing import List, Tuple def number_of_inversions(n: int, q: int, arr: List[int], operations: List[Tuple[int, int]]) -> int: """ Determine the number of inversions in the array after performing all the given operations. An inversion is a pair of indices (i, j) such that i < j and arr[i] > arr[j]. ...
def count_inversions(arr): """ Function to count number of inversions in the array. """ n = len(arr) temp_arr = [0] * n return merge_sort(arr, temp_arr, 0, n - 1) def merge_sort(arr, temp_arr, left, right): """ Function to sort the array and count inversions. """ inv_count = 0 ...
from solution import number_of_inversions def test_example1(): n = 5 q = 3 arr = [6, 3, 9, 1, 7] operations = [(1, 3), (2, 4), (1, 5)] assert number_of_inversions(n, q, arr, operations) == 5 def test_example2(): n = 4 q = 2 arr = [10, 20, 30, 40] operations = [(1, 4), (1, 4)] a...
[ { "docstring": "Function to count number of inversions in the array.", "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list": "(arr)" }, { "docstring": "Function to sort the array and count inversions.", "function_declaration": "def m...
[ 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 count_inversions(arr):\n \"\"\"\n Counts the number of inversions in the array.\n \"\"\"\n return _merge_sort_and_count(arr, 0, len(arr) - 1)\n\nde...
trial_gpt4o_1
{ "original_instruction": "You are given an array of integers and a set of operations. Each operation will reverse the subarray between two given indices.\n\nYou need to determine the number of inversions in the array after performing all the given operations. An inversion is a pair of indices (i, j) such that i < j ...
0.797202
Taco_38828
C
[ "count_inversions", "merge_sort", "merge", "reverse_subarray", "number_of_inversions" ]
5
[ [ "count_inversions", "merge_sort" ], [ "merge_sort", "merge" ], [ "number_of_inversions", "count_inversions" ], [ "number_of_inversions", "reverse_subarray" ] ]
4
[]
false
[]
false
pytest
true
[]
true
23453db4fea0238458877b05b4c0ecf4a5325eda
5ea8e66d66e4148984d34b83bf49f553cc3531e5
v1.0
complete
Taco
Taco_39028_C
def card_rank_to_num(card): """Convert card rank to numerical value. Args: card (str): A string representing a card, e.g., '2H' for 2 of Hearts. Returns: int: Numerical value corresponding to the card rank. """ pass def analyze_hand(hand): """Analyze a poker hand and determine i...
def card_rank_to_num(card): rank = card[0] if rank in '23456789': return int(rank) elif rank == 'T': return 10 elif rank == 'J': return 11 elif rank == 'Q': return 12 elif rank == 'K': return 13 elif rank == 'A': return 14 def analyze_hand(han...
from solution import best_hand_rank def test_single_hand(): n = 1 hands = ["2H 3D 5S 9C KD"] assert best_hand_rank(n, hands) == ["High Card"] def test_flush_hand(): n = 1 hands = ["2H 4H 5H 9H KH"] assert best_hand_rank(n, hands) == ["Flush"] def test_straight_flush_hand(): n = 1 hand...
[ { "docstring": null, "function_declaration": "def card_rank_to_num(card):", "function_name": "card_rank_to_num", "parameter_list": "(card)" }, { "docstring": null, "function_declaration": "def analyze_hand(hand):", "function_name": "analyze_hand", "parameter_list": "(hand)" }, ...
[ 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 evaluate_hand(hand):\n \"\"\"\n Evaluates a poker hand and returns its best ranking.\n \n :param hand: A list of five cards, each represented as a ...
trial_gpt4o_2
{ "original_instruction": "Alice loves playing card games and she has decided to write a program that simulates a simplified version of poker hands assessment. In this version, each hand consists of five cards, and the following hand rankings are considered:\n\n**One Pair**: Two cards of the same rank.\n**Two Pair**:...
0.676529
Taco_39028
C
[ "card_rank_to_num", "analyze_hand", "best_hand_rank" ]
3
[ [ "analyze_hand", "card_rank_to_num" ], [ "best_hand_rank", "analyze_hand" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3e4a75b630e4791abe732b9a04201f5405214f5f
4ffd970ffc34706d1bc802a411516ffd7e099510
v1.0
complete
Taco
Taco_39174_C
from typing import List, Optional def isValidBST(tree: List[Optional[int]]) -> bool: """Determine whether the given binary tree is a valid Binary Search Tree (BST). A valid BST satisfies the following properties: - The left subtree of a node contains only nodes with keys less than the node's key. ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree_from_level_order(level_order): if not level_order or level_order[0] is None: return None root = TreeNode(level_order[0]) queue = [root...
from solution import isValidBST def test_sample(): assert isValidBST([3, 9, 20, None, None, 15, 7]) == False def test_large_valid_bst(): assert isValidBST([50, 30, 70, 20, 40, 60, 80]) == True def test_invalid_bst_left_violation(): assert isValidBST([10, 5, 15, None, None, 6, 20]) == False def test_inva...
[]
[ 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 isValidBST(tree):\n \"\"\"\n Returns True if the given binary tree is a valid Binary Search Tree (BST), False otherwise.\n :param tree: List of intege...
trial_gpt4o_3
{ "original_instruction": "You are given an array of integers representing a binary tree in a level order traversal. Each element of the array represents a node of the tree. If an element in the array is `null`, it indicates that there is no node at that position in the tree.\n\nYour task is to determine whether the ...
0.671452
Taco_39174
C
[ "build_tree_from_level_order", "isValidBST" ]
2
[ [ "isValidBST", "build_tree_from_level_order" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
a426580a703c5e083bb334bbb6ab93facbeaf058
b19daf73757d0d460882f3632dcac81f6db9a5ee
v1.0
complete
Taco
Taco_39024_C
def preprocess_temperatures(temperatures): """ Preprocess the temperature readings using a sparse table to allow for constant time range queries for the maximum temperature in a segment of the corridor. """ def query_max(st, l, r): """ Query the maximum value in the range [l, r] using the pre...
def preprocess_temperatures(temperatures): """ Preprocess the temperature readings using a sparse table to allow for constant time maximum range queries. """ import math # Number of rooms n = len(temperatures) # Determine max power of 2 needed for the sparse table max_log = ma...
def test_preprocess_temperatures(): temperatures = [1, 2, 3, 4, 5] st = preprocess_temperatures(temperatures) assert st[0][0] == 1 assert st[1][0] == 2 assert st[4][0] == 5 assert st[0][1] == 2 assert st[0][2] == 4 def test_query_max(): temperatures = [1, 2, 3, 4, 5] st = prepr...
[ { "docstring": "Preprocess the temperature readings using a sparse table to allow \nfor constant time maximum range queries.", "function_declaration": "def preprocess_temperatures(temperatures):", "function_name": "preprocess_temperatures", "parameter_list": "(temperatures)" }, { "docstring"...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\n\ndef preprocess_temperatures(temperatures):\n \"\"\"\n Preprocess the temperatures with a Sparse Table for fast range maximum queries.\n \"\"...
trial_gpt4o_2
{ "original_instruction": "In a popular programming contest, there is a particular type of problem that involves arrays and queries. You are given an array of integers. The task is to handle multiple queries that ask for the maximum value within a specified subarray.\n\nDisco lives in an apartment with an $N$-length ...
0.544402
Taco_39024
C
[ "preprocess_temperatures", "query_max", "answer_queries" ]
3
[ [ "answer_queries", "preprocess_temperatures" ], [ "answer_queries", "query_max" ] ]
2
[]
false
[]
false
pytest
false
[]
true
45210d27653f7713b31c7f99a3828bdb8726066f
dbedd0f72d65a1515d44728b55258c5793d1db83
v1.0
complete
Taco
Taco_39411_C
from typing import List, Tuple def modular_inverse_exists(A: int, M: int) -> bool: """ Checks if the modular inverse of A modulo M exists. An inverse exists if and only if A and M are coprime (i.e., gcd(A, M) = 1). """ def solution_exists(A: int, Y: int, M: int) -> str: """ Determines whether ...
def modular_inverse_exists(A, M): """ Checks if the modular inverse of A modulo M exists using the Extended Euclidean Algorithm. An inverse exists if and only if A and M are coprime (i.e., gcd(A, M) = 1). """ def extended_gcd(a, b): if a == 0: return b, 0, 1 gcd, x1, y1 =...
from solution import modular_inverse_exists, solution_exists, process_cases def test_modular_inverse_exists(): assert modular_inverse_exists(5, 7) == True # gcd(5, 7) = 1 assert modular_inverse_exists(4, 11) == True # gcd(4, 11) = 1 assert modular_inverse_exists(4, 12) == False # gcd(4, 12) != 1 def te...
[ { "docstring": "Checks if the modular inverse of A modulo M exists using the Extended Euclidean Algorithm.\nAn inverse exists if and only if A and M are coprime (i.e., gcd(A, M) = 1).", "function_declaration": "def modular_inverse_exists(A, M):", "function_name": "modular_inverse_exists", "parameter...
[ 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 mod_inverse(A, M):\n \"\"\"\n Computes the modular inverse of A modulo M using the extended Euclidean algorithm.\n Returns the inverse if it exists, o...
trial_gpt4o_3
{ "original_instruction": "Your friend gives you an equation A * X ≡ Y (mod M) and asks you to find an integer solution for X.\n\nHowever, you know your friend's mischievous nature and suspect that there is no solution to such an equation. Thus, you first want to find out whether there is a solution to it.\n\nTo chec...
0.618744
Taco_39411
C
[ "modular_inverse_exists", "solution_exists", "process_cases" ]
3
[ [ "process_cases", "solution_exists" ], [ "solution_exists", "modular_inverse_exists" ] ]
2
[ "process_cases" ]
false
[]
false
pytest
true
[]
true
073ce4f31528e0939ffe09509c7bdb39eea257fb
35b359f976fba8349b79c9e5fb6a8237ea4289e8
v1.0
complete
Taco
Taco_39236_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(preorder: List[int], inorder: List[int]) -> TreeNode: """ Build a binary tree from given preorder and inorder traversal sequences. """ ... def postorder_traversal(roo...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(preorder, inorder): if not preorder or not inorder: return None root_value = preorder[0] root = TreeNode(root_value) root_index_in_inorder = inor...
def test_construct_tree_and_get_postorder(): # Test case 1 n = 7 preorder = [1, 2, 4, 5, 3, 6, 7] inorder = [4, 2, 5, 1, 6, 3, 7] expected_postorder = [4, 5, 2, 6, 7, 3, 1] assert construct_tree_and_get_postorder(n, preorder, inorder) == expected_postorder # Test case 2 n = 3 pr...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_2
{ "original_instruction": "A binary tree is a data structure in which each node has at most two children, referred to as the left child and the right child. Your task is to implement a program that constructs a binary tree given its preorder and inorder traversal sequences, and then prints its postorder traversal.\n\...
0.53765
Taco_39236
C
[ "build_tree", "postorder_traversal", "construct_tree_and_get_postorder" ]
3
[ [ "construct_tree_and_get_postorder", "build_tree" ], [ "construct_tree_and_get_postorder", "postorder_traversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
039ccdb61ea214daaa8dd840263b35a3cff0094e
99d2ffe2ca77501a5aab0425a4643e8133b0c2f8
v1.0
complete
Taco
Taco_38938_C
def isAlmostPalindrome(S: str) -> bool: """ Determine if the given string S can become a palindrome by removing at most one character. >>> isAlmostPalindrome("abca") True >>> isAlmostPalindrome("abcdef") False >>> isAlmostPalindrome("racecar") True >>> isAlmostPalindrome("madam") ...
def isPalindrome(s, left, right): """ Returns True if the substring s[left:right+1] is a palindrome. """ while left < right: if s[left] != s[right]: return False left += 1 right -= 1 return True def isAlmostPalindrome(S): """ Returns True if the string S ...
def test_almost_palindrome_examples(): assert isAlmostPalindrome("abca") == True assert isAlmostPalindrome("abcdef") == False def test_palindrome(): assert isAlmostPalindrome("racecar") == True assert isAlmostPalindrome("madam") == True def test_almost_palindrome_different_cases(): assert isAlmost...
[ { "docstring": "Returns True if the substring s[left:right+1] is a palindrome.", "function_declaration": "def isPalindrome(s, left, right):", "function_name": "isPalindrome", "parameter_list": "(s, left, right)" }, { "docstring": "Returns True if the string S can be turned into a palindrome ...
[ 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 isAlmostPalindrome(S):\n \"\"\"\n Determine if the string S is almost-palindromic, meaning it can become\n a palindrome by removing at most one charac...
trial_gpt4o_2
{ "original_instruction": "A string is considered almost-palindromic if it can become a palindrome by removing at most one character. Given a string `S`, your task is to determine if it is almost-palindromic.\n\nReturn `True` if the string can be converted to a palindrome by removing at most one character, otherwise ...
0.855253
Taco_38938
C
[ "isPalindrome", "isAlmostPalindrome" ]
2
[ [ "isAlmostPalindrome", "isPalindrome" ] ]
1
[]
false
[]
false
pytest
false
[]
true
87ba22851a0800fdd9c347a527a80cfc45d148ab
b528acc7ee0743dd4e409044fa1824283e6c14ba
v1.0
complete
Taco
Taco_38457_C
def dispense_cash(amount: int) -> str: """ Given an amount, this function calculates the number of each denomination (100s, 50s, 20s, 10s, 5s, 1s) needed to dispense the amount while minimizing the number of bills. >>> dispense_cash(376) == "100s: 3, 50s: 1, 20s: 1, 10s: 0, 5s: 1, 1s: 1" >>> dispens...
def dispense_cash(amount): """ Given an amount, this function calculates the number of each denomination (100s, 50s, 20s, 10s, 5s, 1s) needed to dispense the amount while minimizing the number of bills. """ denominations = [100, 50, 20, 10, 5, 1] bills = {} for denom in denominations: ...
from solution import dispense_cash, process_transactions def test_dispense_cash(): assert dispense_cash(376) == "100s: 3, 50s: 1, 20s: 1, 10s: 0, 5s: 1, 1s: 1" assert dispense_cash(123) == "100s: 1, 50s: 0, 20s: 1, 10s: 0, 5s: 0, 1s: 3" assert dispense_cash(6879) == "100s: 68, 50s: 1, 20s: 1, 10s: 0, 5s: 1...
[ { "docstring": "Given an amount, this function calculates the number of each denomination (100s, 50s, 20s, 10s, 5s, 1s)\nneeded to dispense the amount while minimizing the number of bills.", "function_declaration": "def dispense_cash(amount):", "function_name": "dispense_cash", "parameter_list": "(a...
[ 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 dispense_cash(amount):\n \"\"\"\n Dispenses the given amount in the smallest number of bills.\n \"\"\"\n denominations = [100, 50, 20, 10, 5, 1]\n ...
trial_gpt4o_2
{ "original_instruction": "You've been tasked to create software that simulates an automated teller machine (ATM). The ATM should be able to dispense cash amounts in various denominations (e.g., 100s, 50s, 20s, 10s, 5s, and 1s) but should minimize the number of bills dispensed.\n\n### Input\nThe input consists of mul...
0.595091
Taco_38457
C
[ "dispense_cash", "process_transactions" ]
2
[ [ "process_transactions", "dispense_cash" ] ]
1
[]
false
[]
false
pytest
true
[]
true
217dd286265df0ff4d9dd07306cf8d75280d8d49
344f1b78ebff92017f5f8a40e696f7cb53fefbc5
v1.0
complete
Taco
Taco_39485_C
def is_palindrome(num: int) -> bool: """ Checks if a number is a palindrome. >>> is_palindrome(121) == True >>> is_palindrome(123) == False >>> is_palindrome(99) == True >>> is_palindrome(10101) == True >>> is_palindrome(12321) == True >>> is_palindrome(10) == False """ def larg...
def is_palindrome(num): """ Checks if a number is a palindrome. """ s = str(num) return s == s[::-1] def largest_palindrome(n): """ Finds the largest palindrome number less than or equal to n. """ for num in range(n, 0, -1): if is_palindrome(num): return num
from solution import is_palindrome, largest_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(99) == True assert is_palindrome(10101) == True assert is_palindrome(12321) == True assert is_palindrome(10) == False def t...
[ { "docstring": "Checks if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Finds the largest palindrome number less than or equal to n.", "function_declaration": "def largest_pali...
[ 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_palindrome(num):\n \"\"\"\n Checks if a number is a palindrome.\n \"\"\"\n s = str(num)\n return s == s[::-1]\n\ndef largest_palindrome(n):\n...
trial_gpt4o_0
{ "original_instruction": "A palindrome is a string that reads the same forward and backward. Palindromes are used in various applications, from data validation to search problems. For this task, we will deal with numbers and find the largest palindrome less than or equal to the given number.\n\nWrite a function that...
0.71875
Taco_39485
C
[ "is_palindrome", "largest_palindrome" ]
2
[ [ "largest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4c4e837ce6227d48b60d1046e43cbac9b55146bc
46e0e292f5403b049100a8c6d2a1e9a667ff40e8
v1.0
complete
Taco
Taco_39218_C
import random def get_computer_choice() -> str: """ Randomly returns one of 'rock', 'paper' or 'scissors' choice for the computer. """ return random.choice(['rock', 'paper', 'scissors']) def determine_winner(player_choice: str, computer_choice: str) -> str: """ Determine the winner of a single round o...
import random def get_computer_choice(): return random.choice(['rock', 'paper', 'scissors']) def determine_winner(player_choice, computer_choice): if player_choice == computer_choice: return 'draw' elif (player_choice == "rock" and computer_choice == "scissors") or \ (player_choice == "sc...
from solution import determine_winner def test_rock_beats_scissors(): assert determine_winner("rock", "scissors") == "win" def test_scissors_lose_to_rock(): assert determine_winner("scissors", "rock") == "lose" def test_scissors_beat_paper(): assert determine_winner("scissors", "paper") == "win" def tes...
[ { "docstring": null, "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def determine_winner(player_choice, computer_choice):", "function_name": "determine_winner", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_computer_choice():\n return random.choice(['rock', 'paper', 'scissors'])\n\ndef determine_winner(player_choice, computer_choice):\n ...
trial_gpt4o_0
{ "original_instruction": "Write a program to simulate a game of Rock, Paper, Scissors between a player and the computer. The game should be played over multiple rounds, and after each round, the program should provide the current score. The game ends when the user types \"exit\". Follow these rules for the game:\n\n...
0.60531
Taco_39218
C
[ "get_computer_choice", "determine_winner", "play_game" ]
3
[ [ "play_game", "determine_winner" ], [ "play_game", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fd2f08fdbe5c80bcfa9f6bea06f486ac7d00be96
51ba216ecf6bd0e1153bded82c8eb7a680db2d00
v1.0
complete
Taco
Taco_39038_C
def find_three_evens_sum(test_cases): """ Check if each integer in the test cases can be expressed as the sum of exactly three even integers greater than zero. Args: test_cases (List[int]): List of integers to be checked. Returns: List[Union[Tuple[int, int, int], int]]: List of tuples ...
def find_three_evens_sum(test_cases): results = [] for n in test_cases: if n >= 6 and n % 2 == 0: results.append((2, 2, n - 4)) # Any even number n >= 6 can be expressed as 2 + 2 + (n-4) else: results.append(-1) return results def process_input_and_solve(t, numbers)...
from solution import process_input_and_solve def test_process_input_and_solve(): # Test case 1 t = 4 numbers = [12, 18, 8, 15] result = process_input_and_solve(t, numbers) assert result[0] == (2, 2, 8) or result[0] == (2, 4, 6) or result[0] == (4, 4, 4) or result[0] == (4, 2, 6) or result[0] == (6,...
[ { "docstring": null, "function_declaration": "def find_three_evens_sum(test_cases):", "function_name": "find_three_evens_sum", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def process_input_and_solve(t, numbers):", "function_name": "process_input_...
[ 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 find_three_evens_sum(test_cases):\n results = []\n for n in test_cases:\n if n >= 6 and n % 2 == 0:\n results.append((2, 2, n - 4)) # ...
trial_gpt4o_0
{ "original_instruction": "You are given a list of positive integers. Your task is to find out whether each integer can be expressed as the sum of exactly three even integers greater than zero.\n\nInput\n\nThe first line contains a single integer t (1 ≤ t ≤ 5000), the number of test cases.\n\nEach of the next t lines...
0.727467
Taco_39038
C
[ "find_three_evens_sum", "process_input_and_solve" ]
2
[ [ "process_input_and_solve", "find_three_evens_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b9b2d88630d5d4121c0264a31eb513f3a98a4672
92e04a7dc8cebfe0d01b794d637e2443fef29cea
v1.0
complete
Taco
Taco_39390_C
def solve(grid: List[str], N: int, M: int, sx: int, sy: int, tx: int, ty: int) -> int: """ Determine the minimum number of moves required to reach the target cell from the starting cell. If it is not possible to reach the target cell, return -1. >>> grid = [ ... '0000', ... '0110', ... '0110', ...
from collections import deque def min_moves(grid, N, M, sx, sy, tx, ty): # Helper function to check if a cell is within grid bounds and of the same type def is_valid(nx, ny, cell_type): return 0 <= nx < N and 0 <= ny < M and grid[nx][ny] == cell_type and not visited[nx][ny] visited = [[False] ...
def test_case_1(): grid = [ '0000', '0110', '0110', '0000', ] N, M = 4, 4 sx, sy, tx, ty = 0, 0, 3, 3 assert solve(grid, N, M, sx, sy, tx, ty) == 6 def test_case_2(): grid = [ '000', '010', '000', ] N, M = 3, 3 sx, sy, tx, ty =...
[ { "docstring": null, "function_declaration": "def min_moves(grid, N, M, sx, sy, tx, ty):", "function_name": "min_moves", "parameter_list": "(grid, N, M, sx, sy, tx, ty)" }, { "docstring": null, "function_declaration": "def solve(grid, N, M, sx, sy, tx, ty):", "function_name": "solve"...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_moves(grid, N, M, sx, sy, tx, ty):\n if grid[sx][sy] != grid[tx][ty]:\n return -1\n\n directions = [(-1, 0), ...
trial_gpt4o_4
{ "original_instruction": "You are given a grid of size N x M. Each cell in the grid can either contain a 0 or a 1. A cell containing a 1 is called a \"block\" while a cell containing a 0 is called an \"empty space\". \n\nYou can move vertically or horizontally from one cell to another if both cells are either empty ...
0.748835
Taco_39390
C
[ "min_moves", "solve" ]
2
[ [ "solve", "min_moves" ] ]
1
[]
false
[]
false
pytest
false
[]
true
cb8d6df9a421fb2cb4564f187932aa76607d526d
7f99dc9b630ba33fffe3e162f247ab5fd36953b0
v1.0
complete
Taco
Taco_39500_C
def is_prime(n): """ Returns True if n is a prime number, otherwise False. >>> is_prime(0) False >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(9) False """ def prime_indices(nums): """ Given a list of integers, returns a new list containing only the elements whose indic...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def prime_indices(nums): """ Given a list of integers, returns a new list contain...
from solution import is_prime, prime_indices def test_is_prime(): assert is_prime(0) == False assert is_prime(1) == False assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False def test_prime_indices(): ...
[ { "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": "Given a list of integers, returns a new list containing only the elements\nwhose indices are prime numbe...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is a prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ...
trial_gpt4o_4
{ "original_instruction": "## Discover the Prime Indices\n\nGiven a list of integers, generate a new list that contains only the numbers from the original list whose indices are prime numbers. Recall that the index of the first element in the list is 0.\n\n---\n\n## Input\n\n* A list of integers which may be positive...
0.843066
Taco_39500
C
[ "is_prime", "prime_indices" ]
2
[ [ "prime_indices", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
94e15ccdb4660d4f91252b0318de1b9cd22e7a18
fbe5311b1386c80bd11b7ef887b993004bdf871e
v1.0
complete
Taco
Taco_39526_C
def lowest_common_ancestor(N: int, nodes: List[Tuple[int, int]], p: int, q: int) -> int: """Find the lowest common ancestor (LCA) of two given nodes in the binary tree. The LCA of two nodes p and q in a binary tree is the lowest (i.e., deepest) node that is an ancestor of both p and q, where we allow a node to...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def build_tree(nodes): node_list = [TreeNode(i) for i in range(len(nodes)+1)] for i, (l, r) in enumerate(nodes): if l != 0: node_list[i+1].left = node_list[l] if r ...
from solution import lowest_common_ancestor def test_case_1(): N = 5 nodes = [(2, 3), (4, 5), (0, 0), (0, 0), (0, 0)] p = 4 q = 5 assert lowest_common_ancestor(N, nodes, p, q) == 2 def test_case_2(): N = 3 nodes = [(2, 3), (0, 0), (0, 0)] p = 2 q = 3 assert lowest_common_ancest...
[]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree(n...
trial_gpt4o_8
{ "original_instruction": "You're given a binary tree with N nodes. Your task is to find the lowest common ancestor (LCA) of two given nodes in the tree. The LCA of two nodes p and q in a binary tree is the lowest (i.e., deepest) node that is an ancestor of both p and q, where we allow a node to be a descendant of it...
0.570465
Taco_39526
C
[ "build_tree", "findLCA", "lowest_common_ancestor" ]
3
[ [ "lowest_common_ancestor", "build_tree" ], [ "lowest_common_ancestor", "findLCA" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
cc1f7735b3d3aa0a25d52d12aebba0e72660c00f
8a09cf9149bec23cf5ebb716795a35e1268759b8
v1.0
complete
Taco
Taco_39410_C
def preprocess_array(arr): """ Preprocess the array to get the prefix sums. >>> preprocess_array([1, 2, 3, 4, 5]) [0, 1, 3, 6, 10, 15] >>> preprocess_array([-1, -2, -3, -4, -5]) [0, -1, -3, -6, -10, -15] >>> preprocess_array([0, 0, 0, 0, 0]) [0, 0, 0, 0, 0, 0] """ pass def subarray_sum(pref...
def preprocess_array(arr): """ Preprocess the array to get the prefix sums. """ prefix_sums = [0] * (len(arr) + 1) for i in range(1, len(arr) + 1): prefix_sums[i] = prefix_sums[i - 1] + arr[i - 1] return prefix_sums def subarray_sum(prefix_sums, L, R): """ Returns the sum of the...
def test_preprocess_array(): assert preprocess_array([1, 2, 3, 4, 5]) == [0, 1, 3, 6, 10, 15] assert preprocess_array([-1, -2, -3, -4, -5]) == [0, -1, -3, -6, -10, -15] assert preprocess_array([0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0] def test_subarray_sum(): prefix_sums = preprocess_array([1, 2, 3, 4, 5]...
[ { "docstring": "Preprocess the array to get the prefix sums.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" }, { "docstring": "Returns the sum of the subarray from index L to R using the prefix sums.", "function_decl...
[ 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 subarray_sums(N, Q, array, queries):\n \"\"\"\n Returns the sum of subarrays for each query.\n \n Parameters:\n N (int): Number of elements in t...
trial_gpt4o_2
{ "original_instruction": "You are given an array of N integers and Q queries. Each query consists of two integers L and R (1-based index). For each query, you need to find the sum of the subarray from index L to index R (inclusive) and output the sum for each query.\n\nNote:\n- A subarray is a contiguous part of an ...
0.599138
Taco_39410
C
[ "preprocess_array", "subarray_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_array" ], [ "process_queries", "subarray_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
3f83f8162e394e90306510ba0d60b0175f917ce0
fbae4ec2da10dcd65177787f0c14f2e473fb31ca
v1.0
complete
Taco
Taco_39279_C
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(nodes): """ Build binary tree from node list. """ def is_balanced_tree(root): """ Check if the binary tree is balanced. """ def i...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(nodes): tree_nodes = {} tree_nodes[1] = TreeNode(nodes[1][0]) for i in range(1, len(nodes)): value, left, right = nodes[i] ...
from solution import is_balanced def test_balanced_tree(): n = 3 node_list = [(1, 2, 3), (2, -1, -1), (3, -1, -1)] assert is_balanced(n, node_list) == True def test_unbalanced_tree(): n = 7 node_list = [(1, 2, 3), (2, 4, 5), (3, -1, 6), (4, -1, -1), (5, -1, -1), (6, 7, -1), (7, -1, -1)] assert...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=-1, right=-1):\n self.val = val\n self.left = left\n self.right = right\n\ndef is_balanced...
trial_gpt4o_2
{ "original_instruction": "Given a binary tree, your task is to determine if it is a balanced binary tree.\n\nA balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differs by more than 1.\n\nWrite a function that checks whether a binary tree is balanced or not. ...
0.766152
Taco_39279
C
[ "build_tree", "is_balanced_tree", "is_balanced" ]
3
[ [ "is_balanced", "build_tree" ], [ "is_balanced", "is_balanced_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
c77afe7ace3659553509c64d56e54835699a59e0
b26ca927c01cd6667886c4591cf4ee5092a9c6a4
v1.0
complete
Taco
Taco_39296_C
def solve_sudoku(grid): """ Solve the Sudoku puzzle by filling the empty cells. Modifies the input grid in-place to represent the solution. Returns True if the Sudoku puzzle is solved successfully, else returns False. >>> input_grid = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0,...
def is_valid(grid, row, col, num): """ Check whether it will be legal to assign num to the given row, col. """ # Check if the number is not repeated in the current row and column for i in range(9): if grid[row][i] == num or grid[i][col] == num: return False # Check if th...
from solution import solve_sudoku def test_sudoku_solver(): input_grid = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, ...
[ { "docstring": "Check whether it will be legal to assign num to the given row, col.", "function_declaration": "def is_valid(grid, row, col, num):", "function_name": "is_valid", "parameter_list": "(grid, row, col, num)" }, { "docstring": "Solve the Sudoku puzzle by filling the empty cells.\nM...
[ 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 solve_sudoku(grid):\n \"\"\"\n Solves the Sudoku puzzle by filling the empty cells.\n Modifies the input grid in-place.\n \"\"\"\n def is_valid(...
trial_gpt4o_2
{ "original_instruction": "# Description\n\nYou will be creating a Sudoku solver. Sudoku is a popular number puzzle that you can learn more about [here](https://en.wikipedia.org/wiki/Sudoku). \n\nFor this question, you will be given a partially completed 9x9 Sudoku grid and your task is to complete the grid such that...
0.611515
Taco_39296
C
[ "is_valid", "solve_sudoku" ]
2
[ [ "solve_sudoku", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ecd2dff9b43d5c4baddf1747de415daf87ab98ed
68d86a0ac2567d0e1af486d18c96766a3e1dac03
v1.0
complete
Taco
Taco_39136_C
from typing import List def max_number_friend_pairs(ages: List[int]) -> int: """ In the kingdom of Zombieland, there lives a group of friendly zombies who love to play with numbers. One day, Zombie King Zed devised a new game called "Number-Friends". In this game, two zombies are considered "number-frien...
from collections import Counter def sum_of_digits(n): return sum(int(digit) for digit in str(n)) def max_number_friend_pairs(ages): digit_sum_count = Counter(sum_of_digits(age) for age in ages) return sum(count // 2 for count in digit_sum_count.values())
from solution import max_number_friend_pairs def test_example1(): assert max_number_friend_pairs([12, 21, 13, 31, 22]) == 2 def test_example2(): assert max_number_friend_pairs([18, 99, 27, 54]) == 1 def test_single_zombie(): assert max_number_friend_pairs([10]) == 0 def test_no_pairs(): assert max_n...
[ { "docstring": null, "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def max_number_friend_pairs(ages):", "function_name": "max_number_friend_pairs", "parameter_list": "(ag...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef max_number_friends(zombie_ages):\n \"\"\"\n Returns the maximum number of number-friend pairs that can be formed\n...
trial_gpt4o_9
{ "original_instruction": "In the kingdom of Zombieland, there lives a group of friendly zombies who love to play with numbers. One day, Zombie King Zed devised a new game called \"Number-Friends\". In this game, two zombies are considered \"number-friends\" if the sum of the digits of their ages is equal. The zombie...
0.616771
Taco_39136
C
[ "sum_of_digits", "max_number_friend_pairs" ]
2
[ [ "max_number_friend_pairs", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f4c1a27b15bb3b4ef873ca4bd440b342863cf8b0
8e5b45d3d4f98cf7cd5cd0e0682b03da7483c985
v1.0
complete
Taco
Taco_39395_C
from typing import List, Tuple def preprocess_array_for_min(arr: List[int]) -> Tuple[List[List[int]], List[int]]: """ Preprocess the given array to allow efficient range minimum queries. """ pass def range_minimum_query(st: List[List[int]], log: List[int], L: int, R: int) -> int: """ Answer th...
def preprocess_array_for_min(arr): """ Preprocess the given array to allow efficient range minimum queries. """ import sys n = len(arr) log = [0] * (n + 1) for i in range(2, n + 1): log[i] = log[i // 2] + 1 k = log[n] + 1 st = [[0] * k for _ in range(n)] for i in ra...
def test_preprocess_array_for_min(): arr = [1, 2, 3, 4, 5] st, log = preprocess_array_for_min(arr) assert st[0][0] == 1, "Test case 1 failed" assert st[1][0] == 2, "Test case 2 failed" assert st[0][1] == 1, "Test case 3 failed" assert st[1][1] == 2, "Test case 4 failed" def test_range_minimum_q...
[ { "docstring": "Preprocess the given array to allow efficient range minimum queries.", "function_declaration": "def preprocess_array_for_min(arr):", "function_name": "preprocess_array_for_min", "parameter_list": "(arr)" }, { "docstring": "Answer the range minimum query using the preprocessed...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def preprocess_array_for_min(arr):\n \"\"\"\n Preprocess the given array to allow efficient range minimum queries.\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "You are given an array of `N` integers. You need to perform `Q` queries. In each query, find the smallest integer in the subarray from index `L_i` to `R_i` (both inclusive). \n\n----- Constraints -----\n- 1 ≤ N ≤ 100,000\n- 1 ≤ Q ≤ 100,000\n- 1 ≤ A[i] ≤ 10^9\n- 1 ≤ L_i ≤ R_i ≤ N\n\n----- In...
0.596184
Taco_39395
C
[ "preprocess_array_for_min", "range_minimum_query", "solve" ]
3
[ [ "solve", "preprocess_array_for_min" ], [ "solve", "range_minimum_query" ] ]
2
[]
false
[]
false
pytest
false
[]
true
97fca32f653a85bc4df8134a75785a7f53171fa5
1026c56d2e94ce814e58079545fefe299b79e517
v1.0
complete
Taco
Taco_39432_C
def sum_of_squares_of_digits(num: int) -> int: """ Helper function to calculate the sum of squares of the digits of a number. >>> sum_of_squares_of_digits(19) == 82 >>> sum_of_squares_of_digits(82) == 68 >>> sum_of_squares_of_digits(68) == 100 >>> sum_of_squares_of_digits(100) == 1 """ def ...
def sum_of_squares_of_digits(num): """ Helper function to calculate the sum of squares of the digits of a number. """ return sum(int(digit) ** 2 for digit in str(num)) def is_lucky_number(num): """ Helper function to determine if a number is a lucky number. """ seen = set() while nu...
def test_sum_of_squares_of_digits(): assert sum_of_squares_of_digits(19) == 82 assert sum_of_squares_of_digits(82) == 68 assert sum_of_squares_of_digits(68) == 100 assert sum_of_squares_of_digits(100) == 1 def test_is_lucky_number(): assert is_lucky_number(1) == True assert is_lucky_number(7) =...
[ { "docstring": "Helper function to calculate the sum of squares of the digits of a number.", "function_declaration": "def sum_of_squares_of_digits(num):", "function_name": "sum_of_squares_of_digits", "parameter_list": "(num)" }, { "docstring": "Helper function to determine if a number is a l...
[ 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 return sum(int(digit) ** 2 for digit in str(num))\n\ndef is_lucky(num):\n seen_numbers = set()\n while num != 1 and n...
trial_gpt4o_2
{ "original_instruction": "Write a function `lucky_number` that takes an integer `n` and returns a list of all \"lucky numbers\" less than or equal to `n`.\n\nA \"lucky number\" is a number that reduces to 1 when you repeatedly sum the squares of its digits. If such a reduction is not possible (i.e., the number ends ...
0.628078
Taco_39432
C
[ "sum_of_squares_of_digits", "is_lucky_number", "lucky_number" ]
3
[ [ "is_lucky_number", "sum_of_squares_of_digits" ], [ "lucky_number", "is_lucky_number" ] ]
2
[]
false
[]
false
pytest
false
[]
true
bbbc70ac9d46ccb39ff755f048b4bde9afd7e044
4e599215d5f35427fcd9e2256b085cc0bd396abf
v1.0
complete
Taco
Taco_39809_C
def is_prime(num: int) -> bool: """ Checks if a number is prime. """ pass def generate_primes_up_to(n: int) -> List[int]: """ Generates a list of all prime numbers up to n. """ pass def max_prime_distance_permutation(n: int) -> List[int]: """ Generates a permutation of numbers from...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def generate_primes_up_...
from solution import max_prime_distance_permutation def test_max_prime_distance_permutation_1(): assert max_prime_distance_permutation(1) == [1] def test_max_prime_distance_permutation_4(): result = max_prime_distance_permutation(4) assert sorted(result) == [1, 2, 3, 4] def test_max_prime_distance_permut...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a list of all prime numbers up to n.", "function_declaration": "def generate_primes_up_to(n):", "function_n...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n ...
trial_gpt4o_1
{ "original_instruction": "Little E loves playing with permutations and prime numbers. She has a collection of the first n natural numbers (1 to n) and loves creating permutations of these numbers.\n\nShe defines the \"prime distance\" of a permutation as the number of pairs of elements (i, j) such that 1 ≤ i < j ≤ n...
0.677779
Taco_39809
C
[ "is_prime", "generate_primes_up_to", "max_prime_distance_permutation" ]
3
[ [ "generate_primes_up_to", "is_prime" ], [ "max_prime_distance_permutation", "generate_primes_up_to" ] ]
2
[]
false
[]
false
pytest
true
[]
true
47ebd33a2e5ffdca8f4a53f36efb14a9688c32f6
d2b67169570cb2b2dd0ae6a2d2e8682a23c6a577
v1.0
complete
Taco
Taco_39817_C
def is_prime(n: int) -> bool: """ Determines if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(29) True >>> is_prime(1) False """ pass def concatenated_is_prime(a: int, b: int) -> str: """ Concatenates two integers...
def is_prime(n): """ Determines 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 retu...
from solution import concatenated_is_prime, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(29) == True assert is_prime(28) ...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Concatenates two integers a and b, then checks if the resulting number is prime.", "function_declaration": "def concatena...
[ 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(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n elif n <= 3:\n retur...
trial_gpt4o_8
{ "original_instruction": "Sarah loves playing with numbers and patterns. One day, she thought of a unique number pattern exercise for her friends. She gives them two integers `a` and `b` and asks them to create a new integer by concatenating them (in the form of \"a concatenated with b\") and then check if the new i...
0.805108
Taco_39817
C
[ "is_prime", "concatenated_is_prime" ]
2
[ [ "concatenated_is_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0da54e3d96ac5e4c29056c03dec3541e894d9914
21ef5a9966274cd7bd4ae996c3e73d4553899712
v1.0
complete
Taco
Taco_39541_C
def puzzle_rotation(input_str): """ Modify the given grid by rotating all eligible m x m subgrids by 90 degrees clockwise. >>> puzzle_rotation("""5 1 2 3 4 5 1 0 0 0 1 1 0 8 0 1 1 0 0 0 1 1 2 3 4 5""") "1 2 3 4 5\n1 0 0 0 1\n1 0 8 0 1\n1 0 0 0 1\n1 2 3 4 5" >>> puzzle_rotation("""4 1 1 1 1 1 2 3 1 1 4 5...
def rotate_subgrid(grid): N = len(grid) def can_rotate(x, y, m): for i in range(m+2): if grid[x][y+i] == 0 or grid[x+m+1][y+i] == 0 or grid[x+i][y] == 0 or grid[x+i][y+m+1] == 0: return False return True def rotate_clockwise(x, y, m): subgrid = [...
def test_example_1(): input_data = """5 1 2 3 4 5 1 0 0 0 1 1 0 8 0 1 1 0 0 0 1 1 2 3 4 5""" expected_output = """1 2 3 4 5 1 0 0 0 1 1 0 8 0 1 1 0 0 0 1 1 2 3 4 5""" assert puzzle_rotation(input_data) == expected_output def test_example_2(): input_data = """4 1 1 1 1 1 2 3 1 1 4 5 1 1 1 1 1""" exp...
[ { "docstring": null, "function_declaration": "def rotate_subgrid(grid):", "function_name": "rotate_subgrid", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def str_to_matrix(s):", "function_name": "str_to_matrix", "parameter_list": "(s)" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_90_clockwise(puzzle):\n N = len(puzzle)\n if N == 1:\n return puzzle\n \n def is_surrounded_by_ones(i, j, m):\n # Check if the...
trial_gpt4o_1
{ "original_instruction": "Samantha is organizing a puzzle event and is creating different square puzzles. Each puzzle consists of a grid of integers, with some marked cells that cannot be altered. To make it more challenging, Samantha wants to rotate parts of the grid clockwise by 90 degrees if a condition is met. S...
0.619009
Taco_39541
C
[ "rotate_subgrid", "str_to_matrix", "matrix_to_str", "puzzle_rotation" ]
4
[ [ "puzzle_rotation", "matrix_to_str" ], [ "puzzle_rotation", "rotate_subgrid" ], [ "puzzle_rotation", "str_to_matrix" ] ]
3
[]
false
[]
false
pytest
false
[]
true
157e57b1450f092bce16fa40a4550072571ab7f0
be7dec52b083da6176ad1046fb654051b7647be4
v1.0
complete
Taco
Taco_39553_C
def is_palindrome(num: int) -> bool: """ Check if a given number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False """ def next_palindrome(N: int) -> int: """ Returns the smallest palindrome number greater than N. >>> next_palindrome(123) 131 >>> next_pal...
def is_palindrome(num): """ Check if a given number is a palindrome. """ return str(num) == str(num)[::-1] def next_palindrome(N): """ Returns the smallest palindrome number greater than N. """ N += 1 while not is_palindrome(N): N += 1 return N
from solution import is_palindrome, next_palindrome 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(202) == True assert is_palindrome(12321) == True assert is...
[ { "docstring": "Check if a given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Returns the smallest palindrome number greater than N.", "function_declaration": "def next_palindro...
[ 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 next_palindrome(N):\n \"\"\"\n Finds the smallest palindrome number greater than N.\n \"\"\"\n N += 1\n while True:\n if str(N) == str(N)...
trial_gpt4o_2
{ "original_instruction": "Alex loves playing with numbers and he has recently come across palindrome numbers. A number is called a palindrome if it reads the same from left to right and right to left.\n\nGiven a positive integer N, find the smallest palindrome number P such that P is greater than N.\n\nConstraints\n...
0.770454
Taco_39553
C
[ "is_palindrome", "next_palindrome" ]
2
[ [ "next_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5a5ec30da62e1aedcb2414be6f04abe482591ba
9b868995f475d94ab493189339d260f8ad6c06d6
v1.0
complete
Taco
Taco_39646_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def flattenTree(root): """ Given the root of the binary tree, this function flattens the tree into a singly linked list in-place following the pre-order traversal. ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def flattenTree(root): """ Given the root of the binary tree, this function flattens the tree into a singly linked list in-place following the pre-order traversal...
import pytest from solution import flattenTree, buildTree, preOrderTraversal, solution def test_flattenTree_example1(): nodes = ['1', '2', '5', '3', '4', 'n', '6'] root = buildTree(nodes) flattenTree(root) assert preOrderTraversal(root) == [1, 2, 3, 4, 5, 6] def test_flattenTree_example2(): nodes ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n \"\"\"\n Definition for a binary tree node.\n \"\"\"\n def __init__(self, x):\n self.val = x\n self.left = None\n ...
trial_gpt4o_2
{ "original_instruction": "Given a binary tree, write a function flattenTree() to convert the tree into a singly linked list in-place. The \"linked list\" should use the same TreeNode class where the right child pointer points to the next node in the list and the left child pointer is always null. The linked list sho...
0.521912
Taco_39646
C
[ "flattenTree", "buildTree", "preOrderTraversal", "solution" ]
4
[ [ "solution", "buildTree" ], [ "solution", "flattenTree" ], [ "solution", "preOrderTraversal" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
4611298d99d012e92e02380517ceee7d30ee287f
e1dfe81752f6a1ddc08b18659793c89f60de221c
v1.0
complete
Taco
Taco_39737_C
def min_cars_needed(test_cases): """Determine the minimum number of cars required to accommodate all the friends comfortably. Args: test_cases: A list of tuples, each containing two integers representing the number of friends and the seating capacity of one car respectively. Returns: A lis...
import math def min_cars_needed(test_cases): result = [] for m, n in test_cases: result.append(math.ceil(m / n)) return result def process_input(input_str): lines = input_str.splitlines() T = int(lines[0]) test_cases = [tuple(map(int, line.split())) for line in lines[1:T+1]] return...
def test_min_cars_needed(): input_str = "3\n12 5\n9 4\n6 3" expected_output = "3\n3\n2" assert solve(input_str) == expected_output def test_all_friends_fit_in_one_car(): input_str = "2\n5 5\n3 5" expected_output = "1\n1" assert solve(input_str) == expected_output def test_only_one_friend(): ...
[ { "docstring": null, "function_declaration": "def min_cars_needed(test_cases):", "function_name": "min_cars_needed", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def process_input(input_str):", "function_name": "process_input", "parameter_list...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef minimum_cars(T, test_cases):\n \"\"\"\n Returns the minimum number of cars required for each test case.\n \n Parameters:\n T : in...
trial_gpt4o_2
{ "original_instruction": "A group of friends are planning a road trip and want to rent cars. Each car has a maximum seating capacity of N people. Given that there are M friends participating in the trip, determine the minimum number of cars required to accommodate all the friends comfortably.\n\n------ Input Format ...
0.616478
Taco_39737
C
[ "min_cars_needed", "process_input", "process_output", "solve" ]
4
[ [ "solve", "min_cars_needed" ], [ "solve", "process_input" ], [ "solve", "process_output" ] ]
3
[ "process_input" ]
false
[]
false
pytest
false
[]
true
57d7e3396855e0241047c9a674e67c742e8fe1ff
0fa8fe0a08531f6286a4132b36c46f3f4c13afe3
v1.0
complete
Taco
Taco_39969_C
from typing import List, Tuple def closest_distance(points: List[Tuple[int, int]]) -> str: """ Returns the minimum distance between any two points formatted to six decimal places. >>> closest_distance([(0, 0), (3, 4), (1, 1)]) '1.414214' >>> closest_distance([(1, 1), (4, 4), (5, 1), (3, 3), (0...
from math import sqrt def euclidean_distance(p1, p2): """ Returns the Euclidean distance between two points p1 and p2. Each point is a tuple of (x, y). """ return sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2) def closest_pair_of_points(points): """ Returns the minimum distance between any ...
from solution import closest_distance def test_example_1(): points = [(0, 0), (3, 4), (1, 1)] assert closest_distance(points) == "1.414214" def test_example_2(): points = [(1, 1), (4, 4), (5, 1), (3, 3), (0, 0)] assert closest_distance(points) == "1.414214" def test_example_3(): points = [(0, 0),...
[ { "docstring": "Returns the Euclidean distance between two points p1 and p2.\nEach point is a tuple of (x, y).", "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": "Returns the minimum distance betw...
[ 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 math import sqrt\n\ndef euclidean_distance(p1, p2):\n \"\"\"\n Returns the Euclidean distance between two points p1 and p2.\n Each point is a tuple o...
trial_gpt4o_0
{ "original_instruction": "You are given n points on a 2D plane, and your task is to find the pair of points that are closest to each other. You need to calculate the Euclidean distance between each pair of points and determine the minimum distance.\n\nThe Euclidean distance between two points (x1, y1) and (x2, y2) i...
0.802441
Taco_39969
C
[ "euclidean_distance", "closest_pair_of_points", "closest_distance" ]
3
[ [ "closest_distance", "closest_pair_of_points" ], [ "closest_pair_of_points", "euclidean_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5660ed85af60d58b865898b21ef8132c877a7673
ab857cb726ca096ee6764e64570643ab8d53f6a5
v1.0
complete
Taco
Taco_39796_C
from typing import List, Tuple def precompute_prefix_sums(arr: List[int]) -> List[int]: """ Precompute prefix sums of the array. Args: arr (List[int]): The input array. Returns: List[int]: The prefix sums array. """ # Implement the precompute_prefix_sums function here def sum_of_...
def precompute_prefix_sums(arr): """ Precompute prefix sums of the array. Args: arr (List[int]): The input array. Returns: List[int]: The prefix sums array. """ prefix_sums = [0] * (len(arr) + 1) for i in range(1, len(arr) + 1): prefix_sums[i] = prefix_sums[i - 1] +...
from solution import solve def test_sum_of_subarray(): assert solve(5, [1, 2, 3, 4, 5], 3, [(1, 3), (2, 4), (1, 5)]) == [6, 9, 15] assert solve(5, [1, -2, 3, -4, 5], 3, [(1, 3), (2, 4), (1, 5)]) == [2, -3, 3] assert solve(3, [100000, -100000, 100000], 1, [(1, 3)]) == [100000] assert solve(1, [42], 1, [...
[ { "docstring": "Precompute prefix sums of the array.\n\nArgs:\narr (List[int]): The input array.\n\nReturns:\nList[int]: The prefix sums array.", "function_declaration": "def precompute_prefix_sums(arr):", "function_name": "precompute_prefix_sums", "parameter_list": "(arr)" }, { "docstring":...
[ 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 compute_prefix_sums(arr):\n \"\"\"\n Computes the prefix sums of the given array.\n A prefix sum array is such that prefix_sums[i] = sum(arr[0] to arr...
trial_gpt4o_1
{ "original_instruction": "You are given an array of integers and a series of queries. Each query asks for the sum of a contiguous subarray. The task is to compute the sums of the subarrays as specified by the queries efficiently.\n\nInput\n\nThe first input line contains a single integer n (1 ≤ n ≤ 100000) — the num...
0.607718
Taco_39796
C
[ "precompute_prefix_sums", "sum_of_subarray", "solve" ]
3
[ [ "solve", "precompute_prefix_sums" ], [ "solve", "sum_of_subarray" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e421321e07c82acf394ae27929c8f79d6dd490ff
ea45b8f8202db63ddcabaeaa9e8aad1b2b4e91bf
v1.0
complete
Taco
Taco_40025_C
from typing import List def is_balanced(sequence: str) -> str: """ Check whether a given sequence of brackets is balanced. >>> is_balanced("()") 'YES' >>> is_balanced("([{}])") 'YES' >>> is_balanced("{[()]}") 'YES' >>> is_balanced("([)]") 'NO' >>> is_balanced("][") 'NO' ...
def is_balanced(sequence): stack = [] matching_bracket = {')': '(', ']': '[', '}': '{'} for char in sequence: if char in matching_bracket.values(): stack.append(char) elif char in matching_bracket.keys(): if stack == [] or stack.pop() != matching_bracket[char]: ...
from solution import is_balanced, check_brackets def test_is_balanced(): assert is_balanced("()") == "YES" assert is_balanced("([{}])") == "YES" assert is_balanced("{[()]}") == "YES" assert is_balanced("([)]") == "NO" assert is_balanced("][") == "NO" assert is_balanced("(") == "NO" assert i...
[ { "docstring": null, "function_declaration": "def is_balanced(sequence):", "function_name": "is_balanced", "parameter_list": "(sequence)" }, { "docstring": null, "function_declaration": "def check_brackets(n, sequences):", "function_name": "check_brackets", "parameter_list": "(n,...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_balanced_sequence(sequence):\n \"\"\"\n Returns 'YES' if the sequence of brackets is balanced, otherwise 'NO'.\n \"\"\"\n stack = []\n bracke...
trial_gpt4o_2
{ "original_instruction": "In this challenge, the task is to validate the given sequence of brackets to ensure they are balanced.\n\nA sequence of brackets is considered balanced if:\n1. It consists entirely of pairs of opening/closing brackets in the correct order.\n2. Every closing bracket has a corresponding openi...
0.751698
Taco_40025
C
[ "is_balanced", "check_brackets" ]
2
[ [ "check_brackets", "is_balanced" ] ]
1
[]
false
[]
false
pytest
true
[]
true
080bea3359d7596a8dd1629ee558ee701feb50b1
f705d6aad15dd469b91be1fc69d5beac8b95b400
v1.0
complete
Taco
Taco_40008_C
def is_palindromic_permutation_possible(string: str) -> bool: """ Check if a palindromic permutation of the given string is possible. >>> is_palindromic_permutation_possible("aabb") True >>> is_palindromic_permutation_possible("abc") False """ def count_palindromic_permutations(string: str)...
from collections import Counter from math import factorial def is_palindromic_permutation_possible(string): counter = Counter(string) odd_count = sum(1 for count in counter.values() if count % 2 != 0) return odd_count <= 1 def count_palindromic_permutations(string): if not is_palindromic_permutation_p...
from solution import is_palindromic_permutation_possible, count_palindromic_permutations, count_palindromic_permutations_for_cases def test_is_palindromic_permutation_possible(): assert is_palindromic_permutation_possible("aabb") assert not is_palindromic_permutation_possible("abc") assert is_palindromic_p...
[ { "docstring": null, "function_declaration": "def is_palindromic_permutation_possible(string):", "function_name": "is_palindromic_permutation_possible", "parameter_list": "(string)" }, { "docstring": null, "function_declaration": "def count_palindromic_permutations(string):", "functi...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\nfrom math import factorial\n\ndef count_palindromic_permutations(S):\n \"\"\"\n Returns the number of distinct palindromic p...
trial_gpt4o_4
{ "original_instruction": "Amara is fascinated by strings and their patterns. She has a special liking for permutations of strings. Amara wants to find out how many permutations of a given string are palindromic.\n\nA palindromic string is one that reads the same forward and backward. Help Amara to count the number o...
0.697478
Taco_40008
C
[ "is_palindromic_permutation_possible", "count_palindromic_permutations", "count_palindromic_permutations_for_cases" ]
3
[ [ "count_palindromic_permutations", "is_palindromic_permutation_possible" ], [ "count_palindromic_permutations_for_cases", "count_palindromic_permutations" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f27a1326f91838911b43882bb4545225244ec81f
cc8931453981cf4628e8290f44d2fa5303e24800
v1.0
complete
Taco
Taco_39865_C
from typing import List def longest_consecutive_ones(arr: List[int]) -> int: """ Helper function to find the longest sequence of consecutive ones >>> longest_consecutive_ones([1, 0, 1, 1, 0, 1]) 2 >>> longest_consecutive_ones([1, 1, 1, 1, 0, 1]) 4 >>> longest_consecutive_ones([1, 1, 1, 0, 0, 1]...
def longest_consecutive_ones(arr): """ Helper function to find the longest sequence of consecutive ones """ max_count = 0 current_count = 0 for num in arr: if num == 1: current_count += 1 if current_count > max_count: max_count = current_count els...
from solution import longest_consecutive_ones, process_operations def test_longest_consecutive_ones(): assert longest_consecutive_ones([1, 0, 1, 1, 0, 1]) == 2 assert longest_consecutive_ones([1, 1, 1, 1, 0, 1]) == 4 assert longest_consecutive_ones([1, 1, 1, 0, 0, 1]) == 3 assert longest_consecutive_on...
[ { "docstring": "Helper function to find the longest sequence of consecutive ones ", "function_declaration": "def longest_consecutive_ones(arr):", "function_name": "longest_consecutive_ones", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def process_operations...
[ 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 process_operations(n, m, arr, operations):\n def flip(index):\n arr[index] = 1 - arr[index]\n\n def query():\n max_length, current_length =...
trial_gpt4o_5
{ "original_instruction": "A series of ones and zeroes\n\nYou are given an array consisting of N integers (either 0 or 1), and you need to perform M operations. Each operation can either be:\n\n1. **Flipping**: Change a 0 to 1 or a 1 to 0 at a specified index.\n2. **Querying**: Count the number of consecutive 1s in t...
0.618812
Taco_39865
C
[ "longest_consecutive_ones", "process_operations", "handle_input" ]
3
[ [ "handle_input", "process_operations" ], [ "process_operations", "longest_consecutive_ones" ] ]
2
[ "handle_input" ]
false
[]
false
pytest
true
[]
true
c24b45687d5bacb231b6ffc4de697288d42da71f
2e9a1b9cfc78c7677e96e97943397fc2f9685592
v1.0
complete
Taco
Taco_39609_C
def has_all_ones_submatrix(matrix, n, m, k): """ Check if there is at least one k x k submatrix that contains only 1's. >>> has_all_ones_submatrix([[1, 1, 1], [1, 1, 1], [1, 1, 1]], 3, 3, 2) 'YES' >>> has_all_ones_submatrix([[1, 1, 1, 0], [1, 1, 1, 0], [0, 0, 1, 1], [1, 1, 1, 1]], 4, 4, 3) 'NO' ...
def has_all_ones_submatrix(matrix, n, m, k): # Iterate over each possible top-left corner of k x k submatrix for i in range(n - k + 1): for j in range(m - k + 1): if all(matrix[i + x][j + y] == 1 for x in range(k) for y in range(k)): return "YES" return "NO" def solve(te...
import pytest from solution import has_all_ones_submatrix, solve, process_input def test_has_all_ones_submatrix(): assert has_all_ones_submatrix([[1, 1, 1], [1, 1, 1], [1, 1, 1]], 3, 3, 2) == "YES" assert has_all_ones_submatrix([[1, 1, 1, 0], [1, 1, 1, 0], [0, 0, 1, 1], [1, 1, 1, 1]], 4, 4, 3) == "NO" def tes...
[ { "docstring": null, "function_declaration": "def has_all_ones_submatrix(matrix, n, m, k):", "function_name": "has_all_ones_submatrix", "parameter_list": "(matrix, n, m, k)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "param...
[ 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 has_all_ones_submatrix(T, test_cases):\n results = []\n \n for case in test_cases:\n n, m, k, matrix = case\n found = False\n \n ...
trial_gpt4o_2
{ "original_instruction": "A binary matrix of size n x m is given, where each element is either 0 or 1. We need to find out if there is at least one submatrix of size k x k (where k is given) that contains only 1's (all 1's submatrix).\n\n------ Input ------ \n\nThe first line contains an integer T denoting the total...
0.622537
Taco_39609
C
[ "has_all_ones_submatrix", "solve", "process_input" ]
3
[ [ "solve", "has_all_ones_submatrix" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
234b658d16830373ac4750f267d132e6b6ebe67c
0165c29bf0809cbbc8fb36411826d5a78a87b27c
v1.0
complete
Taco
Taco_40011_C
def solve(test_cases: List[Tuple[int, int, List[str]]]) -> List[str]: """Given a grid of characters, determine if there exists a cycle of the same letter. A cycle is a path in the grid where the first and last letter are the same, with each letter being distinct (i.e., no letter repeats unless it is the st...
from collections import deque def in_bounds(x, y, n, m): return 0 <= x < n and 0 <= y < m def bfs(grid, start, n, m): x0, y0 = start visited = [[False] * m for _ in range(n)] queue = deque([(x0, y0, -1, -1)]) start_char = grid[x0][y0] while queue: x, y, px, py = queue.popleft() ...
from solution import solve def test_example(): test_cases = [ (3, 4, ["aaaa", "abca", "aaaa"]), (4, 4, ["abcd", "efgh", "ijkl", "mnop"]), (5, 5, ["abcde", "abfde", "abfde", "abcde", "abcde"]) ] result = solve(test_cases) assert result == ["Yes", "No", "Yes"] def test_no_cycle_s...
[ { "docstring": null, "function_declaration": "def in_bounds(x, y, n, m):", "function_name": "in_bounds", "parameter_list": "(x, y, n, m)" }, { "docstring": null, "function_declaration": "def bfs(grid, start, n, m):", "function_name": "bfs", "parameter_list": "(grid, start, n, m)"...
[ 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": "def has_cycle_dfs(grid, visited, x, y, px, py, start_letter):\n n, m = len(grid), len(grid[0])\n visited.add((x, y))\n directions = [(-1, 0), (1, 0), (0, ...
trial_gpt4o_7
{ "original_instruction": "Given a grid of characters, determine if there exists a cycle of the same letter. A cycle is a path in the grid where the first and last letter are the same, with each letter being distinct (i.e., no letter repeats unless it is the start and endpoint). The path must consist of at least four...
0.698992
Taco_40011
C
[ "in_bounds", "bfs", "has_cycle", "solve" ]
4
[ [ "bfs", "in_bounds" ], [ "has_cycle", "bfs" ], [ "solve", "has_cycle" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8378226a5e56a5e78342095a21c9209f0d58d415
6f7c20373eee6733020c8d88c8421ff1bec70b34
v1.0
complete
Taco
Taco_40194_C
def are_anagrams(word1: str, word2: str) -> bool: """ Check if two words are anagrams of each other (case insensitive). >>> are_anagrams("listen", "silent") == True >>> are_anagrams("hello", "world") == False >>> are_anagrams("Listen", "SiLeNt") == True >>> are_anagrams("Triangle", "Integral") == Tr...
def are_anagrams(word1, word2): """ Check if two words are anagrams of each other (case insensitive). """ return sorted(word1.lower()) == sorted(word2.lower()) def check_anagrams(pairs): """ Takes a list of word pairs and returns a list of "YES" or "NO" for each pair indicating whether the...
from solution import are_anagrams, check_anagrams def test_are_anagrams(): assert are_anagrams("listen", "silent") == True assert are_anagrams("hello", "world") == False assert are_anagrams("Listen", "SiLeNt") == True assert are_anagrams("Triangle", "Integral") == True assert are_anagrams("apple", ...
[ { "docstring": "Check if two words are anagrams of each other (case insensitive).", "function_declaration": "def are_anagrams(word1, word2):", "function_name": "are_anagrams", "parameter_list": "(word1, word2)" }, { "docstring": "Takes a list of word pairs and returns a list of \"YES\" or \"...
[ 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 are_anagrams(word1, word2):\n \"\"\"\n Check if two words are anagrams of each other (case insensitive).\n \"\"\"\n return sorted(word1.lower()) ==...
trial_gpt4o_1
{ "original_instruction": "Deepa is a software engineer and is working on a project to analyze word frequency in large texts. She needs a function that can determine if two strings are anagrams of each other. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically usi...
0.63277
Taco_40194
C
[ "are_anagrams", "check_anagrams" ]
2
[ [ "check_anagrams", "are_anagrams" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc0c8d3e4462112b3bd19065b4a04fe597962908
9b55c28208f2e0f16dfc669a722ff087062489f4
v1.0
complete
Taco
Taco_40170_C
from typing import List def find_shortest_route(N: int, travel_times: List[List[int]]) -> int: """ Determine the shortest possible total travel time for the delivery van to complete its route. >>> find_shortest_route(3, [[0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0]]) 80 >>> find_s...
from itertools import permutations def calculate_travel_time(route, travel_times): total_time = 0 for i in range(len(route) - 1): total_time += travel_times[route[i]][route[i + 1]] total_time += travel_times[route[-1]][route[0]] # returning to the warehouse return total_time def find_shortest...
from solution import find_shortest_route def test_example_1(): N = 3 travel_times = [ [0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0] ] assert find_shortest_route(N, travel_times) == 80 def test_example_2(): N = 4 travel_times = [ [0, ...
[ { "docstring": null, "function_declaration": "def calculate_travel_time(route, travel_times):", "function_name": "calculate_travel_time", "parameter_list": "(route, travel_times)" }, { "docstring": null, "function_declaration": "def find_shortest_route(N, travel_times):", "function_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": "import itertools\n\ndef find_shortest_route(N, travel_times):\n locations = list(range(1, N + 1))\n min_route_time = float('inf')\n \n for perm in iter...
trial_gpt4o_2
{ "original_instruction": "A delivery company wants to optimize the route for their delivery van. Each day, the van starts from the warehouse and makes deliveries to $N$ different locations. For simplicity, consider the warehouse to be at location number $0$, and the $N$ delivery locations are numbered from $1$ to $N...
0.68275
Taco_40170
C
[ "calculate_travel_time", "find_shortest_route" ]
2
[ [ "find_shortest_route", "calculate_travel_time" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2dc751e446a1f26ca7aa4fbc8ac9fa3cd59bfb5a
f383809832c2050252bd8e887e4ed7f031b1af59
v1.0
complete
Taco
Taco_39669_C
def longest_common_prefix(strings): """ Find the longest common prefix string amongst an array of strings. """ # YOUR CODE HERE def find_longest_common_prefix_for_identifier(test_cases): results = [] for case in test_cases: N, entries, identifier_query = case strings = [entry[1]...
def longest_common_prefix(strings): """ Find the longest common prefix string amongst an array of strings. """ if not strings: return "" prefix = strings[0] for string in strings[1:]: while not string.startswith(prefix): prefix = prefix[:-1] if prefix...
def test_main(): input_data = """2 4 id1 banana id1 bandana id2 candy id1 banner id1 3 id3 apple id3 apricot id3 avocado id3""" expected_output = """ban a""" assert main(input_data) == expected_output def test_no_common_prefix(): input_data = """1 3 id1 dog id1 cat id1 mouse id1""" expect...
[ { "docstring": "Find the longest common prefix string amongst an array of strings.", "function_declaration": "def longest_common_prefix(strings):", "function_name": "longest_common_prefix", "parameter_list": "(strings)" }, { "docstring": null, "function_declaration": "def find_longest_co...
[ 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 longest_common_prefix(strings):\n \"\"\"\n Returns the longest common prefix from a list of strings.\n \"\"\"\n if not strings:\n return \"\...
trial_gpt4o_2
{ "original_instruction": "Alice has a collection of strings, each with an identifier. She wants to find the longest common prefix among a list of strings that share a common identifier. If there are multiple strings with the same longest prefix, return the one which appears first in the list. If there is no common p...
0.690181
Taco_39669
C
[ "longest_common_prefix", "find_longest_common_prefix_for_identifier", "process_input", "main" ]
4
[ [ "find_longest_common_prefix_for_identifier", "longest_common_prefix" ] ]
1
[ "process_input" ]
false
[]
false
pytest
false
[]
true
7e9614ab4e54da87916ff322aff9738e5edece96
b825a9cffe413e3ba64d222a4fdefab93a7b4fa5
v1.0
complete
Taco
Taco_39365_C
from typing import List, Tuple def solution(T: int, test_cases: List[Tuple[int, int, List[Tuple[int, int, int]]]]) -> List[int]: """ A group of adventurers is planning a journey through a series of caves. The caves are connected by one-way tunnels, and each tunnel has a certain travel cost. The adventurers wan...
import heapq def find_min_travel_cost(T, test_cases): results = [] for t in range(T): N = test_cases[t][0] M = test_cases[t][1] edges = test_cases[t][2] adjacency_list = [[] for _ in range(N+1)] for u, v, w in edges: adjacency_list[u].append((v, w)) ...
def test_solution(): # Test case 1 T = 2 test_cases = [ (5, 6, [ (1, 2, 2), (1, 3, 3), (2, 4, 1), (3, 4, 1), (4, 5, 4), (3, 5, 2) ]), (4, 3, [ (1, 2, 3), (1, 3, 5), (2, 4, 1), ...
[ { "docstring": null, "function_declaration": "def find_min_travel_cost(T, test_cases):", "function_name": "find_min_travel_cost", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def dijkstra(N, adjacency_list):", "function_name": "dijkstra", "...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "import heapq\n\ndef find_min_travel_cost(T, test_cases):\n results = []\n for t in range(T):\n N = test_cases[t][0]\n ...
trial_gpt4o_1
{ "original_instruction": "A group of adventurers is planning a journey through a series of caves. The caves are connected by one-way tunnels, and each tunnel has a certain travel cost. The adventurers want to determine if it is possible to travel from the entrance of the cave system to the treasure located deep insi...
0.638291
Taco_39365
C
[ "find_min_travel_cost", "dijkstra", "solution" ]
3
[ [ "find_min_travel_cost", "dijkstra" ], [ "solution", "find_min_travel_cost" ] ]
2
[]
false
[]
false
pytest
false
[]
true
ef8a0a93e0266795881c3f2c23883408d4a68fd2
5ac596c23648cd0f52bc1392fa48fae603d6f360
v1.0
complete
Taco
Taco_39934_C
from typing import List def is_prime(n: int) -> bool: """Helper function to check if a number is prime.""" # TODO: Implement this function def prime_game_winner(prime_numbers: List[int]) -> str: """ Determines the winner of the prime number game given a list of integers. John always starts first a...
def is_prime(n): """Helper function to check if n is a prime number.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def prime_game_winner(pri...
from solution import is_prime, prime_game_winner, prime_game def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(15) == False assert is_prime(1) == False assert is_prime(0) == False assert is_...
[ { "docstring": "Helper function to check if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Determines the winner of the prime number game given a list of integers.\nJohn always starts first and both p...
[ 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_prime(n):\n \"\"\"Helper function to check if n is a prime number.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ...
trial_gpt4o_0
{ "original_instruction": "John is learning about prime numbers and he wants to play a prime number game. The game involves two players who take turns choosing a prime number from a given list. Once a prime number is chosen, it is removed from the list and cannot be chosen again. The game ends when there are no more ...
0.670296
Taco_39934
C
[ "is_prime", "prime_game_winner", "prime_game" ]
3
[ [ "prime_game", "prime_game_winner" ], [ "prime_game_winner", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fb60fa2bc637622eaf1766b0d398d49a1b48ced1
7e70c706c9a4bbd72ef538c33f3964d2b62940ce
v1.0
complete
Taco
Taco_40112_C
from typing import List, Tuple def find(parent: List[int], i: int) -> int: """ Find the root of the element i in the union-find structure. >>> parent = [0, 1, 2, 3] >>> find(parent, 0) 0 >>> find(parent, 1) 1 """ pass def union(parent: List[int], rank: List[int], x: int, y: int): "...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > ...
def test_find(): parent = [0, 1, 2, 3] assert find(parent, 0) == 0 assert find(parent, 1) == 1 def test_union(): parent = [0, 1, 2, 3] rank = [0, 0, 0, 0] union(parent, rank, 0, 1) assert find(parent, 0) == find(parent, 1) assert parent[1] == 0 def test_min_additional_links(): asse...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_0
{ "original_instruction": "A company is planning to build a network of servers to handle incoming client requests efficiently. The company has exactly $N$ servers, each identified by a unique integer from $1$ to $N$. The servers are connected by bidirectional communication links, forming an undirected graph. Each ser...
0.525622
Taco_40112
C
[ "find", "union", "min_additional_links", "process_test_cases" ]
4
[ [ "min_additional_links", "find" ], [ "min_additional_links", "union" ], [ "process_test_cases", "min_additional_links" ], [ "union", "find" ] ]
4
[ "process_test_cases" ]
false
[]
false
pytest
false
[]
true
3d7781738ea350e929cd46692a567bab32b68f11
3b2773ed0f97d14be73026892ff22bee203d45fb
v1.0
complete
Taco
Taco_40245_C
def shortest_cycle(N, roads): """ Compute the shortest possible cycle that visits all checkpoints. If such a cycle does not exist, return -1. Args: N (int): the number of checkpoints roads (List[Tuple[int, int, int]]): list of tuples containing u, v (checkpoints) and d (distance) Returns: ...
import sys def tsp(N, dist): # dp[mask][i] will be the minimum cost to reach node i with the set of nodes in mask dp = [[sys.maxsize] * N for _ in range(1 << N)] dp[1][0] = 0 for mask in range(1 << N): for u in range(N): if mask & (1 << u): for v in range(N): ...
def test_tsp(): assert shortest_cycle(4, [(1, 2, 10), (2, 3, 15), (3, 4, 20), (4, 1, 25), (1, 3, 30), (2, 4, 35)]) == 70 assert shortest_cycle(3, [(1, 2, 10), (2, 3, 20)]) == -1 assert shortest_cycle(2, [(1, 2, 1), (2, 1, 1)]) == 2 assert shortest_cycle(5, [(1, 2, 10), (2, 3, 20), (3, 4, 30), (4, 5, 40)...
[ { "docstring": null, "function_declaration": "def tsp(N, dist):", "function_name": "tsp", "parameter_list": "(N, dist)" }, { "docstring": null, "function_declaration": "def shortest_cycle(N, roads):", "function_name": "shortest_cycle", "parameter_list": "(N, roads)" }, { ...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef floyd_warshall(n, dist):\n for k in range(n):\n for i in range(n):\n for j in range(n):\n if dist[i][j]...
trial_gpt4o_6
{ "original_instruction": "A race track has N checkpoints connected by M bidirectional roads. Each road has a fixed distance between two checkpoints. A racer wants to determine the minimum distance required to visit every checkpoint starting from any checkpoint and return to the original one, forming a cycle.\n\nGive...
0.645971
Taco_40245
C
[ "tsp", "shortest_cycle", "main" ]
3
[ [ "shortest_cycle", "tsp" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c84655ca30de32c703eca1670da0acb75d4684bc
e066e605accff22d9c82b0f70663987f4d3dd625
v1.0
complete
Taco
Taco_40256_C
from typing import List, Tuple def compare(x: str, y: str) -> int: """ Helper comparison function that determines the order of two strings x and y such that the combination x + y or y + x forms a larger number. """ pass def largest_number(arr: List[int]) -> str: """ Takes an array of non-n...
from functools import cmp_to_key def compare(x, y): """ Helper comparison function that determines the order of two strings x and y such that the combination x + y or y + x forms a larger number. """ if x + y > y + x: return -1 else: return 1 def largest_number(arr): """ ...
import pytest from solution import handle_multiple_test_cases, largest_number def test_single_case(): assert largest_number([10, 2, 9]) == "9210" assert largest_number([3, 30, 34, 5, 9]) == "9534330" assert largest_number([1, 0]) == "10" assert largest_number([0, 0]) == "0" def test_handle_multiple_te...
[ { "docstring": "Helper comparison function that determines the order of two strings x and y\nsuch that the combination x + y or y + x forms a larger number.", "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Takes an arra...
[ 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 functools import cmp_to_key\n\ndef largest_number(test_cases):\n def custom_compare(x, y):\n return (y + x > x + y) - (y + x < x + y)\n \n res...
trial_gpt4o_1
{ "original_instruction": "Given an array of non-negative integers, you are tasked with arranging these integers such that they form the largest possible number. The result should be returned as a string.\n\nYou should not consider the leading zeros in the resulting string. If the result is a zero, the function shoul...
0.66921
Taco_40256
C
[ "compare", "largest_number", "handle_multiple_test_cases" ]
3
[ [ "handle_multiple_test_cases", "largest_number" ], [ "largest_number", "compare" ] ]
2
[ "handle_multiple_test_cases" ]
false
[]
false
pytest
true
[]
true
0c7210e1f027ae564bddf9bca0ed1b30c99718c4
f53b4ba82d3c309f3ecf8efa8d87616b382b775d
v1.0
complete
Taco
Taco_40154_C
def can_schedule_events(test_cases): """Determine whether events can be scheduled without overlap for multiple test cases. Args: test_cases (List[List[Tuple[int, int]]]): A list of test cases, each containing a list of events represented as (start_time, end_time) tuples. Returns: List[str]: A list o...
def can_schedule_events(test_cases): results = [] for events in test_cases: events.sort() # Sort events by their start time can_schedule = True end_time = -1 for s, e in events: if s < end_time: can_schedule = False break e...
def test_can_schedule_events(): input_str = "2\n3\n1 3\n2 5\n6 7\n2\n1 2\n3 4\n" assert solve(input_str) == ["NO", "YES"] def test_no_event(): input_str = "1\n0\n" assert solve(input_str) == ["YES"] def test_single_event(): input_str = "1\n1\n0 1\n" assert solve(input_str) == ["YES"] def test...
[ { "docstring": null, "function_declaration": "def can_schedule_events(test_cases):", "function_name": "can_schedule_events", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_...
[ 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_schedule_events(test_cases):\n results = []\n for case in test_cases:\n events = case\n events.sort(key=lambda x: x[0])\n \n ...
trial_gpt4o_2
{ "original_instruction": "John is organizing a series of events for his friends, and he wants to make sure the schedule is balanced. He has a list of N events, each with a start time and an end time. Two events are said to overlap if they share at least one point in time. John wants to find out if he can arrange all...
0.551517
Taco_40154
C
[ "can_schedule_events", "parse_input", "solve" ]
3
[ [ "solve", "can_schedule_events" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
918fb9e1c7e6df59b14a4951bff25a637634fbc3
52f561be4a85de4225c96b4cc8f046e18815b0d1
v1.0
complete
Taco
Taco_40280_C
MOD = 10**9 + 7 def count_sequences(n: int, k: int) -> int: """Compute the number of unique sequences with specified rules. Args: n (int): Number of different stones. k (int): Length of the sequence. Returns: int: Number of unique sequences modulo 10^9 + 7. >>> count_sequences(3,...
MOD = 10**9 + 7 def count_sequences(n, k): if k == 1: return 1 # Only one sequence: [1] if k % 2 == 0: return pow(n - 1, k // 2, MOD) else: return 0 # No valid sequence for odd k def solve(test_cases): results = [] for n, k in test_cases: results.append(count...
from solution import count_sequences, solve, process_input def test_count_sequences_even_k(): assert count_sequences(3, 2) == 2 assert count_sequences(4, 2) == 3 assert count_sequences(4, 4) == 9 assert count_sequences(5, 6) == 64 def test_count_sequences_odd_k(): assert count_sequences(3, 5) == 0...
[ { "docstring": null, "function_declaration": "def count_sequences(n, k):", "function_name": "count_sequences", "parameter_list": "(n, k)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases)" }, { ...
[ 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": "MOD = 10**9 + 7\n\ndef count_unique_sequences(N, K):\n if K == 1:\n return 1\n if K % 2 == 0:\n return 1\n if N == 2:\n return 0\n ...
trial_gpt4o_3
{ "original_instruction": "Alex has a collection of different stones numbered from 1 to N. He enjoys creating unique sequences with these stones by following a set of specific rules. Each sequence should start and end with the stone numbered 1, and every other stone in the sequence should have a number different from...
0.662184
Taco_40280
C
[ "count_sequences", "solve", "process_input" ]
3
[ [ "solve", "count_sequences" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
fc6a798ba9cc033c66dedbd994953aadea7f9bd9
3a513ae65508aa3e6798db716c4f3e450bf57043
v1.0
complete
Taco
Taco_40406_C
def is_cyclic_path(path: str) -> bool: """ Determine if a given path is cyclic (starts and ends at the same point). >>> is_cyclic_path("NESW") True >>> is_cyclic_path("NNSS") True >>> is_cyclic_path("EW") True >>> is_cyclic_path("NNEESWWS") True >>> is_cyclic_path("NS") True ...
def is_cyclic_path(path): """ Determines if a given path is cyclic (starts and ends at the same point). Parameters: path (str): A string representing the path taken by the bird. Returns: bool: True if the path is cyclic, otherwise False. """ x, y = 0, 0 for direction in pat...
import pytest from solution import is_cyclic_path, count_cyclic_paths def test_is_cyclic_path(): assert is_cyclic_path("NESW") == True assert is_cyclic_path("NNSS") == True assert is_cyclic_path("EW") == True assert is_cyclic_path("NNEESWWS") == True assert is_cyclic_path("NS") == True assert i...
[ { "docstring": "Determines if a given path is cyclic (starts and ends at the same point).\n\nParameters:\npath (str): A string representing the path taken by the bird.\n\nReturns:\nbool: True if the path is cyclic, otherwise False.", "function_declaration": "def is_cyclic_path(path):", "function_name": ...
[ 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_cyclic_path(path):\n \"\"\"\n Determines if the given path is cyclic.\n \n A path is considered cyclic if it returns to the starting point\n ...
trial_gpt4o_2
{ "original_instruction": "A group of scientists is studying the habits of migratory birds. They have recorded the paths of several birds, and each path can be represented as a sequence of directions: 'N' for north, 'S' for south, 'E' for east, and 'W' for west. They are trying to determine how many of these paths ar...
0.5931
Taco_40406
C
[ "is_cyclic_path", "count_cyclic_paths" ]
2
[ [ "count_cyclic_paths", "is_cyclic_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7757ef225b1e2979762250cca4ea482ae51c9157
58a6baf83d9b011be6c744a324a9b46f6cbe2bcb
v1.0
complete
Taco
Taco_40089_C
def detect_right_angle_triangle(stars): """ Determine if any three stars form a right-angle triangle. Parameters: stars (list of tuples): List of tuples where each tuple contains the (x, y) coordinates of a star. Returns: str: 'YES' if there exist three stars forming a right-angle tria...
def is_right_angle(x1, y1, x2, y2, x3, y3): """ Returns True if points (x1, y1), (x2, y2), and (x3, y3) form a right-angle triangle. """ # Calculate the square of the lengths of sides a2 = (x2 - x1) ** 2 + (y2 - y1) ** 2 b2 = (x3 - x1) ** 2 + (y3 - y1) ** 2 c2 = (x3 - x2) ** 2 + (y3 - y2) **...
def test_detect_right_angle_triangle(): assert detect_right_angle_triangle([(1, 1), (7, 1), (1, 5), (6, 10), (7, 5)]) == "YES" assert detect_right_angle_triangle([(0, 0), (1, 1), (2, 2), (3, 3)]) == "NO" assert detect_right_angle_triangle([(0, 0), (3, 0), (0, 4)]) == "YES" assert detect_right_angle_tria...
[ { "docstring": "Returns True if points (x1, y1), (x2, y2), and (x3, y3) form a right-angle triangle.", "function_declaration": "def is_right_angle(x1, y1, x2, y2, x3, y3):", "function_name": "is_right_angle", "parameter_list": "(x1, y1, x2, y2, x3, y3)" }, { "docstring": "Determine if any 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 is_right_angle(x1, y1, x2, y2, x3, y3):\n \"\"\"\n Returns True if points (x1, y1), (x2, y2), and (x3, y3) form a right-angle triangle.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "Ethan loves observing the night sky and cataloging stars. He has a list of stars represented by their x and y coordinates in a 2D plane. He believes that some stars may form interesting patterns like triangles or other shapes. One specific pattern he is curious about is a right-angled trian...
0.745389
Taco_40089
C
[ "is_right_angle", "detect_right_angle_triangle" ]
2
[ [ "detect_right_angle_triangle", "is_right_angle" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2302d47b8a1d54e731748c1377694a8a1e5fd436
0784ca0fedb338dfe91038289f0caa5ac11980bf
v1.0
complete
Taco
Taco_40392_C
def is_well_formed(s: str) -> int: """ Check if the string is well-formed. A string is well-formed if it contains only alphabetic characters and has equal numbers of uppercase and lowercase letters. >>> is_well_formed("aAbB") 4 >>> is_well_formed("abcD") -1 >>> is_well_formed("XYzZxy")...
def is_well_formed(s): """ Check if the string is well-formed. A string is well-formed if it contains only alphabetic characters and has equal numbers of uppercase and lowercase letters. """ if not s.isalpha(): return -1 uppercase_count = sum(1 for c in s if c.isupper()) l...
from solution import is_well_formed, process_strings def test_is_well_formed(): assert is_well_formed("aAbB") == 4 assert is_well_formed("abcD") == -1 assert is_well_formed("XYzZxy") == 6 assert is_well_formed("aA") == 2 assert is_well_formed("aAbb") == -1 assert is_well_formed("abc") == -1 ...
[ { "docstring": "Check if the string is well-formed.\n\nA string is well-formed if it contains only alphabetic characters and \nhas equal numbers of uppercase and lowercase letters.", "function_declaration": "def is_well_formed(s):", "function_name": "is_well_formed", "parameter_list": "(s)" }, {...
[ 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_well_formed(s):\n \"\"\"\n Returns the length of the string if it is well-formed, otherwise returns -1.\n A string is considered well-formed if it ...
trial_gpt4o_3
{ "original_instruction": "You are given a list of strings. A string is considered \"well-formed\" if it contains only alphabetic characters and has equal numbers of uppercase and lowercase letters. For each string in the list, you need to determine if it is well-formed or not. If it is well-formed, your output shoul...
0.671324
Taco_40392
C
[ "is_well_formed", "process_strings" ]
2
[ [ "process_strings", "is_well_formed" ] ]
1
[]
false
[]
false
pytest
true
[]
true
21645d505067ed03cbdd2f50aa720c0ff2bf6e6b
62af34d3480321d93bf76be604809c70c29635ce
v1.0
complete
Taco
Taco_40470_C
def answer_queries(arr, queries): """ You are given an array of integers a = [a_1, a_2, ..., a_n] and m queries. Each query is described by a pair of integers l_i, r_i (1 ≤ l_i ≤ r_i ≤ n). For each query, find the maximum integer in the subarray a[l_i..r_i]. Preprocess the array for fast query r...
def preprocess(arr, n): """ Preprocess the list using a sparse table for fast range_maximum queries. """ import math k = int(math.log2(n)) + 1 st = [[0] * (k + 1) for _ in range(n)] # Initialize the sparse table for the intervals with size 1 for i in range(n): st[i][0] = arr[i]...
from solution import answer_queries def test_example_1(): arr = [1, 2, 3, 4, 5] queries = [(1, 3), (2, 5), (1, 5)] expected = [3, 5, 5] assert answer_queries(arr, queries) == expected def test_example_2(): arr = [5, 1, 3, 7, 9, 2, 6, 8] queries = [(3, 4), (1, 7), (2, 8), (4, 8)] expected =...
[ { "docstring": "Preprocess the list using a sparse table for fast range_maximum queries.", "function_declaration": "def preprocess(arr, n):", "function_name": "preprocess", "parameter_list": "(arr, n)" }, { "docstring": "Query the maximum value in the range [l, r] using the preprocessed spar...
[ 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 preprocess_max(array):\n \"\"\"\n Preprocesses the maximum values for subarrays to allow fast querying.\n \"\"\"\n n = len(array)\n max_table = ...
trial_gpt4o_1
{ "original_instruction": "You are given an array of integers a = [a_1, a_2, ..., a_n] and m queries. Each query is described by a pair of integers l_i, r_i (1 ≤ l_i ≤ r_i ≤ n). For each query, find the maximum integer in the subarray a[l_i..r_i].\n\nYour task is to write a program to answer these queries efficiently...
0.733694
Taco_40470
C
[ "preprocess", "range_maximum", "answer_queries" ]
3
[ [ "answer_queries", "preprocess" ], [ "answer_queries", "range_maximum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7737d7193ca85480952038f913221d78a422ec91
e86efed1371174b1dc8b91403714d79c2f29f75c
v1.0
complete
Taco
Taco_40354_C
def is_prime(number): """ Checks if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True """ def max_prime_subsequence_sum(n, elements): """ Returns the sum of the prime subsequence with the highest sum, or "NONE" if no prime subseq...
def is_prime(number): """ Checks if a number is prime. """ if number <= 1: return False if number == 2: return True if number % 2 == 0: return False for i in range(3, int(number**0.5) + 1, 2): if number % i == 0: return False return True def m...
from solution import is_prime, max_prime_subsequence_sum, process_input # is_prime function tests def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(7) == True assert ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { "docstring": "Returns the sum of the prime subsequence with the highest sum, or \"NONE\" if no prime subsequence exists.", "funct...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if ...
trial_gpt4o_2
{ "original_instruction": "Prime Subsequence Sum\n\nYou are given a list of integers and asked to find the prime subsequence with the highest sum. The sequence does not have to be contiguous, but it must be a subsequence of the original list and each element in the subsequence must be a prime number. If no prime subs...
0.667895
Taco_40354
C
[ "is_prime", "max_prime_subsequence_sum", "process_input" ]
3
[ [ "max_prime_subsequence_sum", "is_prime" ], [ "process_input", "max_prime_subsequence_sum" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
d262789e009df25adebf801293946cf99d8d8264
3c78673ab0b9d222181613cb6b6268d67bed780a
v1.0
complete
Taco
Taco_40378_C
from typing import List, Tuple def network_efficiency(T: int, test_cases: List[Tuple[int, int, List[Tuple[int, int, int]]]]) -> List[int]: """Calculate the network efficiency for each test case by finding the total weight of the minimum spanning tree (MST) of the network. Args: T (int): Number of test cas...
from heapq import heappop, heappush def find(parent, i): # Find function with path compression if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): # Union function with union by rank root_x = find(parent, x) ...
def test_network_efficiency(): T = 2 test_cases = [ (4, 5, [(0, 1, 10), (0, 2, 6), (1, 2, 5), (2, 3, 4), (1, 3, 1)]), (3, 3, [(0, 1, 2), (0, 2, 3), (1, 2, 1)]) ] expected_outputs = [11, 3] results = network_efficiency(T, test_cases) for res, exp in zip(results, expected_outputs):...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from heapq import heappop, heappush\n\ndef find(parent, i):\n # Find function with path compression\n if parent[i] == i:\n return i\n else:\n ...
trial_gpt4o_0
{ "original_instruction": "A group of scientists is studying a special type of network composed of N nodes connected by weighted edges. For their experiments, they need to find the \"network efficiency\" value. The efficiency of the network is defined as the sum of the weight of the edges in the minimum spanning tree...
0.651765
Taco_40378
C
[ "find", "union", "kruskal", "network_efficiency" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "network_efficiency", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
70d1a976d467d738ca654c9e18c254cb9f1b3084
23ae739053a5dd0d4d30aea20c3884b1f6e98a97
v1.0
complete
Taco
Taco_39852_C
from typing import List, Tuple def calculate_min_waiting_times(N: int, intersections: List[List[int]]) -> List[int]: """ Calculate the minimum total waiting time for vehicles at each intersection based on the new regulation. Args: N (int): The number of intersections. intersections (List[List[int]...
def calculate_min_waiting_times(N, intersections): min_waiting_times = [] for intersection in intersections: L_i = intersection[0] traffic_lights = intersection[1:] total_waiting_time = 0 for j in range(L_i): G = traffic_lights[2 * j] R = traffic_lights[2 ...
def test_calculate_min_waiting_times(): # Sample Input 1 N = 3 intersections = [ [2, 3, 5, 2, 6], [3, 1, 2, 2, 1, 1, 1], [1, 10, 15] ] expected = [16, 8, 25] assert calculate_min_waiting_times(N, intersections) == expected def test_calculate_min_waiting_times_single_inte...
[ { "docstring": null, "function_declaration": "def calculate_min_waiting_times(N, intersections):", "function_name": "calculate_min_waiting_times", "parameter_list": "(N, intersections)" }, { "docstring": null, "function_declaration": "def parse_input(input_data):", "function_name": "...
[ 1 ]
1
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_min_waiting_times(N, intersections):\n min_waiting_times = []\n for intersection in intersections:\n L_i = intersection[0]\n traf...
trial_gpt4o_0
{ "original_instruction": "In a bustling city, there are many intersections, each with different traffic lights. A new city regulation requires a control system to manage the traffic light timers. The goal is to minimize the total waiting time for vehicles at each intersection.\n\nEach traffic light operates in a cyc...
0.587327
Taco_39852
C
[ "calculate_min_waiting_times", "parse_input", "get_waiting_times_from_input" ]
3
[ [ "get_waiting_times_from_input", "calculate_min_waiting_times" ], [ "get_waiting_times_from_input", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
63f3701fb00ada939d4adaebe62647b34295c133
7251cd7cb722cca615d540960388e79067f78ccf
v1.0
complete
Taco
Taco_40051_C
from heapq import heappop, heappush from typing import List, Tuple def dijkstra(grid: List[List[int]], n: int, m: int) -> int: """ Uses Dijkstra's algorithm to find the minimum cost path in a grid from (0,0) to (n-1,m-1). Args: grid (List[List[int]]): 2D list representing the grid with costs. n (in...
from heapq import heappop, heappush def dijkstra(grid, n, m): """ Uses Dijkstra's algorithm to find the minimum cost path in a grid from (0,0) to (n-1,m-1). """ directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] min_heap = [(grid[0][0], 0, 0)] # (cost, x, y) distances = {(0, 0): grid[0][0]} ...
def test_dijkstra(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] n, m = 3, 3 assert dijkstra(grid, n, m) == 7 grid = [ [1, 2], [1, 1] ] n, m = 2, 2 assert dijkstra(grid, n, m) == 3 def test_parse_input(): input_data = """3 3 1 3 1 1 5 1 4 ...
[ { "docstring": "Uses Dijkstra's algorithm to find the minimum cost path in a grid from (0,0) to (n-1,m-1).", "function_declaration": "def dijkstra(grid, n, m):", "function_name": "dijkstra", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def find_shorte...
[ 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 heapq import heappop, heappush\n\ndef dijkstra(grid, n, m):\n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n dist = [[float('inf')] * m for _ in rang...
trial_gpt4o_2
{ "original_instruction": "Find the Shortest Path in a Weighted Grid\n\nYou are given a grid with `n` rows and `m` columns. Each cell in the grid contains a non-negative integer representing the cost to enter that cell. Your task is to find the shortest path from the top-left corner of the grid (0,0) to the bottom-ri...
0.67172
Taco_40051
C
[ "dijkstra", "find_shortest_paths", "parse_input", "main" ]
4
[ [ "find_shortest_paths", "dijkstra" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
190f39211e3b246a684a14e312c553be35eb9472
e950fd7bf3f255ae1f9499aa9bdccfbe9f30ec09
v1.0
complete
Taco
Taco_40272_C
from typing import List, Tuple def min_cost_to_connect_all_cities(N: int, M: int, roads: List[Tuple[int, int, int]]) -> int: """ Determine the minimum possible cost to connect all cities with the given roads. Args: N (int): The number of cities. M (int): The number of potential roads. ...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[r...
def test_min_cost_to_connect_all_cities(): # Test case 1: standard case with multiple routes N, M = 4, 5 roads = [ (1, 2, 3), (1, 3, 4), (4, 2, 2), (4, 3, 5), (3, 2, 6) ] assert min_cost_to_connect_all_cities(N, M, roads) == 9 # Test case 2: impossible to...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_2
{ "original_instruction": "A long-forgotten kingdom consists of N cities connected by M bidirectional roads. Each road has a certain cost associated with it. The kingdom is attempting to rebuild its road system to ensure that there is a path between every pair of cities while minimizing the total cost of the roads.\n...
0.718679
Taco_40272
C
[ "find", "union", "min_cost_to_connect_all_cities" ]
3
[ [ "min_cost_to_connect_all_cities", "find" ], [ "min_cost_to_connect_all_cities", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
5b2babd03dbaf7a2456ba4f065da857ff48dcdcb
2d5ef94b237daaa87c02e2b9a67189528722b5af
v1.0
complete
Taco
Taco_40566_C
import sys import math def is_prime(num): """ Check if a given number is a prime number. >>> is_prime(2) True >>> is_prime(4) False """ pass def filter_prime_fish_sizes(N, fish_sizes): """ Given the sequence of fish sizes, return the sequence of fish sizes that are pri...
import sys import math def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def fi...
import sys from io import StringIO import pytest from solution import filter_prime_fish_sizes, is_prime def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(13) assert not is_prime(1) assert not is_pr...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def filter_prime_fish_sizes(N, fish_sizes):", "function_name": "filter_prime_fish_sizes", "parameter_list": "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n A prime number is a number greater than 1 that has no p...
trial_gpt4o_2
{ "original_instruction": "Henry loves collecting fish of different types and sizes. He has a sequence of N fish sizes represented as an integer array F, where F[i] is the size of the i-th fish (1-based index). Henry has a unique requirement for his collection: he only wants to keep fish that have sizes which are pri...
0.6244
Taco_40566
C
[ "is_prime", "filter_prime_fish_sizes", "main" ]
3
[ [ "filter_prime_fish_sizes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
32e5f5215c057fc10cedbf5b0ce1c178f4e2af3e
9952e8554858ce4853b23b85927bd9fcacf51cfd
v1.0
complete
Taco
Taco_40373_C
def form_project_team(n: int, employees: List[List[int]]) -> Union[str, List[Tuple[int, int, int]]]: """ Given a list of employees in a company where each employee has a set of skills, determine if there exists an ability to form a project team where everyone in the team is connected either directly or indirect...
def find(x, parent): if parent[x] != x: parent[x] = find(parent[x], parent) return parent[x] def union(x, y, parent, rank): rootX = find(x, parent) rootY = find(y, parent) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[rootX] < r...
import pytest from solution import form_project_team def test_form_project_team_sample_input(): assert form_project_team(5, [[3, 100, 200, 300], [2, 300, 400], [3, 500, 200, 600], [1, 100], [2, 400, 500]]) != "impossible" def test_form_project_team_minimal_case_connected(): assert form_project_team(2, [[1, 1]...
[ { "docstring": null, "function_declaration": "def find(x, parent):", "function_name": "find", "parameter_list": "(x, parent)" }, { "docstring": null, "function_declaration": "def union(x, y, parent, rank):", "function_name": "union", "parameter_list": "(x, y, parent, rank)" }, ...
[ 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 form_project_team(n, employees_skills):\n from collections import defaultdict, deque\n\n # Create a dictionary to map each skill to the list of employees...
trial_gpt4o_1
{ "original_instruction": "Given a list of employees in a company where each employee has a set of skills, your task is to determine if there exists an ability to form a project team where everyone in the team is connected either directly or indirectly through at least one common skill.\n\n-----Input-----\nThe input ...
0.612743
Taco_40373
C
[ "find", "union", "form_project_team" ]
3
[ [ "form_project_team", "find" ], [ "form_project_team", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
087def62565bfc0b3e7342ec4f3a555b9d1a7380
1cf4acf697e2a11d30e84f832669fee424d32cc4
v1.0
complete
Taco
Taco_40697_C
def can_form_palindrome(s: str) -> bool: """ Determines if the string s can be rearranged to form a palindrome. >>> can_form_palindrome("aabb") True >>> can_form_palindrome("abc") False >>> can_form_palindrome("racecar") True """ def rohits_palindrome_inquiry(n: int, strings: List[str])...
def can_form_palindrome(s): """ Determines if the string s can be rearranged to form a palindrome. """ from collections import Counter count = Counter(s) odd_count = sum(1 for v in count.values() if v % 2 != 0) return odd_count <= 1 def rohits_palindrome_inquiry(n, strings): """ Det...
from solution import can_form_palindrome, rohits_palindrome_inquiry def test_can_form_palindrome(): assert can_form_palindrome("aabb") == True assert can_form_palindrome("abc") == False assert can_form_palindrome("racecar") == True assert can_form_palindrome("a") == True assert can_form_palindrome(...
[ { "docstring": "Determines if the string s can be rearranged to form a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": "Determines for each string in a list of strings whether it can be rea...
[ 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_form_palindrome(s):\n \"\"\"\n Checks if a string can be rearranged to form a palindrome.\n \"\"\"\n from collections import Counter\n \n ...
trial_gpt4o_1
{ "original_instruction": "Rohit's Palindrome Inquiry\n\nRohit is fascinated by palindromes. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward. He is currently exploring a list of strings and wants to determine which strings can be rearranged to form a pa...
0.768378
Taco_40697
C
[ "can_form_palindrome", "rohits_palindrome_inquiry" ]
2
[ [ "rohits_palindrome_inquiry", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2e9a345b00b9a756d6ad783a628d04a315a411f6
94f1cb55946b30dc30617a25ec3222f9b97b6a0d
v1.0
complete
Taco
Taco_40803_C
def is_valid_product_name(product_name): """ Verifies if the product name follows the given naming convention. >>> is_valid_product_name("A123Bc") True >>> is_valid_product_name("X567yz") True >>> is_valid_product_name("2fgHJ") False >>> is_valid_product_name("Q890de") True """ ...
import re def is_valid_product_name(product_name): """ Verifies if the product name follows the given naming convention. """ pattern = r'^[A-Z][0-9]{3}[A-Za-z]{2}$' return bool(re.match(pattern, product_name)) def validate_product_names(product_names): """ Validates a list of product names...
from solution import is_valid_product_name, validate_product_names def test_is_valid_product_name(): assert is_valid_product_name("A123Bc") == True assert is_valid_product_name("X567yz") == True assert is_valid_product_name("2fgHJ") == False assert is_valid_product_name("Q890de") == True assert is_...
[ { "docstring": "Verifies if the product name follows the given naming convention.", "function_declaration": "def is_valid_product_name(product_name):", "function_name": "is_valid_product_name", "parameter_list": "(product_name)" }, { "docstring": "Validates a list of product names and prints...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef validate_product_name(product_name):\n \"\"\"\n Validates if the product name follows the company's naming convention rules.\n \n Rule...
trial_gpt4o_2
{ "original_instruction": "A company stores its product information in a large data file. Each product is represented by a string consisting of alphanumeric characters and symbols. Your task is to verify if a given product name follows the company's naming convention rules.\n\nRules:\n1. The product name must start w...
0.57215
Taco_40803
C
[ "is_valid_product_name", "validate_product_names" ]
2
[ [ "validate_product_names", "is_valid_product_name" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e78ede3cb4e2b46c58333386d7baca531fb774dd
b20197fceb5f47ec90898066aa9acb4d3442e93d
v1.0
complete
Taco
Taco_40801_C
def compare_sales(data_month_1: str, data_month_2: str) -> List[Tuple[int, int]]: """ Compare the sales performance of products between two months. Args: data_month_1: A string containing daily sales data for month 1 in the format "product_id,sales" Each entry is separated by a newline. ...
def parse_sales_data(data): sales_dict = {} for line in data.splitlines(): if line.strip(): product_id, sales = map(int, line.split(",")) if product_id in sales_dict: sales_dict[product_id] += sales else: sales_dict[product_id] = sales ...
from solution import compare_sales def test_compare_sales(): data_month_1 = "101,300\n102,250\n103,500\n" data_month_2 = "101,400\n102,300\n103,450\n" expected_output = [(101, 100), (102, 50), (103, 50)] assert compare_sales(data_month_1, data_month_2) == expected_output def test_compare_sales_extra_p...
[ { "docstring": null, "function_declaration": "def parse_sales_data(data):", "function_name": "parse_sales_data", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def compare_sales(data_month_1, data_month_2):", "function_name": "compare_sales", "paramet...
[ 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 parse_sales_data(data):\n sales = {}\n for line in data.strip().split('\\n'):\n product_id, sales_amount = map(int, line.split(','))\n if p...
trial_gpt4o_2
{ "original_instruction": "A company tracks the daily sales of products in two different months and wants to compare the sales performance. Write a program that reads two sets of data representing the daily sales of each product for two different months and outputs the product ID and the absolute difference in total ...
0.613488
Taco_40801
C
[ "parse_sales_data", "compare_sales" ]
2
[ [ "compare_sales", "parse_sales_data" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9f81f4c043f5af5ae322d11d2c85ebd18426aebe
109ea7f1c59a8aea40bfbe9cb4338fa2aecd54a7
v1.0
complete
Taco
Taco_40598_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes_info): """ Builds a binary tree from the list of node information. Args: nodes_info: A list of tuples with information of each node in the format (u, v, l, r...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes_info): nodes = {} for u, v, l, r in nodes_info: if u not in nodes: nodes[u] = TreeNode(v) else: nodes[u].value = v if...
from solution import TreeNode, build_tree, get_subtree_sums def test_single_node_tree(): nodes_info = [(1, 3, -1, -1)] root = build_tree(nodes_info) subtree_sums = get_subtree_sums(root) assert subtree_sums == [3] def test_tree_with_multiple_nodes(): nodes_info = [ (1, 3, 2, 3), (2...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, index, val):\n self.index = index\n self.val = val\n self.left = None\n self.right = None\n ...
trial_gpt4o_2
{ "original_instruction": "You are given a binary tree with N nodes. For each node, you are tasked with calculating the sum of the values of the nodes that are in the subtree of the given node (including itself).\n\nThe binary tree is defined using the following structure:\n- Each of the N nodes has a unique integer ...
0.599675
Taco_40598
C
[ "build_tree", "subtree_sum", "get_subtree_sums", "main" ]
4
[ [ "get_subtree_sums", "subtree_sum" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
bfcf7fe9e7cc351126b5cbc1da40bbbb39f99db9
00a3b4df21f6deb3b2dc50b7d1a840b25e2dc843