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_98508_C
def memoized_factorial(): """ Returns a function to compute the factorial using memoization. """ memo = {} def factorial(n): if n in memo: return memo[n] if n <= 1: memo[n] = 1 else: memo[n] = n * factorial(n-1) return memo[n] ...
def memoized_factorial(): """ Returns a function to compute the factorial using memoization. """ memo = {} def factorial(n): if n in memo: return memo[n] if n <= 1: memo[n] = 1 else: memo[n] = n * factorial(n-1) return memo[n] ...
from solution import solve_factorial def test_sample_input(): test_cases = [0, 1, 5, 10] expected = [1, 1, 120, 3628800] assert solve_factorial(test_cases) == expected def test_zero_and_one(): test_cases = [0, 1] expected = [1, 1] assert solve_factorial(test_cases) == expected def test_small_...
[ { "docstring": "Returns a function to compute the factorial using memoization.", "function_declaration": "def memoized_factorial():", "function_name": "memoized_factorial", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def solve_factorial(test_cases):", "fun...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def memoized_factorial():\n \"\"\"\n Returns a memoized factorial function that caches intermediate results for efficiency.\n \"\"\"\n cache = {}\n ...
trial_gpt4o_2
{ "original_instruction": "A programming competition requires participants to write a function that calculates the factorial of a given non-negative integer n. However, instead of calculating the result directly, participants must implement a memoization technique to store intermediate results for efficiency.\n\nMemo...
0.656484
Taco_98508
C
[ "memoized_factorial", "solve_factorial" ]
2
[ [ "solve_factorial", "memoized_factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
50ec42d879c2af6365a738e44a099607cc17a5c0
081e731908e411d957f4850ea458e6afae26e231
v1.0
complete
Taco
Taco_97895_C
def is_eulerian_circuit_possible(n, m, edges): """Determine whether an Eulerian Circuit is possible for given city maps. Parameters: n (int): Number of intersections (vertices). m (int): Number of roads (edges). edges (List[Tuple[int, int]]): List of roads between intersections. Return...
def is_eulerian_circuit_possible(n, m, edges): if n == 0: return "No" from collections import defaultdict graph = defaultdict(list) degree = [0] * (n + 1) for u, v in edges: graph[u].append(v) graph[v].append(u) degree[u] += 1 degree[v] += 1 ...
import pytest from solution import delivery_heroes_input_manager def test_case_1(): input_data = [ (4, 4), (1, 2), (2, 3), (3, 4), (4, 1), (3, 2), (1, 2), (2, 3), (5, 4), (1, 2), (2, 3), (3, 1), (4, 5), ...
[ { "docstring": null, "function_declaration": "def is_eulerian_circuit_possible(n, m, edges):", "function_name": "is_eulerian_circuit_possible", "parameter_list": "(n, m, edges)" }, { "docstring": null, "function_declaration": "def delivery_heroes_input_manager(input_list):", "functio...
[ 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_eulerian_circuit_possible(n, m, edges):\n from collections import defaultdict, deque\n\n if n == 0:\n return \"No\"\n \n if m == 0:\n ...
trial_gpt4o_3
{ "original_instruction": "A new company called \"Delivery Heroes\" wants to optimize their package delivery routes. They operate in a city represented as a grid where intersections are connected by roads in a bidirectional manner. The company wants to start their delivery from their headquarters and return to it, co...
0.63339
Taco_97895
C
[ "is_eulerian_circuit_possible", "delivery_heroes_input_manager" ]
2
[ [ "delivery_heroes_input_manager", "is_eulerian_circuit_possible" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f5aa0e2052231a57d62d7192bd7d04d226f15936
37596f50c2987e685f6fda222aac27f42d515d98
v1.0
complete
Taco
Taco_98274_C
def solve_grid_puzzle(T, test_cases): """ Generate one possible solution for filling the grid according to the rules: 1. Every integer in row i (1 ≤ i ≤ R) must be unique within that row. 2. Every integer in column j (1 ≤ j ≤ C) must be unique within that column. Args: T: Number of test cases ...
def solve_grid_puzzle(T, test_cases): results = [] for R, C in test_cases: if R > 100 or C > 100: results.append("Impossible") continue grid = [[0] * C for _ in range(R)] if R == 1 and C == 1: grid[0][0] = 1 else: num = 1 ...
from solution import solve_grid_puzzle, format_results def test_single_cell(): T = 1 test_cases = [(1, 1)] results = solve_grid_puzzle(T, test_cases) assert results == [[[1]]] def test_3x3_grid(): T = 1 test_cases = [(3, 3)] results = solve_grid_puzzle(T, test_cases) assert results == ...
[ { "docstring": null, "function_declaration": "def solve_grid_puzzle(T, test_cases):", "function_name": "solve_grid_puzzle", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def format_results(results):", "function_name": "format_results", "para...
[ 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 solve_grid_puzzle(T, test_cases):\n results = []\n for R, C in test_cases:\n if R > 100 or C > 100:\n results.append(\"Impossible\")\n ...
trial_gpt4o_0
{ "original_instruction": "Alice is participating in a coding competition and encounters a grid-based puzzle. The puzzle consists of a rectangular grid of cells with R rows and C columns. Initially, the grid contains only zeros (0). Alice is required to fill the grid with integers according to the following rules:\n\...
0.690167
Taco_98274
C
[ "solve_grid_puzzle", "format_results", "grid_puzzle_main" ]
3
[ [ "grid_puzzle_main", "format_results" ], [ "grid_puzzle_main", "solve_grid_puzzle" ] ]
2
[ "format_results" ]
false
[]
false
pytest
true
[]
true
2f91ac26c20fb3cd4b72f2de90f5bf921074ddf1
377ade29bc9d3aa8b556e6d588940e09cdbd1e97
v1.0
complete
Taco
Taco_98600_C
from typing import List, Tuple def calculate_distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float: """ Calculates the Euclidean distance between two points p1 and p2. """ return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5 def shortest_route_distance(stops: List[Tuple[int, int]]) -> flo...
import itertools import math def calculate_distance(p1, p2): """ Calculates the Euclidean distance between two points p1 and p2. """ return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def shortest_route_distance(stops): """ Finds the shortest route that visits all trip stops exactly...
from solution import shortest_route_distance def test_shortest_route_distance_example1(): stops = [(0, 0), (1, 0), (1, 1), (0, 1)] assert shortest_route_distance(stops) == 4.0000 def test_shortest_route_distance_example2(): stops = [(-1, 2), (2, 2), (2, 3), (-1, 3), (0, 0)] assert shortest_route_dista...
[ { "docstring": "Calculates the Euclidean distance between two points p1 and p2.", "function_declaration": "def calculate_distance(p1, p2):", "function_name": "calculate_distance", "parameter_list": "(p1, p2)" }, { "docstring": "Finds the shortest route that visits all trip stops exactly once...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\nimport math\n\ndef calculate_distance(p1, p2):\n \"\"\"\n Calculates the Euclidean distance between two points p1 and p2.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "A: Trip Route Planning\n\nproblem\n\nYou are given a list of trip stops represented by their respective coordinates on a 2D plane. Each stop has an (x, y) coordinate. Your task is to find the shortest route that visits all the trip stops exactly once and returns to the starting point.\n\nIn...
0.672
Taco_98600
C
[ "calculate_distance", "shortest_route_distance" ]
2
[ [ "shortest_route_distance", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
82a282fe533d95d0bcdfbca14e62c1ad8255bece
42de30f2b2ab32b88d19cbf0e5149e2b8b88bb0f
v1.0
complete
Taco
Taco_98221_C
from typing import List, Tuple def min_time_to_protect_all_marauders(n: int, m: int, marauders: int, guardians: int, forest: List[str], p: int, marauder_locs: List[Tuple[int, int, int]], guardian_locs: List[Tuple[int, int, int]]) -> int: """ Determine the minimal time required for each Marauder to be within the pr...
from collections import deque def bfs(forest, starts, n, m): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] dist = [[float('inf')] * m for _ in range(n)] q = deque() for start in starts: r, c, t = start q.append((r, c, t)) dist[r][c] = 0 while q: r, c, t = q.popleft...
import pytest from solution import min_time_to_protect_all_marauders def test_example_1(): n = 4 m = 4 marauders = 2 guardians = 2 forest = [ "....", ".#..", "..#.", "...." ] p = 2 marauder_locs = [(0, 0, 1), (2, 2, 2)] guardian_locs = [(1, 1, 1), (3,...
[ { "docstring": null, "function_declaration": "def bfs(forest, starts, n, m):", "function_name": "bfs", "parameter_list": "(forest, starts, n, m)" }, { "docstring": null, "function_declaration": "def min_time_to_protect_all_marauders(n, m, marauders, guardians, forest, p, marauder_locs, g...
[ 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": "from collections import deque\nimport sys\n\ndef minimal_protection_time(grid, marauders, guardians, n, m, p):\n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]...
trial_gpt4o_8
{ "original_instruction": "In a mysterious forest, Marauders and Guardians roam through a grid. Guardians always protect the Marauders they encounter within a certain range. Each Marauder seeks to be protected by at least one Guardian. The Marauders and Guardians can move between adjacent cells that share a side. The...
0.562221
Taco_98221
C
[ "bfs", "min_time_to_protect_all_marauders" ]
2
[ [ "min_time_to_protect_all_marauders", "bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
46658ae0d4e217c0b4dbea9565b511eb9bb1420f
addc08ce07d8dbcfce26e3e1faeaa159ad76af7c
v1.0
complete
Taco
Taco_98789_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(node_values, edges): nodes = {i + 1: TreeNode(val) for i, val in enumerate(node_values)} for u, v in edges: if nodes[u].left is None: nodes[u].lef...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(node_values, edges): nodes = {i + 1: TreeNode(val) for i, val in enumerate(node_values)} for u, v in edges: if nodes[u].left is None: nodes[u].lef...
def test_inorder_sum(): N = 5 node_values = [1, 2, 3, 4, 5] edges = [(1, 2), (1, 3), (2, 4), (2, 5)] root = build_tree(node_values, edges) assert inorder_sum(root) == 15 def test_preorder_sum(): N = 5 node_values = [1, 2, 3, 4, 5] edges = [(1, 2), (1, 3), (2, 4), (2, 5)] root = buil...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(node_values, edg...
trial_gpt4o_0
{ "original_instruction": "Little Shino loves binary trees. She recently learned how to traverse a binary tree in different ways. To test her understanding, she wants to create a binary tree and calculate the sum of all node values for each type of traversal.\n\nYou are given the structure of a binary tree and the no...
0.644198
Taco_98789
C
[ "build_tree", "inorder_sum", "preorder_sum", "postorder_sum", "calculate_sums" ]
5
[ [ "calculate_sums", "build_tree" ], [ "calculate_sums", "inorder_sum" ], [ "calculate_sums", "postorder_sum" ], [ "calculate_sums", "preorder_sum" ] ]
4
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
8772de4bbc6f9166bc0cec1cc9590c51707df6b3
238cd345c35cb1d45f990da5d221983ccd7ebd70
v1.0
complete
Taco
Taco_98644_C
from typing import List, Tuple def find_palindrome_pairs(words: List[str]) -> List[Tuple[int, int]]: """ Design a function that takes a list of words and returns a list of all unique pairs of indices (i, j) such that the concatenation of the words words[i] + words[j] is a palindrome. Example: ...
from typing import List, Tuple def is_palindrome(s: str) -> bool: """ Helper function to check if a given string is a palindrome. """ return s == s[::-1] def find_palindrome_pairs(words: List[str]) -> List[Tuple[int, int]]: """ Given a list of words, returns a list of all unique pairs of indic...
from solution import find_palindrome_pairs def test_find_palindrome_pairs_example1(): assert set(find_palindrome_pairs(["bat", "tab", "cat"])) == set([(0, 1), (1, 0)]) def test_find_palindrome_pairs_example2(): assert set(find_palindrome_pairs(["abcd", "dcba", "lls", "s", "sssll"])) == set([(0, 1), (1, 0), (3...
[ { "docstring": "Helper function to check if a given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Given a list of words, returns a list of all unique pairs of indices \n(i, j) such that ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\n\ndef is_palindrome(s: str) -> bool:\n \"\"\"\n Helper function to check if a given string is a palindrome.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "Design a function `find_palindrome_pairs` that takes a list of words and returns a list of all unique pairs of indices (i, j) such that the concatenation of the words `words[i] + words[j]` is a palindrome.\n\n### Function Signature\n`find_palindrome_pairs(words: List[str]) -> List[Tuple[int...
0.695602
Taco_98644
C
[ "is_palindrome", "find_palindrome_pairs" ]
2
[ [ "find_palindrome_pairs", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
664d20463152be7287bc18eae8eef9a7b8a2b371
ac69e6c2f0367feaa32f0f02240e74c1a9b1ca76
v1.0
complete
Taco
Taco_97755_C
import math from functools import reduce from typing import List def gcd(a: int, b: int) -> int: """ Returns the greatest common divisor of a and b. """ pass def gcd_of_list(numbers: List[int]) -> int: """ Returns the gcd of a list of numbers. """ pass def standardized_recipe_quantiti...
import math from functools import reduce def gcd(a, b): """ Returns the greatest common divisor of a and b. """ while b: a, b = b, a % b return a def gcd_of_list(numbers): """ Returns the gcd of a list of numbers. """ return reduce(gcd, numbers) def standardized_recipe_qua...
from solution import gcd, gcd_of_list, standardized_recipe_quantities def test_gcd(): assert gcd(54, 24) == 6 assert gcd(17, 13) == 1 assert gcd(100, 25) == 25 assert gcd(1, 0) == 1 def test_gcd_of_list(): assert gcd_of_list([12, 15, 18, 24, 30]) == 3 assert gcd_of_list([35, 49, 63, 91, 98, 12...
[ { "docstring": "Returns the greatest common divisor of a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the gcd of a list of numbers.", "function_declaration": "def gcd_of_list(numbers):", "function_nam...
[ 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\nfrom functools import reduce\n\ndef compute_gcd(x, y):\n \"\"\"\n Helper function to compute the GCD of two numbers.\n \"\"\"\n while y:\n...
trial_gpt4o_2
{ "original_instruction": "Problem\n\nBalan, a renowned chef, is creating a new recipe that involves multiple ingredients. Given a list of ingredients and their quantities in grams, Balan wants to standardize the recipe so that all ingredient quantities are scaled down by their greatest common divisor (GCD). Your tas...
0.609802
Taco_97755
C
[ "gcd", "gcd_of_list", "standardized_recipe_quantities" ]
3
[ [ "gcd_of_list", "gcd" ], [ "standardized_recipe_quantities", "gcd_of_list" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3dcc89f873872d18b1239ce7c682e0e130c798de
c698b7e7e1c73845c318b12a464010d5fa20e93e
v1.0
complete
Taco
Taco_98343_C
def preprocess_matrix(matrix, N, M): """ Preprocess the matrix to create a prefix sum matrix. """ pass # Replace with your implementation def subrectangle_sum(prefix_sum, r1, c1, r2, c2): """ Calculate the sum of elements in a subrectangle using the prefix sum. """ pass # Replace with y...
def preprocess_matrix(matrix, N, M): """ Preprocess the matrix to create a prefix sum matrix. """ prefix_sum = [[0] * (M + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, M + 1): prefix_sum[i][j] = ( matrix[i-1][j-1] + pr...
from solution import preprocess_matrix, subrectangle_sum, matrix_query def test_preprocess_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] N, M = 3, 3 prefix_sum = preprocess_matrix(matrix, N, M) expected_prefix_sum = [ [0, 0, 0, 0], [0, 1, 3, 6], ...
[ { "docstring": "Preprocess the matrix to create a prefix sum matrix.", "function_declaration": "def preprocess_matrix(matrix, N, M):", "function_name": "preprocess_matrix", "parameter_list": "(matrix, N, M)" }, { "docstring": "Calculate the sum of elements in a subrectangle using the prefix ...
[ 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 precompute_prefix_sum(matrix, N, M):\n \"\"\"\n Computes the prefix sum matrix for the given matrix.\n \"\"\"\n prefix_sum = [[0] * (M + 1) for _ i...
trial_gpt4o_1
{ "original_instruction": "You are given a rectangular matrix of dimensions N x M. Each cell of the matrix contains an integer. There are Q queries, each query gives the coordinates of the top-left and bottom-right corners of a subrectangle. For each query, you need to calculate the sum of all the elements contained ...
0.523382
Taco_98343
C
[ "preprocess_matrix", "subrectangle_sum", "matrix_query" ]
3
[ [ "matrix_query", "preprocess_matrix" ], [ "matrix_query", "subrectangle_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b1c1c657ff0b5d47d22fc28def6e7e18b4af9f67
b6672ebb14c333e87b69d44581ab9d32ccdae5d3
v1.0
complete
Taco
Taco_98964_C
import math from typing import List, Tuple def calculate_distances(stops: List[Tuple[int, int]]) -> List[float]: """ Calculates the distances between consecutive stops and the total distance. Parameters: stops (List[Tuple[int, int]]): List of coordinate tuples (x, y) for each stop. Returns: L...
import math def calculate_distances(stops): """ Calculates the distances between consecutive stops and the total distance. Parameters: stops (list of tuples): List of coordinate tuples (x, y) for each stop. Returns: list of floats: List of distances between consecutive stops, followed by ...
import pytest from solution import road_trip_log def test_single_segment(): assert road_trip_log(2, ["0 0", "3 4"]) == [5.00, 5.00] def test_multiple_segments(): assert road_trip_log(3, ["0 0", "3 4", "6 0"]) == [5.00, 5.00, 10.00] def test_negative_coordinates(): assert road_trip_log(2, ["-1 -1", "2 3"]...
[ { "docstring": "Calculates the distances between consecutive stops and the total distance.\n\nParameters:\nstops (list of tuples): List of coordinate tuples (x, y) for each stop.\n\nReturns:\nlist of floats: List of distances between consecutive stops, followed by the total distance.", "function_declaration...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_distances(n, stops):\n \"\"\"\n Given the number of stops and a list of (x, y) coordinates of each stop,\n calculates the dis...
trial_gpt4o_2
{ "original_instruction": "Alex is planning a road trip and wants to maintain a log of his journey. As part of this, he needs to calculate the distance between each pair of consecutive stops and the total distance traveled by the end of the trip. You need to help him write a program to calculate these distances.\n\nF...
0.608217
Taco_98964
C
[ "calculate_distances", "road_trip_log" ]
2
[ [ "road_trip_log", "calculate_distances" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a2b503c684e1e4205de81c7c774bb6ba1f315b18
41160a70ecad5ab15a12ab02ae4b6351d2ff5b8f
v1.0
complete
Taco
Taco_98513_C
from collections import defaultdict, deque from typing import List, Union, Tuple def find_quest_order(n: int, prerequisites: List[Tuple[str, str]]) -> Union[List[str], str]: """ Determine the order in which quests can be completed given the prerequisites. >>> find_quest_order(4, [("clean_house", "cook_meal"), ...
from collections import defaultdict, deque def find_quest_order(n, prerequisites): # Dictionary to store the prerequisites prereq_map = defaultdict(list) # Dictionary to maintain the in-degree of nodes in_degree = defaultdict(int) all_quests = set() for x, y in prerequisites: prere...
from solution import find_quest_order def test_possible_order(): n = 4 prerequisites = [ ("clean_house", "cook_meal"), ("buy_groceries", "cook_meal"), ("buy_groceries", "clean_house"), ("cook_meal", "play_game") ] result = find_quest_order(n, prerequisites) expected ...
[ { "docstring": null, "function_declaration": "def find_quest_order(n, prerequisites):", "function_name": "find_quest_order", "parameter_list": "(n, prerequisites)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "parameter_list": "()" }...
[ 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 defaultdict, deque\n\ndef find_quest_order(n, quest_prerequisites):\n graph = defaultdict(list)\n in_degree = defaultdict(int)\n \...
trial_gpt4o_4
{ "original_instruction": "You are working on a text-based game involving a series of quests. Each quest has specified prerequisites that need to be completed before it can be started. Given a list of quests and their prerequisites, you need to determine the order in which the quests can be completed, if such an orde...
0.509054
Taco_98513
C
[ "find_quest_order", "solve" ]
2
[ [ "solve", "find_quest_order" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bb5e3f86b7dc4df46e37c281108ac7f00a399ca7
c5e669ca782cc0a3acd7ea53dcd9e1ac65ca1809
v1.0
complete
Taco
Taco_98750_C
def is_strong_password(n: int, password: str) -> str: """ Determines if the given password is strong based on specified criteria. >>> is_strong_password(7, 'A1b#def') 'YES' >>> is_strong_password(7, 'A1bdefgH') 'NO' >>> is_strong_password(7, 'a1bdefg!H') 'YES' >>> is_strong_pass...
def is_strong_password(n, password): """ Determines if the given password is strong based on specified criteria. Parameters: n (int): The minimum length required for the password. password (str): The password string to be evaluated. Returns: str: 'YES' if the password is strong, ot...
def test_is_strong_password(): assert is_strong_password(7, 'A1b#def') == "YES" assert is_strong_password(7, 'A1bdefgH') == "NO" assert is_strong_password(7, 'a1bdefg!H') == "YES" assert is_strong_password(7, 'A1b') == "NO" # Less than 7 characters assert is_strong_password(7, 'abcdefg1!') == "NO" ...
[ { "docstring": "Determines if the given password is strong based on specified criteria.\n\nParameters:\nn (int): The minimum length required for the password.\npassword (str): The password string to be evaluated.\n\nReturns:\nstr: 'YES' if the password is strong, otherwise 'NO'.", "function_declaration": "d...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_strong_password(password, n=8):\n \"\"\"\n Checks if a password is strong based on the given criteria:\n 1. At least n characters long...
trial_gpt4o_2
{ "original_instruction": "John is a security analyst who is developing a password strength checker for an application. Each password must satisfy certain conditions to be considered strong. The conditions are as follows:\n\n1. The password must be at least `n` characters long.\n2. The password must contain at least ...
0.574585
Taco_98750
C
[ "is_strong_password", "check_passwords" ]
2
[ [ "check_passwords", "is_strong_password" ] ]
1
[]
false
[]
false
pytest
false
[]
true
631a231df6d7b8b96c8d90019aee5d46ea8341f5
2d24542ad90f01fcdcfab9bbc150ecac75f52e51
v1.0
complete
Taco
Taco_98560_C
def get_word_score(word): """ Return the score of the word based on its length. Score is calculated as the square of the word's length. """ pass def can_form_word(word, chars): """ Check if 'word' can be formed from the characters in 'chars'. """ pass def max_score(words, availabl...
def get_word_score(word): """ Return the score of the word based on its length. Score is calculated as the square of the word's length. """ return len(word) ** 2 def can_form_word(word, chars): """ Check if 'word' can be formed from the characters in 'chars'. """ from collections im...
import pytest from solution import can_form_word, get_word_score, max_score, process_input def test_get_word_score(): assert get_word_score("a") == 1 assert get_word_score("apple") == 25 assert get_word_score("banana") == 36 def test_can_form_word(): assert not can_form_word("apple", "appl") asser...
[ { "docstring": "Return the score of the word based on its length.\nScore is calculated as the square of the word's length.", "function_declaration": "def get_word_score(word):", "function_name": "get_word_score", "parameter_list": "(word)" }, { "docstring": "Check if 'word' can be formed fro...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef max_score(words, chars):\n \"\"\"\n This function computes the maximum score that can be achieved by forming words fro...
trial_gpt4o_2
{ "original_instruction": "A well-known game requires players to form words from a given set of characters. Each character may be used only once per word, and the length of the word must be at least 1. The scoring mechanism of the game provides points based on the length of the word formed: a word of length `l` earns...
0.66375
Taco_98560
C
[ "get_word_score", "can_form_word", "max_score", "process_input" ]
4
[ [ "max_score", "can_form_word" ], [ "max_score", "get_word_score" ], [ "process_input", "max_score" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
9fb05e2b452d7bb3a2e3b14d0e240488cdec97eb
b7f4f2420b6ac5997c0dca106c8715dfa89dc46c
v1.0
complete
Taco
Taco_99027_C
def find_min_energy(t: int, test_cases: List[Tuple[int, List[List[int]]]]) -> List[int]: """ Calculate the minimum energy required to traverse the magical belt. Parameters: t (int): Number of test cases test_cases (List[Tuple[int, List[List[int]]]]): List of test cases, each containing grid dimensions ...
def find_min_energy(t, test_cases): results = [] for case in test_cases: n, matrix = case dp = [[0] * n for _ in range(n)] dp[0][0] = matrix[0][0] for i in range(1, n): dp[i][0] = dp[i-1][0] + matrix[i][0] dp[0][i] = dp[0][i-1] + mat...
from solution import find_min_energy, parse_input def test_single_case(): t = 1 test_cases = [(3, [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ])] assert find_min_energy(t, test_cases) == [21] def test_multiple_cases(): t = 2 test_cases = [ (3, [ [1, 2, 3], ...
[ { "docstring": null, "function_declaration": "def find_min_energy(t, test_cases):", "function_name": "find_min_energy", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_data):", "function_name": "parse_input", "parameter_l...
[ 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 min_energy(grid):\n \"\"\"\n Given a grid of non-negative integers, calculate the minimum energy required\n to traverse from the top-left corner to th...
trial_gpt4o_3
{ "original_instruction": "In the realm of mystical forests, there are enchanted trees that form a magical boundary known as the \"Mysterious Belt.\" Your mission is to calculate the energy required to traverse this belt.\n\nThe forest can be represented as a 2D grid, where each cell has an energy value associated wi...
0.647036
Taco_99027
C
[ "find_min_energy", "parse_input", "mysterious_belt" ]
3
[ [ "mysterious_belt", "find_min_energy" ], [ "mysterious_belt", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
73b372a8835048b09d65bc8011d1fb857580f541
f637fd49148d991e2f692ce846b07d6b5bc63a2e
v1.0
complete
Taco
Taco_98423_C
def find_optimal_tables(N: int, K: int, knight_coordinates: List[Tuple[int, int]]) -> List[Tuple[float, float]]: """ Find the optimal positions of K tables such that the total sum of the distances from each knight to their assigned table is minimized. Args: - N (int): The number of knights. - ...
def k_means(knights, K): import numpy as np from scipy.spatial import distance def initialize_centroids(knights, K): np.random.seed(42) initial_indices = np.random.choice(len(knights), K, replace=False) return knights[initial_indices] def assign_knights_to_centroids(knights, ce...
from solution import find_optimal_tables def test_example_1(): knight_coordinates = [(1, 3), (2, 2), (3, 1), (8, 8), (9, 9), (10, 10)] N = 6 K = 2 tables = find_optimal_tables(N, K, knight_coordinates) assert round(tables[0][0]) == 2 assert round(tables[0][1]) == 2 assert round(tables[1][0]...
[ { "docstring": null, "function_declaration": "def k_means(knights, K):", "function_name": "k_means", "parameter_list": "(knights, K)" }, { "docstring": null, "function_declaration": "def find_optimal_tables(N, K, knight_coordinates):", "function_name": "find_optimal_tables", "par...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from sklearn.cluster import KMeans\nimport numpy as np\n\ndef get_optimal_table_positions(N, K, coordinates):\n \"\"\"\n Returns the optimal positions of K t...
trial_gpt4o_4
{ "original_instruction": "Problem\n\nKing Arthur is organizing his yearly round table meeting with the $ N $ knights, each represented by a point in a 2D plane. The knights need to be divided into $ K $ distinct groups for discussion, and each group should have at least one knight.\n\nArthur wants to position a roun...
0.537283
Taco_98423
C
[ "k_means", "find_optimal_tables", "main" ]
3
[ [ "find_optimal_tables", "k_means" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy", "scipy" ]
false
b3ab37afd214a273eddd6b61fa13942ab0a4929c
3d07a5bc11f4a228524011254f95dff377981a7f
v1.0
complete
Taco
Taco_98692_C
from itertools import combinations from typing import List, Tuple def area_of_triangle(x1: int, y1: int, x2: int, y2: int, x3: int, y3: int) -> float: """Calculate the area of triangle using the determinant method. >>> area_of_triangle(0, 0, 0, 1, 1, 0) 0.5 >>> area_of_triangle(0, 0, 1, 0, 0, 1) 0....
from itertools import combinations from typing import List, Tuple def area_of_triangle(x1, y1, x2, y2, x3, y3): """Calculate the area of triangle using the determinant method.""" return abs((x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)) / 2) def max_triangle_area(t: int, cases: List[Tuple[int, List[Tuple[int, i...
def test_area_of_triangle(): assert area_of_triangle(0, 0, 0, 1, 1, 0) == 0.5 assert area_of_triangle(0, 0, 1, 0, 0, 1) == 0.5 assert area_of_triangle(0, 0, 1, 1, 2, 2) == 0.0 # collinear points def test_max_triangle_area(): input_data = ( "2\n" "3\n0 0\n0 1\n1 0\n" "4\n0 0\n0 ...
[ { "docstring": "Calculate the area of triangle using the determinant method.", "function_declaration": "def area_of_triangle(x1, y1, x2, y2, x3, y3):", "function_name": "area_of_triangle", "parameter_list": "(x1, y1, x2, y2, x3, y3)" }, { "docstring": null, "function_declaration": "def m...
[ 0, 0, 0, 0, 0, 1, 0, 1, 1, 1 ]
4
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef max_triangle_area(n, stars):\n def triangle_area(p1, p2, p3):\n return abs(p1[0] * (p2[1] - p3[1]) + p2[0] * (p3[1] - p1[1]) + p3...
trial_gpt4o_9
{ "original_instruction": "Raman is an astronomy enthusiast and loves observing the night sky. He has a telescope that can track multiple stars simultaneously. One night, he tracked the positions of $n$ stars in the sky. Each star $i$ has coordinates $(x_i, y_i)$ in a 2D plane. \n\nRaman is interested in knowing the ...
0.692195
Taco_98692
C
[ "area_of_triangle", "max_triangle_area", "process_input", "process_output" ]
4
[ [ "max_triangle_area", "area_of_triangle" ] ]
1
[ "process_input" ]
false
[]
false
pytest
false
[]
true
70da2fb67c240dd67f75a37f5c409ad2c308e29e
2edb5dd75c7868d69c45013565d6d8981e95624b
v1.0
complete
Taco
Taco_98816_C
from typing import List, Tuple def closest_distance(n: int, coordinates: List[Tuple[int, int]]) -> str: """ Given a list of n points on a 2D plane, determine the pair of points that are the closest to each other and compute the Euclidean distance between them. >>> closest_distance(2, [(0, 0), (3, 4)])...
import math import itertools def euclidean_distance(p1, p2): return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def closest_pair_of_points(points): min_distance = float('inf') closest_pair = None # Sort points by x coordinate points.sort() for i, p1 in enumerate(points): ...
import pytest from solution import closest_distance def test_example1(): assert closest_distance(2, [(0, 0), (3, 4)]) == "5.000000" def test_example2(): assert closest_distance(3, [(1, 1), (2, 2), (4, 4)]) == "1.414214" def test_same_point(): assert closest_distance(2, [(0, 0), (0, 0)]) == "0.000000" de...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def closest_pair_of_points(points):", "function_name": "closest_pair_of_points", "p...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef closest_pair_distance(points):\n \"\"\"\n Returns the Euclidean distance between the closest pair of points in the given list.\n points...
trial_gpt4o_1
{ "original_instruction": "Given a list of n points on a 2D plane, your task is to determine the pair of points that are the closest to each other and compute the Euclidean distance between them.\n\n### Input:\n- The first line contains an integer n (2 ≤ n ≤ 10^5), the number of points.\n- The next n lines each conta...
0.682886
Taco_98816
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
64204b17f56a6f5b1cfe0bb81890f2b31f66a0a7
c57c2bb26a9ad16f9d5a955ebd0bb9d1f631a6d6
v1.0
complete
Taco
Taco_98963_C
def find_worst_case_latency_and_count(n, edges): """ Determines the maximum latency for any pair of employees and counts the number of pairs having this maximum latency. >>> find_worst_case_latency_and_count(4, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 4, 9), (1, 3, 2)]) == (9, 1) >>> find_worst_case_latency_an...
import heapq import sys def floyd_warshall(n, edges): dist = [[sys.maxsize] * (n + 1) for _ in range(n + 1)] for i in range(1, n + 1): dist[i][i] = 0 for u, v, w in edges: dist[u][v] = w dist[v][u] = w for k in range(1, n + 1): for i in range(1, n + 1): ...
import pytest from solution import find_worst_case_latency_and_count, solve def test_find_worst_case_latency_and_count(): assert find_worst_case_latency_and_count(4, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 4, 9), (1, 3, 2)]) == (9, 1) assert find_worst_case_latency_and_count(3, [(1, 2, 3), (2, 3, 4), (1, 3, 5)])...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, edges):", "function_name": "floyd_warshall", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def find_worst_case_latency_and_count(n, edges):", "function_name": "find_worst_case_latenc...
[ 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 max_latency_and_count(T, cases):\n import heapq\n \n def dijkstra(graph, start, n):\n INF = float('inf')\n dist = [INF] * (n + 1)\n ...
trial_gpt4o_3
{ "original_instruction": "A new company wants to establish a communication network between its employees. The company has N employees and they want to set up a messenger service that ensures optimal communication time between employees. Each employee has a unique ID between 1 and N. Some pairs of employees are known...
0.570849
Taco_98963
C
[ "floyd_warshall", "find_worst_case_latency_and_count", "solve", "main" ]
4
[ [ "find_worst_case_latency_and_count", "floyd_warshall" ], [ "solve", "find_worst_case_latency_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6fe48465d0aa26dbc477d8231f50b5d2410619aa
9520b69cb13b9faafa930c5c14e6af88e85ac260
v1.0
complete
Taco
Taco_98884_C
def shiftRight(arr, N, K): """ Shift elements of the array to the right by K positions in place. :param arr: List[int] - The array to be shifted. :param N: int - The number of elements in the array. :param K: int - The number of positions to shift. """ pass # Write your code here def reve...
def shiftRight(arr, N, K): """ Shift elements of the array to the right by K positions in place. :param arr: List[int] - The array to be shifted. :param N: int - The number of elements in the array. :param K: int - The number of positions to shift. """ # Effective number of shifts K...
from solution import shiftRight def test_shiftBy3_positions(): arr = [1, 2, 3, 4, 5, 6, 7] shiftRight(arr, 7, 3) assert arr == [5, 6, 7, 1, 2, 3, 4] def test_shiftBy2_positions(): arr = [10, 20, 30, 40, 50] shiftRight(arr, 5, 2) assert arr == [40, 50, 10, 20, 30] def test_shiftByMoreThanLengt...
[ { "docstring": "Shift elements of the array to the right by K positions in place.\n\n:param arr: List[int] - The array to be shifted.\n:param N: int - The number of elements in the array.\n:param K: int - The number of positions to shift.", "function_declaration": "def shiftRight(arr, N, K):", "function...
[ 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 shiftRight(arr, N, K):\n \"\"\"\n Shifts the elements of the array to the right by K positions in-place.\n \n :param arr: List[int], the input arra...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers of size N, your task is to shift the elements of the array to the right by K positions. This should be done in-place without using extra space for another array. If an element is shifted beyond the end of the array, it should wrap around to the beginning.\n\nExamp...
0.723576
Taco_98884
C
[ "shiftRight", "reverse" ]
2
[ [ "shiftRight", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
57724cadb9c92f35e666fb8432490e9ea767a240
94a64a186682d65e354f0552ca8e78559a170801
v1.0
complete
Taco
Taco_99353_C
import math from typing import List def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(0) False >>> is_prime(1) False >>> is_prime(2) True """ pass def apply_grading_rules(scores: List[int]) -> List[int]: """ Apply grading rules to a list of scores. ...
import math def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, apply_grading_rules 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(10) == False assert is_prime(17) =...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Apply grading rules to a list of scores.", "function_declaration": "def apply_grading_rules(scores):", "function_name": "a...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True...
trial_gpt4o_0
{ "original_instruction": "A teacher wants to grade homework assignments using a specific set of rules. The homework consists of Q problems, each with a score that can range from 0 to 100. The teacher has decided to use the following rules to determine the final grade for each assignment:\n\n1. If a score is a perfec...
0.673275
Taco_99353
C
[ "is_prime", "apply_grading_rules", "main" ]
3
[ [ "apply_grading_rules", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b3e5833c13346b89454906ac5e91a75ef95c0df1
afabe00313ed18f6fbe372a47f6008478d43b125
v1.0
complete
Taco
Taco_99143_C
def treasure_hunt_points(n: int, m: int, treasures: List[List[int]]) -> List[int]: """ Determines the total points each team has earned over all the challenges. Args: n (int): The number of teams. m (int): The number of challenges. treasures (List[List[int]]): 2D list where each row represents ...
def calculate_points(matrix): """ Calculates the total points earned by each team over all challenges. Args: matrix (list of list of int): 2D list where each row represents the values of treasures submitted by each team in each challenge. Returns: lis...
from solution import treasure_hunt_points def test_example_case(): n = 4 m = 3 treasures = [ [100, 200, 300], [150, 200, 250], [300, 150, 100], [200, 300, 250] ] assert treasure_hunt_points(n, m, treasures) == [300, 0, 300, 300] def test_all_teams_get_points(): ...
[ { "docstring": "Calculates the total points earned by each team over all challenges.\n\nArgs:\nmatrix (list of list of int): 2D list where each row represents the values of \n treasures submitted by each team in each challenge.\n\nReturns:\nlist of int: List where each element repre...
[ 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 calculate_points(matrix):\n \"\"\"\n Calculates the total points earned by each team over all challenges.\n \n Args:\n matrix (list of list of i...
trial_gpt4o_0
{ "original_instruction": "The National Treasure Hunt is an annual event where N teams participate in a series of treasure hunting challenges. Each team must find and submit treasures in different locations spread across a vast area. The objective of each challenge is to find the most valuable treasure in a given loc...
0.57864
Taco_99143
C
[ "calculate_points", "treasure_hunt_points" ]
2
[ [ "treasure_hunt_points", "calculate_points" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef190f5d9c8d12b768de7ac3462e9acd9aed2bd8
df6711d4478852e03615b5b743ac7f897339fa0c
v1.0
complete
Taco
Taco_99472_C
def is_prime(n: int) -> bool: """Helper function to check if a number is prime.""" def product_of_primes(nums: List[int]) -> int: """ Returns the product of prime numbers in the given list of integers. If there are no primes, returns 1. >>> product_of_primes([2, 3, 4, 7, 8]) == 42 >>> prod...
def is_prime(n): """Helper function to check if a number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import product_of_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(7) == True assert is_prime(9) == False assert is_prime(13) == True assert is_prime(25) == False def test_no_prime_numbers(...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the product of prime numbers in the given list of integers.\nIf there are no primes, returns 1.", "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if...
trial_gpt4o_0
{ "original_instruction": "Given an integer array nums, return the product of the integers in that array that are prime numbers.\nIf there is no such integer in the array, return 1.\n\nExample 1:\nInput: nums = [2, 3, 4, 7, 8]\nOutput: 42\nExplanation:\n2, 3, and 7 are prime numbers. The product of these primes is 2 ...
0.769952
Taco_99472
C
[ "is_prime", "product_of_primes" ]
2
[ [ "product_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a90a286d4023a41f2cb4d996cf2819b0b57e6e0
b55e65fee2db83d28f0465118c5d4cf8f7c629f6
v1.0
complete
Taco
Taco_99013_C
def largest_square_area_from_input(input_str: str) -> int: """ Find the area of the largest square that can be formed entirely of 1s in the given grid input. >>> largest_square_area_from_input('''4 5 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0''') 4 >>> largest_square_area_from_inp...
def largest_square_area(grid): """ Returns the area of the largest square of 1s in the given grid. """ if not grid or not grid[0]: return 0 N = len(grid) M = len(grid[0]) dp = [[0] * M for _ in range(N)] max_side = 0 for i in range(N): for j in range(M): ...
from solution import largest_square_area_from_input def test_largest_square_1(): input_str = '''4 5 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0''' assert largest_square_area_from_input(input_str) == 4 def test_largest_square_2(): input_str = '''3 3 1 1 1 1 1 1 0 1 1''' assert largest_square_area_from_inpu...
[ { "docstring": "Returns the area of the largest square of 1s in the given grid.", "function_declaration": "def largest_square_area(grid):", "function_name": "largest_square_area", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_square_area(grid):\n \"\"\"\n Finds the largest square that can be formed entirely of 1s in the given grid\n and returns its area.\n \"\"\"...
trial_gpt4o_2
{ "original_instruction": "**Problem Statement**\n\nYou are given a grid consisting of `N` rows and `M` columns. Each cell in the grid can have either a value of 0 or 1. Your task is to find the largest square that can be formed entirely of 1s, and return its area.\n\n### Input Format:\n- The first line contains two ...
0.606771
Taco_99013
C
[ "largest_square_area", "parse_input", "largest_square_area_from_input" ]
3
[ [ "largest_square_area_from_input", "largest_square_area" ], [ "largest_square_area_from_input", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
0dfd8680e1bb70c18aa7da7e72cebbce77fec4e5
cd0a0028d004564a9e948f47ba96235df98acf16
v1.0
complete
Taco
Taco_99396_C
def gcd(x, y): """ Returns the greatest common divisor of x and y. """ while y: x, y = y, x % y return x def find_final_element(arr): """ Returns the final remaining element in the array after performing the operations. """ return reduce(gcd, arr) def process_test_cases(t, ...
import math from functools import reduce def gcd(x, y): """ Returns the greatest common divisor of x and y. """ while y: x, y = y, x % y return x def find_final_element(arr): """ Returns the final remaining element in the array after performing the operations. """ return re...
from solution import process_test_cases def test_sample_cases(): assert process_test_cases(2, [(3, [10, 7, 12]), (4, [2, 4, 6, 8])]) == [1, 2] def test_all_elements_same(): assert process_test_cases(1, [(5, [5, 5, 5, 5, 5])]) == [5] def test_mixed_elements(): assert process_test_cases(1, [(4, [4, 8, 12, ...
[ { "docstring": "Returns the greatest common divisor of x and y.", "function_declaration": "def gcd(x, y):", "function_name": "gcd", "parameter_list": "(x, y)" }, { "docstring": "Returns the final remaining element in the array after performing the operations.", "function_declaration": "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\nfrom functools import reduce\n\ndef find_final_remaining_element(arr):\n \"\"\"\n Given an array, returns the final remaining element a...
trial_gpt4o_2
{ "original_instruction": "Alice loves playing with arrays and performing operations on them. One day, she came across a unique operation and decided to turn it into a challenge. The challenge is as follows:\n\nGiven an array of positive integers, Alice performs the following operation until no more operations can be...
0.63159
Taco_99396
C
[ "gcd", "find_final_element", "process_test_cases" ]
3
[ [ "find_final_element", "gcd" ], [ "process_test_cases", "find_final_element" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
fb177916cb1378508de118d3e6328edbb7ae4e8f
63ae49218430e510d1a3dfe35d237ae102ca6519
v1.0
complete
Taco
Taco_99466_C
from typing import List def is_balanced_parentheses(s: str) -> str: """ Returns 'YES' if the string s of parentheses is balanced, otherwise 'NO'. >>> is_balanced_parentheses("()") 'YES' >>> is_balanced_parentheses("(()())") 'YES' >>> is_balanced_parentheses("(()") 'NO' >>> is_balanc...
def is_balanced_parentheses(s): """ Returns 'YES' if the string s of parentheses is balanced, otherwise 'NO'. """ stack = [] for char in s: if char == '(': stack.append(char) elif char == ')': if not stack: return "NO" stack.pop() ...
from solution import is_balanced_parentheses, check_parentheses_balance def test_is_balanced_parentheses(): assert is_balanced_parentheses("()") == "YES" assert is_balanced_parentheses("(()())") == "YES" assert is_balanced_parentheses("(()") == "NO" assert is_balanced_parentheses(")(") == "NO" asse...
[ { "docstring": "Returns 'YES' if the string s of parentheses is balanced, otherwise 'NO'.", "function_declaration": "def is_balanced_parentheses(s):", "function_name": "is_balanced_parentheses", "parameter_list": "(s)" }, { "docstring": "Processes a list of parentheses strings and returns 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 is_balanced_parentheses(strings):\n \"\"\"\n Given a list of strings of parentheses, determine if each string is balanced.\n A string is balanced if e...
trial_gpt4o_2
{ "original_instruction": "You are given a string of parentheses, and you are required to determine if the parentheses are balanced. A string is balanced if every opening parenthesis '(' has a corresponding closing parenthesis ')', and the pairs of parentheses are properly nested.\n\nInput Format\n\nThe input begins ...
0.786518
Taco_99466
C
[ "is_balanced_parentheses", "check_parentheses_balance" ]
2
[ [ "check_parentheses_balance", "is_balanced_parentheses" ] ]
1
[]
false
[]
false
pytest
true
[]
true
69ebeec8fcfbe075c23dd340e9ce8caa0bb6a3d6
f5f30100a8234d963b59be97ff7792327548e8c5
v1.0
complete
Taco
Taco_98783_C
def matchmaking(input_data: str) -> List[int]: """ You are tasked with developing a pairing mechanism for a matchmaking service. The service aims to match individuals based on their preferences and certain constraints. The service stores data about individuals, including their unique IDs, ages, preferences (ea...
import math def count_valid_pairs(datasets): def calculate_distance(x1, y1, x2, y2): return math.sqrt((x1 - x2)**2 + (y1 - y2)**2) results = [] for dataset in datasets: n = dataset[0] individuals = dataset[1] valid_pairs = 0 for i in range(n): ...
from solution import matchmaking def test_matchmaking_single_dataset(): input_data = """4 101 25 hiking photography reading 10.0 20.0 102 27 hiking cooking music 15.0 24.0 103 30 fitness music drawing 14.0 13.0 104 35 reading traveling hiking 40.0 50.0 0""" assert matchmaking(input_data) == [2] def test_match...
[ { "docstring": null, "function_declaration": "def count_valid_pairs(datasets):", "function_name": "count_valid_pairs", "parameter_list": "(datasets)" }, { "docstring": null, "function_declaration": "def parse_input(input_data):", "function_name": "parse_input", "parameter_list": ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import sqrt\n\ndef calculate_distance(x1, y1, x2, y2):\n return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)\n\ndef find_valid_pairs(dataset):\n n = len(d...
trial_gpt4o_2
{ "original_instruction": "You are tasked with developing a pairing mechanism for a matchmaking service. The service aims to match individuals based on their preferences and certain constraints.\n\nThe service stores data about individuals, including their unique IDs, ages, preferences (each person can list up to thr...
0.567295
Taco_98783
C
[ "count_valid_pairs", "parse_input", "matchmaking" ]
3
[ [ "matchmaking", "count_valid_pairs" ], [ "matchmaking", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
9186c42b14a7f3d3898f9e9fc62c6f466a61c064
18c0dfebf25b5b7507812aa59f919ac585ccc467
v1.0
complete
Taco
Taco_99292_C
def calculate_prefix_sum(grid, n, m): """ Calculate the prefix sum of a given grid. >>> calculate_prefix_sum([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3, 3) [[0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45]] """ def query_subgrid_sum(prefix_sum, x1, y1, x2, y2): """ Query the sum of a subgr...
def calculate_prefix_sum(grid, n, m): prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): prefix_sum[i][j] = grid[i - 1][j - 1] + prefix_sum[i - 1][j] + prefix_sum[i][j - 1] - prefix_sum[i - 1][j - 1] return prefix_sum def que...
def test_calculate_prefix_sum(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected = [ [0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45] ] assert calculate_prefix_sum(grid, 3, 3) == expected def test_query_subgrid_sum(): prefix...
[ { "docstring": null, "function_declaration": "def calculate_prefix_sum(grid, n, m):", "function_name": "calculate_prefix_sum", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def query_subgrid_sum(prefix_sum, x1, y1, x2, y2):", "function_name": "quer...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_grid(grid, n, m):\n # Create a prefix sum matrix\n prefix_sum = [[0] * (m + 1) for _ in range(n + 1)]\n \n # Fill the prefix sum matrix\...
trial_gpt4o_4
{ "original_instruction": "Consider a grid of size N x M filled with integers. You are given Q queries each specifying a rectangular sub-grid within the main grid. For each query, calculate the sum of all integers within the specified sub-grid.\n\n-----Input-----\n- The first line contains three integers, N, M, and Q...
0.526757
Taco_99292
C
[ "calculate_prefix_sum", "query_subgrid_sum", "process_queries" ]
3
[ [ "process_queries", "calculate_prefix_sum" ], [ "process_queries", "query_subgrid_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
6dd69df2cdb4e748347b84d1267199777f438373
5ffa2100d803b6a3cc10179a0586185ff1744553
v1.0
complete
Taco
Taco_99228_C
from typing import List def is_prime(n: int) -> bool: """ Check if the given number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(20) False >>> is_prime(1) False """ pass def count_good_numbers(s...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def count_good_numbers(sequences): results = [] for sequence in sequences: ...
def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(20) == False assert is_prime(1) == False def test_count_good_numbers(): assert count_good_numbers(["2 3 5 7 11 13"]) == [6] assert count_goo...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_good_numbers(sequences):", "function_name": "count_good_numbers", "parameter_list": "(sequences)" }, ...
[ 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_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_2
{ "original_instruction": "Given a sequence of integers, we call a \"prime pair\" any two adjacent numbers that are both prime. A \"good number\" is a number in the sequence that is part of at least one prime pair.\n\nYour task is to determine the count of good numbers in a given sequence. A prime number is a number ...
0.705053
Taco_99228
C
[ "is_prime", "count_good_numbers", "process_input" ]
3
[ [ "count_good_numbers", "is_prime" ], [ "process_input", "count_good_numbers" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
5d7040cdf29a2f1bc445e8d3f71a443a1f42890d
5a0c9632bf62f82f8da62f4d92cdebbbabf51849
v1.0
complete
Taco
Taco_99625_C
def can_form_palindrome(word): """ Determines if a word can be rearranged to form a palindrome. A word can be rearranged to form a palindrome if at most one character has an odd number of occurrences while all other characters must have an even number of occurrences. >>> can_form_palindrome("civic") Tru...
def can_form_palindrome(word): """ Determines if a word can be rearranged to form a palindrome. """ # Count occurrences of each character char_count = {} for char in word: if char in char_count: char_count[char] += 1 else: char_count[char] = 1 # C...
def test_can_form_palindrome(): assert can_form_palindrome("civic") == True assert can_form_palindrome("ivicc") == True assert can_form_palindrome("hello") == False assert can_form_palindrome("racecar") == True assert can_form_palindrome("aabbcc") == True assert can_form_palindrome("aabbccd") ==...
[ { "docstring": "Determines if a word can be rearranged to form a palindrome.", "function_declaration": "def can_form_palindrome(word):", "function_name": "can_form_palindrome", "parameter_list": "(word)" }, { "docstring": "Processes a series of words to determine if each can be rearranged to...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_palindrome(word):\n \"\"\"\n Determines if a word can be rearranged to form a palindrome.\n \"\"\"\n # Count occurrences of each character...
trial_gpt4o_0
{ "original_instruction": "Create a program that reads a series of words and determines if each word can be rearranged to form a palindrome.\n\nA string is a palindrome if it reads the same from the front and back, such as \"abba\" or \"racecar\". For the string to be rearranged into a palindrome, at most one charact...
0.758369
Taco_99625
C
[ "can_form_palindrome", "process_words" ]
2
[ [ "process_words", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b97b5affa1e61b8fc4fad1c6945f8019e2a1c0fe
3b3acf4a4642160ef72832a07e80abfe9d02f45b
v1.0
complete
Taco
Taco_99514_C
import math def calculate_segment_length(x1, y1, x2, y2): """ Calculates the Euclidean distance between two points (x1, y1) and (x2, y2). >>> calculate_segment_length(0, 0, 3, 4) 5.0 >>> calculate_segment_length(1, 2, 4, 6) 5.0 >>> calculate_segment_length(3, 3, 6, 7) 5.0 """ pa...
import math def calculate_segment_length(x1, y1, x2, y2): """ Calculates the Euclidean distance between two points (x1, y1) and (x2, y2). """ return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) def total_road_segments_length(n, segments): """ Calculates the total length of all road segments. ...
from solution import calculate_segment_length, total_road_segments_length def test_calculate_segment_length(): assert calculate_segment_length(0, 0, 3, 4) == 5.0 assert calculate_segment_length(1, 2, 4, 6) == 5.0 assert calculate_segment_length(3, 3, 6, 7) == 5.0 def test_total_road_segments_length(): ...
[ { "docstring": "Calculates the Euclidean distance between two points (x1, y1) and (x2, y2).", "function_declaration": "def calculate_segment_length(x1, y1, x2, y2):", "function_name": "calculate_segment_length", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": "Calculates the total len...
[ 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": "import math\n\ndef total_road_length(segments):\n \"\"\"\n This function calculates the total length of all road segments.\n\n Pa...
trial_gpt4o_8
{ "original_instruction": "In a country called Algorithmia, traffic control is a crucial matter. The government conducts a traffic survey every year to understand and alleviate traffic congestion in its capital city. One major intersection in the city has several road segments leading towards and away from it. Each r...
0.607571
Taco_99514
C
[ "calculate_segment_length", "total_road_segments_length" ]
2
[ [ "total_road_segments_length", "calculate_segment_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4525d38a257135a5f9f980f8271b9e9be52f24fc
0e4fbb812ec42ca6d38615e0450e496304b33e58
v1.0
complete
Taco
Taco_99176_C
def preprocess_grid(grid, n, m): """ Preprocess the grid to allow quick retrieval of maximum number of items in any sub-grid. This will build a 2D prefix max matrix. >>> grid = [ ... [1, 3, 2], ... [4, 6, 5], ... [7, 3, 9] ... ] >>> n, m = 3, 3 >>> preprocess_grid(grid, n...
def preprocess_grid(grid, n, m): """ Preprocess the grid to allow quick retrieval of maximum in any sub-grid. This will build a 2D prefix max matrix. """ max_grid = [[0] * m for _ in range(n)] # Initialize the first cell max_grid[0][0] = grid[0][0] # Fill the first row for ...
def test_preprocess_grid(): grid = [ [1, 3, 2], [4, 6, 5], [7, 3, 9] ] expected = [ [1, 3, 3], [4, 6, 6], [7, 7, 9] ] n, m = 3, 3 assert preprocess_grid(grid, n, m) == expected def test_query_max(): grid = [ [1, 3, 2], [4, 6, 5...
[ { "docstring": "Preprocess the grid to allow quick retrieval of maximum in any sub-grid.\nThis will build a 2D prefix max matrix.", "function_declaration": "def preprocess_grid(grid, n, m):", "function_name": "preprocess_grid", "parameter_list": "(grid, n, m)" }, { "docstring": "Retrieve the...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_grid(grid):\n \"\"\"\n Preprocesses the grid to prepare for efficient sub-grid maximum queries.\n \"\"\"\n n = len(grid)\n m = len(gr...
trial_gpt4o_2
{ "original_instruction": "Alex is working on a project where he needs to optimize the storage space of a warehouse. The warehouse can be represented as a 2D grid of size $n \\times m$, where each cell contains a certain number of items. Alex wants to be able to quickly retrieve the maximum number of items in any rec...
0.593677
Taco_99176
C
[ "preprocess_grid", "query_max", "warehouse_queries" ]
3
[ [ "warehouse_queries", "preprocess_grid" ], [ "warehouse_queries", "query_max" ] ]
2
[]
false
[]
false
pytest
false
[]
true
b3dbb77186fa18b1a377894f68f114d7d4fe9139
73e17b17809b3d5e09dfcb828f9c9927713af311
v1.0
complete
Taco
Taco_99680_C
from typing import List from math import gcd MOD = 1000000007 def lcm(a: int, b: int) -> int: return (a * b) // gcd(a, b) def lcm_range(a: int, b: int) -> int: """Given two integers a and b, find the LCM (Least Common Multiple) of all the integers from a to b (inclusive). The result should be returned mo...
from math import gcd from functools import reduce MOD = 1000000007 def lcm(a, b): return a * b // gcd(a, b) def lcm_range(a, b): if a == b: return a % MOD return reduce(lambda x, y: lcm(x, y) % MOD, range(a, b + 1)) # Example test cases print(lcm_range(1, 3)) # Output: 6 print(lcm_range(4, 6)) ...
from solution import lcm_range def test_example_cases(): assert lcm_range(1, 3) == 6 assert lcm_range(4, 6) == 60 assert lcm_range(2, 5) == 60 assert lcm_range(7, 7) == 7 def test_single_element(): assert lcm_range(1, 1) == 1 assert lcm_range(13, 13) == 13 def test_same_multiple(): assert...
[ { "docstring": null, "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def lcm_range(a, b):", "function_name": "lcm_range", "parameter_list": "(a, b)" } ]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\n\nMOD = 1000000007\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm_range(a, b):\n lcm_result = 1\n for num in range(a, b ...
trial_gpt4o_2
{ "original_instruction": "Given two integers a and b, you are required to find the LCM (Least Common Multiple) of all the integers from a to b (inclusive). The LCM of two integers x and y is the smallest positive integer that is divisible by both x and y.\n\nTo make the problem slightly easier, you can directly use ...
0.727813
Taco_99680
C
[ "lcm", "lcm_range" ]
2
[ [ "lcm_range", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c57313094d23eb579221e821a76d92c6d24142cc
60cb9fceee37a8f55948c29005ea231dfebc3bdb
v1.0
complete
Taco
Taco_99298_C
from typing import Tuple, Union def minKnightMoves(start: Tuple[int, int], end: Tuple[int, int]) -> Union[int, str]: """ Determine the minimum number of moves a knight needs to move from start to end on a chessboard. >>> minKnightMoves((0, 0), (7, 7)) 6 >>> minKnightMoves((0, 0), (3, 3)) 2 >>> ...
from collections import deque def is_valid_position(x, y): return 0 <= x < 8 and 0 <= y < 8 def minKnightMoves(start, end): if not is_valid_position(*start) or not is_valid_position(*end): return "Invalid input" if start == end: return 0 moves = [(2, 1), (2, -1), (-2, 1), (-2...
import pytest from solution import minKnightMoves def test_knight_same_position(): assert minKnightMoves((4, 4), (4, 4)) == 0 def test_knight_one_move(): assert minKnightMoves((0, 0), (2, 1)) == 1 assert minKnightMoves((0, 0), (1, 2)) == 1 def test_knight_minimal_moves(): assert minKnightMoves((0, 0)...
[ { "docstring": null, "function_declaration": "def is_valid_position(x, y):", "function_name": "is_valid_position", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def minKnightMoves(start, end):", "function_name": "minKnightMoves", "parameter_list": "(...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_valid_position(x, y):\n return 0 <= x < 8 and 0 <= y < 8\n\ndef minKnightMoves(start, end):\n if not is_valid_positio...
trial_gpt4o_0
{ "original_instruction": "### Chessboard Knight's Move\n\nA knight in chess moves in an L-shape: it can move two squares in one direction (either vertically or horizontally) and then one square in a perpendicular direction, or one square in one direction and then two squares in a perpendicular direction.\n\nGiven th...
0.541592
Taco_99298
C
[ "is_valid_position", "minKnightMoves" ]
2
[ [ "minKnightMoves", "is_valid_position" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc9f493af9f6212cfc11451abc944bd8348b39d3
ffe1d65763a8bc8820f636ab6e9f4d154b6228a4
v1.0
complete
Taco
Taco_99691_C
def is_prime(num): """ Helper function to check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True >>> is_prime(18) False """ pass def sumPrimes(n): """ Return the sum of all prime numbers less than a given non-negative integ...
def is_prime(num): if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def sumPrimes(n): total = 0 for i in range(2, n): if is_prime(i): total += i return total
from solution import is_prime, sumPrimes def test_is_prime(): assert is_prime(2) is True assert is_prime(3) is True assert is_prime(4) is False assert is_prime(17) is True assert is_prime(18) is False assert is_prime(19) is True assert is_prime(1) is False assert is_prime(0) is False ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def sumPrimes(n):", "function_name": "sumPrimes", "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_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n re...
trial_gpt4o_2
{ "original_instruction": "function sumPrimes() is provided to return the sum of all prime numbers that are less than a given non-negative integer n.\n\nCode\n\ndef is_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n...
0.823803
Taco_99691
C
[ "is_prime", "sumPrimes" ]
2
[ [ "sumPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
be62e1e0c4849f24643a6b3f79b31cf22ff1a042
0caf855bbc3b3d3c167865bf53f54f114a45465e
v1.0
complete
Taco
Taco_99812_C
def compute_login_times(n: int, log_entries: List[str]) -> List[str]: """ Compute the amount of time each user spent logged in based on the log entries. The log entries are given in chronological order and a user can only be logged in once. >>> compute_login_times(4, ["09:00 login alice", "12:00 logou...
def parse_time(time_str): """ Parses a time string in HH:MM format and returns the total minutes since midnight. """ hours, minutes = map(int, time_str.split(':')) return hours * 60 + minutes def format_time(total_minutes): """ Formats total minutes as a string in HH:MM format. """ ...
from solution import compute_login_times def test_example_1(): log_entries = [ "09:00 login alice", "12:00 logout alice", "13:00 login bob", "13:45 logout bob" ] result = compute_login_times(4, log_entries) assert result == ["alice 03:00", "bob 00:45"] def test_example_...
[ { "docstring": "Parses a time string in HH:MM format and returns the total minutes since midnight.", "function_declaration": "def parse_time(time_str):", "function_name": "parse_time", "parameter_list": "(time_str)" }, { "docstring": "Formats total minutes as a string in HH:MM format.", ...
[ 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 compute_user_login_times(n, log_entries):\n from collections import defaultdict\n from datetime import datetime\n\n user_login_times = defaultdict(int...
trial_gpt4o_1
{ "original_instruction": "The manager of a multi-user system wants to analyze user logins and statistics for each user. Your task is to implement a system that processes a list of log entries which contain information about user logins and logouts during a single day and computes the amount of time each user spent l...
0.637719
Taco_99812
C
[ "parse_time", "format_time", "compute_login_times" ]
3
[ [ "compute_login_times", "format_time" ], [ "compute_login_times", "parse_time" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3e237144d842a95788f40b5ad740cf5e88689f54
e92b8a8179338386db139769ece881fa1262f853
v1.0
complete
Taco
Taco_99764_C
def quick_sort_comparisons(arr, lo, hi): """ Helper function to count comparisons in Quick Sort """ # your code here def merge_sort_comparisons(arr, temp_arr, left, right): """ Helper function to count comparisons in Merge Sort """ # your code here def merge_and_count(arr, temp_arr, left, mid, right):...
def quick_sort_comparisons(arr, lo, hi): """ Helper function to count comparisons in Quick Sort """ if lo >= hi: return 0 pivot = arr[hi] i = lo - 1 comparisons = 0 for j in range(lo, hi): comparisons += 1 if arr[j] <= pivot: i += 1 arr[i], arr[j] ...
def test_compare_sorts_quick_sort_fewer(): import io import sys input_str = "5\n3 5 1 9 6\n" sys.stdin = io.StringIO(input_str) from solution import compare_sorts compare_sorts(5, [3, 5, 1, 9, 6]) def test_compare_sorts_merge_sort_fewer(): import io import sys input_str = "3\n2 3 1\...
[ { "docstring": "Helper function to count comparisons in Quick Sort ", "function_declaration": "def quick_sort_comparisons(arr, lo, hi):", "function_name": "quick_sort_comparisons", "parameter_list": "(arr, lo, hi)" }, { "docstring": "Helper function to count comparisons in Merge Sort ", ...
[ 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 quick_sort_comparisons(arr):\n def quick_sort(arr, low, high):\n if low < high:\n pi, comparisons = partition(arr, low, high)\n ...
trial_gpt4o_1
{ "original_instruction": "Alice wants to compare the performance of two sorting algorithms: Quick Sort and Merge Sort. Given a list of integers, her goal is to determine which sorting algorithm will perform fewer comparisons for a particular configuration.\n\nImplement a function that simulates the number of compari...
0.55253
Taco_99764
C
[ "quick_sort_comparisons", "merge_sort_comparisons", "merge_and_count", "compare_sorts" ]
4
[ [ "compare_sorts", "merge_sort_comparisons" ], [ "compare_sorts", "quick_sort_comparisons" ], [ "merge_sort_comparisons", "merge_and_count" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8fba9a93d9dd827567e10c463d9e9735f4906d4f
92a0c3977e70fa335f3c93531093fcfd195ad614
v1.0
complete
Taco
Taco_99873_C
def sum_of_digits_is_prime(n): """ Given an integer `n`, determine if the sum of its digits is a prime number. Args: n (int): The positive integer to be analyzed. Returns: bool: True if the sum of the digits is a prime number, otherwise False. Example: >>> sum_of_digits_i...
def is_prime(num): """ Determines 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 sum_of_digits_i...
from solution import sum_of_digits_is_prime def test_sum_of_digits_is_prime(): assert sum_of_digits_is_prime(123) == False, "Test case 123 failed" assert sum_of_digits_is_prime(113) == True, "Test case 113 failed" assert sum_of_digits_is_prime(29) == True, "Test case 29 failed" assert sum_of_digits_is_...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determines if the sum of the digits of n is a prime number.", "function_declaration": "def sum_of_digits_is_prime(n):...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if the given number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n re...
trial_gpt4o_2
{ "original_instruction": "### Task\nSam is learning about prime numbers and he also wants to understand how digits of prime numbers distribute themselves. He needs a program that converts an integer to a list of its digits, then determines if the sum of the digits is a prime number.\n\nGiven an integer `n`, write a ...
0.759787
Taco_99873
C
[ "is_prime", "sum_of_digits_is_prime" ]
2
[ [ "sum_of_digits_is_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f4c19e3813c950fa12054169cc82f514f3d788af
a23e2690dbd814f4fef7f5e25e024661571c2dd8
v1.0
complete
Taco
Taco_99374_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def isSymmetric(root): """ Determines if a binary tree is symmetric. Args: root (TreeNode): The root node of the binary tree. Returns: bool: True if the tree is symmetric...
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def isSymmetric(root): """ Determines if a binary tree is symmetric. Args: root (TreeNode): The root node of the binary tree. Ret...
import pytest from solution import TreeNode, isSymmetric def test_is_symmetric_example1(): # Creating the tree for example 1 root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(2) root.left.left = TreeNode(3) root.left.right = TreeNode(4) root.right.left = TreeNode(4) root....
[]
[ 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 isSymme...
trial_gpt4o_2
{ "original_instruction": "Given a binary tree, your task is to complete the function `isSymmetric()`, that returns true if the binary tree is a mirror of itself (i.e., symmetric around its center) and false otherwise.\n\nExample 1:\nInput:\n 1\n / \\\n 2 2\n / \\ / \\\n3 4 4 3\nOutput:\nTrue\nExplanation:\...
0.55107
Taco_99374
C
[ "isSymmetric", "isMirror" ]
2
[ [ "isSymmetric", "isMirror" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
7903849799f631278de2e9b08b84e392faf511fb
9a959839e898119c3ca3efeb4070235d86da71cc
v1.0
complete
Taco
Taco_99974_C
def minimum_cost_to_connect_streets(n: int, m: int, routes: List[Tuple[int, int, int]]) -> int: """ Determine the minimum total length of routes required to ensure that every street is connected. >>> minimum_cost_to_connect_streets(4, 5, [(1, 2, 10), (1, 3, 6), (2, 3, 5), (3, 4, 7), (1, 4, 12)]) 18 >>> mini...
def find(parent, u): if parent[u] != u: parent[u] = find(parent, parent[u]) return parent[u] def union(parent, rank, u, v): root_u = find(parent, u) root_v = find(parent, v) if root_u != root_v: if rank[root_u] > rank[root_v]: parent[root_v] = root_u elif ra...
def test_example_one(): assert minimum_cost_to_connect_streets(4, 5, [(1, 2, 10), (1, 3, 6), (2, 3, 5), (3, 4, 7), (1, 4, 12)]) == 18 def test_example_two(): assert minimum_cost_to_connect_streets(3, 1, [(1, 2, 15)]) == -1 def test_single_street(): assert minimum_cost_to_connect_streets(1, 0, []) == 0 de...
[ { "docstring": null, "function_declaration": "def find(parent, u):", "function_name": "find", "parameter_list": "(parent, u)" }, { "docstring": null, "function_declaration": "def union(parent, rank, u, v):", "function_name": "union", "parameter_list": "(parent, rank, u, v)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "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": "The city of Codeville has a peculiar street numbering system. Each street is represented by an integer, and the city planners have devised several routes between different streets. Each route connects two different streets bidirectionally and has an associated length.\n\nThe Mayor wants to ...
0.724687
Taco_99974
C
[ "find", "union", "minimum_cost_to_connect_streets" ]
3
[ [ "minimum_cost_to_connect_streets", "find" ], [ "minimum_cost_to_connect_streets", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
6a16790c8354b13697468f3275b60d916c24585b
2f015b5576362db5ad97a279230efb4ce3dd51a7
v1.0
complete
Taco
Taco_99977_C
from typing import List, Tuple def solve_shortest_paths(n: int, m: int, edges: List[Tuple[int, int, int]], q: int, queries: List[Tuple[int, int]]) -> List[int]: """ Solve shortest paths in an undirected graph with weighted edges. >>> solve_shortest_paths(4, 4, [(1, 2, 3), (2, 3, 4), (3, 4, 2), (1, 4, 10)], 3, ...
import heapq import sys from collections import defaultdict def dijkstra(graph, start, n): """Function to execute Dijkstra's algorithm on the graph from a starting node.""" distances = {node: float('infinity') for node in range(1, n + 1)} distances[start] = 0 priority_queue = [(0, start)] whil...
def test_solve_shortest_paths_example(): n = 4 m = 4 edges = [ (1, 2, 3), (2, 3, 4), (3, 4, 2), (1, 4, 10), ] q = 3 queries = [ (1, 4), (1, 3), (2, 4), ] expected = [9, 7, 6] assert solve_shortest_paths(n, m, edges, q, queries) ...
[ { "docstring": "Function to execute Dijkstra's algorithm on the graph from a starting node.", "function_declaration": "def dijkstra(graph, start, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, n)" }, { "docstring": null, "function_declaration": "def solve_shortest_p...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start, n):\n \"\"\"\n Implements Dijkstra's algorithm to find the shortest path from the starting node to all other nodes...
trial_gpt4o_2
{ "original_instruction": "Consider an undirected graph with `N` nodes numbered from `1` to `N` and `M` bidirectional edges. Each edge has an associated weight. You need to answer `Q` queries.\n\nEach query consists of two integers `U` and `V`. You need to find the shortest path from node `U` to node `V` in terms of ...
0.737576
Taco_99977
C
[ "dijkstra", "solve_shortest_paths" ]
2
[ [ "solve_shortest_paths", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
041aff0f0d788db8cd91c75a4b39cc0a4283e759
6964f316c185a27849d93f4e484e4b80f840a165
v1.0
complete
Taco
Taco_99859_C
def factorial(n): """ Calculates the factorial of n modulo 10^9+7. >>> factorial(0) 1 >>> factorial(5) 120 >>> factorial(10) 3628800 """ pass def combinations(n, k): """ Calculates n choose k modulo 10^9+7. >>> combinations(5, 2) 10 >>> combinations(4, 4) ...
def factorial(n): """ Calculates the factorial of n modulo 10^9+7 """ MOD = 10**9 + 7 result = 1 for i in range(2, n+1): result = (result * i) % MOD return result def combinations(n, k): """ Calculates n choose k modulo 10^9+7 """ if k > n: return 0 MOD =...
import pytest from solution import beautiful_clusters, factorial, combinations def test_factorial(): assert factorial(0) == 1 assert factorial(5) == 120 assert factorial(10) == 3628800 def test_combinations(): assert combinations(5, 2) == 10 assert combinations(4, 4) == 1 assert combinations(6...
[ { "docstring": "Calculates the factorial of n modulo 10^9+7", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Calculates n choose k modulo 10^9+7", "function_declaration": "def combinations(n, k):", "function_name"...
[ 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": "from math import comb, factorial\n\nMOD = 10**9 + 7\n\ndef count_beautiful_clusters(N, M):\n \"\"\"\n This function returns the number of possible Beautiful ...
trial_gpt4o_3
{ "original_instruction": "Adam is an avid gardener who loves arranging his plants in a specific pattern. He recently came up with a new type of arrangement he calls the \"Beautiful Cluster\". In this task, you are required to help Adam by calculating the number of possible Beautiful Clusters.\n\nA Beautiful Cluster ...
0.563243
Taco_99859
C
[ "factorial", "combinations", "beautiful_clusters", "process_input_and_output" ]
4
[ [ "beautiful_clusters", "combinations" ], [ "beautiful_clusters", "factorial" ], [ "combinations", "factorial" ], [ "process_input_and_output", "beautiful_clusters" ] ]
4
[]
false
[]
false
pytest
true
[]
true
5fa29e272635e0f5ce039e35ee1b439b3172de92
15e2ea5ca8950847cf18bee697ea48d546d317ff
v1.0
complete
Taco
Taco_99333_C
from typing import List, Tuple def min_trips(test_cases: List[Tuple[int, int, List[int]]]) -> List[int]: """Calculate the minimum number of trips required to deliver all packages without exceeding the weight limit per trip for each test case. Args: test_cases: A list of tuples, where each tuple co...
def min_trips(test_cases): results = [] for case in test_cases: N, W, weights = case weights.sort(reverse=True) trips = 0 while weights: remaining_capacity = W i = 0 while i < len(weights): if weights[...
def test_min_trips(): # Test case 1: Provided in the question test_cases = [ (4, 10, [2, 3, 5, 7]), (5, 15, [1, 2, 3, 4, 5]) ] assert process_min_trips(len(test_cases), test_cases) == [2, 1] # Test case 2: Multiple packages that perfectly fit into trips test_cases = [ ...
[ { "docstring": null, "function_declaration": "def min_trips(test_cases):", "function_name": "min_trips", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def process_min_trips(T, cases):", "function_name": "process_min_trips", "parameter_list": "(...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimum_trips(T, test_cases):\n \"\"\"\n Determine the minimum number of trips required to deliver all packages for each test case.\n \n Parameters...
trial_gpt4o_2
{ "original_instruction": "Write a program that helps the post office efficiently deliver packages. Each package has a weight, and the post office van has a weight limit for each delivery trip.\n\nYou are given a list of package weights and the total weight limit of the van. The goal is to determine the minimum numbe...
0.586248
Taco_99333
C
[ "min_trips", "process_min_trips" ]
2
[ [ "process_min_trips", "min_trips" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8ada6d9177b4c5f72e6f5d37a534c42e7783dde9
5a26065978a081dfaa5c47ed2a831c26b074983f
v1.0
complete
Taco
Taco_99631_C
def is_prime(number): """ Check if a number is prime. """ def next_prime(n): """ Find the next prime number greater than the given number n. """ def replace_primes_with_next(arr): """ Replace each prime number in the list with the next prime number. """ def process_numbers(n, numb...
def is_prime(number): """ Check if a number is prime. """ if number <= 1: return False if number <= 3: return True if number % 2 == 0 or number % 3 == 0: return False i = 5 while i * i <= number: if number % i == 0 or number % (i + 2) == 0: ret...
from solution import is_prime, next_prime, replace_primes_with_next, process_numbers 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(25) == False def test_next_prime(): assert next_prime(2) == 3 ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { "docstring": "Find the next prime number greater than the given number n.", "function_declaration": "def next_prime(n):", "fun...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Determines if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return...
trial_gpt4o_2
{ "original_instruction": "Sarah is a coding enthusiast who loves solving problems. One day she encounters a coding challenge that involves prime number manipulation. The problem statement goes as follows:\n\nYou are given a list of $n$ integers. For each integer in the list, determine whether it is prime or not. If ...
0.659703
Taco_99631
C
[ "is_prime", "next_prime", "replace_primes_with_next", "process_numbers" ]
4
[ [ "next_prime", "is_prime" ], [ "process_numbers", "replace_primes_with_next" ], [ "replace_primes_with_next", "is_prime" ], [ "replace_primes_with_next", "next_prime" ] ]
4
[]
false
[]
false
pytest
true
[]
true
4db285b24ac5f87c8c6bfeb89a44df92014088d3
4574ed7fb1bc78c793a6c655efd06d710d169c12
v1.0
complete
Taco
Taco_4640_C
def fibonacci(n, fib_cache): """ Calculate Fibonacci number with memoization and modulo 10^9 + 9 """ pass def generate_pascals_triangle(n): """ Generate Pascal's triangle up to the nth row. """ pass def modified_pascals_triangle(num_cases, cases): """ Generates the modified Pascal's triang...
def fibonacci(n, fib_cache): """ Calculate Fibonacci number with memoization and modulo 10^9 + 9 """ MOD = 1000000009 if n not in fib_cache: fib_cache[n] = (fibonacci(n - 1, fib_cache) + fibonacci(n - 2, fib_cache)) % MOD return fib_cache[n] def generate_pascals_triangle(n): """ ...
from solution import modified_pascals_triangle, format_output def test_case_1(): results = modified_pascals_triangle(1, [1]) expected_output = "1" assert format_output(results) == expected_output def test_case_2(): results = modified_pascals_triangle(1, [2]) expected_output = "1\n1 1" assert f...
[ { "docstring": "Calculate Fibonacci number with memoization and modulo 10^9 + 9", "function_declaration": "def fibonacci(n, fib_cache):", "function_name": "fibonacci", "parameter_list": "(n, fib_cache)" }, { "docstring": "Generate Pascal's triangle up to the nth row.", "function_declarat...
[ 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 generate_pascals_triangle(num_rows):\n \"\"\"\n Generates the first num_rows of Pascal's triangle.\n \"\"\"\n triangle = []\n for n in range(num...
trial_gpt4o_2
{ "original_instruction": "Tom, a computer science enthusiast, is fascinated by the Fibonacci sequence and Pascal’s triangle. He decides to create a game that combines both concepts. In his game, each number in Pascal’s triangle must be replaced by the corresponding Fibonacci number in the sequence.\n\nThe Fibonacci ...
0.720992
Taco_4640
C
[ "fibonacci", "generate_pascals_triangle", "modified_pascals_triangle", "format_output" ]
4
[ [ "modified_pascals_triangle", "fibonacci" ], [ "modified_pascals_triangle", "generate_pascals_triangle" ] ]
2
[ "format_output" ]
false
[]
false
pytest
true
[]
true
b6e86fd88d5919766da05b742a9fba905cde31b6
9fb45eec9913c2c3bcc547804abd6b673a0482f3
v1.0
complete
Taco
Taco_4775_C
def max_non_adjacent_sum(arr): """ Returns the maximum sum of non-adjacent elements in the array `arr`. """ pass def solve(test_cases): """ Processes multiple test cases and returns the results for each one. """ pass def parse_input(): """ Parses the input for multiple test cas...
def max_non_adjacent_sum(arr): """ Returns the maximum sum of non-adjacent elements in the array `arr`. """ if not arr: return 0 prev_one, prev_two = 0, 0 for num in arr: current = max(prev_one, prev_two + num) prev_two = prev_one prev_one = current ret...
def test_max_non_adjacent_sum(): # Test case with sample input assert max_non_adjacent_sum([3, 2, 7, 10]) == 13 assert max_non_adjacent_sum([3, 2, 5]) == 8 assert max_non_adjacent_sum([1, 2]) == 2 # Test case with negative values assert max_non_adjacent_sum([-1, -2, -3, -4]) == 0 assert max_...
[ { "docstring": "Returns the maximum sum of non-adjacent elements in the array `arr`.", "function_declaration": "def max_non_adjacent_sum(arr):", "function_name": "max_non_adjacent_sum", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_non_adjacent_sum(arr):\n \"\"\"\n Returns the maximum possible sum of non-adjacent elements in the array.\n \"\"\"\n if not arr:\n retur...
trial_gpt4o_1
{ "original_instruction": "Given an array of integers, find the maximum possible sum of non-adjacent elements. You can choose not to take any elements at all.\n\nInput format:\n\nThe first line of input will contain an integer `T`, denoting the number of test cases. \nEach test case will be given in two lines:\n- The...
0.720679
Taco_4775
C
[ "max_non_adjacent_sum", "solve", "parse_input" ]
3
[ [ "parse_input", "solve" ], [ "solve", "max_non_adjacent_sum" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
d67f22ce4ef63285c6beaa310e023ad1ac69e997
f2161033e0d232a91d6833163d3b133a77107f11
v1.0
complete
Taco
Taco_5022_C
def filter_and_sort_primes(numbers: List[int]) -> List[int]: """ Given a list of integers, return a sorted list containing only the prime numbers. >>> filter_and_sort_primes([29, 15, 3, 11, 2, 42, 37, 91]) [2, 3, 11, 29, 37] >>> filter_and_sort_primes([15, 42, 91, 100]) [] >>> filter_and_sort_pr...
def is_prime(n): """ Helper function to check if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False ...
from solution import filter_and_sort_primes def test_filter_and_sort_primes_with_mixed_numbers(): assert filter_and_sort_primes([29, 15, 3, 11, 2, 42, 37, 91]) == [2, 3, 11, 29, 37] def test_filter_and_sort_primes_with_no_primes(): assert filter_and_sort_primes([15, 42, 91, 100]) == [] def test_filter_and_so...
[ { "docstring": "Helper function to check if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a sorted list containing only the prime numbers.", "function_declaration...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ret...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes a list of integers and returns another list containing only the prime numbers from the input list, in ascending order.\n\nFor example, given the input:\n```python\n[29, 15, 3, 11, 2, 42, 37, 91]\n```\n\nYour function should return:\n```python\n[2, 3, 11, 29, 37]\...
0.700993
Taco_5022
C
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
769122a99ea17170e376104d77edcede76f8e9e5
d5fad4ebff79dccca9f0586f17dc462a874298b8
v1.0
complete
Taco
Taco_5266_C
def shortest_travel_times(n: int, m: int, roads: List[Tuple[int, int, int]]) -> List[List[int]]: """ Computes the shortest travel time between each pair of cities using the Floyd-Warshall algorithm. Parameters: n (int): number of cities m (int): number of roads roads (list of tuples): list ...
def floyd_warshall(n, roads): """ Computes the shortest travel time between each pair of cities using the Floyd-Warshall algorithm. Parameters: n (int): number of cities roads (list of tuples): list of roads, where each road is represented as a tuple (u, v, w) Returns: list of list...
from solution import shortest_travel_times def test_example_1(): n = 4 m = 4 roads = [(1, 2, 5), (2, 3, 10), (1, 3, 9), (3, 4, 2)] result = shortest_travel_times(n, m, roads) expected = [ [0, 5, 9, 11], [5, 0, 10, 12], [9, 10, 0, 2], [11, 12, 2, 0], ] assert ...
[ { "docstring": "Computes the shortest travel time between each pair of cities using the Floyd-Warshall algorithm.\n\nParameters:\nn (int): number of cities\nroads (list of tuples): list of roads, where each road is represented as a tuple (u, v, w)\n\nReturns:\nlist of lists: a distance matrix where entry (i, j)...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def floyd_warshall(n, m, roads):\n # Initialize the distance matrix with \"infinity\"\n inf = float('inf')\n dist = [[inf if i != j else 0 for j in range(...
trial_gpt4o_2
{ "original_instruction": "Lena is learning about graphs and has a set of cities connected by bidirectional roads. There are `n` cities and `m` roads. Each road has a travel time associated with it. Lena's goal is to determine the shortest travel time between each pair of cities using a specific algorithm.\n\nYour ta...
0.760629
Taco_5266
C
[ "floyd_warshall", "shortest_travel_times" ]
2
[ [ "shortest_travel_times", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bb71a17a4260e10b54e40cb416cf87b432c1f878
612e3e5c5f4a506de7c6868306ea919fedf7a18e
v1.0
complete
Taco
Taco_5336_C
def snake_to_camel(snake_str: str) -> str: """ Converts a snake_case variable name to CamelCase following the specific style guide rules. >>> snake_to_camel("hello_world") "helloWorld" >>> snake_to_camel("this_is_camel_case") "thisIsCamelCase" >>> snake_to_camel("convert_to_camel_case")...
def snake_to_camel(snake_str): """ Converts a snake_case variable name to CamelCase following the specific style guide rules. """ components = snake_str.split('_') return components[0] + ''.join(x.title() for x in components[1:]) def convert_snake_to_camel(n, variable_names): camel_case_names =...
from solution import snake_to_camel, convert_snake_to_camel def test_snake_to_camel(): assert snake_to_camel("hello_world") == "helloWorld" assert snake_to_camel("this_is_camel_case") == "thisIsCamelCase" assert snake_to_camel("convert_to_camel_case") == "convertToCamelCase" assert snake_to_camel("sing...
[ { "docstring": "Converts a snake_case variable name to CamelCase following the specific style guide rules.", "function_declaration": "def snake_to_camel(snake_str):", "function_name": "snake_to_camel", "parameter_list": "(snake_str)" }, { "docstring": null, "function_declaration": "def c...
[ 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 convert_to_camel_case(snake_str):\n \"\"\"\n Converts a snake_case string to camelCase format.\n \n Parameters:\n snake_str (str): A variable na...
trial_gpt4o_1
{ "original_instruction": "A team of software developers is working on a project with a specific style guide for variable names. The style guide has the following rules:\n1. Variable names should be in CamelCase.\n2. All variable names must start with a lowercase letter.\n3. Each subsequent word in the variable name ...
0.803426
Taco_5336
C
[ "snake_to_camel", "convert_snake_to_camel" ]
2
[ [ "convert_snake_to_camel", "snake_to_camel" ] ]
1
[]
false
[]
false
pytest
true
[]
true
07e7f69355eafc4396c11e1bb008726430bc058d
9efe5a02739ba2fc35863b1ff7d85391cf25a6ca
v1.0
complete
Taco
Taco_4918_C
def merge_sort(lst: List[int]) -> List[int]: """ Sorts a list of integers using the merge sort algorithm. >>> merge_sort([34, 7, 23, 32, 5, 62]) [5, 7, 23, 32, 34, 62] >>> merge_sort([0, -1, 3, 2, 1, -2]) [-2, -1, 0, 1, 2, 3] >>> merge_sort([4, 5, 4, 5, 4, 5]) [4, 4, 4, 5, 5, 5] >>> ...
def merge_sort(lst): """ Sorts a list of integers using the merge sort algorithm. """ if len(lst) <= 1: return lst mid = len(lst) // 2 left_half = merge_sort(lst[:mid]) right_half = merge_sort(lst[mid:]) return merge(left_half, right_half) def merge(left, right): "...
from solution import merge_sort def test_merge_sort_with_positive_numbers(): assert merge_sort([34, 7, 23, 32, 5, 62]) == [5, 7, 23, 32, 34, 62] def test_merge_sort_with_mixed_numbers(): assert merge_sort([0, -1, 3, 2, 1, -2]) == [-2, -1, 0, 1, 2, 3] def test_merge_sort_with_duplicates(): assert merge_so...
[ { "docstring": "Sorts a list of integers using the merge sort algorithm.", "function_declaration": "def merge_sort(lst):", "function_name": "merge_sort", "parameter_list": "(lst)" }, { "docstring": "Helper function to merge two sorted lists.", "function_declaration": "def merge(left, rig...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(lst):\n \"\"\"\n Sorts a list of integers using merge sort algorithm.\n \n :param lst: List of integers to sort\n :return: Sorted lis...
trial_gpt4o_1
{ "original_instruction": "Write a function `merge_sort` that takes a list of integers and sorts it using the merge sort algorithm. Merge sort divides the input list into two halves, recursively sorts each half, and then merges the two sorted halves to produce the sorted list. You are required to demonstrate the func...
0.655907
Taco_4918
C
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6a4351e85536d75e1464a4c9a6eee17e522727af
fb9fd572a52d476331efc600b3666efd93f66d8d
v1.0
complete
Taco
Taco_6025_C
def next_prime(N: int) -> int: """ Find the smallest prime number greater than a given number. >>> next_prime(10) 11 >>> next_prime(29) 31 >>> next_prime(100) 101 """
import math def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True...
from solution import next_prime def test_next_prime_after_10(): assert next_prime(10) == 11 def test_next_prime_after_29(): assert next_prime(29) == 31 def test_next_prime_after_100(): assert next_prime(100) == 101 def test_next_prime_after_1(): assert next_prime(1) == 2 def test_next_prime_after_5...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Function to find the smallest prime number greater than N.", "function_declaration": "def next_prime(N):", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef 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\...
trial_gpt4o_2
{ "original_instruction": "CodeMasterBot loves prime numbers and is interested in finding the smallest prime number greater than a given number. He could use some help with a program that can efficiently find such prime numbers for a given set of queries.\n\nYour task is to write a program that takes multiple test ca...
0.759638
Taco_6025
C
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8f1602451debc483cab67f93409f92dbca9b912
a848d474c8c56112b0ee68399e4e56532d4bc2d6
v1.0
complete
Taco
Taco_5763_C
class TreeNode: def __init__(self, value=0): self.value = value self.left = None self.right = None def build_tree(nodes, edges): """ Build the binary tree from node values and edges >>> build_tree([10, 20, 30, 40, 50], [(1, 2), (1, 3), (2, 4), (2, 5)]) TreeNode Object """ ...
class TreeNode: def __init__(self, value=0): self.value = value self.left = None self.right = None def build_tree(nodes, edges): if not nodes: return None node_dict = {i + 1: TreeNode(value) for i, value in enumerate(nodes)} for u, v in edges: if node_d...
import pytest from solution import process_input_and_solve def test_case1(capsys): input_str = """1 5 10 20 30 40 50 1 2 1 3 2 4 2 5 80""" expected_output = "3\n" process_input_and_solve(input_str) captured = capsys.readouterr() assert captured.out == expected_output def test_case2(capsys): in...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.children = []\n\ndef construct_tree(nodes, edges):\n node_objs = [Tree...
trial_gpt4o_2
{ "original_instruction": "You are given a binary tree and an integer K.\n\nYour task is to find the length of the longest path where each node's value is distinct and the sum of the values does not exceed K.\n\n### Input Format\n\n- The first line contains an integer T, denoting the number of test cases.\n- Each tes...
0.61638
Taco_5763
C
[ "build_tree", "longest_path_sum_k", "process_input_and_solve" ]
3
[ [ "process_input_and_solve", "build_tree" ], [ "process_input_and_solve", "longest_path_sum_k" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
766ad7d44669e1f68ed6a5cf9c9a1ae8aece3c86
56eb0fed8ee2c11fb59677cf4227f8f39498cf63
v1.0
complete
Taco
Taco_5860_C
def is_palindromic_number(n: int) -> bool: """ Check if the given number n is a palindromic number. >>> is_palindromic_number(121) True >>> is_palindromic_number(123) False >>> is_palindromic_number(1331) True """ def palindromic_numbers(t: int, numbers: List[int]) -> List[str]: """ ...
def is_palindromic_number(n): """ Check if the given number n is a palindromic number. """ n_str = str(n) return n_str == n_str[::-1] def palindromic_numbers(t, numbers): """ For a list of numbers, determine if each one is a palindromic number. """ results = [] for number in num...
from solution import is_palindromic_number, palindromic_numbers def test_is_palindromic_number(): assert is_palindromic_number(121) == True assert is_palindromic_number(123) == False assert is_palindromic_number(1331) == True assert is_palindromic_number(56765) == True assert is_palindromic_number(...
[ { "docstring": "Check if the given number n is a palindromic number.", "function_declaration": "def is_palindromic_number(n):", "function_name": "is_palindromic_number", "parameter_list": "(n)" }, { "docstring": "For a list of numbers, determine if each one is a palindromic number.", "fu...
[ 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_palindromic_number(n):\n \"\"\"\n Check if the given number n is a palindromic number.\n \"\"\"\n str_n = str(n)\n r...
trial_gpt4o_2
{ "original_instruction": "A number is called a palindromic number if it remains the same when its digits are reversed. For example, 121 and 1331 are palindromic numbers, while 123 and 1321 are not. Given a number $n$, check if $n$ is a palindromic number.\n\n-----Input-----\n\nThe first line of the input contains an...
0.791238
Taco_5860
C
[ "is_palindromic_number", "palindromic_numbers" ]
2
[ [ "palindromic_numbers", "is_palindromic_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0ca3ea4db4bae72269ccf32af2649a45380241c0
3bc9b8860b3cbe3604240e8c5a5bdb90c40b2b8d
v1.0
complete
Taco
Taco_5132_C
from typing import List, Tuple def max_water_flow(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """ Calculate the maximum water flow from the main reservoir (node 1) to the target household (node n) in a town's water distribution system. >>> max_water_flow(4, 5, [(1, 2, 100), (2, 3, 50), (1, 3, 50...
from collections import deque, defaultdict def bfs(capacity, source, sink, parent): visited = set() queue = deque() queue.append(source) visited.add(source) while queue: node = queue.popleft() for adj in capacity[node]: if adj not in visited and capacity[no...
def test_max_flow_example1(): n = 4 m = 5 edges = [ (1, 2, 100), (2, 3, 50), (1, 3, 50), (3, 4, 100), (2, 4, 100), ] assert max_water_flow(n, m, edges) == 150 def test_max_flow_example2(): n = 3 m = 3 edges = [ (1, 2, 20), (1, 3, 1...
[ { "docstring": null, "function_declaration": "def bfs(capacity, source, sink, parent):", "function_name": "bfs", "parameter_list": "(capacity, source, sink, parent)" }, { "docstring": null, "function_declaration": "def edmonds_karp(n, graph, source, sink):", "function_name": "edmonds...
[ 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, defaultdict\n\ndef bfs(source, sink, parent, graph):\n visited = set()\n queue = deque([source])\n visited.add(source)\n \...
trial_gpt4o_2
{ "original_instruction": "In a town called Techville, there is a unique system of water distribution. The town's reservoirs supply water to the inhabitants through a series of connected pipes. Each pipe has a maximum capacity indicating the highest amount of water it can transport. To ensure efficient water manageme...
0.574139
Taco_5132
C
[ "bfs", "edmonds_karp", "max_water_flow" ]
3
[ [ "edmonds_karp", "bfs" ], [ "max_water_flow", "edmonds_karp" ] ]
2
[]
false
[]
false
pytest
false
[]
true
0efd2f8a55beb9a8d63bf15400a2433e830de6b6
930dd0a2feac6ba43c35a4f021bd1b32fc984cc7
v1.0
complete
Taco
Taco_5574_C
def compare_descriptions(desc1: str, desc2: str) -> bool: """ Compare two descriptions of pipe systems to check if they represent the same pipe system. The comparison should account for possible rotations or shuffling of the commands. Args: desc1 : str : The first pipe system description. desc2 : ...
def normalize_description(description): """ Normalize the pipe description by sorting elements and handling rotations. """ parts = description.split() n = int(parts[0]) elements = parts[1:] def rotate90(elements): rotated = [] for el in elements: if el == 'N': ...
from solution import compare_descriptions, check_pipe_systems def test_compare_identical_descriptions(): desc1 = "12 1 N 1 E 2 S 2 W" desc2 = "12 1 N 1 E 2 S 2 W" assert compare_descriptions(desc1, desc2) == True def test_compare_different_descriptions_rotation(): desc1 = "12 1 N 1 E 2 S 2 W" desc...
[ { "docstring": "Normalize the pipe description by sorting elements and handling rotations.", "function_declaration": "def normalize_description(description):", "function_name": "normalize_description", "parameter_list": "(description)" }, { "docstring": "Compare two descriptions to check if ...
[ 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 normalize_description(description):\n \"\"\"\n Normalize the description by sorting and considering all rotations.\n \"\"\"\n return sorted(descrip...
trial_gpt4o_3
{ "original_instruction": "A magical garden is designed using a system of interconnected water pipes. Each pipe either directs water in one of four cardinal directions (North, South, East, West). The connections between the pipes determine the water flow in the garden. The layout of the pipes and the flow they create...
0.581213
Taco_5574
C
[ "normalize_description", "compare_descriptions", "check_pipe_systems" ]
3
[ [ "check_pipe_systems", "compare_descriptions" ], [ "compare_descriptions", "normalize_description" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2acff04128fdcb651db478db95709b3aa346c207
3fb4e47a41504334bcf4b0f821b61e92ad0aed94
v1.0
complete
Taco
Taco_5927_C
from typing import List, Tuple def knapsack_max_satisfaction(tasks: List[Tuple[int, int]], max_hours: int) -> List[int]: """A helper function to compute the maximum satisfaction points for any given hour limit.""" dp = [0] * (max_hours + 1) for hours, satisfaction in tasks: for h in range(max_hours...
def knapsack_max_satisfaction(tasks, max_hours): n = len(tasks) dp = [0] * (max_hours + 1) for hours, satisfaction in tasks: for h in range(max_hours, hours - 1, -1): dp[h] = max(dp[h], dp[h - hours] + satisfaction) return dp def max_satisfaction_points(tasks, queries): ...
from solution import knapsack_max_satisfaction, max_satisfaction_points def test_knapsack_max_satisfaction(): tasks = [(4, 5), (3, 7), (2, 10)] dp = knapsack_max_satisfaction(tasks, 10) assert dp[5] == 17 assert dp[6] == 17 assert dp[10] == 22 def test_max_satisfaction_points(): tasks = [(4, 5...
[ { "docstring": null, "function_declaration": "def knapsack_max_satisfaction(tasks, max_hours):", "function_name": "knapsack_max_satisfaction", "parameter_list": "(tasks, max_hours)" }, { "docstring": null, "function_declaration": "def max_satisfaction_points(tasks, queries):", "funct...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_satisfaction(n, tasks, q, queries):\n \"\"\"\n Function to calculate the maximum satisfaction points achievable within a given number of hours.\n ...
trial_gpt4o_1
{ "original_instruction": "A website maintenance team needs to distribute its tasks for the upcoming week. Each task needs a certain number of hours to be completed and brings a certain number of satisfaction points when completed. The manager wants to maximize the total satisfaction points while adhering to the week...
0.598297
Taco_5927
C
[ "knapsack_max_satisfaction", "max_satisfaction_points" ]
2
[ [ "max_satisfaction_points", "knapsack_max_satisfaction" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e7c83c632eef05ce172d009411930440fe0e5207
5b40a7d0a0dc39c23947805e7d36fce1a75b9a75
v1.0
complete
Taco
Taco_5804_C
def is_prime(n: int) -> bool: """ Check if a number is a prime. >>> is_prime(11) == True >>> is_prime(101) == True >>> is_prime(10) == False >>> is_prime(1) == False >>> is_prime(2) == True >>> is_prime(4) == False """ def is_palindrome(n: int) -> bool: """ Check if a number is a pa...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def is_palindrome(n): return str(n) == str(n)[::-1] def is_prime_palindrome(n):...
from solution import is_prime, is_palindrome, is_prime_palindrome, solution def test_is_prime(): assert is_prime(11) == True assert is_prime(101) == True assert is_prime(10) == False assert is_prime(1) == False assert is_prime(2) == True assert is_prime(4) == False def test_is_palindrome(): ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": null,...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n*...
trial_gpt4o_0
{ "original_instruction": "You are given an integer n. Check if it is a prime number and also a palindrome. \n\nA prime number is a natural number greater than 1 that has no divisors other than 1 and itself. A palindrome is a number that reads the same backward as forward.\n\nINPUT:\n\nFirst line of input contains t,...
0.727895
Taco_5804
C
[ "is_prime", "is_palindrome", "is_prime_palindrome", "solution" ]
4
[ [ "is_prime_palindrome", "is_palindrome" ], [ "is_prime_palindrome", "is_prime" ], [ "solution", "is_prime_palindrome" ] ]
3
[]
false
[]
false
pytest
true
[]
true
9b5961a69d38a4333d743b1d59c43977c7ce15c3
e0597e1b38bdb8dc39123bbfbd9f34a55702d175
v1.0
complete
Taco
Taco_4970_C
def rotate_90_clockwise(matrix): """ Rotates the given n x n matrix 90 degrees clockwise. Args: matrix (list of list of int): 2D list representing the matrix. Returns: list of list of int: Rotated matrix. """ # Write your code here def process_input(input_string): """ ...
def rotate_90_clockwise(matrix): """ Rotates the given n x n matrix 90 degrees clockwise. Args: matrix (list of list of int): 2D list representing the matrix. Returns: list of list of int: Rotated matrix. """ return [list(row) for row in zip(*matrix[::-1])] def process_input(i...
from solution import rotate_90_clockwise, process_input, rotate_matrices def test_rotate_90_clockwise(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] rotated = rotate_90_clockwise(matrix) expected = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] assert rotat...
[ { "docstring": "Rotates the given n x n matrix 90 degrees clockwise.\n\nArgs:\nmatrix (list of list of int): 2D list representing the matrix.\n\nReturns:\nlist of list of int: Rotated matrix.", "function_declaration": "def rotate_90_clockwise(matrix):", "function_name": "rotate_90_clockwise", "param...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_image(matrix):\n \"\"\"\n Rotates a n x n matrix 90 degrees clockwise.\n \"\"\"\n n = len(matrix)\n # Create a new matrix with the same d...
trial_gpt4o_2
{ "original_instruction": "You are given an image processing system that involves multiple operations on an image represented by a 2D matrix of integers. Each integer corresponds to the brightness of a pixel.\n\nOne of the most important operations in this system is to rotate the image.\n\nA rotation operation consis...
0.513238
Taco_4970
C
[ "rotate_90_clockwise", "process_input", "rotate_matrices" ]
3
[ [ "rotate_matrices", "process_input" ], [ "rotate_matrices", "rotate_90_clockwise" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
c80334ac9a855e3af910a1b6519abed4343e1b76
0926d805196b1a6eca4bbb3989b5a2fe19392e72
v1.0
complete
Taco
Taco_5675_C
def preprocess_array(arr): """ Preprocess the input array to create a prefix sum array to allow efficient range sum queries. >>> preprocess_array([1, 2, 3, 4, 5, 6]) [0, 1, 3, 6, 10, 15, 21] """ pass def range_sum(prefix_sums, L, R): """ Calculate the sum of the subarray arr[L:R+1] using the pr...
def preprocess_array(arr): """ Preprocess the input array to create a prefix sum array to allow efficient range sum queries. """ 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 range_sum(prefix_s...
from solution import preprocess_array, range_sum, process_queries def test_preprocess_array(): arr = [1, 2, 3, 4, 5, 6] expected_prefix_sums = [0, 1, 3, 6, 10, 15, 21] assert preprocess_array(arr) == expected_prefix_sums def test_range_sum(): arr = [1, 2, 3, 4, 5, 6] prefix_sums = preprocess_array...
[ { "docstring": "Preprocess the input array to create a prefix sum array to allow efficient range sum queries.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" }, { "docstring": "Calculate the sum of the subarray arr[L:R+1]...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_array(arr):\n \"\"\"\n Preprocesses the array to create a prefix sum array.\n \n Parameters:\n arr (list): List of integers.\n \n ...
trial_gpt4o_2
{ "original_instruction": "You are given an array of integers and a set of queries. Each query asks for the sum of a subarray defined by a range of indices. Your task is to preprocess the array so that each query can be answered efficiently.\n\n-----Input:-----\n- The first line contains an integer $N$, the number of...
0.593846
Taco_5675
C
[ "preprocess_array", "range_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_array" ], [ "process_queries", "range_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
e7f6b919b1386789cc2d9c010bf3378ce07a13bc
d85b6e2e9080b450f81147ce1baa9e989316ed0f
v1.0
complete
Taco
Taco_5751_C
from typing import List def is_product_of_sums_perfect_square(n: int, A: List[int]) -> str: """ Given an n-length array of integers, determine whether it's possible to partition the array into two non-empty subarrays, such that the product of the sums of these subarrays is a perfect square. >>> is_pr...
import math def is_product_of_sums_perfect_square(n, A): total_sum = sum(A) prefix_sum = 0 for i in range(n - 1): prefix_sum += A[i] rest_sum = total_sum - prefix_sum product = prefix_sum * rest_sum if is_perfect_square(product): return "YES" return...
from solution import is_product_of_sums_perfect_square def test_example_0(): n = 4 A = [1, 2, 3, 4] assert is_product_of_sums_perfect_square(n, A) == "YES" def test_example_1(): n = 3 A = [1, 6, 5] assert is_product_of_sums_perfect_square(n, A) == "NO" def test_single_element_each(): n = ...
[ { "docstring": null, "function_declaration": "def is_product_of_sums_perfect_square(n, A):", "function_name": "is_product_of_sums_perfect_square", "parameter_list": "(n, A)" }, { "docstring": null, "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_squa...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef can_partition_to_perfect_square(n, A):\n total_sum = sum(A)\n prefix_sum = 0\n \n for i in range(n - 1):\n prefix_sum += A[i]...
trial_gpt4o_1
{ "original_instruction": "Given an `n`-length array of integers, `A`, write a function to determine whether it's possible to partition the array into two non-empty subarrays, such that the product of the sums of these subarrays is a perfect square.\n\n### Input Format\n- The first line contains a single integer `n`,...
0.604881
Taco_5751
C
[ "is_product_of_sums_perfect_square", "is_perfect_square" ]
2
[ [ "is_product_of_sums_perfect_square", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fcda11afda5f56a626942a0463bb9a32ba716afb
3f8a31bd4e1562be9997382b337a42acaa944b7b
v1.0
complete
Taco
Taco_5198_C
def find_largest_rectangular_area(n: int, grid: List[List[int]]) -> int: """ In a small village, there is a peculiar game that the villagers love to play during the harvest festival. The game involves a special type of garden, which is essentially a square grid of size NxN. Each cell in the grid either co...
def largest_rectangle_in_histogram(heights): stack = [] max_area = 0 index = 0 while index < len(heights): if not stack or heights[stack[-1]] <= heights[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (he...
def test_largest_rectangular_area(): assert find_largest_rectangular_area(5, [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0], [1, 1, 1, 0, 0] ]) == 6 assert find_largest_rectangular_area(3, [ [1, 1, 1], [1, 1, 1], [1, 1, 1...
[ { "docstring": null, "function_declaration": "def largest_rectangle_in_histogram(heights):", "function_name": "largest_rectangle_in_histogram", "parameter_list": "(heights)" }, { "docstring": null, "function_declaration": "def largest_rectangle_area(matrix):", "function_name": "large...
[ 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 maximalRectangle(grid):\n if not grid or not grid[0]:\n return 0\n\n N = len(grid)\n max_area = 0\n heights = [0] * (N + 1)\n\n for row i...
trial_gpt4o_1
{ "original_instruction": "In a small village, there is a peculiar game that the villagers love to play during the harvest festival. The game involves a special type of garden, which is essentially a square grid of size NxN. Each cell in the grid either contains a plant (denoted by 1) or is empty (denoted by 0). The ...
0.676348
Taco_5198
C
[ "largest_rectangle_in_histogram", "largest_rectangle_area", "find_largest_rectangular_area" ]
3
[ [ "find_largest_rectangular_area", "largest_rectangle_area" ], [ "largest_rectangle_area", "largest_rectangle_in_histogram" ] ]
2
[]
false
[]
false
pytest
false
[]
true
e084b4a035fc1d5a925d89641d4dd2d73a901754
bb7e303f771cf44f3f500270bcef825fba42bcec
v1.0
complete
Taco
Taco_4849_C
import json from typing import List, Union def find_values_by_key(json_obj: Union[dict, list], target_key: str) -> List[str]: """ Traverses the JSON object and returns a list of all values associated with the given key. Args: json_obj (Union[dict, list]): The JSON object to traverse. targe...
import json def find_values_by_key(json_obj, target_key): """ Traverses the JSON object and returns a list of all values associated with the given key. """ values = [] def traverse(obj): if isinstance(obj, dict): for key, value in obj.items(): if key == targ...
from solution import get_values_from_json_string def test_single_occurrence(): json_string = '''{ "json": {"name": "John", "age": 30, "postalCode": "10003"}, "key": "postalCode" }''' assert get_values_from_json_string(json_string) == ["1000...
[ { "docstring": "Traverses the JSON object and returns a list of all values associated with the given key.", "function_declaration": "def find_values_by_key(json_obj, target_key):", "function_name": "find_values_by_key", "parameter_list": "(json_obj, target_key)" }, { "docstring": "Parses the...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\n\ndef find_values(json_obj, target_key):\n \"\"\"\n Traverses the JSON object and returns a list of all values associated with the target key.\n...
trial_gpt4o_2
{ "original_instruction": "A JSON object is represented as a tree with nodes, where each node corresponds to a key within the object. The value at each node can either be a primitive (string, number, boolean, null), an array, or another JSON object.\n\nWrite a function that, given a JSON object and a key, traverses t...
0.632773
Taco_4849
C
[ "find_values_by_key", "get_values_from_json_string" ]
2
[ [ "get_values_from_json_string", "find_values_by_key" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f9da0268beb977c123043353cc672e5d5b44080a
2e08efbb38752c939b41d0ba076854b852aa6793
v1.0
complete
Taco
Taco_7048_C
def largest_prime(n: int): """ Finds the largest prime number less than or equal to the given integer n. Returns "Not valid" if n is not a positive integer. >>> largest_prime(10) 7 >>> largest_prime(29) 29 >>> largest_prime(1) "Not valid" >>> largest_prime(-5) "Not valid" ""...
def is_prime(num): """ Helper function to determine 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 d...
from solution import largest_prime def test_largest_prime_within_range(): assert largest_prime(10) == 7 assert largest_prime(29) == 29 assert largest_prime(15) == 13 def test_largest_prime_edge_cases(): assert largest_prime(2) == 2 assert largest_prime(3) == 3 def test_largest_prime_invalid_input...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds the largest prime number less than or equal to the given integer n.\nReturns \"Not valid\" if n i...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Helper function to check if a given number is prime.\"\"\"\n if num <= 1:\n return False\n if num == 2:\n return ...
trial_gpt4o_2
{ "original_instruction": "A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Write a function that finds the largest prime number less than or equal to a given integer `n`.\n\n```if-not:haskell\nReturn \"Not valid\" if the input is not a positive integer.\n```\n`...
0.822625
Taco_7048
C
[ "is_prime", "largest_prime" ]
2
[ [ "largest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6740e3e7b77bafc05c1e96311d45d7bea26579a4
c34c96942f8b5be4fd6be6d90a688b9b9b2d0333
v1.0
complete
Taco
Taco_6159_C
def robotic_assistant(N: int, array: List[int]) -> int: """ A robotic assistant is tasked with arranging a row of books by their thickness. The assistant is given an array representing the thickness of each book in their current order, and it must determine the minimum number of swaps needed to arrange the ...
def minimum_adjacent_swaps(arr): """ Returns the minimum number of adjacent swaps needed to sort the array in non-decreasing order. """ swaps = 0 n = len(arr) # A modified Bubble Sort to count the swaps for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1...
from solution import robotic_assistant def test_given_example(): assert robotic_assistant(5, [4, 3, 1, 2, 5]) == 5 def test_already_sorted(): assert robotic_assistant(5, [1, 2, 3, 4, 5]) == 0 def test_reverse_sorted(): assert robotic_assistant(5, [5, 4, 3, 2, 1]) == 10 def test_with_duplicates()...
[ { "docstring": "Returns the minimum number of adjacent swaps needed to sort the array in non-decreasing order.", "function_declaration": "def minimum_adjacent_swaps(arr):", "function_name": "minimum_adjacent_swaps", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_swaps_to_sort(arr):\n \"\"\"\n Function to find the minimum number of swaps required to sort the array using adjacent swaps.\n \"\"\"\n n = len...
trial_gpt4o_1
{ "original_instruction": "A robotic assistant is tasked with arranging a row of books by their thickness. The assistant is given an array representing the thickness of each book in their current order, and it must determine the minimum number of swaps needed to arrange the books in non-decreasing order of their thic...
0.609487
Taco_6159
C
[ "minimum_adjacent_swaps", "robotic_assistant" ]
2
[ [ "robotic_assistant", "minimum_adjacent_swaps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
43eaf4b0d486673050ea45f2a94be521ecdf5d29
441f3793a374eeb5cab3a2c60be280969b181e06
v1.0
complete
Taco
Taco_6569_C
def is_prime(n: int) -> bool: """ Helper function to check if a number is prime. """ pass def hasPrimeSumPair(arr: List[int], N: int) -> int: """ Given an integer array A containing N distinct integers, determine if there exists a pair of elements in the array such that the sum of the pai...
import math def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def hasPrimeSumPair(arr, N): ...
from solution import hasPrimeSumPair def test_example_1(): assert hasPrimeSumPair([1, 4, 6, 7], 4) == 1 def test_example_2(): assert hasPrimeSumPair([1, 3, 5], 3) == 0 def test_prime_sum_pair_exists(): assert hasPrimeSumPair([2, 5, 8, 11], 4) == 1 def test_no_prime_sum_pair(): assert hasPrimeSumPair...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def hasPrimeSumPair(arr, N):", "function_name": "hasPrimeSumPair", "parameter_list": "(arr, N)" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime_number(num):\n \"\"\"\n Checks if a given number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "Given an integer array A containing N distinct integers, determine if there exists a pair of elements in the array such that the sum of the pair is a prime number. If such a pair exists, return 1 (True), otherwise return 0 (False).\n\nExample 1:\nInput: N = 4, A = [1, 4, 6, 7]\nOutput: 1\nE...
0.754901
Taco_6569
C
[ "is_prime", "hasPrimeSumPair" ]
2
[ [ "hasPrimeSumPair", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5e1eac471c642c9f2708e06943b157cfddadb9b1
68204c8dff98c37267241c509d4c541bb1ed3cd2
v1.0
complete
Taco
Taco_6505_C
def solve(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """ In a certain country, there are n cities and m direct, bidirectional flights connecting these cities. The cost of each flight between two cities is known. Your task is to select a subset of these flights such that every city is ...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot]...
def test_minimum_spanning_tree_example1(): n = 5 m = 6 edges = [(1, 2, 4), (1, 3, 2), (2, 3, 3), (3, 4, 5), (4, 5, 1), (3, 5, 6)] assert solve(n, m, edges) == 11 def test_minimum_spanning_tree_example2(): n = 4 m = 3 edges = [(1, 2, 3), (2, 3, 4), (3, 4, 5)] assert solve(n, m, edges) ==...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, ran...
trial_gpt4o_1
{ "original_instruction": "In a certain country, there are n cities and m direct, bidirectional flights connecting these cities. The cost of each flight between two cities is known. Your task is to select a subset of these flights such that every city is reachable from any other city (directly or indirectly) and the ...
0.668954
Taco_6505
C
[ "find", "union", "minimum_spanning_tree", "solve" ]
4
[ [ "minimum_spanning_tree", "find" ], [ "minimum_spanning_tree", "union" ], [ "solve", "minimum_spanning_tree" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
509a047debbd418a2e04f03fece44864a2f256aa
a450ada400cc188752602819bc1d99d012457caf
v1.0
complete
Taco
Taco_6512_C
def sum_of_digits(n): """ Helper function to calculate the sum of the digits of a number. """ return sum(int(digit) for digit in str(n)) def find_special_number(x): """ Given an integer x, find the smallest number y (y > x) such that: - y is divisible by 3 but not by 9 - the sum of digi...
def sum_of_digits(n): """ Helper function to calculate the sum of the digits of a number. """ return sum(int(digit) for digit in str(n)) def find_special_number(x): """ Given an integer x, find the smallest number y (y > x) such that: - y is divisible by 3 but not by 9 - the sum of digi...
from solution import find_special_number def test_find_special_number_case_1(): assert find_special_number(10) == 12 def test_find_special_number_case_2(): assert find_special_number(50) == 51 def test_find_special_number_case_boundary(): assert find_special_number(1) == 3 def test_find_special_number_l...
[ { "docstring": "Helper function to calculate the sum of the digits of a number.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Given an integer x, find the smallest number y (y > x) such that:\n- y is divisible ...
[ 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_divisible_by_3_not_9(n):\n \"\"\"\n Function to check if a number is divisible by 3 but not by 9.\n \"\"\"\n return n % 3 == 0 and n % 9 != 0\n\...
trial_gpt4o_2
{ "original_instruction": "John loves playing with numbers. Recently, he got fascinated with numbers that are divisible by 3 but not by 9. But John is also interested in a specific property: the sum of the digits of such numbers should also be divisible by 3 but not by 9.\n\nGiven an integer x, John wants to find the...
0.611186
Taco_6512
C
[ "sum_of_digits", "find_special_number" ]
2
[ [ "find_special_number", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8559a3413efe37330905730d70f5387104fbc056
15202c66bea1214745fb5199a9a88a611468476a
v1.0
complete
Taco
Taco_6890_C
def digital_root(n: int) -> int: """ Calculate the digital root of a number. >>> digital_root(942) 6 >>> digital_root(999999999) 9 >>> digital_root(5) 5 """ pass def magical_number(ages: List[int]) -> int: """ Calculate the magical number for the given ages of Fluffkin family me...
def digital_root(n): """ Calculate the digital root of a number. """ while n >= 10: n = sum(int(digit) for digit in str(n)) return n def magical_number(ages): """ Calculate the magical number for the given ages of Fluffkin family members. """ total_digital_root_sum = sum(dig...
from solution import digital_root, magical_number def test_digital_root_single_digit(): assert digital_root(5) == 5 def test_digital_root_multiple_iterations(): assert digital_root(942) == 6 assert digital_root(123) == 6 assert digital_root(456) == 6 assert digital_root(789) == 6 def test_digital...
[ { "docstring": "Calculate the digital root of a number.", "function_declaration": "def digital_root(n):", "function_name": "digital_root", "parameter_list": "(n)" }, { "docstring": "Calculate the magical number for the given ages of Fluffkin family members.", "function_declaration": "def...
[ 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 digital_root(n):\n \"\"\"\n Computes the digital root of a given number n.\n \"\"\"\n while n >= 10:\n n = sum(int(digit) for digit in str(n...
trial_gpt4o_1
{ "original_instruction": "In an enchanted forest, there are groups of magical creatures called Fluffkins who live in enchanted trees. Each Fluffkin family tree has a special number. The magical number is created by adding together the digital root of each member's age.\n\nThe digital root of a number is calculated b...
0.57533
Taco_6890
C
[ "digital_root", "magical_number" ]
2
[ [ "magical_number", "digital_root" ] ]
1
[]
false
[]
false
pytest
true
[]
true
579d09cc36827feca36c7a0848064d93beb2e55b
8b48f31467ff6a1316cd24db178d8662cf7a41c9
v1.0
complete
Taco
Taco_6483_C
def communication_network(m: int, d: int, coordinates: List[Tuple[int, int, int]]) -> int: """ Determines the number of connected components in the network of drones given the coordinates and distance threshold. >>> communication_network(4, 5, [(0, 0, 0), (3, 4, 0), (7, 1, 5), (2, 2, 2)]) 2 >>> communicatio...
import math def euclidean_distance(a, b): """ Calculates the Euclidean distance between two points a and b in 3D space. """ return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2 + (a[2] - b[2])**2) def find_connected_components(drones, distance_threshold): """ Finds the number of connected comp...
from solution import communication_network def test_case_1(): m, d = 4, 5 coordinates = [ (0, 0, 0), (3, 4, 0), (7, 1, 5), (2, 2, 2) ] assert communication_network(m, d, coordinates) == 2 def test_case_2(): m, d = 3, 3 coordinates = [ (1, 2, 3), ...
[ { "docstring": "Calculates the Euclidean distance between two points a and b in 3D space.", "function_declaration": "def euclidean_distance(a, b):", "function_name": "euclidean_distance", "parameter_list": "(a, b)" }, { "docstring": "Finds the number of connected components in the network of...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef find_connected_components(m, d, positions):\n def distance(drone1, drone2):\n return math.sqrt((drone1[0] - drone2[0])**2 + (drone1[1]...
trial_gpt4o_2
{ "original_instruction": "Alex is a robotics engineer working on a simulation for autonomous drones. Each drone within the simulation moves in a three-dimensional space. The coordinates are denoted as (x, y, z). Drones need to communicate with each other to form a network. \n\nEach drone can establish a communicatio...
0.560847
Taco_6483
C
[ "euclidean_distance", "find_connected_components", "communication_network" ]
3
[ [ "communication_network", "find_connected_components" ], [ "find_connected_components", "euclidean_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6fcff3826b3475bda3b1e3b3ec11357519b5cf0b
34a0bb739ccb65843331fef413059b45067bf535
v1.0
complete
Taco
Taco_6488_C
def minimum_travel_distance(n: int, roads: List[Tuple[int, int, int]], highways: List[Tuple[int, int, int]], s: int, d: int) -> int: """ In a country called Algorithmia, calculate the minimum distance needed to travel from the starting town to the destination town using both roads and highways. Pa...
import heapq def dijkstra(n, roads, highways, start, dest): graph = {i: [] for i in range(1, n+1)} for u, v, w in roads: graph[u].append((w, v)) graph[v].append((w, u)) for x, y, z in highways: graph[x].append((z, y)) graph[y].append((z, x)) distances = {i: float(...
from solution import minimum_travel_distance def test_simple_path_with_both_roads_and_highways(): roads = [ (1, 2, 4), (1, 3, 2), (2, 3, 1), (3, 4, 7), (2, 4, 3), (4, 5, 1) ] highways = [ (3, 5, 2), (1, 5, 8) ] assert minimum_travel_di...
[ { "docstring": null, "function_declaration": "def dijkstra(n, roads, highways, start, dest):", "function_name": "dijkstra", "parameter_list": "(n, roads, highways, start, dest)" }, { "docstring": null, "function_declaration": "def minimum_travel_distance(n, roads, highways, s, d):", ...
[ 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(graph, start, end):\n \"\"\"\n Use Dijkstra's algorithm to find the shortest path from start to end.\n \"\"\"\n n = len(gr...
trial_gpt4o_1
{ "original_instruction": "In a country called Algorithmia, there are n towns connected by m bidirectional roads. Some of these roads are highways, while others are regular roads. Highways are faster and thus more preferable to use.\n\nYou are given the information about Algorithmia in two arrays, `R` and `H`, both o...
0.79091
Taco_6488
C
[ "dijkstra", "minimum_travel_distance" ]
2
[ [ "minimum_travel_distance", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
19deee8609c37993bfab458dc8a5fe130fb6b21f
cf6563d2907ed8ca8a9f41ab5eb4efd6f89c053e
v1.0
complete
Taco
Taco_6320_C
def merge_intervals(intervals: List[List[int]]) -> List[List[int]]: """ Merge overlapping intervals and return the merged intervals sorted by starting times. :param intervals: List of intervals where each interval is a list of two integers [start, end) :return: List of merged intervals >>>...
def merge_intervals(intervals): """ Merge overlapping intervals and return the merged intervals sorted by starting times. :param intervals: List of intervals where each interval is a list of two integers [start, end) :return: List of merged intervals """ if not intervals: return [] ...
from solution import merge_intervals, read_and_merge_intervals def test_merge_intervals_case1(): intervals = [[1, 3], [2, 4], [5, 7]] result = merge_intervals(intervals) assert result == [[1, 4], [5, 7]] def test_merge_intervals_case2(): intervals = [[1, 2], [2, 3], [3, 4], [5, 6], [7, 8]] result ...
[ { "docstring": "Merge overlapping intervals and return the merged intervals sorted by starting times.\n\n:param intervals: List of intervals where each interval is a list of two integers [start, end)\n:return: List of merged intervals", "function_declaration": "def merge_intervals(intervals):", "functio...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_intervals(intervals):\n \"\"\"\n Merges overlapping intervals and returns a list of non-overlapping intervals.\n \n :param intervals: List of...
trial_gpt4o_2
{ "original_instruction": "A company has a scheduling system for their employees but recently encountered difficulties in managing overlapping shifts. To resolve this, they decided to write a program that can automatically merge overlapping intervals of employee shifts and come up with a new schedule that has only no...
0.617504
Taco_6320
C
[ "merge_intervals", "read_and_merge_intervals" ]
2
[ [ "read_and_merge_intervals", "merge_intervals" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54888f784ed67cc1cdbce0cf0e4582e9ebab31c5
2fa6873b49570aabf2df6e702d92960a19516b16
v1.0
complete
Taco
Taco_6461_C
def is_prime(num): """Returns True if num is a prime number, False otherwise. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(1) False >>> is_prime(0) False >>> is_prime(29) True >>> is_prime(30) False """ def sum_of_primes(arr):...
def is_prime(num): """ Returns True if num is a prime number, False otherwise. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(29) == True assert is_prime(30) == False...
[ { "docstring": "Returns True if num is a prime number, False otherwise.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers in the given array arr.", "function_declaration": "def su...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, False otherwise.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_0
{ "original_instruction": "Given an array a_1, a_2, ..., a_{n} of n integers, find the sum of all the prime numbers in the array.\n\nA number x is said to be a prime number if it is greater than 1 and has no positive divisors other than 1 and itself.\n\n\n-----Input-----\n\nThe first line contains a single integer n ...
0.791413
Taco_6461
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
393b9d2d8a7e3fe24e63483ff7c9921ae63e8510
a69c1be542289c3fa4a05f99d28e0d1108853025
v1.0
complete
Taco
Taco_5786_C
def final_position(commands): """ Determine the robot's final position after executing a series of commands. :param commands: List of strings representing the commands. :return: A tuple of integers representing the final x, y coordinates of the robot. """ pass def process_commands(commands...
def final_position(commands): """ Determine the robot's final position after executing a series of commands. :param commands: List of strings representing the commands. :return: A tuple of integers representing the final x, y coordinates of the robot. """ position = (0, 0) for comm...
from solution import final_position, process_commands def test_example_1(): commands = [ "5", "Move 1 2", "Move 3 4", "Return", "Move -1 -1", "Move 5 5" ] assert process_commands(commands) == "5 5" def test_example_2(): commands = [ "3", ...
[ { "docstring": "Determine the robot's final position after executing a series of commands.\n\n:param commands: List of strings representing the commands.\n:return: A tuple of integers representing the final x, y coordinates of the robot.", "function_declaration": "def final_position(commands):", "functi...
[ 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 final_robot_position(commands):\n \"\"\"\n Determines the final position of the robot on the grid after the given series of commands.\n \n Args:\n ...
trial_gpt4o_2
{ "original_instruction": "Problem\n\nYou have been tasked to help a number-moving robot that operates on a grid to return to its home base after a series of commands. The robot starts at the origin of the grid (0, 0).\n\nThe robot receives two types of instructions:\n\n1. \"Move x y\": This command tells the robot t...
0.535475
Taco_5786
C
[ "final_position", "process_commands" ]
2
[ [ "process_commands", "final_position" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5703c96613e8a2bdfbf019793f85c3d4f0873fae
15feb05c1f4c9460a63cb879889e966fed677557
v1.0
complete
Taco
Taco_11760_C
from typing import List def can_be_uniform(s: str) -> bool: """ Checks if the string can be rearranged such that every character appears the same number of times. >>> can_be_uniform('aabbcc') True >>> can_be_uniform('aaabbc') False >>> can_be_uniform('aabccc') False """ def check_unifo...
def can_be_uniform(s): """ Checks if the string can be rearranged such that every character appears the same number of times. """ from collections import Counter counts = Counter(s) values = list(counts.values()) return all(x == values[0] for x in values) def check_uniformity(test_cases): ...
from solution import can_be_uniform, check_uniformity def test_can_be_uniform(): assert can_be_uniform('aabbcc') == True assert can_be_uniform('aaabbc') == False assert can_be_uniform('aabccc') == False assert can_be_uniform('abcabc') == True assert can_be_uniform('aaa') == True assert can_be_u...
[ { "docstring": "Checks if the string can be rearranged such that every character appears the same number of times.", "function_declaration": "def can_be_uniform(s):", "function_name": "can_be_uniform", "parameter_list": "(s)" }, { "docstring": "Given a list of test cases, returns a list of \...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef can_be_uniform(s):\n \"\"\"\n Checks if a given string can be rearranged such that each character appears the same num...
trial_gpt4o_2
{ "original_instruction": "Mina loves strings. She always tries to find interesting patterns in the strings she receives from her friends. One day, she noticed that some strings could be made uniform by changing the order of their characters. A string is considered uniform if every character appears the same number o...
0.615046
Taco_11760
C
[ "can_be_uniform", "check_uniformity" ]
2
[ [ "check_uniformity", "can_be_uniform" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a633c29de3e15409ec14fc983ee6bad4709e3e12
a5c7280149075976585316a34ee0c63a51128c4d
v1.0
complete
Taco
Taco_11667_C
def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True """ def prime_diff(nums: List[int]) -> int: """ Given an integer array nums, return the difference between the largest and smallest prime numbers contained in the a...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def prime_diff(nums): primes = [num for num in num...
from solution import is_prime, prime_diff def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False def test_prime_diff_example1(): nums = [10, 15, 3, 7, 19] assert prime_diff(nums) == 16 ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_diff(nums):", "function_name": "prime_diff", "parameter_list": "(nums)" } ]
[ 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_prime(n):\n \"\"\"\n Check if a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return Tr...
trial_gpt4o_2
{ "original_instruction": "Given an integer array nums, return the difference between the largest and smallest prime numbers contained in the array. If the array contains fewer than 2 prime numbers, return -1.\n\nExample 1:\nInput: nums = [10, 15, 3, 7, 19]\nOutput: 16\nExplanation:\nThe prime numbers in the array ar...
0.746908
Taco_11667
C
[ "is_prime", "prime_diff" ]
2
[ [ "prime_diff", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
744f6e18684ae6a7dc630ecb9e4859f93b0ee982
bda53d638375e294a37b65fa0b5b190dfd2c8c81
v1.0
complete
Taco
Taco_6576_C
def prepare_prefix_sums(shelves): """ Prepare the prefix sums for the books on the shelves. >>> prepare_prefix_sums([4, 5, 3, 2, 6]) [4, 9, 12, 14, 20] """ def total_books_in_range(prefix_sums, left, right): """ Calculate the total number of books in the range l to r (1-based index). >>...
def prepare_prefix_sums(shelves): """ Prepare the prefix sums for the books on the shelves. """ prefix_sums = [0] * len(shelves) prefix_sums[0] = shelves[0] for i in range(1, len(shelves)): prefix_sums[i] = prefix_sums[i - 1] + shelves[i] return prefix_sums def total_books...
def test_prepare_prefix_sums(): assert prepare_prefix_sums([4, 5, 3, 2, 6]) == [4, 9, 12, 14, 20] def test_total_books_in_range(): prefix_sums = [4, 9, 12, 14, 20] assert total_books_in_range(prefix_sums, 1, 3) == 12 assert total_books_in_range(prefix_sums, 2, 5) == 16 assert total_books_in_range(p...
[ { "docstring": "Prepare the prefix sums for the books on the shelves.", "function_declaration": "def prepare_prefix_sums(shelves):", "function_name": "prepare_prefix_sums", "parameter_list": "(shelves)" }, { "docstring": "Calculate the total number of books in the range l to r (1-based index...
[ 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 books_in_range(N, Q, books, queries):\n \"\"\"\n Returns the total number of books in the given range of shelves for each query.\n \n Parameters:\n...
trial_gpt4o_2
{ "original_instruction": "Alex is a librarian and needs to help a student, Charlie, retrieve books from a series of shelves. Each shelf has a number of books, and Charlie wants to inquire about a specific range of books across multiple shelves.\n\nYou need to write a function that efficiently handles multiple querie...
0.604701
Taco_6576
C
[ "prepare_prefix_sums", "total_books_in_range", "books_query" ]
3
[ [ "books_query", "prepare_prefix_sums" ], [ "books_query", "total_books_in_range" ] ]
2
[]
false
[]
false
pytest
false
[]
true
a24c1161f61c0f5c0f2c985f46e8ae07294318e0
d5da4c86f72eed3c7af7048f190feb9e284d8bcf
v1.0
complete
Taco
Taco_6239_C
def are_chambers_connected(n: int, tunnels: List[Tuple[int, int]], queries: List[Tuple[int, int]]) -> List[str]: """ Determines if each given pair of chambers is connected directly or indirectly by the tunnels. Args: n (int): The number of chambers. tunnels (List[Tuple[int, int]]): List of tuples r...
def find_connected_components(n, tunnels): from collections import defaultdict, deque # Create adjacency list adjacency_list = defaultdict(list) for a, b in tunnels: adjacency_list[a].append(b) adjacency_list[b].append(a) # To keep track of visited nodes and components ...
def test_are_chambers_connected(): n = 3 tunnels = [(1, 2), (2, 3)] queries = [(1, 2), (1, 3), (2, 3)] assert are_chambers_connected(n, tunnels, queries) == ["YES", "YES", "YES"] n = 4 tunnels = [(1, 2), (2, 3), (3, 4), (4, 1), (1, 3), (2, 4)] queries = [(1, 3), (2, 4), (1, 4)] asse...
[ { "docstring": null, "function_declaration": "def find_connected_components(n, tunnels):", "function_name": "find_connected_components", "parameter_list": "(n, tunnels)" }, { "docstring": null, "function_declaration": "def are_chambers_connected(n, tunnels, queries):", "function_name...
[ 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 dfs(graph, start, visited):\n stack = [start]\n while stack:\n node = stack.pop()\n if not visited[node]:\n visited[node] = True...
trial_gpt4o_1
{ "original_instruction": "A group of archaeologists has discovered an ancient and complex system of interconnected underground tunnels. Each tunnel connects two chamber entrances, and the chambers are numbered 1 through $N$. To prevent getting lost, the archaeologists want to know if it's possible to travel from one...
0.540493
Taco_6239
C
[ "find_connected_components", "are_chambers_connected" ]
2
[ [ "are_chambers_connected", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
false
[]
true
20a3089d1663366d0032381f41df630630876754
b030f520612586b7f50603153bbecc7cbb151f26
v1.0
complete
Taco
Taco_11616_C
def largest_rectangle_area(histogram): """ Calculates the largest rectangular area that can be obtained from a histogram. >>> largest_rectangle_area([2, 1, 5, 6, 2, 3]) 10 >>> largest_rectangle_area([4, 2]) 4 >>> largest_rectangle_area([]) 0 >>> largest_rectangle_area([1]) 1 >>> largest_rect...
def largest_rectangle_area(histogram): """ Calculates the largest rectangular area that can be obtained. """ stack = [] max_area = 0 index = 0 while index < len(histogram): if not stack or histogram[stack[-1]] <= histogram[index]: stack.append(index) inde...
from solution import process_histogram_input, largest_rectangle_area def test_largest_rectangle_area(): assert largest_rectangle_area([2, 1, 5, 6, 2, 3]) == 10 assert largest_rectangle_area([4, 2]) == 4 assert largest_rectangle_area([]) == 0 assert largest_rectangle_area([1]) == 1 assert largest_re...
[ { "docstring": "Calculates the largest rectangular area that can be obtained.", "function_declaration": "def largest_rectangle_area(histogram):", "function_name": "largest_rectangle_area", "parameter_list": "(histogram)" }, { "docstring": "Processes multiple datasets of histograms and return...
[ 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 largest_rectangle_area(histogram):\n \"\"\"\n Computes the largest rectangular area in a histogram.\n :param histogram: List[int] - List of integers r...
trial_gpt4o_4
{ "original_instruction": "Create a program to determine the largest rectangular area that can be obtained from a histogram. A histogram is represented by a list of integers where each integer represents the height of a bar. The width of each bar is 1.\n\nInput\n\nThe input consists of multiple data sets. Each data s...
0.588316
Taco_11616
C
[ "largest_rectangle_area", "process_histogram_input" ]
2
[ [ "process_histogram_input", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6fd867d48c489ec55b71a942874f09b5f522fb1d
143b2a2f62ae94be556efa0d179d50221b4f356d
v1.0
complete
Taco
Taco_12081_C
def is_power_of_two(n): """ Determines if a number is a power of two. >>> is_power_of_two(1) True >>> is_power_of_two(2) True >>> is_power_of_two(3) False """ def longestPowerOfTwoSubsequence(arr): """ Returns the length of the longest subsequence where each element is a power of two. >...
def is_power_of_two(n): """ Helper function to determine if a number is a power of two. """ return (n & (n - 1)) == 0 and n != 0 def longestPowerOfTwoSubsequence(arr): """ Returns the length of the longest subsequence where each element is a power of two. """ return sum(1 for x in arr i...
from solution import is_power_of_two, longestPowerOfTwoSubsequence def test_is_power_of_two(): assert is_power_of_two(1) == True assert is_power_of_two(2) == True assert is_power_of_two(4) == True assert is_power_of_two(8) == True assert is_power_of_two(16) == True assert is_power_of_two(32) ==...
[ { "docstring": "Helper function to determine if a number is a power of two.", "function_declaration": "def is_power_of_two(n):", "function_name": "is_power_of_two", "parameter_list": "(n)" }, { "docstring": "Returns the length of the longest subsequence where each element is a power of two."...
[ 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 longestPowerOfTwoSubsequence(arr):\n \"\"\"\n Returns the length of the longest subsequence where each element is a power of two.\n \"\"\"\n def is...
trial_gpt4o_3
{ "original_instruction": "Given an array of integers, find the length of the longest subsequence such that each element in the subsequence is a power of two. \nExample 1:\nInput: arr = [1, 8, 4, 16, 2, 32]\nOutput: 5\nExplanation: The longest subsequence composed of powers of two is [1, 2, 4, 8, 16].\nExample 2:\nIn...
0.688334
Taco_12081
C
[ "is_power_of_two", "longestPowerOfTwoSubsequence" ]
2
[ [ "longestPowerOfTwoSubsequence", "is_power_of_two" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a8f2c9f618736f65680c7b2d2766bab49122306d
3650ee7dd9e416aa160db8ebf10975353f91f352
v1.0
complete
Taco
Taco_7152_C
from typing import List, Tuple def count_groups(n: int, m: int, pairs: List[Tuple[int, int]]) -> int: """ Given the number of residents and unique interests along with pairs of residents sharing common interests, determine the number of distinct groups that can be formed where all participants in each grou...
def find(parent, x): if parent[x] != x: parent[x] = find(parent, parent[x]) return parent[x] def union(parent, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: parent[rootX] = rootY def count_groups(n, m, pairs): parent = [i for i in range(n + 1)] ...
from solution import count_groups def test_example_1(): assert count_groups(5, 4, [(1, 2), (2, 3), (4, 5), (3, 4)]) == 1 def test_example_2(): assert count_groups(5, 3, [(1, 2), (2, 3), (4, 5)]) == 2 def test_no_pairs(): assert count_groups(5, 0, []) == 5 def test_single_pair(): assert count_groups(...
[ { "docstring": null, "function_declaration": "def find(parent, x):", "function_name": "find", "parameter_list": "(parent, x)" }, { "docstring": null, "function_declaration": "def union(parent, x, y):", "function_name": "union", "parameter_list": "(parent, x, y)" }, { "doc...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_groups(n, m, connections):\n \"\"\"\n Find the number of distinct groups formed based on shared interests.\n \n :param n: Number of residents\...
trial_gpt4o_2
{ "original_instruction": "In a remote town, the residents have an unusual habit of forming groups for any activity they plan, always ensuring that all participants in each group share a common interest. The number of interests and individuals in the town is vast and varied.\n\nGiven an integer $n$ representing the n...
0.62931
Taco_7152
C
[ "find", "union", "count_groups" ]
3
[ [ "count_groups", "find" ], [ "count_groups", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e660ce4bd3828e49b21e414373ca120dc74b2f6b
57e8b48b230cdc1cc7e3802b7df65b1544065800
v1.0
complete
Taco
Taco_11923_C
def palindrome_partitions(s: str): """ Returns all possible ways to partition 's' such that each substring is a palindrome. >>> palindrome_partitions("a") [["a"]] >>> palindrome_partitions("aa") [["a", "a"], ["aa"]] >>> palindrome_partitions("ab") [["a", "b"]] >>> palindrome_pa...
def is_palindrome(s): """ Helper function to check if a given string 's' is a palindrome. """ return s == s[::-1] def palindrome_partitions(s): """ Returns all possible ways to partition 's' such that each substring is a palindrome. """ def backtrack(start, path): if start == le...
from solution import palindrome_partitions def test_single_character(): assert palindrome_partitions("a") == [["a"]] def test_two_characters_all_same(): assert palindrome_partitions("aa") == [["a", "a"], ["aa"]] def test_two_characters_different(): assert palindrome_partitions("ab") == [["a", "b"]] def ...
[ { "docstring": "Helper function to check if a given string 's' is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns all possible ways to partition 's' such that each substring is a palindrome....
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n return s == s[::-1]\n\ndef palindrome_partitions(s):\n result = []\n def backtrack(start, path):\n if start == len(s):\n ...
trial_gpt4o_2
{ "original_instruction": "# Palindrome Partitioning\n\nWrite a function `palindrome_partitions` (or `palindromePartitions`/`PalindromePartitions` depending on language rules) that, given a string `s`, returns all possible ways to partition `s` such that each substring is a palindrome.\n\n### Example\nFor `s = \"aab\...
0.723469
Taco_11923
C
[ "is_palindrome", "palindrome_partitions" ]
2
[ [ "palindrome_partitions", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f9b6fd769075af7de7472600c56c09aee6d75705
e91f16e09ca029a4431d7805533350d001546166
v1.0
complete
Taco
Taco_7190_C
def is_palindrome(n: int) -> bool: """ Check if a given number is a palindrome. >>> is_palindrome(121) True >>> is_palindrome(123) False >>> is_palindrome(1221) True >>> is_palindrome(12321) True >>> is_palindrome(10) False """ def count_palindromic_numbers_in_r...
def is_palindrome(n): """ Check if a given number is a palindrome. """ return str(n) == str(n)[::-1] def count_palindromic_numbers_in_range(L, R): """ Count the number of palindromic and non-palindromic numbers in the range [L, R]. """ palindromic_count = 0 non_palindromic_count = 0...
from solution import is_palindrome, count_palindromic_numbers_in_range, process_test_cases def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1221) == True assert is_palindrome(12321) == True assert is_palindrome(10) == False def tes...
[ { "docstring": "Check if a given number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Count the number of palindromic and non-palindromic numbers in the range [L, R].", "function_declaratio...
[ 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 is_palindromic(n):\n \"\"\"\n Checks if a number n is palindromic.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef count_palindromic_numbers(L, R):...
trial_gpt4o_7
{ "original_instruction": "John loves playing with numbers and recently found the concept of palindromic numbers fascinating. A palindromic number is a number that remains the same when its digits are reversed.\n\nJohn came up with a challenging game. Given a range [L, R], he wants to find out how many numbers in tha...
0.716075
Taco_7190
C
[ "is_palindrome", "count_palindromic_numbers_in_range", "process_test_cases" ]
3
[ [ "count_palindromic_numbers_in_range", "is_palindrome" ], [ "process_test_cases", "count_palindromic_numbers_in_range" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
ac2844c02e9b3a5702ca44fa56896477a21040f5
980d9923d37edc3058d652eb7f90881e76132760
v1.0
complete
Taco
Taco_12735_C
def generate_transformations(s: str) -> List[str]: """ Transform each digit in the string to its corresponding letter and return all possible transformations in lexicographical order. >>> generate_transformations("2") ["2", "c"] >>> generate_transformations("a") ["a"] >>> generate_transformation...
def digit_to_letter(digit): return chr(ord('a') + int(digit)) def generate_transformations(s): transformations = {s} for i, char in enumerate(s): if char.isdigit(): new_transformations = set() for transformation in transformations: new_transformations.ad...
from solution import generate_transformations def test_single_digit(): assert generate_transformations("2") == ["2", "c"] def test_single_non_digit(): assert generate_transformations("a") == ["a"] def test_combined_string_1(): assert generate_transformations("2a4") == ["2a4", "2ae", "ca4", "cae"] def te...
[ { "docstring": null, "function_declaration": "def digit_to_letter(digit):", "function_name": "digit_to_letter", "parameter_list": "(digit)" }, { "docstring": null, "function_declaration": "def generate_transformations(s):", "function_name": "generate_transformations", "parameter_...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def transform_string(s: str):\n corresponding_letters = [\n 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'\n ]\n\n possible_transformations = set...
trial_gpt4o_6
{ "original_instruction": "You are given a string consisting of digits (0-9) and lowercase letters (a-z). Each digit can be transformed into a corresponding letter where 0 corresponds to 'a', 1 to 'b', ..., and 9 to 'j'. Your task is to find all possible transformations of the given string and return them in lexicogr...
0.704183
Taco_12735
C
[ "digit_to_letter", "generate_transformations" ]
2
[ [ "generate_transformations", "digit_to_letter" ] ]
1
[]
false
[]
false
pytest
true
[]
true
497a5a397367eec7922f239970af1a144acf8fbb
5d14f36f9a9259d37670928843d7862cb37c2c81
v1.0
complete
Taco
Taco_13106_C
def is_valid_sequence(sequence: str) -> str: """ Checks if the sequence adheres to the kingdom's rules: - Must start with a non-zero digit. - Length must be a prime number. - Should not be a palindrome. >>> is_valid_sequence("239") "VALID" >>> is_valid_sequence("12321") "INVALID...
def is_prime(n): """ Helper function to check if a number is prime """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 r...
from solution import is_valid_sequence def test_valid_sequence(): assert is_valid_sequence("239") == "VALID" assert is_valid_sequence("1234567") == "VALID" def test_starts_with_zero(): assert is_valid_sequence("012345") == "INVALID" def test_non_prime_length(): assert is_valid_sequence("1234") == "IN...
[ { "docstring": "Helper function to check if a number is prime ", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Checks if the sequence adheres to the kingdom's rules:\n- Must start with a non-zero digit.\n- Length must be a...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if...
trial_gpt4o_8
{ "original_instruction": "In an ancient kingdom, the citizens communicate using a special numerical code. This code consists of sequences of digits from 0 to 9. However, not all sequences are valid; a valid sequence follows these specific rules:\n- The sequence must start with a non-zero digit.\n- The length of the ...
0.599687
Taco_13106
C
[ "is_prime", "is_valid_sequence" ]
2
[ [ "is_valid_sequence", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4caef869ba742d8a41382cc4c2e63850134e246d
26055e885a506d093c8f9bc0fb5de41cf5ddd096
v1.0
complete
Taco
Taco_5165_C
from typing import List def complete_sudoku(grid: List[List[int]]) -> List[List[int]]: """ Complete the given incomplete Sudoku grid. Args: grid (List[List[int]]): N × N Sudoku grid with 0 representing empty cells. Returns: List[List[int]]: A valid complete grid that satisfies all Sudoku ...
def is_valid(board, num, pos): n = len(board) sqrt_n = int(n**0.5) row, col = pos # Check row for j in range(n): if board[row][j] == num and col != j: return False # Check column for i in range(n): if board[i][col] == num and row != i: return...
import pytest from solution import complete_sudoku def test_example(): grid = [ [1, 0, 3, 4], [4, 3, 2, 1], [2, 1, 4, 3], [3, 4, 1, 0] ] result = complete_sudoku(grid) assert result == [ [1, 2, 3, 4], [4, 3, 2, 1], [2, 1, 4, 3], [3, 4, 1, ...
[ { "docstring": null, "function_declaration": "def is_valid(board, num, pos):", "function_name": "is_valid", "parameter_list": "(board, num, pos)" }, { "docstring": null, "function_declaration": "def find_empty(board):", "function_name": "find_empty", "parameter_list": "(board)" ...
[ 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_valid(board, num, pos):\n n = len(board)\n sqrt_n = int(n**0.5)\n row, col = pos\n \n # Check row\n for j in range(n):\n if board[r...
trial_gpt4o_0
{ "original_instruction": "You are given a special kind of Sudoku problem on an N×N grid, where N is a perfect square. Each entry in the grid is either a number from 1 to N or an empty cell represented by 0. The objective is to complete the grid such that:\n1. Each row contains all numbers from 1 to N exactly once.\n...
0.514899
Taco_5165
C
[ "is_valid", "find_empty", "solve_sudoku", "complete_sudoku" ]
4
[ [ "complete_sudoku", "solve_sudoku" ], [ "solve_sudoku", "find_empty" ], [ "solve_sudoku", "is_valid" ] ]
3
[]
false
[]
false
pytest
true
[]
true
eba9609c49da8bbb5cfb78f625d8fc99986ed723
e02ef77412f19f08229d14ca5cd2a6f485faa008
v1.0
complete
Taco
Taco_12430_C
def find_min_diff_groups(arr): """ You are given an array of integers. Your task is to form two groups such that the absolute difference between the sums of the two groups is minimized. The solution must ensure that every element from the array belongs to exactly one group. Args: arr: List[int] - ...
from itertools import combinations def find_min_diff_groups(arr): total_sum = sum(arr) n = len(arr) min_diff = float('inf') best_group1 = [] best_group2 = [] for size in range(n // 2 + 1): for combo in combinations(arr, size): group1_sum = sum(combo) group2_sum ...
import pytest from solution import find_min_diff_groups, process_test_cases def test_find_min_diff_groups(): group1, group2 = find_min_diff_groups([1, 6, 5, 11]) assert abs(sum(group1) - sum(group2)) == 1 group1, group2 = find_min_diff_groups([10, 20, 15]) assert abs(sum(group1) - sum(group2)) == ...
[ { "docstring": null, "function_declaration": "def find_min_diff_groups(arr):", "function_name": "find_min_diff_groups", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def process_test_cases(test_cases):", "function_name": "process_test_cases", "paramet...
[ 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 find_partition(n, arr):\n \"\"\"\n Function to partition the array into two groups with minimal\n absolute difference between their sums.\n \"\"\"\...
trial_gpt4o_3
{ "original_instruction": "You are given an array of integers. Your task is to form two groups such that the absolute difference between the sums of the two groups is minimized.\n\nIf there are multiple ways to achieve this, print any of them. The solution must ensure that every element from the array belongs to exac...
0.674161
Taco_12430
C
[ "find_min_diff_groups", "process_test_cases", "solve" ]
3
[ [ "process_test_cases", "find_min_diff_groups" ], [ "solve", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
e70b11071e60e5f7bffa20e605a6be859b276774
f6c7a2c1d7f869647d4494d7f692862760301dde
v1.0
complete
Taco
Taco_13698_C
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ # Your code here def sum_primes_up_to(n): """ Returns the sum of all prime numbers from 1 to n (inclusive). >>> sum_primes_up_to(10) 17 >>> sum_primes_up_to(1) 0 >>> sum_primes_up_to(2) 2 ...
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def sum_primes_up_to(n): """ Returns the sum of all prime numbers fro...
from solution import sum_primes_up_to def test_sum_primes_up_to_10(): assert sum_primes_up_to(10) == 17 # Primes are 2, 3, 5, 7 def test_sum_primes_up_to_1(): assert sum_primes_up_to(1) == 0 # No prime numbers between 1 to 1 def test_sum_primes_up_to_2(): assert sum_primes_up_to(2) == 2 # Primes are 2...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers from 1 to n (inclusive).", "function_declaration": "def s...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n retu...
trial_gpt4o_2
{ "original_instruction": "-----Input-----\n\nThe input contains a single integer $n$ ($1 \\le n \\le 100$).\n\n\n-----Output-----\n\nOutput the sum of all prime numbers from 1 to $n$ (inclusive).\n\n\n-----Example-----\nInput\n10\n\nOutput\n17", "prompt_id": "00013698", "row_id": 13698, "seed_ids": "[14708]" }
0.833025
Taco_13698
C
[ "is_prime", "sum_primes_up_to" ]
2
[ [ "sum_primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dd9b2ba4560459f699e0088fea0771ae336d765d
15a8334829aa26a5cca4b070f870e49a08e05702
v1.0
complete
Taco
Taco_7369_C
from typing import List def smallest_missing_integer(lst: List[int]) -> int: """ Find the smallest missing integer from the list. >>> smallest_missing_integer([3, 1, 6]) == 2 >>> smallest_missing_integer([1, 2, 3, 4, 5, 6, 7]) == 8 >>> smallest_missing_integer([1, 3, 4, 5]) == 2 """ def generate_s...
def smallest_missing_integer(lst): i = 1 while True: if i not in lst: return i i += 1 def generate_sequence(initial_list, M): while len(initial_list) < M: missing = smallest_missing_integer(initial_list) initial_list.append(missing) return initial_list def s...
def test_smallest_missing_integer(): assert smallest_missing_integer([3, 1, 6]) == 2 assert smallest_missing_integer([1, 2, 3, 4, 5, 6, 7]) == 8 assert smallest_missing_integer([1, 3, 4, 5]) == 2 def test_generate_sequence(): assert generate_sequence([3, 1, 6], 8) == [3, 1, 6, 2, 4, 5, 7, 8] assert...
[ { "docstring": null, "function_declaration": "def smallest_missing_integer(lst):", "function_name": "smallest_missing_integer", "parameter_list": "(lst)" }, { "docstring": null, "function_declaration": "def generate_sequence(initial_list, M):", "function_name": "generate_sequence", ...
[ 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_missing_integer(seq):\n num_set = set(seq)\n smallest_int = 1\n while smallest_int in num_set:\n smallest_int += 1\n return smallest_in...
trial_gpt4o_2
{ "original_instruction": "#### Coding Assessment Question\n\nChef loves to play with numbers, and he recently came across an interesting sequence problem. The problem involves generating a sequence from a given set of integers and determining specific sequence properties. The sequence in question is created as follo...
0.702712
Taco_7369
C
[ "smallest_missing_integer", "generate_sequence", "sum_of_first_n_integers", "solve_chef_problem" ]
4
[ [ "generate_sequence", "smallest_missing_integer" ], [ "solve_chef_problem", "generate_sequence" ], [ "solve_chef_problem", "sum_of_first_n_integers" ] ]
3
[]
false
[]
false
pytest
false
[]
true
816a792b5e9a6bb5095ae7b2f57fe3c177cd70fb
fbcb24fd3a1a2a62a7e65affbeca3ad760ffa467
v1.0
complete
Taco
Taco_11910_C
import numpy as np def euclidean_distance(p1, p2): return np.sqrt(np.sum((np.array(p1) - np.array(p2)) ** 2)) def k_means_clustering(plants, k): """ Cluster the plants into k clusters based on their preferences using k-means algorithm. Args: plants (list of tuples): List of plants' preference...
import numpy as np def euclidean_distance(p1, p2): return np.sqrt(np.sum((np.array(p1) - np.array(p2)) ** 2)) def k_means_clustering(plants, k): centroids = plants[:k] prev_centroids = [[None, None, None]] * k while centroids != prev_centroids: clusters = [[] for _ in range(k)] for pla...
from solution import k_means_clustering def test_k_means_clustering_simple(): plants = [(3, 5, 1), (10, 10, 10), (2, 3, 2), (11, 11, 10), (4, 5, 1), (9, 9, 9)] k = 2 clusters = k_means_clustering(plants, k) # Both clusters should have 3 plants each assert len(clusters) == 2 assert len(clus...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def k_means_clustering(plants, k):", "function_name": "k_means_clustering", "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 numpy as np\n\ndef euclidean_distance(p1, p2):\n return np.sqrt(np.sum((np.array(p1) - np.array(p2)) ** 2))\n\ndef k_means_clustering(plants, k):\n ce...
trial_gpt4o_0
{ "original_instruction": "Alex, an avid gardener, decides to organize the various plants in his garden into clusters to manage them better and make his daily watering routine easier. Each plant in his garden has a unique preference for water, light, and soil type, represented as tuples with three integers: `(water, ...
0.692718
Taco_11910
C
[ "euclidean_distance", "k_means_clustering", "print_clusters", "main" ]
4
[ [ "k_means_clustering", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
553e511aae7bf94e643d4b9e2a085597c795bcf8
2a90085c5d77c67e59e91aa8080ab27a8256ec73
v1.0
complete
Taco
Taco_13225_C
def check_pair_with_difference(n, k, arr): """ Determines if there exist two distinct elements in the array whose difference is exactly k. >>> check_pair_with_difference(5, 4, [1, 5, 9, 13, 17]) == "YES" >>> check_pair_with_difference(4, 100, [1, 2, 3, 4]) == "NO" >>> check_pair_with_difference(3, 0...
def has_pair_with_difference(arr, k): """ Determines if there exist two distinct elements in the array whose difference is exactly k. """ elements = set() for num in arr: if (num + k) in elements or (num - k) in elements: return "YES" elements.add(num) return "NO" # ...
from solution import check_pair_with_difference def test_example_case_1(): assert check_pair_with_difference(5, 4, [1, 5, 9, 13, 17]) == "YES" def test_example_case_2(): assert check_pair_with_difference(4, 100, [1, 2, 3, 4]) == "NO" def test_no_difference_k(): assert check_pair_with_difference(3, 0, [1,...
[ { "docstring": "Determines if there exist two distinct elements in the array whose difference is exactly k.", "function_declaration": "def has_pair_with_difference(arr, k):", "function_name": "has_pair_with_difference", "parameter_list": "(arr, k)" }, { "docstring": null, "function_decla...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def has_pairs_with_difference_k(arr, k):\n \"\"\"\n Determines if there exist two distinct elements in the array whose difference is exactly k.\n \n Pa...
trial_gpt4o_2
{ "original_instruction": "You are given an array of $n$ integers and an integer $k$. Determine if there exist two distinct elements in the array whose difference is exactly $k$.\n\n-----Input-----\n\nThe first line contains two integers $n$ ($2 \\leq n \\leq 10^5$) and $k$ ($0 \\leq k \\leq 10^9$).\n\nThe second lin...
0.719834
Taco_13225
C
[ "has_pair_with_difference", "check_pair_with_difference" ]
2
[ [ "check_pair_with_difference", "has_pair_with_difference" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ab4312b2a144981d9c42e0e15ff770dbd4c94fd1
54c78b79470307b5d9d559bc07dcb0e1383a3885
v1.0
complete
Taco
Taco_12831_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def insert_into_bst(root, value): if root is None: return TreeNode(value) elif value < root.value: root.left = insert_into_bst(root.left, value) else: root.ri...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def insert_into_bst(root, value): if root is None: return TreeNode(value) elif value < root.value: root.left = insert_into_bst(root.left, value) else: root.ri...
from solution import height_of_bst def test_height_of_bst_example1(): assert height_of_bst(9, [5, 3, 8, 1, 4, 7, 10, 2, 9]) == 3 def test_height_of_bst_example2(): assert height_of_bst(5, [10, 5, 15, 4, 6]) == 2 def test_height_of_bst_single_node(): assert height_of_bst(1, [42]) == 0 def test_height_of_...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_1
{ "original_instruction": "Alice has recently learned about binary search trees (BST) in her data structures class. A binary search tree is a binary tree in which for each node, the value of all the nodes in the left subtree is less than the value of the node, and the value of all the nodes in the right subtree is gr...
0.55348
Taco_12831
C
[ "insert_into_bst", "compute_height", "height_of_bst" ]
3
[ [ "height_of_bst", "compute_height" ], [ "height_of_bst", "insert_into_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
297a6126077e6fc7f1a358d593719b9d67a0f78f
32b3c11cb353fc1e2ae1b19c9a039ea6f39d3095
v1.0
complete
Taco
Taco_13374_C
def transport_supplies(data: str) -> List[int]: """ Calculate the maximum value of supplies that can be transported without exceeding the weight capacity. :param data: Input data containing multiple datasets in the form of strings. :return: List of maximum values for each dataset. >>> transport_supplie...
def knapsack(n, W, items): # Initialize a matrix to keep track of maximum value at each weight limit dp = [[0] * (W + 1) for _ in range(n + 1)] # Fill the dp array for i in range(1, n + 1): wi, vi = items[i - 1] for w in range(W + 1): if wi > w: dp[i][w] ...
from solution import transport_supplies def test_single_dataset(): data = "4 5\n2 3\n1 2\n3 4\n2 2\n0 0" expected = [7] assert transport_supplies(data) == expected def test_multiple_datasets(): data = "4 5\n2 3\n1 2\n3 4\n2 2\n3 8\n3 8\n5 2\n7 10\n1 100\n100 1000\n0 0" expected = [7, 10, 1000] ...
[ { "docstring": null, "function_declaration": "def knapsack(n, W, items):", "function_name": "knapsack", "parameter_list": "(n, W, items)" }, { "docstring": null, "function_declaration": "def parse_input(data):", "function_name": "parse_input", "parameter_list": "(data)" }, { ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def knapsack(n, W, items):\n dp = [0] * (W + 1)\n \n for i in range(n):\n weight, value = items[i]\n for w in range(W, weight - 1, -1):\n ...
trial_gpt4o_2
{ "original_instruction": "You are responsible for distributing supplies to various locations for a logistics company. Each supply unit has a certain weight and value, and your task is to maximize the value of supplies delivered within a given weight limit.\n\nYou need to solve this problem by writing a program based...
0.602259
Taco_13374
C
[ "knapsack", "parse_input", "transport_supplies" ]
3
[ [ "transport_supplies", "knapsack" ], [ "transport_supplies", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
e4191dcd8a9a91b4d8b6c00717e1a9cd42edfa36
309e33b05443665d39f47576b8742944e0d797b0
v1.0
complete
Taco
Taco_12024_C
def parse_chess_position(position): """ Parses a chess position in standard notation (e.g., 'e2') and returns the corresponding 0-indexed (x, y) tuple. >>> parse_chess_position('a1') (0, 0) >>> parse_chess_position('h8') (7, 7) >>> parse_chess_position('e2') (4, 1) >>> parse_chess_position('d4')...
def parse_chess_position(position): """ Parses a chess position in standard notation (e.g., 'e2') and returns the corresponding 0-indexed (x, y) tuple. """ col = ord(position[0]) - ord('a') row = int(position[1]) - 1 return (col, row) def is_valid_knight_move(start, move): """ Determine...
import pytest from solution import parse_chess_position, is_valid_knight_move, is_within_bounds, is_valid_knight_path def test_parse_chess_position(): assert parse_chess_position('a1') == (0, 0) assert parse_chess_position('h8') == (7, 7) assert parse_chess_position('e2') == (4, 1) assert parse_chess_p...
[ { "docstring": "Parses a chess position in standard notation (e.g., 'e2') and returns the corresponding 0-indexed (x, y) tuple.", "function_declaration": "def parse_chess_position(position):", "function_name": "parse_chess_position", "parameter_list": "(position)" }, { "docstring": "Determin...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_knight_move(start, n, moves):\n def pos_to_coords(pos):\n col = ord(pos[0]) - ord('a')\n row = int(pos[1]) - 1\n return (row, ...
trial_gpt4o_6
{ "original_instruction": "Write a program that determines whether a given sequence of moves on a chessboard will result in a valid path for a knight starting at a specific position. Recall that a knight moves in an L-shape: two squares in one direction and then one square perpendicular, or one square in one directio...
0.673006
Taco_12024
C
[ "parse_chess_position", "is_valid_knight_move", "is_within_bounds", "is_valid_knight_path" ]
4
[ [ "is_valid_knight_path", "is_valid_knight_move" ], [ "is_valid_knight_path", "is_within_bounds" ], [ "is_valid_knight_path", "parse_chess_position" ] ]
3
[]
false
[]
false
pytest
true
[]
true
9a9549392a8f1422fa48f37dc5b7fb5885565d46
0ddd4a1ec74cc56c64ba839dffe00bd47d03aaf1
v1.0
complete
Taco
Taco_18793_C
def solve_magic_square_problem(n: int, arr: List[int]) -> str: """ Check if the provided array can be rearranged into an n x n magic square and if so, print the magic square, otherwise print "No magic square can be formed”. >>> solve_magic_square_problem(3, [8, 1, 6, 3, 5, 7, 4, 9, 2]) '8 1 6\n3 5 7\n4 9 2...
def is_magic_square(square, n): # Calculate the magic constant magic_constant = n * (n * n + 1) // 2 # Check rows for row in square: if sum(row) != magic_constant: return False # Check columns for col in range(n): if sum(square[row][col] for row in range(n)) != ...
import pytest from solution import solve_magic_square_problem def test_magic_square_3x3_possible(): n = 3 arr = [8, 1, 6, 3, 5, 7, 4, 9, 2] expected_output = '''8 1 6 3 5 7 4 9 2''' assert solve_magic_square_problem(n, arr) == expected_output def test_magic_square_3x3_impossible(): n = 3 arr =...
[ { "docstring": null, "function_declaration": "def is_magic_square(square, n):", "function_name": "is_magic_square", "parameter_list": "(square, n)" }, { "docstring": null, "function_declaration": "def to_magic_square(arr, n):", "function_name": "to_magic_square", "parameter_list"...
[ 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 can_form_magic_square(n, arr):\n from itertools import permutations\n\n # Function to check if a matrix is a magic square\n def is_magic_square(matrix...
trial_gpt4o_4
{ "original_instruction": "A friend of yours is a world-class mathematician who loves solving complex mathematical challenges. Recently, he encountered a problem in converting an array of integers into a magic square. A magic square is a square matrix in which the sum of the numbers in each row, each column, and both...
0.698912
Taco_18793
C
[ "is_magic_square", "to_magic_square", "format_output", "solve_magic_square_problem" ]
4
[ [ "solve_magic_square_problem", "format_output" ], [ "solve_magic_square_problem", "to_magic_square" ], [ "to_magic_square", "is_magic_square" ] ]
3
[ "format_output" ]
false
[]
false
pytest
true
[]
true
3dddf0e082cb3170d671dcce1d3ee94d123d8c8b
ad40e9e40f5f03a9f45af0960cee0e895446a4e5
v1.0
complete
Taco
Taco_13523_C
def algoburg_tunnel(N: int, M: int, tunnels: List[Tuple[int, int, int]], Q: int, reserved_idxs: List[int]) -> Tuple[int, int]: """ Determine the minimal possible total repair cost and the number of different ways to achieve this cost for the underground tunnels in Algoburg. >>> alg...
MOD = 1000000007 def find_min_cost(N, M, tunnels, Q, reserved): import heapq parent = list(range(N + 1)) rank = [0] * (N + 1) def find(x): if parent[x] != x: parent[x] = find(parent[x]) # path compression return parent[x] def union(x, y): rootX = find(x) ...
from solution import algoburg_tunnel def test_example_criteria(): N = 4 M = 5 tunnels = [ (1, 2, 4), (2, 3, 5), (3, 4, 6), (1, 4, 7), (2, 4, 3) ] Q = 2 reserved = [2, 3] assert algoburg_tunnel(N, M, tunnels, Q, reserved) == (0, 1) def test_single_tun...
[ { "docstring": null, "function_declaration": "def find_min_cost(N, M, tunnels, Q, reserved):", "function_name": "find_min_cost", "parameter_list": "(N, M, tunnels, Q, reserved)" }, { "docstring": null, "function_declaration": "def algoburg_tunnel(N, M, tunnels, Q, reserved_idxs):", "...
[ 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.143
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_minimum_cost_and_ways(n, m, tunnels, reserved_indices):\n MOD = 1_000_000_007\n\n # Create adjacency list for the graph\n adj_list = [[] for _ in...
trial_gpt4o_7
{ "original_instruction": "In the technologically advanced city of Algoburg, there is a unique system of underground tunnels connecting the city's neighborhoods. The city comprises N neighborhoods connected by M bidirectional tunnels. Unfortunately, the tunnels require maintenance.\n\nDue to budget constraints, the c...
0.612391
Taco_13523
C
[ "find_min_cost", "algoburg_tunnel" ]
2
[ [ "algoburg_tunnel", "find_min_cost" ] ]
1
[]
false
[]
false
pytest
true
[]
true
da37c16da16a1e02a59a8db982b3aa0ce1122aa0
d91f85d4082ee3c627ba18650de8400eb02215d0
v1.0
complete
Taco
Taco_18742_C
def minimum_max_diff(grid: List[List[int]]) -> int: """ Given an n x m grid of integers representing altitudes, find the minimal possible value of the maximum difference in altitude between any two adjacent cells in the optimal path from the top-left to the bottom-right corner. Return -1 if it's impossible to reach...
from collections import deque def can_reach_with_diff(grid, n, m, max_diff): directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] visited = [[False] * m for _ in range(n)] queue = deque([(0, 0)]) visited[0][0] = True while queue: x, y = queue.popleft() if x == n - 1 and y == m - 1: ...
def test_minimum_max_diff(): assert minimum_max_diff([ [1, 2, 2], [3, 8, 2], [5, 3, 5] ]) == 2 assert minimum_max_diff([ [1, 1000000], [1000000, 1] ]) == 999999 assert minimum_max_diff([ [1, 2], [2, 1] ]) == 1 assert minimum_max_diff([ ...
[ { "docstring": null, "function_declaration": "def can_reach_with_diff(grid, n, m, max_diff):", "function_name": "can_reach_with_diff", "parameter_list": "(grid, n, m, max_diff)" }, { "docstring": null, "function_declaration": "def minimum_max_diff(grid):", "function_name": "minimum_m...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef min_max_path_diff(grid):\n n = len(grid)\n m = len(grid[0])\n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n \n def is_valid(...
trial_gpt4o_1
{ "original_instruction": "Given an $n \\times m$ grid, each cell of the grid contains a value which represents the altitude at that position. Alice and Bob are going for a hike, and they want to find a path from the top-left corner (1, 1) to the bottom-right corner ($n$, $m$) of the grid such that the maximum differ...
0.659263
Taco_18742
C
[ "can_reach_with_diff", "minimum_max_diff" ]
2
[ [ "minimum_max_diff", "can_reach_with_diff" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1e55259ef42ab033c8f22bcae77c828f3610c7aa
639f0c4a6d84746dab9680e716432f7e13bedd2b
v1.0
complete
Taco
Taco_18428_C
def find_unique_paths(m: int, n: int, grid: List[List[str]]) -> int: """ Given a matrix, find the number of distinct paths from the top-left to the bottom-right corner of the matrix, such that you can only move either down or right at any point in time. Additionally, certain cells are blocked, and you canno...
def unique_paths_with_obstacles(matrix): m = len(matrix) n = len(matrix[0]) # Create a 2D dp array initializing zeros everywhere dp = [[0]*n for _ in range(m)] # Initialize the starting point dp[0][0] = 1 if matrix[0][0] == '.' else 0 # Fill the dp array for i in range(m):...
import pytest from solution import find_unique_paths def test_find_unique_paths_no_obstacles(): grid = [ ". . .", ". . .", ". . ." ] m, n = 3, 3 grid = [row.split() for row in grid] assert find_unique_paths(m, n, grid) == 6 def test_find_unique_paths_with_obstacles(): g...
[ { "docstring": null, "function_declaration": "def unique_paths_with_obstacles(matrix):", "function_name": "unique_paths_with_obstacles", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def find_unique_paths(m, n, grid):", "function_name": "find_unique_pa...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def num_paths(matrix):\n \"\"\"\n Returns the number of distinct paths from the top-left to the bottom-right of the matrix.\n You can only move either dow...
trial_gpt4o_2
{ "original_instruction": "Given a matrix, find the number of distinct paths from the top-left to the bottom-right corner of the matrix, such that you can only move either down or right at any point in time. Additionally, certain cells are blocked, and you cannot pass through those cells.\n\n### Input Format\n- The f...
0.733898
Taco_18428
C
[ "unique_paths_with_obstacles", "find_unique_paths" ]
2
[ [ "find_unique_paths", "unique_paths_with_obstacles" ] ]
1
[]
false
[]
false
pytest
true
[]
true
26c2eaec02cf17edd73ec96e2e2f25b5d8cc5c21
077512dc0a170fe7ad563c0e4dafa4e748029c1a
v1.0
complete
Taco
Taco_19101_C
def is_palindrome(s: str) -> bool: """ Check if the given string is a palindrome. >>> is_palindrome("101") True >>> is_palindrome("1100") False >>> is_palindrome("0110") True >>> is_palindrome("1") True """ pass def min_subsequences(s: str) -> int: """ Deter...
def is_palindrome(s): return s == s[::-1] def min_subsequences(s): if is_palindrome(s): return 1 return 2 def process_cases(cases): results = [] for s in cases: results.append(min_subsequences(s)) return results
from solution import is_palindrome, min_subsequences, process_cases def test_is_palindrome(): assert is_palindrome("101") assert not is_palindrome("1100") assert is_palindrome("0110") assert is_palindrome("1") assert is_palindrome("11") assert not is_palindrome("10") def test_min_subsequences(...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def min_subsequences(s):", "function_name": "min_subsequences", "parameter_list": "(s)" }, { "d...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_reversal_subsequences(S):\n \"\"\"\n Returns the minimum number of contiguous subsequences the binary string \n must be divided into, such that re...
trial_gpt4o_1
{ "original_instruction": "Mr. LD, an eccentric AI researcher, designed a binary communication system between his AI agents. Each agent sends a binary message that consists of a series of `0`s and `1`s. The receiver agent must reconstruct the original message correctly, but the communication system is so simple that ...
0.738715
Taco_19101
C
[ "is_palindrome", "min_subsequences", "process_cases" ]
3
[ [ "min_subsequences", "is_palindrome" ], [ "process_cases", "min_subsequences" ] ]
2
[ "process_cases" ]
false
[]
false
pytest
true
[]
true
8ad333d0e420bff0f50a74a3682c46fe45768928
1d479fc1c5470d170b40aa9dcc2324e53cdd490a
v1.0
complete
Taco
Taco_18591_C
def convert_to_minutes(time_str): """ Convert time string in "HH:MM" format to total minutes from 00:00. >>> convert_to_minutes("09:00") 540 >>> convert_to_minutes("12:00") 720 """ pass def max_overlapping_shifts(shifts): """ Find the maximum number of overlapping shifts given a list of...
def convert_to_minutes(time_str): hours, minutes = map(int, time_str.split(':')) return hours * 60 + minutes def max_overlapping_shifts(shifts): events = [] for start, end in shifts: events.append((convert_to_minutes(start), 'start')) events.append((convert_to_minutes(end), 'end')) ...
def test_max_overlapping_shifts_example1(): shifts = [("09:00", "17:00"), ("12:00", "20:00"), ("11:00", "15:00")] assert max_overlapping_shifts(shifts) == 3 def test_max_overlapping_shifts_example2(): shifts = [("08:00", "12:00"), ("12:00", "16:00"), ("10:00", "14:00"), ("11:00", "15:00")] assert max_o...
[ { "docstring": null, "function_declaration": "def convert_to_minutes(time_str):", "function_name": "convert_to_minutes", "parameter_list": "(time_str)" }, { "docstring": null, "function_declaration": "def max_overlapping_shifts(shifts):", "function_name": "max_overlapping_shifts", ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_overlapping_shifts(n, shifts):\n \"\"\"\n Returns the maximum number of overlapping shifts.\n \"\"\"\n events = []\n \n # Collect all sta...
trial_gpt4o_1
{ "original_instruction": "You are a software developer tasked with developing a new scheduling algorithm for hospital shifts. Hospitals have different numbers of doctors available each day, and each doctor has different start and end times for their shifts. Your goal is to find the maximum number of overlapping shif...
0.56011
Taco_18591
C
[ "convert_to_minutes", "max_overlapping_shifts" ]
2
[ [ "max_overlapping_shifts", "convert_to_minutes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
487a8326a34e6cd9826a3066c3f18280d54899f5
317ee9635283ed964ae02eb4bfb632f18baaf5ea
v1.0
complete
Taco
Taco_13415_C
def digit_sum(n: int) -> int: """ Returns the sum of the digits of a number n. >>> digit_sum(123) 6 >>> digit_sum(49) 13 >>> digit_sum(0) 0 >>> digit_sum(999) 27 """ pass def count_magical_numbers(l: int, r: int, d: int) -> int: """ Returns the count of magical numbers in the ra...
def digit_sum(n): """ Returns the sum of the digits of a number n. """ return sum(int(digit) for digit in str(n)) def count_magical_numbers(l, r, d): """ Returns the count of magical numbers in the range [l, r] where the sum of its digits is divisible by d. If there are no magical numb...
from solution import digit_sum, count_magical_numbers, process_test_cases def test_digit_sum(): assert digit_sum(123) == 6 assert digit_sum(49) == 13 assert digit_sum(0) == 0 assert digit_sum(999) == 27 def test_count_magical_numbers(): assert count_magical_numbers(1, 10, 3) == 3 assert count_...
[ { "docstring": "Returns the sum of the digits of a number n.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "Returns the count of magical numbers in the range [l, r] where \nthe sum of its digits is divisible by d.\nIf t...
[ 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 sum_of_digits(n):\n \"\"\"\n Returns the sum of the digits of a number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef count_magica...
trial_gpt4o_1
{ "original_instruction": "In a land far away, there exists a peculiar set of numbers called \"Magical Numbers.\" A number is said to be magical if the sum of its digits is divisible by a given integer `d`. Given a range of integers from `l` to `r` (inclusive), find the count of magical numbers within that range. If ...
0.623699
Taco_13415
C
[ "digit_sum", "count_magical_numbers", "process_test_cases", "main" ]
4
[ [ "count_magical_numbers", "digit_sum" ], [ "process_test_cases", "count_magical_numbers" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
36cec8552c4eebad36d9574d17351c7750bfe193
2989cdc00bc8e45665ae454f83f2845f179e8874
v1.0
complete
Taco
Taco_12105_C
from typing import List, Tuple def initialize_towers(n: int, m: int, connections: List[Tuple[int, int, int]]) -> List[List[int]]: """ Initialize the tower connections and bandwidths. """ def floyd_warshall(n: int, bandwidth_matrix: List[List[int]]) -> List[List[int]]: """ Apply Floyd-Warshall alg...
def initialize_towers(n, m, connections): # Initialize matrix with zero bandwidths bandwidth_matrix = [[0 if i != j else float('inf') for j in range(n)] for i in range(n)] for a, b, c in connections: bandwidth_matrix[a-1][b-1] = max(bandwidth_matrix[a-1][b-1], c) bandwidth_matrix[b-1][a-1] ...
def test_initialize_towers(): n = 4 m = 3 connections = [(1, 2, 5), (2, 3, 10), (3, 4, 20)] expected = [ [float('inf'), 5, 0, 0], [5, float('inf'), 10, 0], [0, 10, float('inf'), 20], [0, 0, 20, float('inf')] ] assert initialize_towers(n, m, connections) == expecte...
[ { "docstring": null, "function_declaration": "def initialize_towers(n, m, connections):", "function_name": "initialize_towers", "parameter_list": "(n, m, connections)" }, { "docstring": null, "function_declaration": "def floyd_warshall(n, bandwidth_matrix):", "function_name": "floyd_...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\nclass UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n self.maxBand = 0\n \n ...
trial_gpt4o_4
{ "original_instruction": "The city of Codeville is upgrading its communication network. The network consists of n communication towers that need to be connected with m bidirectional cables. Each cable has a certain bandwidth capacity. The network must be designed to handle q queries, which will help determine the ov...
0.505265
Taco_12105
C
[ "initialize_towers", "floyd_warshall", "handle_queries", "main" ]
4
[ [ "handle_queries", "floyd_warshall" ] ]
1
[ "handle_queries" ]
false
[]
false
pytest
false
[]
true
593bdf9007c3d91b07ecade2a6128bd35a182b28
187ec572cbf19d2431f2b30c896c0e1b0349db47