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_71812_C | from typing import List, Tuple
def code_review_paths(n: int, r: int, edges: List[Tuple[int, int]], q: int, queries: List[Tuple[int, int]]) -> List[str]:
""" Determine if there is a path of code reviews between developers.
Args:
n: Number of developers.
r: Number of review relationships.
... | from collections import defaultdict, deque
def create_graph(edges):
graph = defaultdict(list)
for u, v in edges:
graph[u].append(v)
return graph
def bfs(graph, start, goal):
queue = deque([start])
visited = set()
while queue:
node = queue.popleft()
if node == goal:
... | from solution import code_review_paths
def test_single_path_exists():
n = 5
r = 4
edges = [(1, 2), (2, 3), (3, 4), (4, 5)]
q = 3
queries = [(1, 3), (1, 4), (2, 5)]
assert code_review_paths(n, r, edges, q, queries) == ['YES', 'YES', 'YES']
def test_no_path_exists():
n = 3
r = 2
edge... | [
{
"docstring": null,
"function_declaration": "def create_graph(edges):",
"function_name": "create_graph",
"parameter_list": "(edges)"
},
{
"docstring": null,
"function_declaration": "def bfs(graph, start, goal):",
"function_name": "bfs",
"parameter_list": "(graph, start, goal)"
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict, deque\n\ndef create_graph(edges):\n graph = defaultdict(list)\n for u, v in edges:\n graph[u].append(v)\n retu... | trial_gpt4o_0 | {
"original_instruction": "In a development company, there is a system that tracks which developer reviews whose code. Each developer can have multiple reviewers, and a developer can review multiple developers' code. You need to determine if there is a path of code reviews from one developer to another.\n\nYou will b... | 0.574115 | Taco_71812 | C | [
"create_graph",
"bfs",
"code_review_paths"
] | 3 | [
[
"code_review_paths",
"bfs"
],
[
"code_review_paths",
"create_graph"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | a16bdaa08bc2b73896bd1138a177cf22a6c0c44b | 9c9e68f2d9fcd601cb0efc097ffaf2de9b60ef27 | |||
v1.0 | complete | Taco | Taco_71832_C | def minimum_toll(N: int, M: int, roads: List[Tuple[int, int, int]]) -> int:
""" Determine the minimum total toll fee required to travel from Atlantis to Elantia.
Args:
N (int): Number of locations including Atlantis and Elantia.
M (int): Total number of roads.
roads (List[Tuple[int, int... | import heapq
def minimum_toll(N, M, roads):
graph = [[] for _ in range(N + 1)]
for u, v, w in roads:
graph[u].append((v, w))
graph[v].append((u, w))
return dijkstra(1, N, graph)
def dijkstra(start, end, graph):
min_heap = [(0, start)] # (toll cost, current node)
costs = [float('i... | from solution import minimum_toll
def test_minimum_toll_sample1():
N, M = 5, 6
roads = [
(1, 2, 2),
(1, 3, 4),
(2, 3, 1),
(2, 4, 7),
(3, 5, 3),
(4, 5, 1)
]
assert minimum_toll(N, M, roads) == 6
def test_minimum_toll_sample2():
N, M = 3, 2
roads =... | [
{
"docstring": null,
"function_declaration": "def minimum_toll(N, M, roads):",
"function_name": "minimum_toll",
"parameter_list": "(N, M, roads)"
},
{
"docstring": null,
"function_declaration": "def dijkstra(start, end, graph):",
"function_name": "dijkstra",
"parameter_list": "(s... | [
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 heapq\n\ndef minimum_toll_fee(n, m, roads):\n \"\"\"\n Finds the minimum toll fee from Atlantis (node 1) to Elantia (node n).\n \n Parameters:\n... | trial_gpt4o_2 | {
"original_instruction": "Two cities, Atlantis and Elantia, are connected by a series of straight roads. Each road either connects Atlantis to Elantia directly or passes through several smaller towns in between. Both cities are engaged in trading, and each road has a certain toll fee. Your task is to determine the m... | 0.680316 | Taco_71832 | C | [
"minimum_toll",
"dijkstra"
] | 2 | [
[
"minimum_toll",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f067f811791c5b564b1d0447cfc7fd0396f1199d | 224ca0e6d8004d6f683bff61b7d88ada14323bbe | |||
v1.0 | complete | Taco | Taco_71758_C | def is_valid_expression(expression: str) -> bool:
"""
Checks if the arithmetic expression is valid based on specific constraints.
Args:
expression (str): The arithmetic expression to be validated.
Returns:
bool: True if the expression is valid, False otherwise.
>>> is_valid_expression("12... | def is_valid_expression(expression):
"""
Checks if the arithmetic expression is valid based on specific constraints.
"""
if not expression or expression[0] in '+*' or expression[-1] in '+*':
return False
num_additions = 0
num_multiplications = 0
prev_char = None
for char in exp... | from solution import is_valid_expression, validate_expressions
def test_is_valid_expression():
assert is_valid_expression("12+7*3") == True
assert is_valid_expression("15+35+21") == True
assert is_valid_expression("3*5*7*") == False
assert is_valid_expression("123*456+789") == True
assert is_valid_... | [
{
"docstring": "Checks if the arithmetic expression is valid based on specific constraints.",
"function_declaration": "def is_valid_expression(expression):",
"function_name": "is_valid_expression",
"parameter_list": "(expression)"
},
{
"docstring": "Validates a list of arithmetic expressions... | [
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_valid_expression(expression):\n if not expression or expression[0] in \"+*\" or expression[-1] in \"+*\":\n return \"Invalid\"\n \n add_coun... | trial_gpt4o_1 | {
"original_instruction": "Write a program that analyzes arithmetic expressions to determine if they are valid within the constraints of a specific calculator. This calculator supports only addition and multiplication of positive integers with specific limits on the number of operations performed.\n\nThe constraints ... | 0.609458 | Taco_71758 | C | [
"is_valid_expression",
"validate_expressions"
] | 2 | [
[
"validate_expressions",
"is_valid_expression"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | de87478a65adacf4f49da0a4d756a01152adbe86 | 5fabf555fbba054e70a4b446f9c2f4d11183dfa2 | |||
v1.0 | complete | Taco | Taco_71972_C | def minimal_tree_distance(W: int, H: int, grid: List[List[int]]) -> int:
""" You have a rectangular grid consisting of W columns and H rows. Each cell in the grid has either a 1 indicating it has a tree
or a 0 indicating it is empty. You want to place exactly one house anywhere in the grid such that the su... | def min_manhattan_distance_sum(grid, W, H):
trees = [(i, j) for i in range(H) for j in range(W) if grid[i][j] == 1]
def manhattan_distance(x1, y1, x2, y2):
return abs(x1 - x2) + abs(y1 - y2)
min_distance_sum = float('inf')
for x in range(H):
for y in range(W):
... | from solution import minimal_tree_distance
def test_minimal_tree_distance_sample_input():
grid = [
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]
]
assert minimal_tree_distance(3, 3, grid) == 4
def test_minimal_tree_distance_all_zeros():
grid = [
[0, 0, 0],
[0, 0, 0],
... | [
{
"docstring": null,
"function_declaration": "def min_manhattan_distance_sum(grid, W, H):",
"function_name": "min_manhattan_distance_sum",
"parameter_list": "(grid, W, H)"
},
{
"docstring": null,
"function_declaration": "def minimal_tree_distance(W, H, grid):",
"function_name": "mini... | [
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 get_minimum_distance(W, H, grid):\n trees = [(i, j) for i in range(H) for j in range(W) if grid[i][j] == 1]\n \n def manhattan_distance(x1, y1, x2, y2... | trial_gpt4o_4 | {
"original_instruction": "You have a rectangular grid consisting of W columns and H rows. Each cell in the grid has either a 1 indicating it has a tree or a 0 indicating it is empty. You want to place exactly one house anywhere in the grid such that the sum of Manhattan distances from the house to all trees is minim... | 0.597749 | Taco_71972 | C | [
"min_manhattan_distance_sum",
"minimal_tree_distance"
] | 2 | [
[
"minimal_tree_distance",
"min_manhattan_distance_sum"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fa89411413c32d6c12a9f62aeab463217436a4c2 | e338929ae99162e8fa7186cb8c4fbe1dce410ab6 | |||
v1.0 | complete | Taco | Taco_72008_C | def check_road_network(input_str: str) -> list:
""" Determine if there exists any road in the network such that its removal disconnects the graph.
Each test case starts with two integers `n` and `m` where
`n` is the number of cities (nodes) and `m` is the number of roads (edges). The following
`m`... | def find_union_parent(parent, i):
if parent[i] == i:
return i
else:
return find_union_parent(parent, parent[i])
def union(parent, rank, x, y):
xroot = find_union_parent(parent, x)
yroot = find_union_parent(parent, y)
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot
... | def test_simple_case():
input_str = "4 5\n1 2 3\n1 3 4\n2 3 5\n2 4 6\n3 4 2\n0 0\n"
assert check_road_network(input_str) == ["Safe"]
def test_safe_case():
input_str = "5 5\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n5 1 7\n0 0\n"
assert check_road_network(input_str) == ["Safe"]
def test_disconnected_case():
inpu... | [
{
"docstring": null,
"function_declaration": "def find_union_parent(parent, i):",
"function_name": "find_union_parent",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(... | [
1
] | 1 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_union_parent(parent, i):\n if parent[i] == i:\n return i\n else:\n return find_union_parent(parent, parent[i])\n\ndef union(parent, ra... | trial_gpt4o_0 | {
"original_instruction": "You are given a network of cities represented as a weighted undirected graph. Each city is connected by roads, and each road has an associated distance. Your task is to determine if it is possible to travel between all pairs of cities considering the following potential disruptions:\n\n1. A... | 0.67031 | Taco_72008 | C | [
"find_union_parent",
"union",
"is_connected",
"check_road_network"
] | 4 | [
[
"check_road_network",
"is_connected"
],
[
"is_connected",
"find_union_parent"
],
[
"is_connected",
"union"
],
[
"union",
"find_union_parent"
]
] | 4 | [] | false | [] | false | pytest | false | [] | true | 0cde6698119914c2e0c6d14d9863b9fa0c9afac2 | 7f7b6081b1dae4367cb182165183c9b8cd69ec1f | |||
v1.0 | complete | Taco | Taco_72100_C | def number_of_ways(n: int, arr: List[int], k: int) -> int:
"""
Calculate the number of different ways to make all elements of the array equal after a series of operations.
Args:
n (int): The length of the array.
arr (List[int]): The array of integers.
k (int): The given integer for the operatio... | import math
from functools import reduce
from math import gcd
def gcd_array(arr):
return reduce(gcd, arr)
def number_of_ways(n, arr, k):
if n == 1:
return -1 # Problem specification does not allow n=1 to have significant variety.
differences = []
for i in range(n):
differences.ap... | from solution import number_of_ways
def test_case_1():
assert number_of_ways(3, [1, 5, 3], 1) == 2
def test_case_2():
assert number_of_ways(4, [7, 9, 12, 18], 2) == 1
def test_case_3():
assert number_of_ways(2, [10, 20], 0) == 10
def test_case_4():
assert number_of_ways(5, [1, 5, 5, 5, 5], 0) == 4
... | [
{
"docstring": null,
"function_declaration": "def gcd_array(arr):",
"function_name": "gcd_array",
"parameter_list": "(arr)"
},
{
"docstring": null,
"function_declaration": "def number_of_ways(n, arr, k):",
"function_name": "number_of_ways",
"parameter_list": "(n, arr, k)"
}
] | [
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 count_ways_to_equal_array_elements(n, arr, k):\n \"\"\"\n Calculate the number of different ways to make all elements of the array equal\n... | trial_gpt4o_2 | {
"original_instruction": "You are given an array of integers `arr` with a length of `|arr| = n (1 ≤ n ≤ 500)`. You need to make a series of operations on the array such that after each operation, each element in the array is incremented by a value divisible by the difference between its index and a given integer `k ... | 0.677801 | Taco_72100 | C | [
"gcd_array",
"number_of_ways"
] | 2 | [
[
"number_of_ways",
"gcd_array"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b8660389876668a594d244047c9ae9b8ed932002 | ed5dd295d0fdda8d37945b4885220ea99bcd4788 | |||
v1.0 | complete | Taco | Taco_71956_C | def minimum_activation_cost(test_cases: List[Tuple[int, int, List[Tuple[int, int, int]]]]) -> List[int]:
""" Computes the minimum activation cost to connect all machines in a network.
Given a list of test cases where each test case contains:
- an integer N: the number of machines,
- an integer M: the nu... | def find(parent, i):
if parent[i] == i:
return i
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] = xroot
... | def test_minimum_activation_cost():
test_cases = [
(4, 5, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 4, 6), (2, 4, 7)]),
(3, 3, [(1, 2, 1), (2, 3, 2), (1, 3, 4)]),
(4, 3, [(1, 2, 1), (2, 3, 2), (3, 4, 3)]),
(4, 2, [(1, 2, 1), (2, 3, 2)])
]
expected_results = [12, 3, 6, -1]
ass... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
0,
0,
0,
1
] | 1 | hard | 0.25 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi... | trial_gpt4o_4 | {
"original_instruction": "A company operates a network of machines connected by a series of cables. The network is represented as a graph with N nodes (machines) and M edges (cables). The machines have unique IDs ranging from 1 to N.\n\nThe company wants to determine the minimum cost to ensure that all machines are ... | 0.598203 | Taco_71956 | C | [
"find",
"union",
"kruskal_minimum_cost",
"minimum_activation_cost"
] | 4 | [
[
"kruskal_minimum_cost",
"find"
],
[
"kruskal_minimum_cost",
"union"
],
[
"minimum_activation_cost",
"kruskal_minimum_cost"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | false | [] | true | eb492c2d6fa25ff74c363ed1e7548e5ace723d05 | 90b1fbc46dcc4a41181f88c12066d66dbb00da2f | |||
v1.0 | complete | Taco | Taco_72131_C | from typing import List, Tuple
def longest_same_value_path(n: int, edges: List[Tuple[int, int]], values: List[int]) -> int:
""" Given a binary tree, find the length of the longest path which contains the same value.
>>> longest_same_value_path(5, [(1, 2), (1, 3), (3, 4), (3, 5)], [1, 1, 2, 2, 2])
2
>>>... | from collections import defaultdict
def longest_same_value_path(n, edges, values):
tree = defaultdict(list)
for u, v in edges:
tree[u].append(v)
tree[v].append(u)
max_path = [0]
def dfs(node, parent):
current_val = values[node - 1]
max_length = 0
f... | from solution import longest_same_value_path
def test_example_1():
assert longest_same_value_path(5, [(1, 2), (1, 3), (3, 4), (3, 5)], [1, 1, 2, 2, 2]) == 2
def test_example_2():
assert longest_same_value_path(3, [(1, 2), (1, 3)], [1, 1, 1]) == 2
def test_example_3():
assert longest_same_value_pa... | [
{
"docstring": null,
"function_declaration": "def longest_same_value_path(n, edges, values):",
"function_name": "longest_same_value_path",
"parameter_list": "(n, edges, values)"
},
{
"docstring": null,
"function_declaration": "def example_implementation():",
"function_name": "example... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict, deque\n\ndef longest_path_with_same_value(n, edges, values):\n # Construct the adjacency list\n tree = defaultdict(list)... | trial_gpt4o_1 | {
"original_instruction": "Alex loves solving problems involving binary trees. One day, he came across an interesting problem and needs your help to solve it. Given a binary tree, find the length of the longest path which contains the same value.\n\nA path in a binary tree is a sequence of nodes where each pair of ad... | 0.593588 | Taco_72131 | C | [
"longest_same_value_path",
"example_implementation"
] | 2 | [
[
"example_implementation",
"longest_same_value_path"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 05c5eb96c2c0742a6bca3377efbf28266d71f19c | ad383d34108fa566abc42286ac4f7dcdc1e29334 | |||
v1.0 | complete | Taco | Taco_72059_C | def compute_max_width(n, m, paths):
"""
Heidi has been tasked with securing a series of historic sites connected via ancient pathways. Each pathway has a certain width, and Heidi wants to ensure the pathways can support the traffic of tourists while keeping the scenic beauty intact. To decide which pathways to ... | import heapq
def prim_mst(graph, n):
"""
Uses Prim's algorithm to find the MST of a graph.
Returns the total weight of the MST and the edges in the MST.
"""
# Min heap to select the edge with minimum weight in cut
min_heap = [(0, 1, -1)] # (weight, vertex, parent)
visited = [False] * (n + ... | from solution import compute_max_width
def test_example_case():
n = 4
m = 5
paths = [
(1, 2, 5),
(2, 3, 7),
(3, 4, 6),
(1, 3, 4),
(2, 4, 8),
]
assert compute_max_width(n, m, paths) == [7, 8]
def test_case_with_all_paths_mst():
n = 3
m = 2
paths =... | [
{
"docstring": "Uses Prim's algorithm to find the MST of a graph.\nReturns the total weight of the MST and the edges in the MST.",
"function_declaration": "def prim_mst(graph, n):",
"function_name": "prim_mst",
"parameter_list": "(graph, n)"
},
{
"docstring": "Given the number of sites n, nu... | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_W_max(n, m, edges):\n from heapq import heappop, heappush\n import sys\n\n def prim_mst():\n mst = []\n used = [False] * n\n ... | trial_gpt4o_5 | {
"original_instruction": "Heidi has been tasked with securing a series of historic sites connected via ancient pathways. Each pathway has a certain width, and Heidi wants to ensure the pathways can support the traffic of tourists while keeping the scenic beauty intact. To decide which pathways to reinforce, Heidi mu... | 0.662248 | Taco_72059 | C | [
"prim_mst",
"compute_max_width"
] | 2 | [
[
"compute_max_width",
"prim_mst"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3ebd5569d8a96001af7d65f7cdba804f76ce1cf7 | db017ed2243a9ffd39dde6dfc5ed990c7d1aa1a7 | |||
v1.0 | complete | Taco | Taco_72026_C | MOD = 10**9 + 7
def factorial(n):
"""
Calculate the factorial of n modulo MOD.
"""
result = 1
for i in range(1, n + 1):
result = (result * i) % MOD
return result
def valid_timtables_count(n):
"""
Return the number of valid timetables for n topics modulo MOD.
"""
return ... | MOD = 10**9 + 7
def factorial(n):
"""
Calculate the factorial of n modulo MOD.
"""
result = 1
for i in range(1, n + 1):
result = (result * i) % MOD
return result
def valid_timtables_count(n):
"""
Return the number of valid timetables for n topics modulo MOD.
"""
return ... | from solution import solve
def test_single_case():
assert solve("1\n1") == "1"
assert solve("1\n2") == "2"
assert solve("1\n3") == "6"
def test_multiple_cases():
assert solve("3\n1\n2\n3") == "1\n2\n6"
def test_large_case():
assert solve("1\n10") == "3628800"
assert solve("1\n20") == "1463260... | [
{
"docstring": "Calculate the factorial of n modulo MOD.",
"function_declaration": "def factorial(n):",
"function_name": "factorial",
"parameter_list": "(n)"
},
{
"docstring": "Return the number of valid timetables for n topics modulo MOD.",
"function_declaration": "def valid_timtables_c... | [
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 factorial(n):\n if n == 0 or n == 1:\n return 1\n result = 1\n for i in range(2, n+1):\n result *= i\n return result\n\ndef count_val... | trial_gpt4o_2 | {
"original_instruction": "A group of students decided to form a study group for their upcoming coding exam. They have a list of topics they need to cover, and they want to create a timetable to plan their studies. However, they don't want to study the same topic on consecutive days.\n\nEach topic is represented by a... | 0.59863 | Taco_72026 | C | [
"factorial",
"valid_timtables_count",
"solve"
] | 3 | [
[
"solve",
"valid_timtables_count"
],
[
"valid_timtables_count",
"factorial"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 133e778ddeec71fd66b4c56a83a26770f0fcab1b | 7378cfa3e727d1bed8b487505e156f8272ea21fe | |||
v1.0 | complete | Taco | Taco_72326_C | def maximalRectangle(matrix: List[List[int]]) -> int:
""" Given a 2D grid of integers, find the largest rectangular submatrix that only contains the number 1.
Return the area of this largest rectangular submatrix.
Args:
matrix: A list of lists of integers representing the 2D grid.
Returns:... | def maximalRectangle(matrix):
if not matrix or not matrix[0]:
return 0
max_area = 0
n, m = len(matrix), len(matrix[0])
heights = [0] * m
for row in range(n):
for col in range(m):
if matrix[row][col] == 1:
heights[col] += 1
else:
... | def test_maximalRectangle():
grid1 = [
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 0, 0, 1, 0]
]
assert maximalRectangle(grid1) == 6
grid2 = [
[0, 1],
[1, 0]
]
assert maximalRectangle(grid2) == 1
grid3 = [
[1, 1, 1, 1],
... | [
{
"docstring": null,
"function_declaration": "def maximalRectangle(matrix):",
"function_name": "maximalRectangle",
"parameter_list": "(matrix)"
},
{
"docstring": null,
"function_declaration": "def largestRectangleArea(heights):",
"function_name": "largestRectangleArea",
"paramete... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n\n max_area = 0\n n, m = len(matrix), len(matrix[0])\n \n heights... | trial_gpt4o_0 | {
"original_instruction": "Given a 2D grid of integers, you are tasked with finding the largest rectangular submatrix that only contains the number `1`. You should return the area of this largest rectangular submatrix.\n\nFor example, consider the 2D grid [[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, ... | 0.702542 | Taco_72326 | C | [
"maximalRectangle",
"largestRectangleArea"
] | 2 | [
[
"maximalRectangle",
"largestRectangleArea"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 8107806b4236df0c536239e3203f42b16fc653f6 | 19f5dd89fa264a6369895f4cad83a33d070c1755 | |||
v1.0 | complete | Taco | Taco_72130_C | def minimum_spanning_tree(n: int, edges: List[Tuple[int, int, int]]) -> int:
"""
Find the minimum cost to connect all the vertices in an undirected graph.
If the graph is disconnected, return -1.
Args:
n (int): number of vertices
edges (List[Tuple[int, int, int]]): list of edges where each ed... | 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 rank[ro... | from solution import minimum_spanning_tree
def test_mst_example1():
assert minimum_spanning_tree(4, [(1, 2, 2), (1, 3, 3), (2, 3, 4), (3, 4, 1), (4, 2, 5)]) == 6
def test_mst_example2():
assert minimum_spanning_tree(3, [(1, 2, 4)]) == -1
def test_mst_single_node():
assert minimum_spanning_tree(1, []) == ... | [
{
"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,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n \n def find(self, u):\n if self.pare... | trial_gpt4o_1 | {
"original_instruction": "You are given an undirected graph with $n$ vertices and $m$ edges. Each edge has a weight associated with it. Your task is to find the minimum cost to connect all the vertices (i.e., the cost of a Minimum Spanning Tree).\n\nIf the graph is disconnected, output -1, indicating that not all ve... | 0.770821 | Taco_72130 | C | [
"find",
"union",
"minimum_spanning_tree"
] | 3 | [
[
"minimum_spanning_tree",
"find"
],
[
"minimum_spanning_tree",
"union"
],
[
"union",
"find"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | bd3e46521db0571d1ed957d8e97257cc9810ffc9 | 95f31d78fb70b3ce28feab773ec732c51ed58a50 | |||
v1.0 | complete | Taco | Taco_72143_C | def preprocess_prefix_sum(impacts):
""" Precompute the prefix sums for the given impact values.
>>> preprocess_prefix_sum([1, -2, 3, 10, -5]) [0, 1, -1, 2, 12, 7]
>>> preprocess_prefix_sum([-1, 3, 4, 0, -3, 2]) [0, -1, 2, 6, 6, 3, 5]
"""
pass
def query_sum(prefix_sum, left, right):
""" Compute ... | def preprocess_prefix_sum(impacts):
"""
Precompute the prefix sums for the given impact values.
Params:
impacts: List of integers representing the impact values of segments.
Returns:
A list of prefix sums.
"""
n = len(impacts)
prefix_sum = [0] * (n + 1)
for i in range(1... | def test_example_1():
n = 5
queries = [(1, 3), (2, 5), (1, 5)]
impacts = [1, -2, 3, 10, -5]
expected_output = [2, 6, 7]
assert process_queries(n, queries, impacts) == expected_output
def test_example_2():
n = 6
queries = [(3, 4), (1, 6)]
impacts = [-1, 3, 4, 0, -3, 2]
expected_outpu... | [
{
"docstring": "Precompute the prefix sums for the given impact values.\n\nParams:\nimpacts: List of integers representing the impact values of segments.\n\nReturns:\nA list of prefix sums.",
"function_declaration": "def preprocess_prefix_sum(impacts):",
"function_name": "preprocess_prefix_sum",
"pa... | [
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 preprocess_prefix_sum(impacts):\n \"\"\"\n Precompute the prefix sums for the given impact values.\n \n Params:\n impacts: List of integers repr... | trial_gpt4o_0 | {
"original_instruction": "The Social Media Analytics Corp. (SMACorp) operates a robust system to analyze user engagement across various platforms. To ensure fast and efficient analysis, SMACorp divides the user's activity log into segments. Each segment contains the activity data for a certain duration (e.g., one ho... | 0.509411 | Taco_72143 | C | [
"preprocess_prefix_sum",
"query_sum",
"process_queries"
] | 3 | [
[
"process_queries",
"preprocess_prefix_sum"
],
[
"process_queries",
"query_sum"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | false | [] | true | a6fa88ccf84c595a2f49d3036845f78f03c28776 | 88377de9ffcef6c4f33cdba02fa0e8c1e980d064 | |||
v1.0 | complete | Taco | Taco_72182_C | from typing import List, Tuple
def preprocess(arr: List[int]) -> List[int]:
"""Preprocess the array to create prefix sums which will help in answering range sum queries efficiently.
>>> preprocess([1, 2, 3, 4, 5])
[0, 1, 3, 6, 10, 15]
>>> preprocess([5, 1, 2, 3, 4])
[0, 5, 6, 8, 11, 15]
"""
de... | def preprocess(arr):
"""
Preprocess the array to create prefix sums which will help in answering range sum queries efficiently.
"""
prefix_sums = [0] * (len(arr) + 1)
for i in range(len(arr)):
prefix_sums[i + 1] = prefix_sums[i] + arr[i]
return prefix_sums
def range_sum(l, r, prefix_sum... | from solution import preprocess, range_sum, process_queries
def test_preprocess():
assert preprocess([1, 2, 3, 4, 5]) == [0, 1, 3, 6, 10, 15]
assert preprocess([5, 1, 2, 3, 4]) == [0, 5, 6, 8, 11, 15]
def test_range_sum():
prefix_sums = preprocess([1, 2, 3, 4, 5])
assert range_sum(1, 3, prefix_sums) =... | [
{
"docstring": "Preprocess the array to create prefix sums which will help in answering range sum queries efficiently.",
"function_declaration": "def preprocess(arr):",
"function_name": "preprocess",
"parameter_list": "(arr)"
},
{
"docstring": "Returns the sum of array elements from index l ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def range_sum_queries(n, A, queries):\n \"\"\"\n Calculates the sum of the elements in the subarray A[l-1:r-1] for each query.\n \n Parameters:\n n ... | trial_gpt4o_2 | {
"original_instruction": "You are given an array of integers $A$ of length $n$ and a sequence of $q$ queries. For each query, you are given two integers $l$ and $r$ (1-based index), and you need to find the sum of the elements in the subarray $A[l-1, r-1]$.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $1 \\leq q... | 0.663336 | Taco_72182 | C | [
"preprocess",
"range_sum",
"process_queries"
] | 3 | [
[
"process_queries",
"preprocess"
],
[
"process_queries",
"range_sum"
]
] | 2 | [
"process_queries"
] | false | [] | false | pytest | true | [] | true | a0133c69cfdb5385af96dfccc9ebdf9fbeb2a954 | 8da2d0e73ab572f98c74d9410661659514549bbb | |||
v1.0 | complete | Taco | Taco_72288_C | def is_valid_parentheses(s: str) -> str:
"""
Determines if the input string with parentheses, square brackets, and curly braces is valid.
Parameters:
s (str): The input string to be validated.
Returns:
str: "YES" if the input string is valid, otherwise "NO".
>>> is_valid_parenthes... | def is_valid_parentheses(s):
"""
Determines if the input string with parentheses, square brackets, and curly braces is valid.
Parameters:
s (str): The input string to be validated.
Returns:
str: "YES" if the input string is valid, otherwise "NO".
"""
stack = []
mapping = {'... | from solution import validate_multiple_cases, is_valid_parentheses
def test_is_valid_parentheses():
assert is_valid_parentheses("()[]{}") == "YES"
assert is_valid_parentheses("([{}])") == "YES"
assert is_valid_parentheses("[[") == "NO"
assert is_valid_parentheses("{[()]}") == "YES"
assert is_valid_... | [
{
"docstring": "Determines if the input string with parentheses, square brackets, and curly braces is valid.\n\nParameters:\ns (str): The input string to be validated.\n\nReturns:\nstr: \"YES\" if the input string is valid, otherwise \"NO\".",
"function_declaration": "def is_valid_parentheses(s):",
"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 is_valid_bracket_sequence(s):\n stack = []\n bracket_map = {')': '(', ']': '[', '}': '{'}\n \n for char in s:\n if char in bracket_map.value... | trial_gpt4o_2 | {
"original_instruction": "Given a string composed of parenthesis '(', ')', square brackets '[', ']', and curly braces '{', '}', determine if the input string is valid. An input string is valid if:\n\n1. Open brackets are closed by the same type of brackets.\n2. Open brackets are closed in the correct order.\n\nRetur... | 0.807717 | Taco_72288 | C | [
"is_valid_parentheses",
"validate_multiple_cases"
] | 2 | [
[
"validate_multiple_cases",
"is_valid_parentheses"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0dac03cc757400a4cff19691155b34d79a635783 | 2bf75bc50e5b15263b182b470fd335ef29601dc5 | |||
v1.0 | complete | Taco | Taco_72302_C | def min_route_length(N: int, M: int, roads: List[Tuple[int, int, int]]) -> int:
""" Calculate the total minimum length of the route for a delivery truck to complete a tour without taking the same road twice. If the tour is not possible, return -1.
>>> min_route_length(4, 6, [
... (1, 2, 10),
... (1, 3, ... | import itertools
def tsp(graph, start):
"""
Solves the Traveling Salesman Problem using brute force.
"""
n = len(graph)
vertices = list(range(n))
vertices.remove(start)
min_path = float('inf')
for permutation in itertools.permutations(vertices):
current_pathweight = 0
... | import pytest
from solution import min_route_length
def test_min_route_length_simple():
assert min_route_length(4, 6, [
(1, 2, 10),
(1, 3, 15),
(1, 4, 20),
(2, 3, 35),
(2, 4, 25),
(3, 4, 30)
]) == 80
def test_min_route_length_no_path():
assert min_route_leng... | [
{
"docstring": "Solves the Traveling Salesman Problem using brute force.",
"function_declaration": "def tsp(graph, start):",
"function_name": "tsp",
"parameter_list": "(graph, start)"
},
{
"docstring": null,
"function_declaration": "def min_route_length(N, M, roads):",
"function_name... | [
0,
0,
0,
0,
1,
0,
1,
0
] | 2 | hard | 0.25 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def min_route_length(N, M, roads):\n from itertools import combinations, product\n import sys\n \n # Create adjacency matrix\n inf = sys.maxsize\n ... | trial_gpt4o_7 | {
"original_instruction": "In a city, there are N intersections connected by M roads. Each road has a certain length. A delivery truck starts from a particular intersection and wants to return to the starting point after delivering all packages. However, the truck must not take the same road twice along its route. Ad... | 0.731166 | Taco_72302 | C | [
"tsp",
"min_route_length"
] | 2 | [
[
"min_route_length",
"tsp"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 657ad97f5d9bbb5a87911721e9c3a6fa23fe1209 | 5fee020fbe8d74a9e0606f4d718ff719b11cb13d | |||
v1.0 | complete | Taco | Taco_71992_C | from typing import List
def maximalRectangle(grid: List[str]) -> int:
"""
Given a grid of '0's and '1's, this function returns the area of the largest rectangle containing only '1's.
>>> maximalRectangle([
... "10100",
... "10111",
... "11111",
... "10010",
... ])
6
>... | def maximalRectangle(grid):
"""
Given a grid of '0's and '1's, this function returns the area of the largest rectangle containing only '1's.
"""
if not grid:
return 0
max_area = 0
heights = [0] * len(grid[0])
for row in grid:
for i in range(len(row)):
# ... | from solution import maximalRectangle
def test_maximal_rectangle_example_1():
grid = [
"10100",
"10111",
"11111",
"10010",
]
assert maximalRectangle(grid) == 6
def test_maximal_rectangle_example_2():
grid = [
"00",
"00",
]
assert maximalRectangle... | [
{
"docstring": "Given a grid of '0's and '1's, this function returns the area of the largest rectangle containing only '1's.",
"function_declaration": "def maximalRectangle(grid):",
"function_name": "maximalRectangle",
"parameter_list": "(grid)"
},
{
"docstring": "Given an array of heights c... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def maximalRectangle(grid):\n \"\"\"\n Given a grid of '0's and '1's, this function returns the area of the largest rectangle containing only '1's.\n \"\"... | trial_gpt4o_0 | {
"original_instruction": "Problem\n\nYou are given a grid consisting only of characters '0' and '1'. You need to find the largest rectangular sub-grid that contains only the character '1' and output its area.\n\nConstraints\n\n* 1 ≤ R, C ≤ 1000\n\nInput\n\nThe input is given in the following format:\n\n```\nR C\ngri... | 0.654454 | Taco_71992 | C | [
"maximalRectangle",
"largestRectangleArea"
] | 2 | [
[
"maximalRectangle",
"largestRectangleArea"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 785c58594b65b80be43ea83f1b112f11462d1ba2 | 969bd5a676702177529dd8b0e22369b6883480ab | |||
v1.0 | complete | Taco | Taco_71978_C | def is_overlapping(x1, y1, x2, y2, xx1, yy1, xx2, yy2):
"""Check if two rectangles overlap."""
return not (x2 < xx1 or xx2 < x1 or y2 > yy1 or yy2 > y1)
def check_overlap(n, rectangles):
"""Check if any rectangles in the given list overlap."""
for i in range(n):
for j in range(i + 1, n):
... | def is_overlapping(x1, y1, x2, y2, xx1, yy1, xx2, yy2):
"""
Check if two rectangles (x1, y1, x2, y2) and (xx1, yy1, xx2, yy2) overlap.
"""
return not (x2 < xx1 or xx2 < x1 or y2 > yy1 or yy2 > y1)
def check_overlap(n, rectangles):
"""
Check if any rectangles in the given list overlap.
"""
... | def test_is_overlapping():
assert not is_overlapping(1, 4, 3, 2, 6, 4, 8, 2)
assert is_overlapping(1, 4, 3, 2, 2, 3, 5, 1)
assert not is_overlapping(1, 4, 3, 2, 4, 5, 6, 3)
assert is_overlapping(1, 4, 4, 1, 2, 5, 6, 2)
def test_check_overlap():
assert check_overlap(3, [[1, 4, 3, 2], [2, 3, 5, 1], [... | [
{
"docstring": "Check if two rectangles (x1, y1, x2, y2) and (xx1, yy1, xx2, yy2) overlap.",
"function_declaration": "def is_overlapping(x1, y1, x2, y2, xx1, yy1, xx2, yy2):",
"function_name": "is_overlapping",
"parameter_list": "(x1, y1, x2, y2, xx1, yy1, xx2, yy2)"
},
{
"docstring": "Check... | [
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_overlapping(rect1, rect2):\n \"\"\"\n Checks if two rectangles overlap.\n Each rectangle is defined by two points (x1, y1) for top-left and (x2, y2... | trial_gpt4o_1 | {
"original_instruction": "You have been given a list of rectangles, each defined by its vertices in a 2D plane with integer coordinates. Your task is to determine if they overlap at any point. If they do, output \"Overlapping\", otherwise output \"Not Overlapping\".\n\nA rectangle is represented by its top-left and ... | 0.617663 | Taco_71978 | C | [
"is_overlapping",
"check_overlap",
"main"
] | 3 | [
[
"check_overlap",
"is_overlapping"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | c9deb82dda4ffa1cf00abf58d0502ed532b35bc3 | 0b7d6ed0dd576501c18dfd82c2975366b763252b | |||
v1.0 | complete | Taco | Taco_72590_C | def categorize_numbers(numbers: List[int]) -> Tuple[List[int], List[int]]:
""" Categorize the given list of numbers into a list of primes and non-primes.
>>> categorize_numbers([1, 2, 3, 4, 5, 6])
([2, 3, 5], [1, 4, 6])
>>> categorize_numbers([7, 8, 9, 10, 11, 12])
([7, 11], [8, 9, 10, 12])
""" | 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(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def categorize_nu... | from solution import categorize_numbers
def test_case_1():
numbers = [1, 2, 3, 4, 5, 6]
primes, non_primes = categorize_numbers(numbers)
assert primes == [2, 3, 5]
assert non_primes == [1, 4, 6]
def test_case_2():
numbers = [7, 8, 9, 10, 11, 12]
primes, non_primes = categorize_numbers(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": "Categorize the given list of numbers into a list of primes and non-primes.",
"function_declaration": "def c... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n retur... | trial_gpt4o_1 | {
"original_instruction": "You are given a list of N integers. Your task is to categorize them into two lists: one containing all prime numbers and the other containing non-prime numbers. Write a function to accomplish this and return both lists.\n\n### Input\n- The first line contains a single integer N (1 ≤ N ≤ 10^... | 0.611256 | Taco_72590 | C | [
"is_prime",
"categorize_numbers"
] | 2 | [
[
"categorize_numbers",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 07f2e801e15abe504460719f3e38b97b2c3cd003 | 132b4bb6ccf24557f90fcfe7ca36980aba495c1c | |||
v1.0 | complete | Taco | Taco_72320_C | def is_balanced(expression):
"""Returns 'YES' if the expression is balanced, otherwise 'NO'.
>>> is_balanced('()') == 'YES'
True
>>> is_balanced('((()))') == 'YES'
True
>>> is_balanced('(()))') == 'NO'
True
>>> is_balanced('((()()') == 'NO'
True
>>> is_balanced('') == 'YES'
T... | def is_balanced(expression):
"""
Returns "YES" if the expression is balanced, otherwise "NO".
"""
stack = []
for char in expression:
if char == '(':
stack.append(char)
elif char == ')':
if not stack:
return "NO"
stack.pop()
... | def test_is_balanced():
assert is_balanced('()') == 'YES'
assert is_balanced('((()))') == 'YES'
assert is_balanced('(()))') == 'NO'
assert is_balanced('((()()') == 'NO'
assert is_balanced('') == 'YES'
assert is_balanced(')(') == 'NO'
def test_check_expressions():
expressions = ['()', '((())... | [
{
"docstring": "Returns \"YES\" if the expression is balanced, otherwise \"NO\".",
"function_declaration": "def is_balanced(expression):",
"function_name": "is_balanced",
"parameter_list": "(expression)"
},
{
"docstring": "Check a list of expressions for balanced parentheses.\n\nParameters:\... | [
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(expression):\n \"\"\"\n Checks if the given expression containing only parentheses is balanced.\n \"\"\"\n stack = []\n for char in ... | trial_gpt4o_2 | {
"original_instruction": "For a series of expressions containing parentheses, check if each expression is balanced. A balanced expression has every opening parenthesis matched with a proper closing parenthesis.\n\nConstraints\n\n* 1 ≤ n ≤ 10000\n* Length of each expression ≤ 10000\n\nInput\n\nn\nexpression1\nexpress... | 0.690953 | Taco_72320 | C | [
"is_balanced",
"check_expressions"
] | 2 | [
[
"check_expressions",
"is_balanced"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 11e0f3f05cc18f1e85e255cb2311c1402162ccff | cd9f7e586b97e59fcff2526e4370b5b1ba1831e9 | |||
v1.0 | complete | Taco | Taco_72621_C | import math
from typing import List
def is_perfect_square(n: int) -> bool:
"""
Determines if a given number n is a perfect square.
>>> is_perfect_square(1) True
>>> is_perfect_square(2) False
>>> is_perfect_square(4) True
>>> is_perfect_square(10) False
>>> is_perfect_square(16) True
"... | import math
def is_perfect_square(n):
"""
Determines if a given number n is a perfect square.
"""
root = int(math.sqrt(n))
return root * root == n
def check_perfect_squares(sequence):
"""
For each integer in the sequence, determines whether it is a perfect square.
Returns a list of 'YE... | from solution import is_perfect_square, check_perfect_squares, main
def test_is_perfect_square():
assert is_perfect_square(1) == True
assert is_perfect_square(2) == False
assert is_perfect_square(4) == True
assert is_perfect_square(10) == False
assert is_perfect_square(16) == True
def test_check_p... | [
{
"docstring": "Determines if a given number n is a perfect square.",
"function_declaration": "def is_perfect_square(n):",
"function_name": "is_perfect_square",
"parameter_list": "(n)"
},
{
"docstring": "For each integer in the sequence, determines whether it is a perfect square.\nReturns 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": "import math\n\ndef perfect_squares(N, arr):\n \"\"\"\n Given a list of N integers, this function returns a list of 'YES' or 'NO'\n indicating whether each... | trial_gpt4o_1 | {
"original_instruction": "You are given a sequence of N integers, each in the range 1 to 10^6. For each integer in the sequence, determine whether it is a perfect square and print 'YES' if it is, and 'NO' otherwise.\n\nA perfect square is an integer that is the square of an integer.\n\nConstraints\n\n* All integers ... | 0.655704 | Taco_72621 | C | [
"is_perfect_square",
"check_perfect_squares",
"main"
] | 3 | [
[
"check_perfect_squares",
"is_perfect_square"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 39ea5ac1fd73c3b04c72015806628d2cf682de8f | 88d3b78c845f21785a366e99e526443eab82ddd8 | |||
v1.0 | complete | Taco | Taco_72784_C | import heapq
from typing import List
def optimal_palace_location(n: int, roads: List[List[int]]) -> int:
"""
Determine the minimum possible value for the maximum travel cost from the palace
to any other city and return the city where the palace should be built.
>>> optimal_palace_location(4, [[1... | import heapq
def dijkstra(n, graph, start):
"""
Function to perform Dijkstra's algorithm from the start node.
Returns a list of minimum distances from start to all other nodes.
"""
distances = [float('inf')] * n
distances[start] = 0
priority_queue = [(0, start)]
while priority_queu... | def test_optimal_palace_location():
assert optimal_palace_location(
4,
[
[1, 2, 3],
[2, 3, 4],
[3, 4, 5],
[4, 1, 6]
]
) == 7
assert optimal_palace_location(
3,
[
[1, 2, 1],
[2, 3, 1],
... | [
{
"docstring": "Function to perform Dijkstra's algorithm from the start node.\nReturns a list of minimum distances from start to all other nodes.",
"function_declaration": "def dijkstra(n, graph, start):",
"function_name": "dijkstra",
"parameter_list": "(n, graph, start)"
},
{
"docstring": "... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef dijkstra(graph, start, n):\n \"\"\"\n Implements Dijkstra's algorithm to find the shortest path from start node to all other nodes in the... | trial_gpt4o_8 | {
"original_instruction": "In a kingdom, there are several cities connected by various roads. The roads are bidirectional and each road has a certain travel cost. The king wants to build a new palace in one of the cities such that the maximum travel cost from this city to any other city is minimized.\n\nYou are given... | 0.664179 | Taco_72784 | C | [
"dijkstra",
"optimal_palace_location"
] | 2 | [
[
"optimal_palace_location",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | cb9b4edced9e73bdca81b4fb1e93d94748bf2549 | 3af2cf0286984551f5a855a51c159f86cc85af43 | |||
v1.0 | complete | Taco | Taco_72724_C | def max_sub_grid_sum(grid):
"""
Finds the maximum sum of a contiguous sub-grid in the given grid.
>>> max_sub_grid_sum([
[1, 2, -1],
[-3, 4, 2],
[1, -1, 3]
]) == 9
>>> max_sub_grid_sum([
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15... | def max_sub_grid_sum(grid):
"""
Finds the maximum sum of a contiguous sub-grid in the given grid.
"""
R, C = len(grid), len(grid[0])
max_sum = float('-inf')
for left in range(C):
temp = [0] * R
for right in range(left, C):
for i in range(R):
temp[i] +... | import pytest
from solution import max_sub_grid_sum
def test_case_1():
grid = [
[1, 2, -1],
[-3, 4, 2],
[1, -1, 3]
]
assert max_sub_grid_sum(grid) == 9
def test_case_2():
grid = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16]
... | [
{
"docstring": "Finds the maximum sum of a contiguous sub-grid in the given grid.",
"function_declaration": "def max_sub_grid_sum(grid):",
"function_name": "max_sub_grid_sum",
"parameter_list": "(grid)"
},
{
"docstring": "Helper function to perform Kadane's algorithm on 1D array to find the ... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_sub_grid_sum(grid):\n \"\"\"\n Finds the maximum sum of a contiguous sub-grid in the given grid.\n \"\"\"\n R, C = len(grid), len(grid[0])\n ... | trial_gpt4o_0 | {
"original_instruction": "You are given a grid with rows and columns, filled with positive integers. You need to find the maximum sum of a contiguous sub-grid in the given grid. A contiguous sub-grid is defined as the rectangular section of the grid that can be obtained by selecting a subarray of contiguous rows and... | 0.655663 | Taco_72724 | C | [
"max_sub_grid_sum",
"kadane_1d",
"read_grid_input"
] | 3 | [
[
"max_sub_grid_sum",
"kadane_1d"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | a4cac458877bb4429855c345560e54d4e08bf4fb | d962dbfe61b0ab26edf3e8d10d6592489aea6df3 | |||
v1.0 | complete | Taco | Taco_72652_C | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def create_linked_list(lst):
""" Create a linked list from a list of integers.
>>> create_linked_list([1, 2, 3]).val
1
"""
def reverse_linked_list(head):
""" Reverse a linked list.
>>> head = create_linked... | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def create_linked_list(lst):
if not lst:
return None
head = ListNode(lst[0])
current = head
for value in lst[1:]:
current.next = ListNode(value)
current = current.next
return head
def r... | from solution import reverse_list_of_integers
def test_reverse_list_of_integers():
assert reverse_list_of_integers(5, [1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
assert reverse_list_of_integers(3, [10, 20, 30]) == [30, 20, 10]
assert reverse_list_of_integers(1, [100]) == [100]
assert reverse_list_of_integers(4... | [] | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef create_linked_list(nums):\n if not nums:\n ... | trial_gpt4o_1 | {
"original_instruction": "Sarah recently learned about linked lists in her programming class and decided to test her skills with an interesting problem. She wants to create a linked list from a list of integers. After creating the linked list, she needs to reverse it.\n\nYour task is to help Sarah by writing a progr... | 0.601222 | Taco_72652 | C | [
"create_linked_list",
"reverse_linked_list",
"linked_list_to_list",
"reverse_list_of_integers"
] | 4 | [
[
"reverse_list_of_integers",
"create_linked_list"
],
[
"reverse_list_of_integers",
"linked_list_to_list"
],
[
"reverse_list_of_integers",
"reverse_linked_list"
]
] | 3 | [] | false | [
"ListNode"
] | true | pytest | true | [] | true | bd478ff78cb233f5a0d10b281d3e273d5b7e15ec | de25e7e235e48e473afbeafa25bca72a3ce9f224 | |||
v1.0 | complete | Taco | Taco_72114_C | from typing import List, Tuple
def can_form_word(s: str, word: str) -> bool:
"""
Helper function to check if a word can be formed from the letters of string s without reusing any letters.
"""
from collections import Counter
s_counter = Counter(s)
word_counter = Counter(word)
for char, ... | def can_form_word(s, word):
"""
Helper function to check if a word can be formed from the letters of string s without reusing any letters.
"""
from collections import Counter
s_counter = Counter(s)
word_counter = Counter(word)
for char, count in word_counter.items():
if s_counte... | import pytest
from solution import can_form_word, count_formable_words, process_test_cases
def test_can_form_word():
assert can_form_word("aabbcc", "abc") == True
assert can_form_word("aabbcc", "aaa") == False
assert can_form_word("aabbcc", "bbb") == False
assert can_form_word("aabbcc", "cca") == True
... | [
{
"docstring": "Helper function to check if a word can be formed from the letters of string s without reusing any letters.",
"function_declaration": "def can_form_word(s, word):",
"function_name": "can_form_word",
"parameter_list": "(s, word)"
},
{
"docstring": "Returns the count of words th... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_formable_words(S, words):\n \"\"\"\n Returns the count of words from the list that can be formed using the letters of the string S \n without re... | trial_gpt4o_2 | {
"original_instruction": "Given a string S and an array of words W, determine the count of words from the array that can be formed using the letters of the string S without reusing any letters. Each letter in the string S can be used only once per word.\n\nInput:\n\nThe first line contains the integer T, the number ... | 0.755936 | Taco_72114 | C | [
"can_form_word",
"count_formable_words",
"process_test_cases"
] | 3 | [
[
"count_formable_words",
"can_form_word"
],
[
"process_test_cases",
"count_formable_words"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | true | [] | true | de7c4bd521bfb969633f3c113d76f09656739ee6 | d7d35370bb5ade16cd195d9738b312e8f559ca4b | |||
v1.0 | complete | Taco | Taco_72977_C | from typing import List, Tuple
from collections import Counter
def can_form_palindrome(name: str) -> Tuple[str, str]:
""" Determines if the given product name can be rearranged into a palindrome.
Returns a tuple of (result, palindrome) where result is "YES" or "NO"
and palindrome is any one possible palin... | from collections import Counter
def can_form_palindrome(name):
"""
Determines if the given product name can be rearranged into a palindrome.
Returns a tuple of (result, palindrome) where result is "YES" or "NO"
and palindrome is any one possible palindromic permutation or None if it's not possible.
... | def test_can_form_palindrome_yes():
result, palindrome = can_form_palindrome("AABB")
assert result == "YES"
assert palindrome == "ABBA" or palindrome == "BAAB"
def test_can_form_palindrome_no():
result, palindrome = can_form_palindrome("CAR")
assert result == "NO"
assert palindrome is None
def... | [
{
"docstring": "Determines if the given product name can be rearranged into a palindrome.\nReturns a tuple of (result, palindrome) where result is \"YES\" or \"NO\" \nand palindrome is any one possible palindromic permutation or None if it's not possible.",
"function_declaration": "def can_form_palindrome(n... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def can_form_palindrome(name):\n \"\"\"\n Checks if the given product name can be rearranged to form a palindrome.\n Returns \"YES\" with any one of the p... | trial_gpt4o_3 | {
"original_instruction": "Your friend Jeff Zebos is trying to enhance his product catalog by giving each product a catchy name. However, due to certain restrictions, he's only able to use alphabetic characters and wants to generate new names based on predefined sets of valid names.\n\nUnfortunately, Jeff learned tha... | 0.672724 | Taco_72977 | C | [
"can_form_palindrome",
"process_names"
] | 2 | [
[
"process_names",
"can_form_palindrome"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 78fc2f1191b93a82dd0b4a4ac9b6f8634bbb891f | 4da3fd12773c56fbda316a75394ca4ab98115a06 | |||
v1.0 | complete | Taco | Taco_72386_C | def minimum_effort_path(grid: List[List[int]]) -> int:
"""Find the minimum possible effort to travel from the top-left corner to the bottom-right corner of the grid.
Each cell's value represents its height, and you can only move to a neighboring cell if the new cell's value is
less than or equal to the cur... | import heapq
def minimum_effort_path(grid):
m, n = len(grid), len(grid[0])
heap = [(0, 0, 0)] # (effort, row, col)
efforts = [[float('inf')] * n for _ in range(m)]
efforts[0][0] = 0
directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
while heap:
effort, x, y = heapq.heappop(heap)
... | from solution import read_input_and_solve
def test_minimum_effort_path_case_1():
input_str = "3 3\n1 2 2\n3 8 2\n5 3 5"
assert read_input_and_solve(input_str) == 2
def test_minimum_effort_path_case_2():
input_str = "2 2\n1 2\n2 3"
assert read_input_and_solve(input_str) == 1
def test_minimum_effort_pa... | [
{
"docstring": null,
"function_declaration": "def minimum_effort_path(grid):",
"function_name": "minimum_effort_path",
"parameter_list": "(grid)"
},
{
"docstring": null,
"function_declaration": "def read_input_and_solve(input_str):",
"function_name": "read_input_and_solve",
"para... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef minimum_effort_path(grid):\n m, n = len(grid), len(grid[0])\n heap = [(0, 0, 0)] # (effort, row, col)\n efforts = [[float('inf')] * n... | trial_gpt4o_0 | {
"original_instruction": "You are given a matrix `grid` consisting of `m` rows and `n` columns filled with integers. A cell at (i, j) in `grid` represents the height of the particular cell. You can only move up, down, left, or right if and only if the new cell's value is less than or equal to the current cell's valu... | 0.664053 | Taco_72386 | C | [
"minimum_effort_path",
"read_input_and_solve"
] | 2 | [
[
"read_input_and_solve",
"minimum_effort_path"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6240dad0819b04de7a48e15ecff8fe96c0a33d07 | df151e08d9b5f02f85973308b9045a35e3e158c5 | |||
v1.0 | complete | Taco | Taco_72484_C | import heapq
def dijkstra(graph, start, n):
distances = [float('inf')] * (n + 1)
distances[start] = 0
pq = [(0, start)]
while pq:
current_distance, current_node = heapq.heappop(pq)
if current_distance > distances[current_node]:
continue
for neighbor, weight in gra... | import heapq
def dijkstra(graph, start, n):
distances = [float('inf')] * (n + 1)
distances[start] = 0
pq = [(0, start)]
while pq:
current_distance, current_node = heapq.heappop(pq)
if current_distance > distances[current_node]:
continue
for neighbor, weight in gra... | def test_kingdom_problems_case_1():
input_data = [
(4, 5, [(1, 2, 3), (1, 3, 1), (2, 3, 1), (2, 4, 5), (3, 4, 2)])
]
expected_output = [2]
assert solve_kingdom_problems(input_data) == expected_output
def test_kingdom_problems_case_2():
input_data = [
(3, 3, [(1, 2, 4), (2, 3, 2), (1... | [
{
"docstring": null,
"function_declaration": "def dijkstra(graph, start, n):",
"function_name": "dijkstra",
"parameter_list": "(graph, start, n)"
},
{
"docstring": null,
"function_declaration": "def solve_kingdom_problems(test_cases):",
"function_name": "solve_kingdom_problems",
... | [
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 min_max_shortest_path(T, test_cases):\n from heapq import heappop, heappush\n import math\n \n def dijkstra(graph, start):\n distances = {no... | trial_gpt4o_2 | {
"original_instruction": "A kingdom has n villages connected by m bidirectional roads. The roads vary in length, and the king wants to strengthen the roads in such a way that the maximum length of the shortest path between any two villages is minimized. In other words, the king wants to ensure that the farthest shor... | 0.690607 | Taco_72484 | C | [
"dijkstra",
"solve_kingdom_problems"
] | 2 | [
[
"solve_kingdom_problems",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | dabcf12b12fa6969efabbd99f549e192d8a6516a | e56c0dfac340dc580cbe536f6fcc5d843e973a3e | |||
v1.0 | complete | Taco | Taco_72576_C | import datetime
from typing import List
def get_day_of_week(date: str) -> str:
"""
Takes a date string in 'YYYY-MM-DD' format and returns the day of the week.
"""
pass
def process_dates(dates: List[str]) -> List[str]:
"""
Process multiple date strings and print the corresponding day of the wee... | import datetime
def get_day_of_week(date):
"""
Takes a date string in 'YYYY-MM-DD' format and returns the day of the week.
"""
date_object = datetime.datetime.strptime(date, '%Y-%m-%d')
return date_object.strftime('%A')
def process_dates(dates):
"""
Process multiple date strings and print ... | from solution import get_day_of_week, process_dates
def test_get_day_of_week():
assert get_day_of_week("2023-10-05") == "Thursday"
assert get_day_of_week("1999-12-31") == "Friday"
assert get_day_of_week("2000-01-01") == "Saturday"
assert get_day_of_week("2023-01-01") == "Sunday"
assert get_day_of_w... | [
{
"docstring": "Takes a date string in 'YYYY-MM-DD' format and returns the day of the week.",
"function_declaration": "def get_day_of_week(date):",
"function_name": "get_day_of_week",
"parameter_list": "(date)"
},
{
"docstring": "Process multiple date strings and print the corresponding day ... | [
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 datetime\n\ndef process_dates(dates):\n \"\"\"\n Process a list of date strings and print the day of the week for each date.\n Each date should be ... | trial_gpt4o_2 | {
"original_instruction": "Write a program that processes a series of dates and determines which day of the week each date falls on.\n\nConstraints:\n\n- The date will be given in the format YYYY-MM-DD.\n- The input will consist of multiple dates, one per line.\n- The input ends with an empty line.\n- The years given... | 0.658665 | Taco_72576 | C | [
"get_day_of_week",
"process_dates"
] | 2 | [
[
"process_dates",
"get_day_of_week"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0cc4401ad7add6239b3d326059b66e49753fb839 | 4d9a43a96df556924a57bdeb9390b3c7b51ab8e9 | |||
v1.0 | complete | Taco | Taco_72542_C | def get_denominations(denominations: int) -> List[int]:
"""
Convert the binary representation of denominations into a list of coin values.
>>> get_denominations(0b0111) == [1, 5, 10]
>>> get_denominations(0b1001) == [1, 25]
"""
def min_coins(amount: int, denominations: int) -> int:
"""
... | def get_denominations(denominations):
"""
Convert the binary representation of denominations into a list of coin values.
"""
coin_values = [1, 5, 10, 25]
available_coins = []
for i in range(4):
if (denominations >> i) & 1:
available_coins.append(coin_values[i])
... | from solution import min_coins
def test_min_coins_example():
assert min_coins(12, 0b0111) == 3 # 1 dime + 2 pennies
def test_min_coins_no_pennies():
assert min_coins(3, 0b0110) == -1 # 3 cannot be made with nickels and dimes
def test_min_coins_only_pennies():
assert min_coins(4, 0b0001) == 4 # 4 p... | [
{
"docstring": "Convert the binary representation of denominations into a list of coin values.",
"function_declaration": "def get_denominations(denominations):",
"function_name": "get_denominations",
"parameter_list": "(denominations)"
},
{
"docstring": "Calculate the minimum number of coins... | [
0,
0,
0,
0,
0,
1,
0,
0,
1,
1
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def min_coins_needed(amount, denominations):\n \"\"\"\n Returns the minimum number of coins needed to make the payment or -1 if it's not possible.\n \n ... | trial_gpt4o_8 | {
"original_instruction": "## Task\nYou are given a vending machine that only accepts coins of certain denominations.\n\nDenominations are represented using binary representation:\n```\n0001 - penny (1 cent)\n0010 - nickel (5 cents)\n0100 - dime (10 cents)\n1000 - quarter (25 cents)\n```\nFor example, if the vending ... | 0.674143 | Taco_72542 | C | [
"get_denominations",
"min_coins"
] | 2 | [
[
"min_coins",
"get_denominations"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b5913b2b55a93237b34578f6cc5877e983496fdb | 693526df5cd8024ac9d961bdcc65521444cde575 | |||
v1.0 | complete | Taco | Taco_73037_C | from typing import List, Tuple
def next_simultaneous_watering_day(test_cases: List[Tuple[int, List[int]]]) -> List[int]:
""" Determines the next day when all plants will be watered simultaneously.
Each test case consists of a number of plants and their watering frequencies.
The function should return ... | import math
from functools import reduce
MOD = 1000000007
def lcm(a, b):
return abs(a * b) // math.gcd(a, b)
def lcm_multiple(*args):
return reduce(lcm, args)
def next_simultaneous_watering_day(test_cases):
results = []
for case in test_cases:
n, frequencies = case
next_day = lcm_mul... | from solution import next_simultaneous_watering_day
def test_single_case():
assert next_simultaneous_watering_day([(3, [2, 3, 5])]) == [30]
def test_multiple_cases():
assert next_simultaneous_watering_day([(3, [2, 3, 5]), (2, [4, 6])]) == [30, 12]
def test_large_numbers():
assert next_simultaneous_wateri... | [
{
"docstring": null,
"function_declaration": "def lcm(a, b):",
"function_name": "lcm",
"parameter_list": "(a, b)"
},
{
"docstring": null,
"function_declaration": "def lcm_multiple(*args):",
"function_name": "lcm_multiple",
"parameter_list": "(*args)"
},
{
"docstring": nul... | [
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 gcd\nfrom functools import reduce\n\nMOD = 1000000007\n\ndef lcm(a, b):\n return (a * b) // gcd(a, b)\n\ndef lcm_of_list(frequencies):\n ret... | trial_gpt4o_2 | {
"original_instruction": "John loves gardening and has a beautiful garden with N different plants. He waters these plants with a unique watering system that has multiple watering schedules. Each plant has its own watering frequency in days. When plants are watered on the same day, they grow together and bloom beauti... | 0.563407 | Taco_73037 | C | [
"lcm",
"lcm_multiple",
"next_simultaneous_watering_day"
] | 3 | [
[
"lcm_multiple",
"lcm"
],
[
"next_simultaneous_watering_day",
"lcm_multiple"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | cd42f045f1354f4e1abe8937eacf9e2fe8d6f7e4 | 376ce6a0fbc80674a6c8fe459b03fcd1c2caa24e | |||
v1.0 | complete | Taco | Taco_72609_C | def are_dictionaries_equivalent(d1, d2):
"""
Checks if two dictionaries are equivalent by comparing their sequences.
:param d1: Dictionary 1, a dict of words to sequences
:param d2: Dictionary 2, a dict of words to sequences
:return: True if dictionaries are equivalent, False otherwise
"""
... | def are_dictionaries_equivalent(d1, d2):
"""
Checks if two dictionaries are equivalent by comparing their sequences.
:param d1: Dictionary 1, a dict of words to sequences
:param d2: Dictionary 2, a dict of words to sequences
:return: True if dictionaries are equivalent, False otherwise
"""
... | import pytest
from solution import are_dictionaries_equivalent, parse_input, compare_dictionaries
def test_are_dictionaries_equivalent():
d1 = {'hello': 'h1^', 'world': 'w1@'}
d2 = {'hello': 'h1^', 'world': 'w1@'}
assert are_dictionaries_equivalent(d1, d2) == True
d3 = {'hello': 'h1^'}
d4 = {'hel... | [
{
"docstring": "Checks if two dictionaries are equivalent by comparing their sequences.\n\n:param d1: Dictionary 1, a dict of words to sequences\n:param d2: Dictionary 2, a dict of words to sequences\n:return: True if dictionaries are equivalent, False otherwise",
"function_declaration": "def are_dictionari... | [
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 are_dictionaries_equivalent(dict1, dict2):\n \"\"\"\n Function to check if two given dictionaries are equivalent.\n \"\"\"\n return dict1 == dict2\... | trial_gpt4o_2 | {
"original_instruction": "In a fictional world, a group of magical wizards use a special form of communication called \"spell encryption\" to send secret messages. The messages are encrypted using a combination of magical gestures, represented by unique sequences of letters and symbols.\n\nEach wizard has a personal... | 0.595091 | Taco_72609 | C | [
"are_dictionaries_equivalent",
"parse_input",
"compare_dictionaries"
] | 3 | [
[
"compare_dictionaries",
"are_dictionaries_equivalent"
],
[
"compare_dictionaries",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 61f1f726fc58660f837a20cfefc6e2c5970be6b6 | 3b8600f1200b6541e15b1d96665beccf5097aa5b | |||
v1.0 | complete | Taco | Taco_72867_C | def longestPalindromicSubarrayLength(nums: List[int]) -> int:
"""
Write a function that takes an array of integers and returns the length of the longest
contiguous subarray that forms a palindrome. A subarray is a contiguous part of an array
that can be obtained by deleting zero or more elements from... | def is_palindrome(subarray):
"""
Helper function to check if a given subarray is a palindrome.
"""
return subarray == subarray[::-1]
def longestPalindromicSubarrayLength(nums):
"""
Returns the length of the longest contiguous subarray that forms a palindrome.
"""
max_length = 0
n = ... | from solution import longestPalindromicSubarrayLength
def test_empty_array():
assert longestPalindromicSubarrayLength([]) == 0
def test_single_element():
assert longestPalindromicSubarrayLength([1]) == 1
def test_all_elements_same():
assert longestPalindromicSubarrayLength([2, 2, 2, 2, 2]) == 5
def test... | [
{
"docstring": "Helper function to check if a given subarray is a palindrome.",
"function_declaration": "def is_palindrome(subarray):",
"function_name": "is_palindrome",
"parameter_list": "(subarray)"
},
{
"docstring": "Returns the length of the longest contiguous subarray that forms a palin... | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def longestPalindromicSubarrayLength(arr):\n \"\"\"\n Return the length of the longest contiguous subarray that forms a palindrome.\n \"\"\"\n n = len(... | trial_gpt4o_5 | {
"original_instruction": "Write a function that takes an array of integers and returns the length of the longest contiguous subarray that forms a palindrome. A subarray is a contiguous part of an array that can be obtained by deleting zero or more elements from either end of the array.\n\n```\nlongestPalindromicSuba... | 0.72775 | Taco_72867 | C | [
"is_palindrome",
"longestPalindromicSubarrayLength"
] | 2 | [
[
"longestPalindromicSubarrayLength",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8d5a751a7dfd87328c68f355d7cccf588ad33b1b | 97439386eec8a6f1b7863d024117416e79100169 | |||
v1.0 | complete | Taco | Taco_72718_C | def count_unique_prime_cycles(N: int, primes: List[int]) -> int:
""" Counts the number of unique Prime Cycles from the given list of prime numbers.
>>> count_unique_prime_cycles(3, [11, 13, 17])
3
>>> count_unique_prime_cycles(1, [7])
1
>>> count_unique_prime_cycles(4, [2, 3, 5, 7])
4
>>... | def generate_cyclic_permutations(primes):
"""
Generate all cyclic permutations of the given list of prime numbers.
"""
N = len(primes)
cycles = []
for i in range(N):
cycle = primes[i:] + primes[:i]
cycles.append(tuple(cycle))
return cycles
def count_unique_prime_cycles(N, pr... | from solution import count_unique_prime_cycles
def test_small_case():
assert count_unique_prime_cycles(3, [11, 13, 17]) == 3
def test_single_prime():
assert count_unique_prime_cycles(1, [7]) == 1
def test_multiple_unique_cycles():
assert count_unique_prime_cycles(4, [2, 3, 5, 7]) == 4
def test_larger_ca... | [
{
"docstring": "Generate all cyclic permutations of the given list of prime numbers.",
"function_declaration": "def generate_cyclic_permutations(primes):",
"function_name": "generate_cyclic_permutations",
"parameter_list": "(primes)"
},
{
"docstring": "Counts the number of unique Prime Cycle... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_unique_prime_cycles(primes):\n \"\"\"\n Function to count unique prime cycles formed from a given list of prime numbers.\n \n Parameters:\n ... | trial_gpt4o_2 | {
"original_instruction": "Bob likes playing with prime numbers. He recently learned about a new concept called \"Prime Cycles\". A Prime Cycle is a sequence of prime numbers where each prime number is shifted to create a cyclic permutation. Bob wants to find out how many unique Prime Cycles can be formed from a give... | 0.73101 | Taco_72718 | C | [
"generate_cyclic_permutations",
"count_unique_prime_cycles"
] | 2 | [
[
"count_unique_prime_cycles",
"generate_cyclic_permutations"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b3a5334b27bdda53412466b70cd159fc03c2f6a4 | 88eb8bf153e3f110bedf46e0b4ae50043772337b | |||
v1.0 | complete | Taco | Taco_72566_C | from typing import List, Tuple
def treasure_hunt(t: int, cases: List[Tuple[Tuple[int, int], List[str]]]) -> List[int]:
""" You are participating in a treasure hunt game where you need to find the shortest path through a grid filled with obstacles and treasures. The grid is represented as an `n x m` matrix, where e... | from itertools import permutations
from collections import deque
def bfs(grid, start, goals):
n, m = len(grid), len(grid[0])
q = deque([(start, 0)])
visited = set([start])
distances = {}
while q:
(x, y), dist = q.popleft()
if (x, y) in goals:
distances[(x, y)] = dist
... | from solution import treasure_hunt
def test_example_1():
t = 2
cases = [
((5, 5), [
'S0000',
'010T0',
'01000',
'T0000',
'0000E'
]),
((3, 3), [
'S1T',
'111',
'TE0'
])
]
assert ... | [
{
"docstring": null,
"function_declaration": "def bfs(grid, start, goals):",
"function_name": "bfs",
"parameter_list": "(grid, start, goals)"
},
{
"docstring": null,
"function_declaration": "def find_shortest_path(grid):",
"function_name": "find_shortest_path",
"parameter_list": ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\nfrom itertools import combinations\n\ndef min_steps_to_collect_treasures(grid):\n n, m = len(grid), len(grid[0])\n \n def f... | trial_gpt4o_9 | {
"original_instruction": "You are participating in a treasure hunt game where you need to find the shortest path through a grid filled with obstacles and treasures. The grid is represented as an `n x m` matrix, where each cell can contain:\n\n- '0' (empty cell): You can walk through it.\n- '1' (obstacle): You cannot... | 0.657016 | Taco_72566 | C | [
"bfs",
"find_shortest_path",
"treasure_hunt"
] | 3 | [
[
"find_shortest_path",
"bfs"
],
[
"treasure_hunt",
"find_shortest_path"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 8bc746768ffe465776ef8d768eac7007e1664c3e | 035804117b000254b8b48fb60ebc69ada999c171 | |||
v1.0 | complete | Taco | Taco_72520_C | def analyze_taxi_data(M: int, rides: List[Tuple[int, int, float]]) -> List[Tuple[int, int, float]]:
""" Analyze taxi fare data to identify pricing patterns among different companies.
Group the records by company ID, and for each company, sort the rides by distance in ascending order.
If two rides have the s... | def analyze_taxi_data(M, rides):
from collections import defaultdict
# Dictionary to hold the rides grouped by company_id
company_data = defaultdict(list)
# Parsing the input rides
for ride in rides:
company_id, distance, fare = ride
company_data[company_id].append((distanc... | from solution import analyze_taxi_data, taxi_fare_analysis
def test_analyze_taxi_data():
input_data = [
(1, 10, 15.75),
(2, 15, 19.50),
(1, 5, 12.00),
(2, 15, 20.00),
(1, 5, 15.00),
(2, 20, 25.00),
]
expected_output = [
(1, 5, 15.00),
(1,... | [
{
"docstring": null,
"function_declaration": "def analyze_taxi_data(M, rides):",
"function_name": "analyze_taxi_data",
"parameter_list": "(M, rides)"
},
{
"docstring": null,
"function_declaration": "def taxi_fare_analysis(input_str):",
"function_name": "taxi_fare_analysis",
"para... | [
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 sort_taxi_rides(records):\n from collections import defaultdict\n \n rides = defaultdict(list)\n \n for record in records:\n company_id, ... | trial_gpt4o_1 | {
"original_instruction": "In a bustling city, the taxi companies maintain records of their taxi fares for different rides. Each taxi company has a unique company ID and records the distance of the ride along with the fare charged for that distance. The city council wants to analyze this data to identify pricing patt... | 0.544539 | Taco_72520 | C | [
"analyze_taxi_data",
"taxi_fare_analysis"
] | 2 | [
[
"taxi_fare_analysis",
"analyze_taxi_data"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 5130457bed07e390040993af392e215f1316cb30 | 7afa5019d8a341e2f82d69ab577d100e12bc1ef5 | |||
v1.0 | complete | Taco | Taco_72426_C | def solve(input_string: str) -> str:
"""
Bob is interested in finding out if it's possible to design an algorithm that can detect the shortest path in a weighted undirected graph from a starting node to a target node. The graph does not contain any negative weights.
:param input_string: A formatted input ... | import heapq
def dijkstra(n, edges, start, end):
graph = {i: [] for i in range(1, n + 1)}
for u, v, w in edges:
graph[u].append((w, v))
graph[v].append((w, u))
heap = [(0, start)]
distances = {i: float('inf') for i in range(1, n + 1)}
distances[start] = 0
while heap:
... | from solution import solve
def test_case_1():
input_data = "2\n4 4\n1 2 4\n1 3 2\n2 3 5\n3 4 1\n1 4\n3 2\n1 2 5\n2 3 7\n1 3"
expected_output = "3\n12"
assert solve(input_data) == expected_output
def test_case_2():
input_data = "1\n2 1\n1 2 1\n1 2"
expected_output = "1"
assert solve(input_data)... | [
{
"docstring": null,
"function_declaration": "def dijkstra(n, edges, start, end):",
"function_name": "dijkstra",
"parameter_list": "(n, edges, start, end)"
},
{
"docstring": null,
"function_declaration": "def find_shortest_paths(test_cases):",
"function_name": "find_shortest_paths",
... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef dijkstra_shortest_path(n, edges, start, target):\n graph = [[] for _ in range(n + 1)]\n \n for u, v, w in edges:\n graph[u].app... | trial_gpt4o_1 | {
"original_instruction": "Bob is a digital sentient AI who recently obtained access to universally stored data of countless human societies. He is intrigued by a specific problem in graph theory and asks for your help to solve it.\n\nBob is interested in finding out if it's possible to design an algorithm that can d... | 0.769478 | Taco_72426 | C | [
"dijkstra",
"find_shortest_paths",
"parse_input",
"solve"
] | 4 | [
[
"find_shortest_paths",
"dijkstra"
],
[
"solve",
"find_shortest_paths"
],
[
"solve",
"parse_input"
]
] | 3 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 269b95678d60fb3f8ecfa020a2a362b4686eeecf | 326140b908ba4985b5c0579f8706ff1ce7c02b38 | |||
v1.0 | complete | Taco | Taco_72680_C | from typing import List, Tuple
def shortest_travel_time(n: int, m: int, roads: List[Tuple[int, int, int]], q: int, queries: List[Tuple[int, int]]) -> List[int]:
"""
Determines the shortest time from the start building to the destination building for each query.
:param n: Total number of buildings.
... | import heapq
def dijkstra(n, adj, start):
"""
Implementation of Dijkstra's algorithm to find the shortest path from a single source to all other nodes.
"""
dist = {i: float('inf') for i in range(1, n + 1)}
dist[start] = 0
pq = [(0, start)]
while pq:
current_dist, u = heapq.heap... | def test_shortest_travel_time():
# Define the test case
n = 5
m = 5
q = 3
roads = [
(1, 2, 10),
(2, 3, 20),
(3, 4, 30),
(4, 5, 40),
(1, 3, 100)
]
queries = [
(1, 5),
(3, 1),
(3, 4)
]
expected_output = [
100,... | [
{
"docstring": "Implementation of Dijkstra's algorithm to find the shortest path from a single source to all other nodes.",
"function_declaration": "def dijkstra(n, adj, start):",
"function_name": "dijkstra",
"parameter_list": "(n, adj, start)"
},
{
"docstring": "Determines the shortest time... | [
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 heapq\n\ndef dijkstra(n, graph, start, end):\n distance = {i: float('inf') for i in range(1, n+1)}\n distance[start] = 0\n priority_queue = [(0, st... | trial_gpt4o_2 | {
"original_instruction": "During a rescue operation, Alex needs to navigate several buildings connected by roads in a disaster-stricken city. The city can be represented as a graph where nodes are buildings and edges are roads connecting them. Each road either allows traffic in one direction or both directions, and ... | 0.782853 | Taco_72680 | C | [
"dijkstra",
"shortest_travel_time"
] | 2 | [
[
"shortest_travel_time",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 57ab4bda032345cd8e77f3229216dd3243df36d5 | c6fccdcb954db5cd651de3aff891db962b1ff59c | |||
v1.0 | complete | Taco | Taco_73056_C | from typing import List, Tuple
def find_distinct_pairs_count(arr: List[int], k: int) -> int:
""" Finds the number of unique pairs that add up to k in the given array.
>>> find_distinct_pairs_count([4, 3, 5, 7, 8], 10) 1
>>> find_distinct_pairs_count([1, 5, 7, -1], 6) 2
>>> find_distinct_pairs_count([1,... | def find_distinct_pairs_count(arr, k):
"""
Finds the number of unique pairs that add up to k in the given array.
"""
seen = set()
pairs = set()
for num in arr:
target = k - num
if target in seen:
ordered_pair = tuple(sorted((num, target)))
pairs.add(o... | from solution import find_distinct_pairs_count, solve, parse_input
def test_find_distinct_pairs_count():
assert find_distinct_pairs_count([4, 3, 5, 7, 8], 10) == 1
assert find_distinct_pairs_count([1, 5, 7, -1], 6) == 2
assert find_distinct_pairs_count([1, 2, 3, 4, 5], 5) == 2
assert find_distinct_pair... | [
{
"docstring": "Finds the number of unique pairs that add up to k in the given array.",
"function_declaration": "def find_distinct_pairs_count(arr, k):",
"function_name": "find_distinct_pairs_count",
"parameter_list": "(arr, k)"
},
{
"docstring": null,
"function_declaration": "def solve(... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_distinct_pairs_with_sum(arr, k):\n \"\"\"\n Returns the number of distinct pairs in the arr that add up to k.\n \"\"\"\n seen = set()\n pa... | trial_gpt4o_1 | {
"original_instruction": "You are given an integer array $arr$ and an integer $k$. Find the number of distinct pairs of numbers in the array that add up to the integer $k$. A pair $(x, y)$ is considered unique if there are no previously counted pairs with both $x$ and $y$ the same.\n\n-----Input:-----\n- First line ... | 0.670775 | Taco_73056 | C | [
"find_distinct_pairs_count",
"solve",
"parse_input"
] | 3 | [
[
"solve",
"find_distinct_pairs_count"
]
] | 1 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | c7e748fcfb8573a7b71222c22265276b4efbcf94 | 742a83a814c6da133ed49d7887e3fa22398aa73e | |||
v1.0 | complete | Taco | Taco_73200_C | def is_prime(n):
"""
Determines if a number is a prime number.
"""
pass
def is_palindrome(n):
"""
Determines if a number is a palindrome.
"""
pass
def is_prime_palindrome(x):
"""
Determines if a number is both a prime number and a palindrome.
"""
pass
def process_test_... | def is_prime(n):
"""
Determines if a number is a prime number.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def is_palindrome(n):
... | from solution import is_prime, is_palindrome, is_prime_palindrome, process_test_cases
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(1) == False
assert is_prime(13) == True
assert is_prime(15)... | [
{
"docstring": "Determines if a number is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Determines if a number is a palindrome.",
"function_declaration": "def is_palindrome(n):",
"function_name": ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\... | trial_gpt4o_0 | {
"original_instruction": "Write a program to determine whether a number is a prime number and also a palindrome. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. A palindrome is a number that reads the same forward and backward.\n\n------ Input Format ------\n\n- The f... | 0.710546 | Taco_73200 | C | [
"is_prime",
"is_palindrome",
"is_prime_palindrome",
"process_test_cases"
] | 4 | [
[
"is_prime_palindrome",
"is_palindrome"
],
[
"is_prime_palindrome",
"is_prime"
],
[
"process_test_cases",
"is_prime_palindrome"
]
] | 3 | [
"process_test_cases"
] | false | [] | false | pytest | true | [] | true | 051dbed5e730591e716a3488a7a5b0e6519fcbe5 | d56daa95b3d9a21380c828b570f3613efbcc9eaa | |||
v1.0 | complete | Taco | Taco_73207_C | def compute_uniqueness_score(s: str) -> int:
""" Given a list of integers represented as a space-separated string, compute its "uniqueness score" defined as the number of unique prime factors across all the integers in the list.
>>> compute_uniqueness_score("6")
2
>>> compute_uniqueness_score("6 10 15")... | from math import isqrt
def prime_factors(n):
factors = set()
# Divide by 2 until n is odd
while n % 2 == 0:
factors.add(2)
n //= 2
# Check for odd factors from 3 up to sqrt(n)
for i in range(3, isqrt(n) + 1, 2):
while n % i == 0:
factors.add(i)
n //= ... | from solution import compute_uniqueness_score
def test_single_number():
assert compute_uniqueness_score("6") == 2 # Prime factors: 2, 3
def test_multiple_numbers():
assert compute_uniqueness_score("6 10 15") == 3 # Prime factors: 2, 3, 5
def test_unique_prime():
assert compute_uniqueness_score("2 3 5 7... | [
{
"docstring": null,
"function_declaration": "def prime_factors(n):",
"function_name": "prime_factors",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def uniqueness_score(numbers):",
"function_name": "uniqueness_score",
"parameter_list": "(numbers)"
}... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef sieve(limit):\n is_prime = [True] * (limit + 1)\n p = 2\n while p * p <= limit:\n if is_prime[p]:\n for i in range(p ... | trial_gpt4o_3 | {
"original_instruction": "Given a list of integers, we can define its \"uniqueness score\" as the number of unique prime factors across all the integers in the list.\n\nWrite a function to compute the uniqueness score of a given list of integers.\n\n### Input\n- A single line containing space-separated integers. Eac... | 0.639624 | Taco_73207 | C | [
"prime_factors",
"uniqueness_score",
"compute_uniqueness_score"
] | 3 | [
[
"compute_uniqueness_score",
"uniqueness_score"
],
[
"uniqueness_score",
"prime_factors"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | d0a367ffab15418ac281198290887e76366d1db5 | 19cf0d24e40703c6ed78ab7e3c5309a219af3db0 | |||
v1.0 | complete | Taco | Taco_73047_C | from typing import List
def sum_of_cubed_digits(n: int) -> int:
"""Returns the sum of the digits of `n` each raised to the power of 3."""
return sum(int(digit) ** 3 for digit in str(n))
def is_prime(num: int) -> bool:
"""Returns True if `num` is a prime number, else False."""
if num <= 1:
retu... | from math import isqrt
def sum_of_cubed_digits(n):
"""
Returns the sum of the digits of `n` each raised to the power of 3.
"""
return sum(int(digit) ** 3 for digit in str(n))
def is_prime(num):
"""
Returns True if `num` is a prime number, else False.
"""
if num <= 1:
return Fal... | from solution import interesting_properties
def test_sample_input():
assert interesting_properties([123, 9474, 372]) == ["NO", "NO", "NO"]
def test_single_small_number():
assert interesting_properties([5]) == ["NO"]
assert interesting_properties([7]) == ["NO"]
def test_single_large_number():
assert i... | [
{
"docstring": "Returns the sum of the digits of `n` each raised to the power of 3.",
"function_declaration": "def sum_of_cubed_digits(n):",
"function_name": "sum_of_cubed_digits",
"parameter_list": "(n)"
},
{
"docstring": "Returns True if `num` is a prime number, else False.",
"function... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ... | trial_gpt4o_3 | {
"original_instruction": "Kalyani has a sequence of integers and she wants to know some interesting properties about the sequence. For each given integer, she wants to calculate the sum of the digits raised to the power of 3. The task is to compute this sum for every element in the sequence and check if the result i... | 0.654232 | Taco_73047 | C | [
"sum_of_cubed_digits",
"is_prime",
"interesting_properties"
] | 3 | [
[
"interesting_properties",
"is_prime"
],
[
"interesting_properties",
"sum_of_cubed_digits"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 9041d326c8c0e38c9675cef8313b3fe73462d643 | 8416c1a435f87228495e3816bb9364125d4c439b | |||
v1.0 | complete | Taco | Taco_73162_C | def turtle_visits_targets(n: int, k: int, targets: List[Tuple[int, int]], command_sequence: str) -> Union[Tuple[int, int], int]:
""" Determine if the turtle can visit all the target points within the grid.
>>> turtle_visits_targets(3, 4, [(1, 1), (2, 2), (3, 3)], 'NESW') (1, 1)
>>> turtle_visits_targets(3, ... | def calculate_final_position(x_start, y_start, command_sequence):
x, y = x_start, y_start
for cmd in command_sequence:
if cmd == 'N':
y += 1
elif cmd == 'E':
x += 1
elif cmd == 'S':
y -= 1
elif cmd == 'W':
x -= 1
return (x, y)
... | def test_turtle_visits_targets_success():
n = 3
k = 4
targets = [(1, 1), (2, 2), (3, 3)]
command_sequence = "NESW"
assert turtle_visits_targets(n, k, targets, command_sequence) == (1, 1)
def test_turtle_visits_targets_fail():
n = 3
k = 4
targets = [(1, 1), (2, 2), (4, 5)]
command_se... | [
{
"docstring": null,
"function_declaration": "def calculate_final_position(x_start, y_start, command_sequence):",
"function_name": "calculate_final_position",
"parameter_list": "(x_start, y_start, command_sequence)"
},
{
"docstring": null,
"function_declaration": "def turtle_visits_targe... | [
0,
0,
0,
0,
0,
0,
1,
0,
0
] | 1 | hard | 0.111 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def can_visit_all_targets(N, K, targets, command_sequence):\n \"\"\"\n Determine if it's possible for the turtle to visit all the target points\n exactly ... | trial_gpt4o_7 | {
"original_instruction": "Gene Corporation is working on a new robotic turtle that navigates inside a 2D grid factory. The turtle has a unique property: it can execute a fixed sequence of operations repeatedly. Specifically, the turtle can move in four directions (N, E, S, W) within the grid. For each direction, the... | 0.637498 | Taco_73162 | C | [
"calculate_final_position",
"turtle_visits_targets"
] | 2 | [
[
"turtle_visits_targets",
"calculate_final_position"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 8d6bf9c203e95ed91f1f46d55ab88fce1d4147a4 | 70c69acb157f4a953a0b97ccf04801e6edb2e5c6 | |||
v1.0 | complete | Taco | Taco_73066_C | def max_events(events):
"""
Returns the maximum number of events that can be attended without overlapping.
"""
# Your code here
def parse_and_solve(n, events):
"""
Given the number of events and a list of their start and end times, returns the maximum number of events that can be attended witho... | def max_events(events):
"""
Returns the maximum number of events that can be attended without overlapping.
"""
# Sort events by their end times to prioritize finishing earliest.
events.sort(key=lambda x: x[1])
count = 0
last_end_time = 0
for start, end in events:
if sta... | from solution import parse_and_solve
def test_max_events_sample_1():
n = 3
events = [(1, 2), (2, 3), (3, 4)]
assert parse_and_solve(n, events) == 3
def test_max_events_sample_2():
n = 3
events = [(1, 2), (1, 2), (1, 2)]
assert parse_and_solve(n, events) == 1
def test_max_events_no_overlap():
... | [
{
"docstring": "Returns the maximum number of events that can be attended without overlapping.",
"function_declaration": "def max_events(events):",
"function_name": "max_events",
"parameter_list": "(events)"
},
{
"docstring": "Given the number of events and a list of their start and end time... | [
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 max_events(events):\n \"\"\"\n Given a list of events with start and end times, determine the maximum number\n of events that can be attended without ... | trial_gpt4o_2 | {
"original_instruction": "Jane needs to organize a series of events, each with different start and end times, but she cannot attend more than one event at a time. Given a list of events, each described by a start time and end time, determine the maximum number of events Jane can attend without overlapping.\n\n-----I... | 0.573542 | Taco_73066 | C | [
"max_events",
"parse_and_solve"
] | 2 | [
[
"parse_and_solve",
"max_events"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3541d9af6102682141919bb5e4eb5457519ae0c1 | c23fc61b58d063aaeadae8858d49c778932367d5 | |||
v1.0 | complete | Taco | Taco_73171_C | def resolve_shortest_path(N: int, M: int, grid: List[str], start: Tuple[int, int], target: Tuple[int, int]) -> int:
"""
Find the shortest path from the starting position to the target position in the grid.
The grid consists of empty cells (.) and obstacles (*).
The robot can move up, down, left, or righ... | from collections import deque
def shortest_path(grid, start, target):
N = len(grid)
M = len(grid[0])
# Converting to 0-indexed
start_row, start_col = start[0] - 1, start[1] - 1
target_row, target_col = target[0] - 1, target[1] - 1
# Directions for moving up, down, left, right
dire... | import pytest
from solution import resolve_shortest_path
def test_example1():
N = 5
M = 7
grid = [
".......",
".*.*.*.",
".......",
".*.*.*.",
"......."
]
start = (1, 1)
target = (5, 7)
assert resolve_shortest_path(N, M, grid, start, target) == 10
de... | [
{
"docstring": null,
"function_declaration": "def shortest_path(grid, start, target):",
"function_name": "shortest_path",
"parameter_list": "(grid, start, target)"
},
{
"docstring": null,
"function_declaration": "def resolve_shortest_path(N, M, grid, start, target):",
"function_name"... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef shortest_path(grid, start, target):\n N = len(grid)\n M = len(grid[0])\n start = (start[0] - 1, start[1] - 1) # conve... | trial_gpt4o_1 | {
"original_instruction": "You are given an $N \\times M$ grid consisting of characters `.` and `*`. The `.` character represents an empty cell and the `*` character represents an obstacle. You are also provided with the starting position of a robot that needs to be navigated to a target position. The robot can move ... | 0.700184 | Taco_73171 | C | [
"shortest_path",
"resolve_shortest_path"
] | 2 | [
[
"resolve_shortest_path",
"shortest_path"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 001b6c0d5b1342cada4c71dac32c8a93e96cb9f6 | 81cd543d38c7a287c8659acd81c97eb564ae5f2b | |||
v1.0 | complete | Taco | Taco_73136_C | from typing import List
def find_longest_words(rack: List[str], dictionary: List[str]) -> List[str]:
""" Determine the longest word(s) you can form from a given set of letters.
>>> find_longest_words(["a", "e", "l", "p", "p"], ["pale", "leap", "plea", "apple"])
["apple"]
>>> find_longest_words(["a", "e... | from collections import Counter
def can_form_word(rack_counter, word):
word_counter = Counter(word)
for letter, count in word_counter.items():
if count > rack_counter[letter]:
return False
return True
def find_longest_words(rack, dictionary):
rack_counter = Counter(rack)
valid_... | from solution import find_longest_words
def test_single_longest_word():
dictionary = ["pale", "leap", "plea", "apple"]
rack = ["a", "e", "l", "p", "p"]
assert find_longest_words(rack, dictionary) == ["apple"]
def test_multiple_longest_words():
dictionary = ["pale", "leap", "plea", "pep"]
rack = ["... | [
{
"docstring": null,
"function_declaration": "def can_form_word(rack_counter, word):",
"function_name": "can_form_word",
"parameter_list": "(rack_counter, word)"
},
{
"docstring": null,
"function_declaration": "def find_longest_words(rack, dictionary):",
"function_name": "find_longes... | [
0,
0,
0,
0,
1
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import Counter\n\ndef find_longest_words(rack, dictionary):\n \"\"\"\n Find the longest words that can be formed from the given rack of lett... | trial_gpt4o_4 | {
"original_instruction": "A scrabble helper\n\nDesign a function that helps determine the longest word you can form from a given set of letters. You have a dictionary of valid words and a rack of letters. Write a function that takes the rack of letters and returns the longest valid word(s) that can be formed from it... | 0.736368 | Taco_73136 | C | [
"can_form_word",
"find_longest_words"
] | 2 | [
[
"find_longest_words",
"can_form_word"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c8ec45c418a524e759966865e59adaad42211e6f | 9bbb58a63f3cc98434b6b7ac8b2db41b8634431c | |||
v1.0 | complete | Taco | Taco_73411_C | def shortest_path_with_portals(n: int, m: int, maze: List[List[str]], start: Tuple[int, int], end: Tuple[int, int]) -> int:
""" Find the shortest path in a grid maze with obstacles and portals from start to destination.
>>> shortest_path_with_portals(5, 5, [['.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.'], ... | from collections import deque
def bfs(maze, start, end):
n = len(maze)
m = len(maze[0])
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
queue = deque([(start[0], start[1], 0)]) # (x, y, distance)
visited = set()
visited.add((start[0], start[1]))
# Finding all portals
portals = {}
... | def test_sample_1():
n, m = 5, 5
maze = [
['.', '.', '.', '.', '.'],
['.', '#', '.', '#', '.'],
['.', '#', '.', '#', '.'],
['.', '.', 'P', '.', '.'],
['.', '#', '.', '#', '.']
]
start = (0, 0)
end = (4, 4)
assert shortest_path_with_portals(n, m, maze, star... | [
{
"docstring": null,
"function_declaration": "def bfs(maze, start, end):",
"function_name": "bfs",
"parameter_list": "(maze, start, end)"
},
{
"docstring": null,
"function_declaration": "def shortest_path_with_portals(n, m, maze, start, end):",
"function_name": "shortest_path_with_po... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef shortest_path_in_maze(n, m, maze, start, end):\n directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] # down, up, right, and le... | trial_gpt4o_1 | {
"original_instruction": "You are given a grid-based maze composed of cells where each cell is either empty (denoted by '.') or contains an obstacle (denoted by '#'). You're tasked with finding the shortest path from a starting point to a destination point without stepping on obstacles. The maze allows four possible... | 0.624999 | Taco_73411 | C | [
"bfs",
"shortest_path_with_portals"
] | 2 | [
[
"shortest_path_with_portals",
"bfs"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | c681ea824d1c348be2b00e6e50391b723e8f5c9e | 25253325ae01798bb493e7abaaf8edf3d4e16ca9 | |||
v1.0 | complete | Taco | Taco_73192_C | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def list_to_tree(lst):
if not lst:
return None
def inner(index):
if index >= len(lst) or lst[index] == "None":
return None
node = ... | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def list_to_tree(lst):
if not lst:
return None
def inner(index):
if index >= len(lst) or lst[index] == "None":
return None
node = ... | from solution import solution
def test_example_1():
assert solution("1,2,2,3,3,None,None,4,4") == False
def test_example_2():
assert solution("3,9,20,None,None,15,7") == True
def test_single_node():
assert solution("1") == True
def test_none_tree():
assert solution("None") == True
def test_balanced... | [] | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from typing import Optional\nimport collections\n\n# Define TreeNode class\nclass TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = ... | trial_gpt4o_2 | {
"original_instruction": "You are given a binary tree where each node contains an integer value. Your task is to determine if the tree is balanced. A balanced tree is defined as one where the depth of the two subtrees of every node never differs by more than 1.\n\nInput\n\nThe input consists of a binary tree in the ... | 0.756136 | Taco_73192 | C | [
"list_to_tree",
"isBalanced",
"solution"
] | 3 | [
[
"solution",
"isBalanced"
],
[
"solution",
"list_to_tree"
]
] | 2 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | 31bc367850c44162142b0ecab5834f0bc4298e07 | 9deda3a838cade4b7a4417c081d31438409c1c3c | |||
v1.0 | complete | Taco | Taco_73504_C | def is_special(number: int) -> bool:
"""
Check if a number is special: odd and all digits are unique.
>>> is_special(125) True
>>> is_special(1023457) True
>>> is_special(1234) False # Even number
>>> is_special(112) False # Repeated digit
>>> is_special(2) False # Even number
"""
de... | def is_special(number):
"""
Check if a number is special: odd and all digits are unique.
"""
str_num = str(number)
if number % 2 == 0: # Not an odd number
return False
if len(set(str_num)) != len(str_num): # Digits are not unique
return False
return True
def find_smallest_... | import pytest
from solution import is_special, find_smallest_special_number_greater_than, process_test_cases
def test_is_special():
assert is_special(125) == True
assert is_special(1023457) == True
assert is_special(1234) == False # Even number
assert is_special(112) == False # Repeated digit
ass... | [
{
"docstring": "Check if a number is special: odd and all digits are unique.",
"function_declaration": "def is_special(number):",
"function_name": "is_special",
"parameter_list": "(number)"
},
{
"docstring": "Find the smallest special number greater than N.",
"function_declaration": "def... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_special_number(num):\n \"\"\"\n Check if a number is special: consists of distinct digits and is odd.\n \"\"\"\n num_str = str(num)\n return ... | trial_gpt4o_3 | {
"original_instruction": "Bob is building a machine that requires the use of special numbers. A number is considered special if it is an odd number and all of its digits are distinct.\n\nGiven an integer N, Bob wants to know the smallest special number that is greater than N.\n\nInput:\nThe first line contains an in... | 0.636681 | Taco_73504 | C | [
"is_special",
"find_smallest_special_number_greater_than",
"process_test_cases"
] | 3 | [
[
"find_smallest_special_number_greater_than",
"is_special"
],
[
"process_test_cases",
"find_smallest_special_number_greater_than"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | true | [] | true | ae807c2ce0bdffac610ecd3d54c7bfd5c6f1899b | 94e8f208311f85ae633b49a4e8f38427ffbc3b5b | |||
v1.0 | complete | Taco | Taco_73138_C | def is_prime(num: int) -> bool:
"""Check if a given number is a prime number.
>>> is_prime(2)
True
>>> is_prime(3)
True
>>> is_prime(4)
False
>>> is_prime(5)
True
>>> is_prime(10)
False
>>> is_prime(13)
True
"""
def sort_primes_in_list(n: int, integers: List[int]... | def is_prime(num):
"""
Check if a number is a prime number.
"""
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 sort_primes... | from solution import is_prime, sort_primes_in_list
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(10) == False
assert is_prime(13) == True
def test_sort_primes_in_list():
assert sort_primes_i... | [
{
"docstring": "Check if a number is a prime number.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Sorts the prime numbers in the list in ascending order while keeping non-prime numbers in their original positions.",... | [
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 Determine whether a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True... | trial_gpt4o_1 | {
"original_instruction": "You are given a list of n integers, and you need to sort this list in such a way that all the prime numbers in the list are sorted in ascending order, while the non-prime numbers remain in their original positions.\n\nInput\n\nThe single line contains an integer n (1 ≤ n ≤ 1000), followed b... | 0.758786 | Taco_73138 | C | [
"is_prime",
"sort_primes_in_list"
] | 2 | [
[
"sort_primes_in_list",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | ad18956bed096ae9930d8aee1d5a8fc315f2d9dd | b476416b1bf19b4b5f67b0433f77d4f696cc3e45 | |||
v1.0 | complete | Taco | Taco_73506_C | def count_one_row_words(words: List[str]) -> int:
""" Given a collection of words, determine the number of words that can be typed using letters of only one row of a standard QWERTY keyboard.
A standard QWERTY keyboard can be visualized as follows:
QWERTYUIOP
ASDFGHJKL
ZXCVBNM
You can ... | def can_be_typed_on_one_row(word, rows):
for row in rows:
if all(char in row for char in word.lower()):
return True
return False
def count_one_row_words(words):
rows = [
set("qwertyuiop"),
set("asdfghjkl"),
set("zxcvbnm")
]
count = 0
for word in ... | from solution import count_one_row_words
def test_count_one_row_words():
assert count_one_row_words(["Hello", "Alaska", "Dad", "Peace", "Quiz"]) == 2
def test_count_one_row_words_empty():
assert count_one_row_words([]) == 0
def test_count_one_row_words_single_row():
assert count_one_row_words(["qwerty", ... | [
{
"docstring": null,
"function_declaration": "def can_be_typed_on_one_row(word, rows):",
"function_name": "can_be_typed_on_one_row",
"parameter_list": "(word, rows)"
},
{
"docstring": null,
"function_declaration": "def count_one_row_words(words):",
"function_name": "count_one_row_wor... | [
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_be_typed_on_one_row(word, rows):\n for row in rows:\n if all(char in row for char in word.lower()):\n return True\n return False\n\... | trial_gpt4o_0 | {
"original_instruction": "Given a collection of words, determine the number of words that can be typed using letters of only one row of a standard QWERTY keyboard.\n\nA standard QWERTY keyboard can be visualized as follows:\n```\nQWERTYUIOP\nASDFGHJKL\nZXCVBNM\n```\nYou can assume the input words will only contain a... | 0.641515 | Taco_73506 | C | [
"can_be_typed_on_one_row",
"count_one_row_words"
] | 2 | [
[
"count_one_row_words",
"can_be_typed_on_one_row"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3cbebdd670f55bc29e84b1bf4c8fc2d885ceb6d5 | f7698db9342e377d53d437ecb07910235fc5e05d | |||
v1.0 | complete | Taco | Taco_73024_C | def get_next_state(grid, M, N):
"""
Calculate the next state of the traffic lights grid based on the current state.
Parameters:
- grid: List of List of characters representing the current state ('G' for green, 'R' for red)
- M: Number of rows in the grid
- N: Number of columns in the grid
... | def get_next_state(grid, M, N):
next_grid = [['R'] * N for _ in range(M)]
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
for i in range(M):
for j in range(N):
green_count = 0
red_count = 0
for di, dj in directions:
ni, nj = i + d... | def test_get_next_state():
grid = [
['G', 'G', 'G'],
['G', 'R', 'G'],
['G', 'G', 'G']
]
expected = [
['G', 'R', 'G'],
['R', 'G', 'R'],
['G', 'R', 'G']
]
assert get_next_state(grid, 3, 3) == expected
def test_traffic_lights_after_k_steps_1_step():
... | [
{
"docstring": null,
"function_declaration": "def get_next_state(grid, M, N):",
"function_name": "get_next_state",
"parameter_list": "(grid, M, N)"
},
{
"docstring": null,
"function_declaration": "def traffic_lights_after_k_steps(M, N, K, grid):",
"function_name": "traffic_lights_aft... | [
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 next_state(M, N, K, grid):\n def adjacent_same(state, row, col):\n return (row > 0 and grid[row - 1][col] == state) or \\\n (row < M - ... | trial_gpt4o_1 | {
"original_instruction": "In a particular town, there is a grid of streets with M rows and N columns, represented as a matrix with cells. Each cell represents an intersection of streets. Each intersection can have a traffic light with two states: green (G) or red (R). The traffic light switches states according to t... | 0.559044 | Taco_73024 | C | [
"get_next_state",
"traffic_lights_after_k_steps"
] | 2 | [
[
"traffic_lights_after_k_steps",
"get_next_state"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | b9e623144485aff9329e73b73362d128bcb88a22 | ef37b2f1a0d8fbe5d9d8dbf04e89c826da506645 | |||
v1.0 | complete | Taco | Taco_73221_C | def prefix_sum(array, n, m):
"""
Computes the prefix sum array for a given 2D array.
"""
ps = [[0] * (m + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, m + 1):
ps[i][j] = array[i-1][j-1] + ps[i-1][j] + ps[i][j-1] - ps[i-1][j-1]
return ps
def rectangle... | def prefix_sum(array, n, m):
"""
Computes the prefix sum array for a given 2D array.
"""
ps = [[0] * (m + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, m + 1):
ps[i][j] = array[i-1][j-1] + ps[i-1][j] + ps[i][j-1] - ps[i-1][j-1]
return ps
def rectangle... | from solution import rectangle_query
def test_rectangle_query_single_query():
A = [
[2, 1, 4],
[3, 0, 5],
[7, 2, 2]
]
queries = [(1, 1, 2, 2)]
assert rectangle_query(A, queries) == [6]
def test_rectangle_query_multiple_queries():
A = [
[2, 1, 4],
[3, 0, 5],
... | [
{
"docstring": "Computes the prefix sum array for a given 2D array.",
"function_declaration": "def prefix_sum(array, n, m):",
"function_name": "prefix_sum",
"parameter_list": "(array, n, m)"
},
{
"docstring": "Handles rectangle queries using a prefix sum array.",
"function_declaration": ... | [
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 prefix_sum(array, n, m):\n \"\"\"\n Computes the prefix sum array for a given 2D array.\n \"\"\"\n ps = [[0] * (m + 1) for _ in range(n + 1)]\n ... | trial_gpt4o_0 | {
"original_instruction": "Hey, \n\nI need some help with a programming challenge that I found on a competitive coding website. It's a bit tricky and my solution keeps failing for the larger test cases. Could you help me write a more efficient version? \n\nThe problem is called \"Rectangle Query\". I’m attaching the ... | 0.596392 | Taco_73221 | C | [
"prefix_sum",
"rectangle_query"
] | 2 | [
[
"rectangle_query",
"prefix_sum"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6fd5653b298fcc6793ba64b28431d340043e226d | 7ffe839be3ac85b7403460dd050c3b5fc99a4e04 | |||
v1.0 | complete | Taco | Taco_72925_C | from typing import List, Tuple
def largest_uniform_square(grid: List[List[str]], n: int, m: int) -> int:
"""
Given a grid of size n x m consisting of lowercase English letters,
find the largest square subgrid such that all the characters in the subgrid are the same.
"""
pass
def solve_problem(tes... | def largest_uniform_square(grid, n, m):
dp = [[0]*m for _ in range(n)]
max_side_len = 1
# Initialize the DP table
for i in range(n):
for j in range(m):
if i == 0 or j == 0:
dp[i][j] = 1
else:
if grid[i][j] == grid[i-1][j] == grid[i][j-1] =... | def test_largest_uniform_square():
grid1 = [
['a', 'a', 'a', 'a'],
['a', 'b', 'a', 'a'],
['a', 'b', 'b', 'b']
]
assert largest_uniform_square(grid1, 3, 4) == 2
grid2 = [
['a', 'b', 'c', 'd'],
['a', 'b', 'c', 'd'],
['a', 'b', 'c', 'd'],
['a', '... | [
{
"docstring": null,
"function_declaration": "def largest_uniform_square(grid, n, m):",
"function_name": "largest_uniform_square",
"parameter_list": "(grid, n, m)"
},
{
"docstring": null,
"function_declaration": "def solve_problem(test_cases):",
"function_name": "solve_problem",
... | [
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 largest_same_char_square(n, m, grid):\n max_side = min(n, m)\n largest_square_side = 1\n \n for side in range(2, max_side + 1):\n found = Fa... | trial_gpt4o_1 | {
"original_instruction": "Given a grid of size $n \\times m$ consisting of lowercase English letters, you need to find the largest square subgrid such that all the characters in the subgrid are the same.\n\n### Input\n\nThe first line contains two integers $t$ ($1 \\le t \\le 10$) — the number of test cases. \n\nFor... | 0.623324 | Taco_72925 | C | [
"largest_uniform_square",
"solve_problem",
"read_input",
"output_result"
] | 4 | [
[
"solve_problem",
"largest_uniform_square"
]
] | 1 | [
"read_input"
] | false | [] | false | pytest | true | [] | true | 2d4790129ae9dbb524ff0103616e013934719c81 | 8e630445c98c86c8bc9ba14a6eaac8f5718ba1a5 | |||
v1.0 | complete | Taco | Taco_72835_C | def prime_squares(n: int) -> list:
"""
Return a list where the i-th element is the square of the i-th prime number, for the first n prime numbers.
>>> prime_squares(0) == []
>>> prime_squares(1) == [4]
>>> prime_squares(2) == [4, 9]
>>> prime_squares(3) == [4, 9, 25]
>>> prime_squares(... | def is_prime(num):
"""Helper function to determine if a number is prime."""
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while (i * i) <= num:
if num % i == 0 or num % (i + 2) == 0:
return False... | from solution import prime_squares
def test_prime_squares_zero():
assert prime_squares(0) == []
def test_prime_squares_one():
assert prime_squares(1) == [4]
def test_prime_squares_two():
assert prime_squares(2) == [4, 9]
def test_prime_squares_three():
assert prime_squares(3) == [4, 9, 25]
def test... | [
{
"docstring": "Helper function to determine if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Return a list where the i-th element is the square of the i-th prime number, for the first n prime numb... | [
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": "# Task\nGiven an integer `n`, return a list where the `i`-th element (0-indexed) is the square of the `i`-th prime number, for the first `n` prime numbers. \n\n# Example\n\nFor `n = 0`, the output should be `[]`.\n\nFor `n = 1`, the output should be `[4]`. (The first prime number is 2, and ... | 0.674597 | Taco_72835 | C | [
"is_prime",
"prime_squares"
] | 2 | [
[
"prime_squares",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f02d0e9a187b37213a9807154f1f7845d30aecfa | 9d9099693b7391ddc9e5546620c17bfed91e4290 | |||
v1.0 | complete | Taco | Taco_72968_C | def is_within_bounds(m: int, n: int, x: int, y: int, instructions: str) -> str:
"""
Determines if the robot's sequence of instructions keeps it within the grid.
:param m: Number of rows in the grid.
:param n: Number of columns in the grid.
:param x: Starting x-coordinate (row) of the robot.
... | def is_within_bounds(m, n, x, y, instructions):
"""
Determines if the robot's sequence of instructions keeps it within the grid.
:param m: Number of rows in the grid.
:param n: Number of columns in the grid.
:param x: Starting x-coordinate (row) of the robot.
:param y: Starting y-coordinate... | from solution import is_within_bounds, process_robots_and_instructions
def test_is_within_bounds():
assert is_within_bounds(5, 5, 1, 1, 'RDU') == 'YES'
assert is_within_bounds(5, 5, 2, 2, 'LLR') == 'NO'
assert is_within_bounds(5, 5, 3, 3, 'DDDUU') == 'NO'
assert is_within_bounds(3, 3, 3, 3, 'UUUUUU') =... | [
{
"docstring": "Determines if the robot's sequence of instructions keeps it within the grid.\n\n:param m: Number of rows in the grid.\n:param n: Number of columns in the grid.\n:param x: Starting x-coordinate (row) of the robot.\n:param y: Starting y-coordinate (column) of the robot.\n:param instructions: Seque... | [
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_within_grid(m, n, x, y, s):\n \"\"\"\n Check if the robot remains within the grid boundaries.\n \n :param m: Number of rows in the grid\n :pa... | trial_gpt4o_7 | {
"original_instruction": "A game developer is designing a new strategy game where players need to manage a fleet of robots to mine resources on a grid. Each robot has a sequence of instructions encoded as a string, where 'L' indicates a move left, 'R' indicates a move right, 'U' indicates a move up, and 'D' indicate... | 0.608254 | Taco_72968 | C | [
"is_within_bounds",
"process_robots_and_instructions"
] | 2 | [
[
"process_robots_and_instructions",
"is_within_bounds"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 9cdea79554d5b3f1794c33240d84dd1710f013f2 | af353828d8a273bf1a52ed41c2fd5927f5c36a6a | |||
v1.0 | complete | Taco | Taco_73073_C | class TreeNode:
def __init__(self, value=0, left=None, right=None):
self.value = value
self.left = left
self.right = right
def insertIntoBST(root, value):
if not root:
return TreeNode(value)
if value < root.value:
root.left = insertIntoBST(root.left, value)
else:... | class TreeNode:
def __init__(self, value=0, left=None, right=None):
self.value = value
self.left = left
self.right = right
def insertIntoBST(root, value):
if not root:
return TreeNode(value)
if value < root.value:
root.left = insertIntoBST(root.left, value)
else:... | def test_merge_bsts():
cases = [
("3,1,4", "2,5", "1 2 3 4 5"),
("10,5,1", "8,3,7", "1 3 5 7 8 10"),
("", "1,2,3", "1 2 3"),
("4,2,6", "", "2 4 6"),
("", "", "")
]
for bst1, bst2, expected in cases:
assert " ".join(map(str, mergeBSTs(bst1, bst2))) == expected... | [] | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef i... | trial_gpt4o_0 | {
"original_instruction": "Given two binary search trees, BST1 and BST2, your task is to merge these trees into a single binary search tree with all the elements from both input trees. The resulting tree must also satisfy the properties of a binary search tree:\n1. The left subtree of a node contains only nodes with ... | 0.490146 | Taco_73073 | C | [
"insertIntoBST",
"mergeBSTs",
"process_merge",
"main"
] | 4 | [
[
"mergeBSTs",
"insertIntoBST"
],
[
"process_merge",
"mergeBSTs"
]
] | 2 | [] | false | [
"TreeNode"
] | true | pytest | false | [] | true | 9a455ac1baf6063a0f88761fc6bbbe03d52c9e55 | 95e3da2fe4e25ea9d7054f2905cd97595a4e2073 | |||
v1.0 | complete | Taco | Taco_73559_C | import re
def is_password_valid(password: str) -> str:
"""
Validate the password based on the given criteria:
1. at least 8 characters long
2. contains at least one uppercase letter
3. contains at least one lowercase letter
4. contains at least one digit
5. contains at least one special cha... | import re
def is_password_valid(password):
"""
Validate the password based on the given criteria:
1. at least 8 characters long
2. contains at least one uppercase letter
3. contains at least one lowercase letter
4. contains at least one digit
5. contains at least one special character from ... | from solution import is_password_valid, validate_passwords
def test_is_password_valid():
assert is_password_valid("Passw0rd!") == "valid"
assert is_password_valid("password") == "invalid"
assert is_password_valid("P@ssw0rd") == "valid"
assert is_password_valid("short!") == "invalid"
assert is_passw... | [
{
"docstring": "Validate the password based on the given criteria:\n1. at least 8 characters long\n2. contains at least one uppercase letter\n3. contains at least one lowercase letter\n4. contains at least one digit\n5. contains at least one special character from the set: !@#$%^&*()-+",
"function_declarati... | [
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 re\n\ndef is_password_valid(password):\n \"\"\"\n Validate the password based on the given criteria:\n 1. at least 8 characters long\n 2. contai... | trial_gpt4o_0 | {
"original_instruction": "A software development company is working on a new feature for auto-validation of passwords. The passwords need to meet several criteria in order to be considered valid. The criteria are as follows:\n\n1. The password must be at least 8 characters long.\n2. The password must contain at leas... | 0.612569 | Taco_73559 | C | [
"is_password_valid",
"validate_passwords"
] | 2 | [
[
"validate_passwords",
"is_password_valid"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e940691d5983e6417e14108b0754800ad6bff3cb | c48279ce22c8ae9206e40f01269039a0709048e3 | |||
v1.0 | complete | Taco | Taco_73834_C | def sort_and_merge(list1, list2):
"""
Implement a function that takes two lists of integers, sorts each list in ascending order,
and then merges the two sorted lists into one sorted list in ascending order without using
any built-in sort or merge functions. The function should return the final merged... | def bubble_sort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
def merge_sorted_lists(list1, list2):
sorted_list = []
i, j = 0, 0
while i < len(list1) and j < len(list2):
if list1[... | from solution import sort_and_merge
def test_sort_and_merge():
list1 = [3, 1, 5]
list2 = [2, 8, 4]
assert sort_and_merge(list1, list2) == [1, 2, 3, 4, 5, 8]
def test_sort_and_merge_empty_lists():
list1 = []
list2 = []
assert sort_and_merge(list1, list2) == []
def test_sort_and_merge_one_empty... | [
{
"docstring": null,
"function_declaration": "def bubble_sort(arr):",
"function_name": "bubble_sort",
"parameter_list": "(arr)"
},
{
"docstring": null,
"function_declaration": "def merge_sorted_lists(list1, list2):",
"function_name": "merge_sorted_lists",
"parameter_list": "(list... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def sort_and_merge(list1, list2):\n def bubble_sort(arr):\n n = arr.length\n for i in range(n):\n for j in range(0, n - i - 1):\n ... | trial_gpt4o_2 | {
"original_instruction": "Implement a function `sort_and_merge` that takes two lists of integers, sorts each list in ascending order, and then merges the two sorted lists into one sorted list in ascending order without using any built-in sort or merge functions. The function should return the final merged sorted lis... | 0.590468 | Taco_73834 | C | [
"bubble_sort",
"merge_sorted_lists",
"sort_and_merge"
] | 3 | [
[
"sort_and_merge",
"bubble_sort"
],
[
"sort_and_merge",
"merge_sorted_lists"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 7792551b62b947f5587082ad530ad8779b8e3a45 | 4142e83d26630ccf2f161cf5f45b95ac8ed5560e | |||
v1.0 | complete | Taco | Taco_73932_C | import math
from typing import List
def is_prime(n: int) -> bool:
""" Determines if a given number n is a prime number.
>>> is_prime(3)
True
>>> is_prime(4)
False
"""
def find_primes(numbers: List[int]) -> List[int]:
""" Returns a list of prime numbers found in the original list.
>... | import math
def is_prime(n):
"""
Determines if a given number n is a prime number.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
max_divisor = int(math.sqrt(n)) + 1
for d in range(3, max_divisor, 2):
if n % d == 0:
... | from solution import is_prime, find_primes
def test_is_prime():
assert is_prime(3)
assert not is_prime(4)
assert is_prime(5)
assert is_prime(2)
assert not is_prime(1)
assert not is_prime(0)
assert is_prime(29)
assert not is_prime(100)
def test_find_primes_with_mixed_numbers():
numb... | [
{
"docstring": "Determines if a given number n is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime numbers found in the original list.",
"function_declaration": "def find_primes(n... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ... | trial_gpt4o_2 | {
"original_instruction": "Write a function that takes a list of integers and returns a list of the prime numbers found in the original list. A prime number is a number that has no positive divisors other than 1 and itself. The order of the primes in the returned list should match the order in which they appear in th... | 0.797448 | Taco_73932 | C | [
"is_prime",
"find_primes"
] | 2 | [
[
"find_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | a8107cfbfc4852d5225e574d8b33c4cab289554a | b516fedc526aabe5100a60d2f5213ec8f6f38735 | |||
v1.0 | complete | Taco | Taco_73346_C | import math
from typing import List
def calculate_distance(x1: int, y1: int, x2: int, y2: int) -> float:
""" Calculate the distance between two points.
>>> calculate_distance(0, 0, 3, 4)
5.0
"""
def bird_journeys(m: int, data: List[int]) -> List[float]:
""" Given the number of birds and their ... | import math
def calculate_distance(x1, y1, x2, y2):
return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
def bird_journeys(m, data):
results = []
index = 0
for i in range(m):
ki = data[index]
index += 1
waypoints = data[index: index + ki*2]
index += ki*2
total_dist... | from solution import bird_journeys
def test_bird_journeys():
# Test case 1
m = 2
data = [3, 0, 0, 3, 4, 6, 0, 4, 1, 1, 2, 2, 3, 3, 4, 4]
result = bird_journeys(m, data)
expected = [10.0000000000, 4.2426406871]
assert len(result) == len(expected)
for r, e in zip(result, expected):
as... | [
{
"docstring": null,
"function_declaration": "def calculate_distance(x1, y1, x2, y2):",
"function_name": "calculate_distance",
"parameter_list": "(x1, y1, x2, y2)"
},
{
"docstring": null,
"function_declaration": "def bird_journeys(m, data):",
"function_name": "bird_journeys",
"pa... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef bird_journey_lengths(m: int, birds_data: list):\n \"\"\"\n This function takes the number of birds and their waypoint data and returns\n ... | trial_gpt4o_3 | {
"original_instruction": "A group of researchers is studying the migratory patterns of a certain species of birds. They have tracked the paths taken by several birds using a set of waypoints for each bird's journey. Each bird's path is defined as a series of straight line segments connecting these waypoints in seque... | 0.587455 | Taco_73346 | C | [
"calculate_distance",
"bird_journeys"
] | 2 | [
[
"bird_journeys",
"calculate_distance"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b023305ceedf6c30236b00f88257f0af41dfaa86 | 97c32d22591b93a013e4e304e057811a11a70fbf | |||
v1.0 | complete | Taco | Taco_73723_C | def can_distribute_workload(N: int, M: int, R: List[int], employee_preferences: Dict[int, List[int]]) -> str:
""" Determine if there is a way to assign employees such that all departments have at least their minimum required
number of employees while ensuring every employee is assigned to at least one departme... | def can_distribute_workload(N, M, R, employee_preferences):
from itertools import permutations
def is_valid_assignment(employee_assignment):
department_counts = [0] * N
for employee, depts in employee_assignment.items():
for dept in depts:
department_counts[dept]... | def test_can_distribute_workload_case1():
N = 3
M = 3
R = [1, 1, 1]
employee_preferences = {
0: [0, 1],
1: [1, 2],
2: [2]
}
assert can_distribute_workload(N, M, R, employee_preferences) == "YES"
def test_can_distribute_workload_case2():
N = 3
M = 3
R = [2, 1,... | [
{
"docstring": null,
"function_declaration": "def can_distribute_workload(N, M, R, employee_preferences):",
"function_name": "can_distribute_workload",
"parameter_list": "(N, M, R, employee_preferences)"
},
{
"docstring": null,
"function_declaration": "def distribute_workload():",
"f... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def can_distribute_workload(N, M, requirements, employees):\n from collections import defaultdict\n from itertools import combinations\n\n # Create a list... | trial_gpt4o_2 | {
"original_instruction": "A large corporation has $N$ departments and $M$ employees. The company wants to implement a new policy to equally distribute workload among departments. Each employee can work in multiple departments and each department has a different minimum number of employees required to function effici... | 0.655898 | Taco_73723 | C | [
"can_distribute_workload",
"distribute_workload"
] | 2 | [
[
"distribute_workload",
"can_distribute_workload"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 5cdbd00a87b1f49b5fa9c2a0948904d19b236205 | fc9cfbbc28fc60870a34605b5432928dea8875ca | |||
v1.0 | complete | Taco | Taco_73548_C | def find_festival_city(n, roads):
"""
Finds the city that should be chosen as the festival city to minimize the longest travel time.
Args:
n (int): The number of cities.
roads (List[Tuple[int, int, int]]): A list of tuples representing the roads,
where e... | from collections import deque, defaultdict
def bfs_farthest(start, n, adj):
"""
Utilizes BFS to find the farthest node from the starting node, along with its distance.
"""
distance = [-1] * (n + 1)
distance[start] = 0
queue = deque([start])
farthest_node = start
max_distance = 0
... | def test_find_festival_city():
assert find_festival_city(4, [(1, 2, 4), (2, 3, 2), (2, 4, 6)]) == 2
assert find_festival_city(3, [(1, 2, 1), (1, 3, 1)]) == 1
assert find_festival_city(5, [(1, 2, 5), (1, 3, 1), (2, 4, 2), (3, 5, 3)]) == 1
def test_example_cases():
test_cases = [
(4, [(1, 2, 4), ... | [
{
"docstring": "Utilizes BFS to find the farthest node from the starting node, along with its distance.",
"function_declaration": "def bfs_farthest(start, n, adj):",
"function_name": "bfs_farthest",
"parameter_list": "(start, n, adj)"
},
{
"docstring": "Finds the city that should be chosen 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": "from collections import deque, defaultdict\n\ndef bfs_farthest(start, n, adj):\n \"\"\"\n Utilizes BFS to find the farthest node from the starting node, alon... | trial_gpt4o_0 | {
"original_instruction": "The kingdom of Lynaria is famous for its beautiful landscapes and unique transportation network. The transportation network consists of $n$ cities connected by $n-1$ bidirectional roads forming a tree. Each road has a certain travel time associated with it.\n\nThe citizens of Lynaria want t... | 0.671722 | Taco_73548 | C | [
"bfs_farthest",
"find_festival_city",
"process_test_cases"
] | 3 | [
[
"find_festival_city",
"bfs_farthest"
],
[
"process_test_cases",
"find_festival_city"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | false | [] | true | e1178e51b2e838e1e88ed694c711a9d7c05acc9b | edd0ebb27a8ef55f97cf2bcd7a164afdc7079da3 | |||
v1.0 | complete | Taco | Taco_74055_C | def can_be_palindrome_after_one_removal(s: str) -> bool:
"""
Check if the string can be made into a palindrome by removing at most one character.
>>> can_be_palindrome_after_one_removal("abca") True
>>> can_be_palindrome_after_one_removal("racecar") True
>>> can_be_palindrome_after_one_removal("abcd... | def can_be_palindrome_after_one_removal(s: str) -> bool:
def is_palindrome_range(start, end):
return all(s[i] == s[end - i + start] for i in range(start, (end + start) // 2 + 1))
left, right = 0, len(s) - 1
while left < right:
if s[left] != s[right]:
# Work out if either the de... | from solution import can_be_palindrome_after_one_removal, validate_strings_can_become_palindromes
def test_can_be_palindrome_after_one_removal():
assert can_be_palindrome_after_one_removal("abca") == True
assert can_be_palindrome_after_one_removal("racecar") == True
assert can_be_palindrome_after_one_remov... | [
{
"docstring": null,
"function_declaration": "def can_be_palindrome_after_one_removal(s):",
"function_name": "can_be_palindrome_after_one_removal",
"parameter_list": "(s)"
},
{
"docstring": null,
"function_declaration": "def validate_strings_can_become_palindromes(T, strings):",
"fun... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def can_be_palindrome(s):\n \"\"\"\n Check if the string can be a palindrome by removing at most one character.\n \"\"\"\n def is_palindrome_range(left... | trial_gpt4o_2 | {
"original_instruction": "Mona is a software engineer at a tech firm. One of her tasks involves validating user input for a new feature. For this feature, users can input a string that must be a palindrome after removing at most one character. Mona needs to write a function to validate these strings efficiently. \n\... | 0.787811 | Taco_74055 | C | [
"can_be_palindrome_after_one_removal",
"validate_strings_can_become_palindromes"
] | 2 | [
[
"validate_strings_can_become_palindromes",
"can_be_palindrome_after_one_removal"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 5078c1ccfca5f2853ef00459f32a0d031d4824bb | 3ed29a148886bb38c942d426695151a451fd8f5c | |||
v1.0 | complete | Taco | Taco_74106_C | from typing import List, Tuple
def preprocess_forest(R: int, C: int, forest: List[str]) -> List[List[int]]:
"""
Create a 2D array to store cumulative sum of animals in the forest grid.
"""
pass
def query_animals(dp: List[List[int]], r1: int, c1: int, r2: int, c2: int) -> int:
"""
Calculate the... | def preprocess_forest(R, C, forest):
# Create a 2D array to store cumulative sum
dp = [[0] * (C + 1) for _ in range(R + 1)]
# Fill the cumulative sum array
for r in range(1, R + 1):
for c in range(1, C + 1):
dp[r][c] = (1 if forest[r - 1][c - 1] == 'A' else 0) + dp[r - 1][c] + d... | def test_preprocess_forest():
R, C = 5, 5
forest = [
".....",
".....",
".A.A.",
"..A..",
"....."
]
expected = [
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 2, 2],
[0, 0, 1, 2, 3, 3],
[0, ... | [
{
"docstring": null,
"function_declaration": "def preprocess_forest(R, C, forest):",
"function_name": "preprocess_forest",
"parameter_list": "(R, C, forest)"
},
{
"docstring": null,
"function_declaration": "def query_animals(dp, r1, c1, r2, c2):",
"function_name": "query_animals",
... | [
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 prepare_animal_count_matrix(forest, R, C):\n \"\"\"\n Prepare 2D prefix sum array for the animal counts in the forest grid.\n \"\"\"\n prefix_sum =... | trial_gpt4o_1 | {
"original_instruction": "You are a forest ranger tasked with monitoring wildlife in a large, rectangular forest. The forest is divided into a grid of cells, where each cell can either be empty or have an animal. Your goal is to make periodic reports about the distribution of animals in the forest.\n\nAt any point, ... | 0.568467 | Taco_74106 | C | [
"preprocess_forest",
"query_animals",
"forest_animals"
] | 3 | [
[
"forest_animals",
"preprocess_forest"
],
[
"forest_animals",
"query_animals"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 38605754a0260b3e1e7e6dea000755b54f7117e7 | 7b04bcb726fd61710f2b92da893d975b793a93d6 | |||
v1.0 | complete | Taco | Taco_73919_C | import re
from collections import defaultdict
def word_count(input_string: str) -> dict:
"""
Returns a dictionary with the count of each unique word in the input string.
>>> word_count("Hello, hello! How are you?")
{"hello": 2, "how": 1, "are": 1, "you": 1}
>>> word_count("")
{}
>>> w... | import re
from collections import defaultdict
def word_count(input_string):
"""
Returns a dictionary with the count of each unique word in the input string.
"""
# Remove punctuation and make the string lowercase
words = re.findall(r'\b\w+\b', input_string.lower())
word_freq = defaultdict(int)
... | from solution import word_count, most_common_word
def test_word_count_basic():
assert word_count("Hello, hello! How are you?") == {"hello": 2, "how": 1, "are": 1, "you": 1}
def test_word_count_empty():
assert word_count("") == {}
def test_word_count_punctuation():
assert word_count("Cats, cats, cats.") =... | [
{
"docstring": "Returns a dictionary with the count of each unique word in the input string.",
"function_declaration": "def word_count(input_string):",
"function_name": "word_count",
"parameter_list": "(input_string)"
},
{
"docstring": "Returns the word that appears the most number of times ... | [
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\nfrom collections import Counter\n\ndef word_count(text):\n \"\"\"\n Returns a dictionary with unique words as keys and their counts as values.\n ... | trial_gpt4o_2 | {
"original_instruction": "**Step 1:** Create a function called `word_count()` that takes a string and returns a dictionary where the keys are unique words, and the values are the number of times those words appeared in the input string. Ignore punctuation and case sensitivity.\n\nFor example, `word_count(\"Hello, he... | 0.762555 | Taco_73919 | C | [
"word_count",
"most_common_word"
] | 2 | [
[
"most_common_word",
"word_count"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | eda2b6a3caef05aa22fb5cab310e00458dc2ea68 | 6f5049f449f4ed9845cd8515623c34b2912465e5 | |||
v1.0 | complete | Taco | Taco_73363_C | def can_schedule_workshops(rooms, workshops):
"""
Function to determine if all workshops can be scheduled without time overlaps
and within room capacity constraints.
Params:
- rooms (list of tuples): (roomName, capacity, timeSlots)
- workshops (list of tuples): (workshopName, requiredCapaci... | def can_schedule_workshops(rooms, workshops):
"""
Function to determine if all workshops can be scheduled without time overlaps
and within room capacity constraints.
Params:
- rooms (list of tuples): (roomName, capacity, timeSlots)
- workshops (list of tuples): (workshopName, requiredCapaci... | from solution import can_schedule_workshops, parse_input, schedule_conference
def test_parse_input():
input_string = """2
roomA 50 3 0 30 60
roomB 100 2 30 60
3
workshop1 50 0
workshop2 50 30
workshop3 50 60"""
expected_rooms = [('roomA', 50, [0, 30, 60]),
('roomB... | [
{
"docstring": "Function to determine if all workshops can be scheduled without time overlaps\nand within room capacity constraints.\n\nParams:\n- rooms (list of tuples): (roomName, capacity, timeSlots)\n- workshops (list of tuples): (workshopName, requiredCapacity, preferredTimeSlot)\n\nReturns:\n- (str): \"po... | [
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 can_schedule_workshops(rooms, workshops):\n \"\"\"\n Function to determine if all workshops can be scheduled without time overlaps\n and within room c... | trial_gpt4o_0 | {
"original_instruction": "You are tasked with organizing a series of workshops for a conference. Each workshop takes place in a separate room, and each room has a specific capacity and a list of time slots when it is available. You want to find out if it is possible to schedule all the workshops such that no two wor... | 0.573966 | Taco_73363 | C | [
"can_schedule_workshops",
"parse_input",
"schedule_conference"
] | 3 | [
[
"schedule_conference",
"can_schedule_workshops"
],
[
"schedule_conference",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 0c6672bf71034dfc0a512c741fc1c55f0b35d0c3 | b1ca966c954a7c4b9f75fd85b9072bf0d1b2e68b | |||
v1.0 | complete | Taco | Taco_74264_C | def next_palindrome(n: int) -> int:
""" Given an integer n, find the smallest palindromic number that is greater than n.
>>> next_palindrome(123)
131
>>> next_palindrome(808)
818
>>> next_palindrome(1)
2
>>> next_palindrome(10)
11
>>> next_palindrome(99)
101
>>> next... | def is_palindrome(num):
"""
Returns True if num is a palindromic number, False otherwise.
"""
return str(num) == str(num)[::-1]
def next_palindrome(n):
"""
Given an integer n, returns the smallest palindromic number greater than n.
"""
n += 1
while not is_palindrome(n):
n +=... | from solution import next_palindrome
def test_next_palindrome():
assert next_palindrome(123) == 131
assert next_palindrome(808) == 818
assert next_palindrome(1) == 2
assert next_palindrome(10) == 11
assert next_palindrome(99) == 101
assert next_palindrome(12321) == 12421
assert next_palindr... | [
{
"docstring": "Returns True if num is a palindromic number, False otherwise.",
"function_declaration": "def is_palindrome(num):",
"function_name": "is_palindrome",
"parameter_list": "(num)"
},
{
"docstring": "Given an integer n, returns the smallest palindromic number greater than n.",
... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def next_palindromic_number(n):\n \"\"\"\n Returns the smallest palindromic number greater than n.\n \"\"\"\n def is_palindrome(num):\n return s... | trial_gpt4o_1 | {
"original_instruction": "Alice has a number in her mind and loves experimenting with its properties. She has recently become fascinated with palindromic numbers. A palindromic number is a number that remains the same when its digits are reversed. For example, 121 and 1331 are palindromic numbers.\n\nAlice is curiou... | 0.758578 | Taco_74264 | C | [
"is_palindrome",
"next_palindrome"
] | 2 | [
[
"next_palindrome",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | be3056912740bf5917ef8569c5ff6f8d7369025e | 11ecc6d758db05c3dfa5b7ac79235e2dd0367a20 | |||
v1.0 | complete | Taco | Taco_74062_C | def are_cities_connected(n: int, connections: List[Tuple[int, int]], queries: List[Tuple[int, int]]) -> List[str]:
""" Determine if there is a path between cities for given queries.
Input:
n: Number of cities
connections: List of tuples representing direct connections between cities
quer... | def find_connected_components(n, connections):
def dfs(node, component_id):
stack = [node]
while stack:
curr = stack.pop()
if components[curr] == -1:
components[curr] = component_id
for neighbor in adjacency_list[curr]:
stac... | def test_are_cities_connected_basic():
n = 5
connections = [(0, 1), (1, 2), (2, 3), (3, 4)]
queries = [(0, 4), (1, 3), (0, 5)]
assert are_cities_connected(n, connections, queries) == ["Yes", "Yes", "No"]
def test_are_cities_connected_single_connection():
n = 2
connections = [(0, 1)]
queries... | [
{
"docstring": null,
"function_declaration": "def find_connected_components(n, connections):",
"function_name": "find_connected_components",
"parameter_list": "(n, connections)"
},
{
"docstring": null,
"function_declaration": "def are_cities_connected(n, connections, queries):",
"fun... | [
0,
0,
0,
0,
1
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(x, parent):\n if parent[x] != x:\n parent[x] = find(parent[x], parent)\n return parent[x]\n\ndef union(x, y, parent, rank):\n rootX = find... | trial_gpt4o_4 | {
"original_instruction": "You are given a list of connections where each connection is a tuple of two integers representing a direct path between two cities. There are N cities labeled from 0 to N-1. You are also given a list of queries where each query is a tuple of two integers representing two cities. For each qu... | 0.639637 | Taco_74062 | C | [
"find_connected_components",
"are_cities_connected"
] | 2 | [
[
"are_cities_connected",
"find_connected_components"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | ce6e88acdd2033bb909e7bc08ee462255843755e | c287f166fccfb42625b34c025fa8939f9e3c687b | |||
v1.0 | complete | Taco | Taco_73886_C | def isSubstring(s1, s2):
"""
Checks if s2 is a substring of s1.
"""
pass # implement isSubstring function
def isRotatedVersion(s1, s2):
"""
Given two strings s1 and s2, determine if s2 is a rotated version of s1.
A rotation of a string is obtained by moving characters from the beginning o... | def isSubstring(s1, s2):
"""
Checks if s2 is a substring of s1.
"""
return s2 in s1
def isRotatedVersion(s1, s2):
"""
Returns True if s2 is a rotated version of s1, False otherwise.
"""
if len(s1) != len(s2):
return False
concatenated = s1 + s1
return isSubstring(concate... | from solution import isRotatedVersion
def test_rotated_version_true():
assert isRotatedVersion("bottle", "tlebot") == True
assert isRotatedVersion("waterbottle", "erbottlewat") == True
assert isRotatedVersion("abcd", "dabc") == True
def test_rotated_version_false():
assert isRotatedVersion("hello", "w... | [
{
"docstring": "Checks if s2 is a substring of s1.",
"function_declaration": "def isSubstring(s1, s2):",
"function_name": "isSubstring",
"parameter_list": "(s1, s2)"
},
{
"docstring": "Returns True if s2 is a rotated version of s1, False otherwise.",
"function_declaration": "def isRotate... | [
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 isSubstring(s1, s2):\n \"\"\"\n Return True if s2 is a substring of s1, else False.\n \"\"\"\n return s2 in s1\n\ndef isRotatedVersion(s1, s2):\n ... | trial_gpt4o_4 | {
"original_instruction": "Given two strings s1 and s2, write a function to determine if s2 is a rotated version of s1. A rotation of a string is obtained by moving characters from the beginning of the string to the end of the string. For example, \"bottle\" and \"tlebot\" are rotated versions of the string \"bottlet... | 0.742457 | Taco_73886 | C | [
"isSubstring",
"isRotatedVersion"
] | 2 | [
[
"isRotatedVersion",
"isSubstring"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 56b2536c04ebfbdafc035841bacfbfb3f56f75f9 | d3598f32e91055fbd868f9c8a9ccd129b8fc84db | |||
v1.0 | complete | Taco | Taco_74010_C | def sum_of_primes(numbers: List[int]) -> Union[int, str]:
""" Write a function that takes a list of numbers and returns the sum of all the numbers that are prime.
If there are no prime numbers in the list, return the string "No prime numbers found."
>>> sum_of_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17... | def is_prime(n):
"""
Checks if a number is prime.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def sum_of_primes(numbers):
"""... | from solution import sum_of_primes
def test_sum_of_primes_with_primes():
assert sum_of_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17
def test_sum_of_primes_with_no_primes():
assert sum_of_primes([4, 6, 8, 10, 12]) == "No prime numbers found"
def test_sum_of_primes_all_primes():
assert sum_of_primes([13, ... | [
{
"docstring": "Checks if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Sums all the prime numbers in the provided list.\nReturns the sum or \"No prime numbers found\" if there are no primes.",
"fu... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ... | trial_gpt4o_2 | {
"original_instruction": "Write a function that takes a list of numbers and returns the sum of all the numbers that are prime. If there are no prime numbers in the list, return the string \"No prime numbers found.\"\n\nFor instance:\n\n```\nsum_of_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) => 17\n\nsum_of_primes([4, 6,... | 0.730519 | Taco_74010 | C | [
"is_prime",
"sum_of_primes"
] | 2 | [
[
"sum_of_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | af2993b48c1b15e168ebfaf09388ae79dc09eb76 | e18d6aec655e38eeaf922b22539e2c76f53d68e8 | |||
v1.0 | complete | Taco | Taco_74213_C | def count_rearrangements(k: int, segments: List[int]) -> int:
""" Julia and her friends have a unique way of sending secret messages to each other. Each message is divided into segments, and each segment contains a non-negative integer. They enjoy decoding messages by rearranging the segments based on specific rule... | def sum_of_digits(n):
return sum(int(d) for d in str(n))
def count_rearrangements(k, segments):
MOD = 10**9 + 7
# Count segments by sum of digits % 3 category
count_0 = 0
count_1 = 0
count_2 = 0
for segment in segments:
sum_digits = sum_of_digits(segment)
if sum_digits ... | from solution import count_rearrangements
def test_example1():
assert count_rearrangements(3, [123, 456, 789]) == 6
def test_example2():
assert count_rearrangements(4, [111, 222, 333, 444]) == 24
def test_single_segment():
assert count_rearrangements(1, [123]) == 1
def test_all_zeroes():
assert coun... | [
{
"docstring": null,
"function_declaration": "def sum_of_digits(n):",
"function_name": "sum_of_digits",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def count_rearrangements(k, segments):",
"function_name": "count_rearrangements",
"parameter_list": "(k... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "MOD = 10**9 + 7\n\ndef digit_sum(n):\n \"\"\"\n Returns the sum of digits of the integer n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\nde... | trial_gpt4o_1 | {
"original_instruction": "Julia and her friends have a unique way of sending secret messages to each other. Each message is divided into segments, and each segment contains a non-negative integer. They enjoy decoding messages by rearranging the segments based on specific rules.\n\nYou are given a message as a list o... | 0.592949 | Taco_74213 | C | [
"sum_of_digits",
"count_rearrangements"
] | 2 | [
[
"count_rearrangements",
"sum_of_digits"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 81693f4578ce5f37974f79be512ceae41d508ed7 | 9bb90702451a554c70bd6059eea92d6e91ffb61d | |||
v1.0 | complete | Taco | Taco_73935_C | def apply_operations(N, M, operations):
""" Apply a set of crate removal operations to a farm grid.
Args:
- N (int): Number of rows in the farm.
- M (int): Number of columns in the farm.
- operations (list of tuples): List of operations where each operation
is represented by a tuple (r1, c1, ... | def apply_operations(N, M, operations):
# Initial farm grid, filled with 1s
farm = [[1] * M for _ in range(N)]
# Apply each operation
for r1, c1, r2, c2 in operations:
for i in range(r1 - 1, r2):
for j in range(c1 - 1, c2):
farm[i][j] = 0
return farm
de... | def test_apply_operations():
N, M = 3, 4
operations = [
(1, 1, 2, 2),
(2, 3, 3, 4)
]
expected_output = [
[0, 0, 1, 1],
[0, 0, 0, 0],
[1, 1, 0, 0]
]
assert apply_operations(N, M, operations) == expected_output
def test_process_test_cases():
T = 1
t... | [
{
"docstring": null,
"function_declaration": "def apply_operations(N, M, operations):",
"function_name": "apply_operations",
"parameter_list": "(N, M, operations)"
},
{
"docstring": null,
"function_declaration": "def process_test_cases(T, test_cases):",
"function_name": "process_test... | [
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 remove_crates(N, M, operations):\n # Initialize the grid with each cell having one crate.\n grid = [[1 for _ in range(M)] for _ in range(N)]\n\n # App... | trial_gpt4o_2 | {
"original_instruction": "Fiona the Farmer has a rectangular farm with $N$ rows and $M$ columns, all filled with steel crates. Each cell in the farm grid is identified by its coordinates $(i,j)$, where $1 \\leq i \\leq N$ and $1 \\leq j \\leq M$. Recently, she acquired a magic plow that can remove crates in various ... | 0.554935 | Taco_73935 | C | [
"apply_operations",
"process_test_cases",
"solution"
] | 3 | [
[
"process_test_cases",
"apply_operations"
],
[
"solution",
"process_test_cases"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | false | [] | true | 20c4139bb9aa6a41507964f6dc6179f4c7ac885e | 52e6b0a39984f46929d6403e1422f1c4cd12e510 | |||
v1.0 | complete | Taco | Taco_74340_C | def is_bitonic_sequence(arr):
"""
Check if a given array forms a bitonic sequence.
>>> is_bitonic_sequence([1, 2, 3, 2, 1])
True
>>> is_bitonic_sequence([1, 3, 2])
True
>>> is_bitonic_sequence([1, 2, 3, 4])
False
>>> is_bitonic_sequence([4, 2, 1])
False
>>> is_bitonic_sequenc... | def is_bitonic_sequence(arr):
"""
Check if a given array forms a bitonic sequence.
"""
n = len(arr)
if n < 3:
return False
increasing = True
# Find the peak point
for i in range(1, n):
if increasing:
if arr[i] <= arr[i - 1]:
increasing = False
... | def test_is_bitonic_sequence():
assert is_bitonic_sequence([1, 2, 3, 2, 1]) == True
assert is_bitonic_sequence([1, 3, 2]) == True
assert is_bitonic_sequence([1, 2, 3, 4]) == False
assert is_bitonic_sequence([4, 2, 1]) == False
assert is_bitonic_sequence([1, 1, 2, 3]) == False
def test_is_bitonic_su... | [
{
"docstring": "Check if a given array forms a bitonic sequence.",
"function_declaration": "def is_bitonic_sequence(arr):",
"function_name": "is_bitonic_sequence",
"parameter_list": "(arr)"
},
{
"docstring": "Determines if there exists a contiguous subarray that, when flattened into a single... | [
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 generate_spiral_matrix(M, N):\n spiral_matrix = [[0] * N for _ in range(M)]\n num = 1\n left, right = 0, N - 1\n top, bottom = 0, M - 1\n\n whil... | trial_gpt4o_3 | {
"original_instruction": "You are given a matrix of size MxN filled with the integers from 1 to MxN in a spiral order. Your task is to determine if there exists a contiguous subarray that, when flattened into a single row, forms a bitonic sequence. A sequence is called bitonic if it first strictly increases and then... | 0.564663 | Taco_74340 | C | [
"is_bitonic_sequence",
"is_spiral_bitonic_sequence_exists",
"is_bitonic_subarray_exists"
] | 3 | [
[
"is_bitonic_subarray_exists",
"is_spiral_bitonic_sequence_exists"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | d51310acbc8e983126c1a284a2da52f9f89ffd6f | fe90c43f9ded8682e95547d89455a94838b1683d | |||
v1.0 | complete | Taco | Taco_74231_C | from typing import List, Tuple
def minimum_upgrade_cost(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int:
""" Determine the minimum cost to upgrade the roads to ensure every city is reachable from any other city.
n: The number of cities.
m: The number of roads.
roads: A list of tuples, ea... | def find(parent, i):
if parent[i] == i:
return i
else:
parent[i] = find(parent, parent[i])
return parent[i]
def union(parent, rank, x, y):
xroot = find(parent, x)
yroot = find(parent, y)
if xroot != yroot:
if rank[xroot] < rank[yroot]:
parent[xroot] = yr... | def test_minimum_upgrade_cost():
assert minimum_upgrade_cost(4, 4, [(1, 2, 1), (2, 3, 4), (3, 4, 3), (1, 4, 5)]) == 8
assert minimum_upgrade_cost(4, 2, [(1, 2, 3), (3, 4, 2)]) == -1
assert minimum_upgrade_cost(5, 6, [(1, 2, 2), (1, 3, 2), (3, 4, 3), (4, 5, 1), (2, 3, 4), (1, 4, 3)]) == 8
assert minimum_... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren... | trial_gpt4o_0 | {
"original_instruction": "In a distant land, cities are connected by roads. The government has decided to upgrade the roads to attract tourists. Each road has a cost associated with upgrading it. The government wants to upgrade a subset of these roads such that every city is reachable from any other city (a connecte... | 0.66752 | Taco_74231 | C | [
"find",
"union",
"kruskal",
"minimum_upgrade_cost"
] | 4 | [
[
"kruskal",
"find"
],
[
"kruskal",
"union"
],
[
"minimum_upgrade_cost",
"kruskal"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | false | [] | true | 8f47c770c51428093b3534f599fdc255d76cc9ae | ba1d019aefb9ce5676f49b0a8587dbddd89d2e93 | |||
v1.0 | complete | Taco | Taco_73139_C | from typing import List, Dict, Any
def race_results(runners: List[Dict[str, Any]]) -> Dict[str, str]:
""" Determines the final standings for a marathon race based on the finish times of the runners.
Each runner passes through multiple checkpoints, and their progress is recorded in an input array of objects.
... | from typing import List, Dict, Any
from datetime import datetime
def race_results(runners: List[Dict[str, Any]]) -> Dict[str, str]:
def parse_time(time_str):
return datetime.strptime(time_str, "%H:%M:%S")
def tie_breaker(runner1, runner2):
times1 = runner1["times"]
times2 = runner2... | from solution import race_results
def test_no_ties():
runners = [
{"name": "Alice", "times": ["00:15:30", "00:30:25", "00:45:10", "01:10:05"]},
{"name": "Bob", "times": ["00:14:25", "00:28:20", "00:42:30", "01:05:25"]},
{"name": "Charlie", "times": ["00:17:10", "00:34:05", "00:50:00", "01:1... | [
{
"docstring": null,
"function_declaration": "def race_results(runners):",
"function_name": "race_results",
"parameter_list": "(runners)"
},
{
"docstring": null,
"function_declaration": "def ordinal(n):",
"function_name": "ordinal",
"parameter_list": "(n)"
},
{
"docstring... | [
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 convert_time_to_seconds(time_str):\n \"\"\"\n Convert a time string in the format HH:MM:SS to seconds.\n \"\"\"\n h, m, s = map(int, time_str.split... | trial_gpt4o_6 | {
"original_instruction": "You are tasked to determine the final standings for a marathon race. There are several competitors, and their progress needs to be evaluated based on specific checkpoints they pass during the marathon. A runner's final position is determined by how quickly they pass through the checkpoints ... | 0.622483 | Taco_73139 | C | [
"race_results",
"ordinal"
] | 2 | [
[
"race_results",
"ordinal"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8ed34ee14839b53017e4458cef445ef7e359de7d | a68e87153a2f46cc8f86140861360ae1bb6ce5b9 | |||
v1.0 | complete | Taco | Taco_74414_C | def is_prime(n):
"""
Check if a number is a prime number.
>>> is_prime(2) True
>>> is_prime(3) True
>>> is_prime(4) False
>>> is_prime(17) True
>>> is_prime(20) False
"""
def sum_of_digits(n):
"""
Returns the sum of digits of the number n.
>>> sum_of_digits(123) 6
>>> su... | def is_prime(n):
"""
Check if a number is a prime number.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
re... | from solution import is_prime, sum_of_digits, will_lock_open, process_cases
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(20) == False
def test_sum_of_digits():
assert sum_of_digits(123) == 6
... | [
{
"docstring": "Check if a number is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns the sum of digits of the number n.",
"function_declaration": "def sum_of_digits(n):",
"function_name": "s... | [
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(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if... | trial_gpt4o_1 | {
"original_instruction": "Sara has a unique lock mechanism that requires a code to be cracked in order to open it. The lock is designed in a way that it only opens if the sum of digits of a given number is a prime number. You need to write a code that helps Sara determine if the lock will open for a given number or ... | 0.702597 | Taco_74414 | C | [
"is_prime",
"sum_of_digits",
"will_lock_open",
"process_cases"
] | 4 | [
[
"process_cases",
"will_lock_open"
],
[
"will_lock_open",
"is_prime"
],
[
"will_lock_open",
"sum_of_digits"
]
] | 3 | [
"process_cases"
] | false | [] | false | pytest | true | [] | true | 682de06782b3b96933b930f8923ef591170ff287 | 537155347b25a9a3e015a648b95dc505c9eb99c3 | |||
v1.0 | complete | Taco | Taco_74120_C | from typing import List
from collections import defaultdict, deque
def find_exact_path(n: int, edges: List[List[int]], queries: List[List[int]]) -> List[str]:
"""
Given an undirected graph with N nodes and M edges, determine if there exists a path between two given nodes u and v
that passes through exactl... | from collections import deque, defaultdict
def find_exact_path(n, edges, queries):
graph = defaultdict(list)
for u, v in edges:
graph[u].append(v)
graph[v].append(u)
def bfs(u, distance, target_distance, target):
queue = deque([(u, 1)])
visited = set()
while queue:
... | from solution import find_exact_path, process_graph_query
# Test helper functions
def test_helper_bfs():
edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [3, 6]]
queries = [(1, 4, 4), (1, 6, 2), (2, 5, 3)]
expected = ["Yes", "Yes", "No"]
assert find_exact_path(6, edges, queries) == expected
de... | [
{
"docstring": null,
"function_declaration": "def find_exact_path(n, edges, queries):",
"function_name": "find_exact_path",
"parameter_list": "(n, edges, queries)"
},
{
"docstring": null,
"function_declaration": "def process_graph_query(n, m, edge_list, q, query_list):",
"function_na... | [
0,
0,
0,
0,
0,
1,
0,
1,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def bfs_path_exact_k(adjacency_list, start, end, k):\n from collections import deque\n \n queue = deque([(start, 1)]) # (current_node, current_depth)\n ... | trial_gpt4o_7 | {
"original_instruction": "Given an undirected graph with N nodes and M edges, you need to find if there exists a path between two given nodes u and v that passes through exactly k nodes. \n\nA valid path is defined as a sequence of nodes starting from node u, ending at node v, and with the length of the path being e... | 0.672327 | Taco_74120 | C | [
"find_exact_path",
"process_graph_query"
] | 2 | [
[
"process_graph_query",
"find_exact_path"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7c2a8b377e8854e9c169a9cc60c69ebd24c61543 | 5ac008790ff476ac893ab102b10521cd7717fe7d | |||
v1.0 | complete | Taco | Taco_74416_C | def max_subarray_sum(arr):
""" Returns the maximum possible sum of a contiguous subarray within the given array.
>>> max_subarray_sum([1, 2, 3, 4]) == 10
>>> max_subarray_sum([1, -2, 3, 4]) == 7
>>> max_subarray_sum([-1, -2, -3, -4]) == -1
>>> max_subarray_sum([1, -3, 2, 1, -1]) == 3
"""
def so... | def max_subarray_sum(arr):
"""
Returns the maximum possible sum of a contiguous subarray within the given array.
"""
max_sum = float('-inf')
current_sum = 0
for num in arr:
current_sum = max(num, current_sum + num)
max_sum = max(max_sum, current_sum)
return max_sum
... | from solution import max_subarray_sum, solve, parse_input
def test_single_positive_array():
assert max_subarray_sum([1, 2, 3, 4]) == 10
def test_single_mixed_array():
assert max_subarray_sum([1, -2, 3, 4]) == 7
def test_single_negative_array():
assert max_subarray_sum([-1, -2, -3, -4]) == -1
def test_si... | [
{
"docstring": "Returns the maximum possible sum of a contiguous subarray within the given array.",
"function_declaration": "def max_subarray_sum(arr):",
"function_name": "max_subarray_sum",
"parameter_list": "(arr)"
},
{
"docstring": null,
"function_declaration": "def solve(test_cases):... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_subarray_sum(arr):\n \"\"\"\n Returns the maximum possible sum of a contiguous subarray within the given array.\n \"\"\"\n max_sum = float('-in... | trial_gpt4o_0 | {
"original_instruction": "Develop a program that calculates the maximum possible sum of a contiguous subarray within a given array of integers.\n\n------ Input Format ------ \n\n- The first line contains an integer T, the number of test cases.\n- Each of the next T pairs of lines:\n - The first line contains an int... | 0.693332 | Taco_74416 | C | [
"max_subarray_sum",
"solve",
"parse_input"
] | 3 | [
[
"solve",
"max_subarray_sum"
]
] | 1 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 474919d6c4aacdd5aec45fa96d9a591aab6fdd27 | 71207ed04698be9479dd812a82cd577a89af9d4a | |||
v1.0 | complete | Taco | Taco_73876_C | import itertools
def base26_generator():
length = 1
while True:
for s in itertools.product("abcdefghijklmnopqrstuvwxyz", repeat=length):
yield ''.join(s)
length += 1
def generate_shortcodes(urls: List[str]) -> List[str]:
""" Generate unique shortcodes based on the original URLs... | import itertools
# A generator for base-26 alphabetic sequences
def base26_generator():
length = 1
while True:
for s in itertools.product("abcdefghijklmnopqrstuvwxyz", repeat=length):
yield ''.join(s)
length += 1
def generate_shortcodes(urls):
url_to_shortcode = {}
generato... | from solution import generate_shortcodes
def test_generate_shortcodes_simple():
urls = ["https://example.com/page1", "https://example.com/page2"]
expected = ["a", "b"]
assert generate_shortcodes(urls) == expected
def test_generate_shortcodes_repeated_url():
urls = [
"https://first.com",
... | [
{
"docstring": null,
"function_declaration": "def base26_generator():",
"function_name": "base26_generator",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def generate_shortcodes(urls):",
"function_name": "generate_shortcodes",
"parameter_list": "(urls)"... | [
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 generate_shortcodes(urls):\n def num_to_shortcode(num):\n \"\"\"Converts a number into a base-26-like shortcode.\"\"\"\n shortcode = []\n ... | trial_gpt4o_2 | {
"original_instruction": "You are working on a new online social media platform that is implementing a feature to shorten lengthy URLs. One of the requirements is to ensure that each shortened URL is unique and easy to remember. To achieve this, you need to generate unique shortcodes based on the original URLs provi... | 0.516913 | Taco_73876 | C | [
"base26_generator",
"generate_shortcodes"
] | 2 | [
[
"generate_shortcodes",
"base26_generator"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 900aa4ce14e25ea4128df7fb2a06d9b5bd62d903 | 2ea214517052dcaf7266114bf2d5f6a28bc15ae5 | |||
v1.0 | complete | Taco | Taco_74227_C | def solve_maze_problem(n: int, m: int, grid_data: List[str], start_x: int, start_y: int, target_x: int, target_y: int) -> int:
""" Determine the shortest path from the start cell to the target cell in a maze described by a grid of passable and impassable cells.
Args:
n (int): The number of rows in the ... | from collections import deque
def shortest_path_maze(n, m, maze, x1, y1, x2, y2):
"""
Returns the length of the shortest path from the start cell (x1, y1) to the target cell (x2, y2) in the maze.
"""
if (x1, y1) == (x2, y2):
return 0
# Directions for moving up, down, left, right
di... | import pytest
from solution import solve_maze_problem
def test_shortest_path_example():
n, m = 5, 5
grid_data = [
"0 1 0 0 0",
"0 1 0 1 0",
"0 0 0 1 0",
"0 1 0 1 0",
"0 0 0 0 0"
]
start_x, start_y = 0, 0
target_x, target_y = 4, 4
assert solve_maze_problem... | [
{
"docstring": "Returns the length of the shortest path from the start cell (x1, y1) to the target cell (x2, y2) in the maze.",
"function_declaration": "def shortest_path_maze(n, m, maze, x1, y1, x2, y2):",
"function_name": "shortest_path_maze",
"parameter_list": "(n, m, maze, x1, y1, x2, y2)"
},
... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef shortest_path_in_maze(n, m, maze, x1, y1, x2, y2):\n \"\"\"\n Returns the length of the shortest path from (x1, y1) to (... | trial_gpt4o_2 | {
"original_instruction": "You are given a grid representing a maze where some cells are passable and some are walls. Your task is to determine the shortest path from the start cell to the target cell. The maze is defined by a matrix with 0's and 1's — 0 represents a passable cell and 1 represents a wall. You can mov... | 0.674467 | Taco_74227 | C | [
"shortest_path_maze",
"solve_maze_problem"
] | 2 | [
[
"solve_maze_problem",
"shortest_path_maze"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 56088834c0162b2d425a8331aece8c6b0669554b | 0e67c1cc741856add42ffc23b34fd361151d45fe | |||
v1.0 | complete | Taco | Taco_74049_C | from typing import List, Tuple
def min_platform_jumps(Sx: int, Sy: int, Tx: int, Ty: int, platforms: List[Tuple[int, int, int, int]]) -> int:
""" Determine the minimum number of platforms a player must jump on to reach a target coordinate.
:param Sx: Starting x-coordinate of the player
:param Sy: Starting ... | from collections import deque
def min_platform_jumps(Sx, Sy, Tx, Ty, platforms):
def is_adjacent_or_overlap(p1, p2):
# p1 and p2 are platforms with structure (X1, Y1, X2, Y2)
X1_1, Y1_1, X2_1, Y2_1 = p1
X1_2, Y1_2, X2_2, Y2_2 = p2
if X1_1 <= X2_2 and X2_1 >= X1_2 and (Y1_1 == Y2_2 o... | from solution import solve, parse_input
def test_example_1():
input_str = '2\n0 0 10 10\n3\n0 0 2 2\n2 2 5 5\n5 5 10 10\n0 0 3 3\n3\n0 0 2 2\n5 5 7 7\n8 8 10 10\n'
test_cases = parse_input(input_str)
result = solve(test_cases)
assert result == [2, -1]
def test_no_valid_start_or_end():
input_s... | [
{
"docstring": null,
"function_declaration": "def min_platform_jumps(Sx, Sy, Tx, Ty, platforms):",
"function_name": "min_platform_jumps",
"parameter_list": "(Sx, Sy, Tx, Ty, platforms)"
},
{
"docstring": null,
"function_declaration": "def solve(test_cases):",
"function_name": "solve"... | [
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, defaultdict\n\ndef is_adjacent_or_overlapping(p1, p2):\n \"\"\"\n Check if two platforms p1 and p2 are adjacent or overlapping... | trial_gpt4o_8 | {
"original_instruction": "In a gaming environment, there are a number of rectangular platforms. Each platform is defined by two coordinates: (X1, Y1) and (X2, Y2), which represent the bottom-left and top-right corners of the rectangle, respectively. A player is initially standing at a starting coordinate (Sx, Sy). T... | 0.617059 | Taco_74049 | C | [
"min_platform_jumps",
"solve",
"parse_input",
"print_output"
] | 4 | [
[
"solve",
"min_platform_jumps"
]
] | 1 | [
"parse_input",
"print_output"
] | false | [] | false | pytest | true | [] | true | e36e11bba70c085ef9349544081c5a2c6e543b13 | 78444064660064da84e54605711968f3ab577171 | |||
v1.0 | complete | Taco | Taco_74695_C | from typing import List
def sort_dates(dates: List[str]) -> List[str]:
"""
Takes a list of date strings in various formats and returns a list of dates sorted in ascending order.
The output dates will be in 'YYYY-MM-DD' format.
>>> sort_dates(['2023-01-15', '15-01-2023', 'January 15, 2023', '2023-02-2... | from datetime import datetime
# We will use different formats to parse the different types of date strings
FORMATS = [
'%Y-%m-%d', # YYYY-MM-DD
'%d-%m-%Y', # DD-MM-YYYY
'%B %d, %Y' # Month DD, YYYY
]
def parse_date(date_str):
"""
Parses a date string into a datetime object.... | from solution import sort_dates
def test_sort_dates_format1():
dates = [
'2023-01-15',
'2021-12-01',
'2022-06-30',
'2021-01-15'
]
result = sort_dates(dates)
expected = ['2021-01-15', '2021-12-01', '2022-06-30', '2023-01-15']
assert result == expected
def test_sort_d... | [
{
"docstring": "Parses a date string into a datetime object.",
"function_declaration": "def parse_date(date_str):",
"function_name": "parse_date",
"parameter_list": "(date_str)"
},
{
"docstring": "Takes a list of date strings, parses them, and returns a list of dates in 'YYYY-MM-DD' format."... | [
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 datetime import datetime\n\ndef parse_date(date_str):\n formats = [\"%Y-%m-%d\", \"%d-%m-%Y\", \"%B %d, %Y\"]\n for fmt in formats:\n try:\n ... | trial_gpt4o_8 | {
"original_instruction": "Problem Statement\n\nYou have been tasked with developing a new software feature for a professional scheduling application. The feature allows users to set reminders for important dates and events. One critical aspect of your implementation is to handle various date formats from different u... | 0.68282 | Taco_74695 | C | [
"parse_date",
"sort_dates"
] | 2 | [
[
"sort_dates",
"parse_date"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 92242c7d98147ed8f160bd560bb307ecce4f7adb | 0598df42a3810e738347faebdf4740583124e1eb | |||
v1.0 | complete | Taco | Taco_74686_C | def preprocess_grid(grid):
"""
Preprocess the grid to create a prefix sum array.
"""
pass
def sum_in_subgrid(prefix_sum, r1, c1, r2, c2):
"""
Calculate the sum of the subgrid using the prefix sum array.
"""
pass
def chocolate_sum_queries(grid, queries):
"""
Process each query t... | def preprocess_grid(grid):
"""
Preprocess the grid to create a prefix sum array.
"""
r = len(grid)
c = len(grid[0])
prefix_sum = [[0] * (c + 1) for _ in range(r + 1)]
for i in range(1, r + 1):
for j in range(1, c + 1):
prefix_sum[i][j] = grid[i-1][j-1] + prefix_sum[i... | def test_preprocess_grid():
grid = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
expected_prefix_sum = [
[0, 0, 0, 0],
[0, 1, 3, 6],
[0, 5, 12, 21],
[0, 12, 27, 45]
]
assert preprocess_grid(grid) == expected_prefix_sum
def test_sum_in_subgrid():
pre... | [
{
"docstring": "Preprocess the grid to create a prefix sum array.",
"function_declaration": "def preprocess_grid(grid):",
"function_name": "preprocess_grid",
"parameter_list": "(grid)"
},
{
"docstring": "Calculate the sum of the subgrid using the prefix sum array.",
"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 precompute_prefix_sums(grid, r, c):\n \"\"\"\n Precomputes the prefix sums of the grid.\n \"\"\"\n prefix_sums = [[0] * (c + 1) for _ in range(r + ... | trial_gpt4o_2 | {
"original_instruction": "Problem\n\nYou are given a box of chocolates arranged in a grid of size r x c and a list of queries. Each chocolate piece in the grid has a sweetness value, and each query asks you to find the sum of the sweetness values in a subgrid defined by its corners.\n\nTo be more specific, each quer... | 0.533757 | Taco_74686 | C | [
"preprocess_grid",
"sum_in_subgrid",
"chocolate_sum_queries"
] | 3 | [
[
"chocolate_sum_queries",
"preprocess_grid"
],
[
"chocolate_sum_queries",
"sum_in_subgrid"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | c1aa82839aedaad28fb308740d4c0fab6b548bbd | 7a37dda51835afd579fb794b234f8dfe0e96ab80 | |||
v1.0 | complete | Taco | Taco_73955_C | class SegmentTree:
def __init__(self, data):
self.n = len(data)
self.data = data[:]
self.tree = [0] * (2 * self.n)
self.build()
def build(self):
# Initialize leaves
for i in range(self.n):
self.tree[self.n + i] = self.data[i]
# Build the t... | class SegmentTree:
def __init__(self, data):
self.n = len(data)
self.data = data[:]
self.tree = [0] * (2 * self.n)
self.build()
def build(self):
# Initialize leaves
for i in range(self.n):
self.tree[self.n + i] = self.data[i]
# Build the t... | def test_generic_case():
input_data = """5 4
1 2 3 4 5
2 1 3
1 2 6
2 1 3
2 2 5
"""
output_data = """6
10
18"""
assert genos_robot_team(input_data) == output_data
def test_all_updates():
input_data = """3 3
1 2 3
1 1 10
1 2 20
1 3 30"""
output_data = "" # No range queries, so no output
assert g... | [] | [
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 FenwickTree:\n def __init__(self, size):\n self.size = size\n self.tree = [0] * (size + 1)\n\n def update(self, index, delta):\n w... | trial_gpt4o_2 | {
"original_instruction": "Genos has decided to create his own team of powerful robots. To manage the team efficiently, he needs to maintain the skill levels of the robots and respond to queries about the total skill levels of robots within specific ranges quickly. Given the number of robots and their initial skill l... | 0.547845 | Taco_73955 | C | [
"handle_operations",
"process_input",
"genos_robot_team"
] | 3 | [
[
"genos_robot_team",
"handle_operations"
],
[
"genos_robot_team",
"process_input"
]
] | 2 | [
"process_input"
] | false | [
"SegmentTree"
] | true | pytest | false | [] | true | 98a02e32dba70887e512a8dc889ef1bfba31f2c3 | 4e3d2303359abaffa0f553c50040c2f57a4acf73 | |||
v1.0 | complete | Taco | Taco_74772_C | def is_beautiful_song(song: str) -> bool:
""" Determines if a song is beautiful based on the given criteria.
"""
def beautiful_playlist(playlist: List[str]) -> List[bool]:
""" Determines if each song in the playlist is beautiful.
>>> beautiful_playlist(["ABC", "BAB", "AC"]) == [True, True, False]
... | def is_beautiful_song(song):
"""
Determines if a song is beautiful based on the given criteria.
"""
for i in range(len(song) - 1):
if abs(ord(song[i]) - ord(song[i + 1])) > 1:
return False
return True
def beautiful_playlist(playlist):
"""
Determines if each song in the p... | from solution import beautiful_playlist
def test_beautiful_playlist():
assert beautiful_playlist(["ABC", "BAB", "AC"]) == [True, True, False]
assert beautiful_playlist(["A", "BB", "CCC"]) == [True, True, True]
assert beautiful_playlist(["CBA", "ABC", "BAD"]) == [True, True, False]
assert beautiful_play... | [
{
"docstring": "Determines if a song is beautiful based on the given criteria.",
"function_declaration": "def is_beautiful_song(song):",
"function_name": "is_beautiful_song",
"parameter_list": "(song)"
},
{
"docstring": "Determines if each song in the playlist is beautiful.",
"function_d... | [
1,
0
] | 1 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_beautiful_song(song):\n \"\"\"\n Determines if a song is beautiful based on the given criteria.\n \"\"\"\n for i in range(len(song) - 1):\n ... | trial_gpt4o_0 | {
"original_instruction": "## Task\nAlex is a fan of both music and coding. He has a playlist of songs, each represented as a string of note names (like \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"). Alex considers a song beautiful if, for every note in the song, the note in the next position is either the same, e... | 0.63776 | Taco_74772 | C | [
"is_beautiful_song",
"beautiful_playlist"
] | 2 | [
[
"beautiful_playlist",
"is_beautiful_song"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 11c259b8e62e873155692d7977fc4da0307e170a | 58e089cd983f1585895f2ddf8747fe6a80490009 | |||
v1.0 | complete | Taco | Taco_74762_C | def palindromic_decomposition(n: int) -> List[List[str]]:
"""
Given an integer n, return a list of all possible palindromic decompositions of n.
A palindromic decomposition of n is a list of strings, where each string is a palindrome and the concatenation of all the strings is equal to n.
Example ... | def is_palindrome(s):
return s == s[::-1]
def palindromic_decomposition(n):
s = str(n)
results = []
def helper(start, path):
if start == len(s):
results.append(path[:])
return
for end in range(start + 1, len(s) + 1):
part = s[start:end]
i... | from solution import palindromic_decomposition
def test_palindromic_decomposition_example_1():
assert palindromic_decomposition(121) == [["1","2","1"], ["121"]]
def test_palindromic_decomposition_example_2():
assert palindromic_decomposition(1221) == [["1","2","2","1"], ["1", "22", "1"], ["1221"]]
def test_p... | [
{
"docstring": null,
"function_declaration": "def is_palindrome(s):",
"function_name": "is_palindrome",
"parameter_list": "(s)"
},
{
"docstring": null,
"function_declaration": "def palindromic_decomposition(n):",
"function_name": "palindromic_decomposition",
"parameter_list": "(n... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_palindrome(s):\n \"\"\"\n Check if a string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef palindromic_decomposition(n):\n \"\"\"\n... | trial_gpt4o_2 | {
"original_instruction": "Given an integer n, return a list of all possible palindromic decompositions of n.\n\nA palindromic decomposition of n is a list of strings, where each string is a palindrome and the concatenation of all the strings is equal to n.\n\nExample 1:\nInput: n = 121\nOutput: [[\"1\",\"2\",\"1\"],... | 0.716932 | Taco_74762 | C | [
"is_palindrome",
"palindromic_decomposition"
] | 2 | [
[
"palindromic_decomposition",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8dcef1764e0ca0b6a00c920c62198ccd1b616918 | cea68ba31c433366708f107061f471a2adf60c8b | |||
v1.0 | complete | Taco | Taco_74830_C | def is_prime(n: int) -> bool:
""" Helper function to check if a number is prime.
>>> is_prime(2)
True
>>> is_prime(3)
True
>>> is_prime(4)
False
>>> is_prime(5)
True
>>> is_prime(9)
False
>>> is_prime(11)
True
"""
def closest_primes(x: int) -> tuple:
""" Retu... | 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 closest_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(5) == True
assert is_prime(9) == False
assert is_prime(11) == True
def test_closest_primes():
assert closest_primes(10) == (7... | [
{
"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 closest prime numbers around the given number x.",
"function_declaration": "def closest_primes(... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n*... | trial_gpt4o_1 | {
"original_instruction": "In a remote town of the country Byteland, there lived a developer named Ben. He loved prime numbers and often tried to incorporate them into his work. One day, he came up with a new challenge for his friends: to find the closest prime numbers around a given number `x`. Specifically, he want... | 0.735341 | Taco_74830 | C | [
"is_prime",
"closest_primes"
] | 2 | [
[
"closest_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 1dcbca64094fbe27a8a43c3e8db3566a25e096ae | d0d11fa96eeb0ae72d90d7acd66e4a6cc12876bb | |||
v1.0 | complete | Taco | Taco_74684_C | from collections import deque
from typing import List
def is_path_exists(grid: List[List[str]], N: int, M: int) -> str:
"""
Determines if there is a path from the top-left corner (1, 1) to the bottom-right corner (N, M).
:param grid: List[List[str]] - The grid representing the 2D grid with open ('.') and ... | def is_path_exists(grid, N, M):
"""
Determines if there is a path from the top-left corner (1, 1) to the bottom-right corner (N, M).
:param grid: List[List[str]] - The grid representing the 2D grid with open ('.') and blocked ('#') cells
:param N: int - Number of rows in the grid
:param M: int - Nu... | def test_is_path_exists():
assert is_path_exists(
[['.', '.', '.', '.', '.'],
['.', '#', '#', '#', '.'],
['.', '#', '.', '.', '#'],
['.', '#', '.', '.', '#'],
['.', '.', '.', '.', '.']],
5, 5) == "YES"
assert is_path_exists(
[['.', '#', '.'],
... | [
{
"docstring": "Determines if there is a path from the top-left corner (1, 1) to the bottom-right corner (N, M).\n\n:param grid: List[List[str]] - The grid representing the 2D grid with open ('.') and blocked ('#') cells\n:param N: int - Number of rows in the grid\n:param M: int - Number of columns in the grid\... | [
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_path_exists(N, M, grid):\n from collections import deque\n \n def is_valid(x, y):\n return 0 <= x < N and 0 <= y < M and grid[x][y] == '.'\n... | trial_gpt4o_1 | {
"original_instruction": "In a video game, a player controls a character on a 2D grid. The grid has $N$ rows and $M$ columns, and the character starts at the cell $(1, 1)$. The goal is to reach the cell $(N, M)$ by moving only up, down, left, or right, but there are some restrictions:\n\n- Some cells in the grid are... | 0.655449 | Taco_74684 | C | [
"is_path_exists",
"solve"
] | 2 | [
[
"solve",
"is_path_exists"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 764b3b57982495bb430892036540b179c889c37a | 31bf6bb13945b1774b34bec03f2a65eadf12c568 | |||
v1.0 | complete | Taco | Taco_74886_C | def is_palindrome(num):
""" Check if a number is a palindrome. """
return str(num) == str(num)[::-1]
def is_prime(num):
""" Check if a number is a prime number. """
if num < 2:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return Tr... | def is_palindrome(num):
return str(num) == str(num)[::-1]
def is_prime(num):
if num < 2:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
def digit_sum(num):
return sum(int(digit) for digit in str(num))
def smallest_palindrom... | from solution import smallest_palindrome_with_prime_digit_sum
def test_example_case():
assert smallest_palindrome_with_prime_digit_sum(123) == 131
def test_smallest_palindrome_less_than_10():
assert smallest_palindrome_with_prime_digit_sum(1) == 2
def test_large_number():
assert smallest_palindrome_with_... | [
{
"docstring": null,
"function_declaration": "def is_palindrome(num):",
"function_name": "is_palindrome",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_palindrome(num):\n return str(num) == str(num)[::-1]\n\ndef is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + ... | trial_gpt4o_0 | {
"original_instruction": "Alice is learning about palindrome numbers - numbers that read the same forwards and backwards. She is fascinated by them and wants to find the smallest palindrome number that is greater than or equal to a given integer M. Additionally, to make it more interesting, she wants to ensure that ... | 0.606216 | Taco_74886 | C | [
"is_palindrome",
"is_prime",
"digit_sum",
"smallest_palindrome_with_prime_digit_sum"
] | 4 | [
[
"smallest_palindrome_with_prime_digit_sum",
"digit_sum"
],
[
"smallest_palindrome_with_prime_digit_sum",
"is_palindrome"
],
[
"smallest_palindrome_with_prime_digit_sum",
"is_prime"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 4dcbc2fcfa76fe95f40763ba2e81f69efba0a478 | 5c0f9cd27dbdcc2b67efe0cfd24361ae7d0c3a0f | |||
v1.0 | complete | Taco | Taco_74917_C | def num_paths(n: int, grid_input: List[str]) -> int:
""" Find the number of distinct paths from the top-left corner to the bottom-right corner in a grid.
The grid is represented as a list of strings where '0' is an empty cell and '1' is a blocked cell.
>>> num_paths(3, ["0 0 0", "0 1 0", "0 0 0"])
2
... | def find_paths(grid):
n = len(grid)
if grid[0][0] == 1 or grid[n-1][n-1] == 1:
return 0
dp = [[0] * n for _ in range(n)]
dp[0][0] = 1
for i in range(n):
for j in range(n):
if grid[i][j] == 0:
if i > 0:
dp[i][j] += dp[i-1][j]
... | def test_find_paths():
grid1 = ["0 0 0", "0 1 0", "0 0 0"]
assert num_paths(3, grid1) == 2
grid2 = ["0 1 0", "1 1 0", "0 0 0"]
assert num_paths(3, grid2) == 0
grid3 = ["0 0 0 0", "0 1 1 0", "0 0 0 0", "1 1 0 0"]
assert num_paths(4, grid3) == 3
grid4 = ["0 0 0", "0 1 1", "0 0 0... | [
{
"docstring": null,
"function_declaration": "def find_paths(grid):",
"function_name": "find_paths",
"parameter_list": "(grid)"
},
{
"docstring": null,
"function_declaration": "def num_paths(n, grid_input):",
"function_name": "num_paths",
"parameter_list": "(n, grid_input)"
}
] | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def number_of_paths(n, grid):\n # If the starting or ending cell is blocked, return 0 as there are no paths\n if grid[0][0] == 1 or grid[n-1][n-1] == 1:\n ... | trial_gpt4o_2 | {
"original_instruction": "You are given a grid of `n x n` cells where each cell can be either empty or blocked. An empty cell is represented by `0`, and a blocked cell is represented by `1`. The task is to find the number of distinct paths from the top-left corner (0,0) to the bottom-right corner (n-1,n-1), where yo... | 0.695059 | Taco_74917 | C | [
"find_paths",
"num_paths"
] | 2 | [
[
"num_paths",
"find_paths"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | da094f0f80109c8b476e54d4cb83cc0422bd1abe | 55edcd14f0db74a7126c1213057ec8a52bb7cd6b | |||
v1.0 | complete | Taco | Taco_74308_C | def parse_input(input_str: str):
"""
Parses the input string and returns a list of test cases.
Each test case is a tuple containing:
- the grid (2D list)
- the list of container lengths
>>> input_str = "4 4\n....\n....\n....\n....\n3\n3\n2\n2\n3 3\n..#\n.#.\n..#\n1\n3\n3 3\n..#\n.#.\n..#\n1... | def parse_input(input_str):
"""
Parses the input string and returns a list of test cases.
Each test case is a tuple containing:
- the grid (2D list)
- the list of container lengths
"""
lines = input_str.strip().split('\n')
cases = []
i = 0
while i < len(lines):
if lines[i... | def test_parse_input():
input_str = "4 4\n....\n....\n....\n....\n3\n3\n2\n2\n3 3\n..#\n.#.\n..#\n1\n3\n3 3\n..#\n.#.\n..#\n1\n4\n0\n"
expected_output = [
([['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']], [3, 2, 2]),
([['.', '.', '#'], ['.', '#', '.'], ['... | [
{
"docstring": "Parses the input string and returns a list of test cases.\nEach test case is a tuple containing:\n- the grid (2D list)\n- the list of container lengths",
"function_declaration": "def parse_input(input_str):",
"function_name": "parse_input",
"parameter_list": "(input_str)"
},
{
... | [
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.111 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def can_place_horizontally(grid, row, col, length):\n if col + length > len(grid[0]):\n return False\n for c in range(col, col + length):\n if ... | trial_gpt4o_9 | {
"original_instruction": "A warehouse manager needs an efficient way to manage incoming shipments and store them in the warehouse. The warehouse can be visualized as a 2D grid of cells, where each cell either contains goods or is empty. A shipment consists of multiple containers, each of which requires a certain num... | 0.646688 | Taco_74308 | C | [
"parse_input",
"find_max_cells_used",
"optimal_placement"
] | 3 | [
[
"optimal_placement",
"find_max_cells_used"
],
[
"optimal_placement",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | false | [] | true | 4f07db57acf6c07790b630c64725a85f4c6ee67c | a3a6a0a9c17cf0fe7936b30bd8b19ef2d9975c27 | |||
v1.0 | complete | Taco | Taco_74376_C | class TreeNode:
def __init__(self, value=0):
self.value = value
self.children = []
def add_value_to_node(tree, node_id, value):
pass
def sum_subtree(tree, node_id):
pass
def create_tree(values, edges):
pass
def process_queries(n, values, edges, queries):
"""
Given a binary tr... | class TreeNode:
def __init__(self, value=0):
self.value = value
self.children = []
def add_value_to_node(tree, node_id, value):
tree[node_id].value += value
def sum_subtree(tree, node_id):
def dfs_sum(node):
total = node.value
for child in node.children:
total +... | def test_process_queries():
n = 5
values = [1, 2, 3, 4, 5]
edges = [(1, 2), (1, 3), (2, 4), (2, 5)]
queries = [(2, 1), (1, 3, 5), (2, 1)]
assert process_queries(n, values, edges, queries) == [15, 20]
def test_process_queries_single_node():
n = 1
values = [10]
edges = []
queries = [(... | [] | [
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, val=0):\n self.val = val\n self.children = []\n self.subtree_sum = val\n\ndef build_tree(n, values, ed... | trial_gpt4o_2 | {
"original_instruction": "You are given a binary tree with N nodes. Each node has a distinct integer value. You are also given Q queries of the following types:\n\n- \\texttt{1 v x}: Given node v (1 ≤ v ≤ N) and integer x, add the value x to the value of node v.\n- \\texttt{2 v}: Given node v (1 ≤ v ≤ N), compute an... | 0.576689 | Taco_74376 | C | [
"add_value_to_node",
"sum_subtree",
"create_tree",
"process_queries"
] | 4 | [
[
"process_queries",
"add_value_to_node"
],
[
"process_queries",
"create_tree"
],
[
"process_queries",
"sum_subtree"
]
] | 3 | [
"process_queries"
] | false | [
"TreeNode"
] | true | pytest | false | [] | true | 20a63b65ec68b3979e85b1df7537eed9ee671666 | 427331f67b9e6215a87584469008001042d394e3 | |||
v1.0 | complete | Taco | Taco_75095_C | def is_prime(n: int) -> bool:
""" Check if a number is prime.
>>> is_prime(11)
True
>>> is_prime(4)
False
"""
...
def classify_number(x: int) -> str:
""" Classify the integer as 'Good' if the sum of its digits is a prime number, otherwise 'Bad'.
>>> classify_number(29)
'Good'
... | 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 classify_number(x):
digit_sum = sum(... | from solution import classify_number
def test_good_number():
assert classify_number(29) == "Good"
def test_bad_number():
assert classify_number(13) == "Bad"
assert classify_number(40) == "Bad"
def test_prime_digit_sum_edge_case():
assert classify_number(2) == "Good"
assert classify_number(5) == "... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def classify_number(x):",
"function_name": "classify_number",
"parameter_list": "(x)"
}
] | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n return True\n ... | trial_gpt4o_1 | {
"original_instruction": "Haru has a list of integers and wants to classify each integer as either 'Good' or 'Bad'. An integer is considered 'Good' if the sum of its digits is a prime number. Otherwise, it is considered 'Bad'.\n\n-----Input-----\n\nEach test contains multiple test cases. The first line contains an i... | 0.734365 | Taco_75095 | C | [
"is_prime",
"classify_number"
] | 2 | [
[
"classify_number",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 72c64e1fb84e6c0c4ee309c6f5f93ea33f12c030 | aa9ccbf68cb25a1493c64439834813014377b925 | |||
v1.0 | complete | Taco | Taco_74972_C | def is_prime(n):
"""
Helper function to determine if a given number n is prime.
>>> is_prime(2)
True
>>> is_prime(3)
True
>>> is_prime(4)
False
>>> is_prime(5)
True
"""
# Implement the logic to check if the given number n is prime
def filter_primes(numbers):
"""
... | def is_prime(n):
"""
Helper function to determine if a given number n 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... | def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(10) == False
assert is_prime(13) == True
assert is_prime(17) == True
assert is_prime(19) == True
assert is_prime(20) == False
def test_fi... | [
{
"docstring": "Helper function to determine if a given number n is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of prime numbers from the given list of integers.",
"function_declaration": "def... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n Returns True if prime, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n i... | trial_gpt4o_1 | {
"original_instruction": "Write a function that takes in a list of integers and returns a list containing only the prime numbers from the given list. \n\nFor example:\n\n```\nInput: [2, 4, 7, 10, 13, 16]\nOutput: [2, 7, 13]\n```\n\nThe function should efficiently identify prime numbers by minimizing the number of op... | 0.769715 | Taco_74972 | C | [
"is_prime",
"filter_primes"
] | 2 | [
[
"filter_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | d7358e2aaf3f2dcf0e7f654fd2bcd09c06a8ec95 | 3c07686cf3050ea74de4e6c5f86787c8a810349c | |||
v1.0 | complete | Taco | Taco_74953_C | import heapq
from collections import defaultdict
def dijkstra(n, pathways, start):
graph = defaultdict(list)
for u, v, w in pathways:
graph[u].append((v, w))
graph[v].append((u, w))
distances = {i: float('inf') for i in range(n)}
distances[start] = 0
pq = [(0, start)]
while pq... | import heapq
from collections import defaultdict
def dijkstra(n, pathways, start):
graph = defaultdict(list)
for u, v, w in pathways:
graph[u].append((v, w))
graph[v].append((u, w))
distances = {i: float('inf') for i in range(n)}
distances[start] = 0
pq = [(0, start)]
while pq... | from solution import find_farthest_room
def test_simple_case():
assert find_farthest_room(4, [[0, 1, 1], [1, 2, 2], [1, 3, 2]], 0) == (2, 3)
def test_single_room():
assert find_farthest_room(1, [], 0) == (0, 0)
def test_star_topology():
assert find_farthest_room(4, [[0, 1, 1], [0, 2, 1], [0, 3, 1]], 0) =... | [
{
"docstring": null,
"function_declaration": "def dijkstra(n, pathways, start):",
"function_name": "dijkstra",
"parameter_list": "(n, pathways, start)"
},
{
"docstring": null,
"function_declaration": "def find_farthest_room(n, pathways, s):",
"function_name": "find_farthest_room",
... | [
0,
0,
0,
0,
0,
0,
1,
0,
1
] | 2 | hard | 0.222 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\nfrom collections import defaultdict\n\ndef find_farthest_room(n, pathways, s):\n # Create an adjacency list\n graph = defaultdict(list)\n fo... | trial_gpt4o_8 | {
"original_instruction": "You are an explorer trying to locate a rare artifact hidden in one of the rooms in an ancient temple. The temple has a number of rooms connected by a series of pathways. Each room is represented as a node in a graph, and each pathway between rooms is given as an edge with a certain length. ... | 0.660679 | Taco_74953 | C | [
"dijkstra",
"find_farthest_room"
] | 2 | [
[
"find_farthest_room",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0dea72a24f8440e5019388dd2df940b1ece95e42 | 65152d9f1d802db20ae42d5d5343fdb3a501c4d1 | |||
v1.0 | complete | Taco | Taco_75084_C | from typing import List
def quick_sort(arr: List[int]) -> List[int]:
""" QuickSort algorithm implementation.
>>> quick_sort([3, -1, 4, 1, 5, 9])
[-1, 1, 3, 4, 5, 9]
>>> quick_sort([5, 4, 5, 4, 5])
[4, 4, 5, 5, 5]
"""
pass
def merge_sort(arr: List[int]) -> List[int]:
""" MergeSort algor... | def quick_sort(arr):
"""
QuickSort algorithm implementation.
"""
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quick_sort(left) + middle + quick... | def test_quick_sort_empty():
assert quick_sort([]) == []
def test_quick_sort_single_element():
assert quick_sort([1]) == [1]
def test_quick_sort_multiple_elements():
assert quick_sort([3, -1, 4, 1, 5, 9]) == [-1, 1, 3, 4, 5, 9]
def test_quick_sort_duplicates():
assert quick_sort([5, 4, 5, 4, 5]) == [... | [
{
"docstring": "QuickSort algorithm implementation.",
"function_declaration": "def quick_sort(arr):",
"function_name": "quick_sort",
"parameter_list": "(arr)"
},
{
"docstring": "MergeSort algorithm implementation.",
"function_declaration": "def merge_sort(arr):",
"function_name": "me... | [
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 quicksort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in ... | trial_gpt4o_1 | {
"original_instruction": "You are tasked with evaluating the performance of different sorting algorithms on a list of integers. Specifically, you need to implement and compare QuickSort and MergeSort. \n\nWrite a program that reads a list of integers and outputs the sorted list using both QuickSort and MergeSort alg... | 0.66027 | Taco_75084 | C | [
"quick_sort",
"merge_sort",
"sort_integers"
] | 3 | [
[
"sort_integers",
"merge_sort"
],
[
"sort_integers",
"quick_sort"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 4ed14081e520890bdae85534735ce221ef6f130e | 16e84f1bcdb9b24661490b285446c7b0520eda4e | |||
v1.0 | complete | Taco | Taco_75253_C | def is_prime(n: int) -> bool:
"""
Helper function to check if a number is prime.
Parameters:
n (int): The number to check.
Returns:
bool: True if n is a prime number, False otherwise.
"""
pass
def findPrimes(arr: List[int]) -> List[int]:
"""
Returns a list of prime num... | 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
p = 3
while p * p <= n:
if n % p == 0:
return False
p += 2
return True
def findPrime... | from solution import findPrimes, is_prime
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(5) == True
assert is_prime(1) == False
assert is_prime(0) == False
assert is_prime(-1) == False
assert is_prime(17) == True
... | [
{
"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 a list of prime numbers from the given list of positive integers.\n\nParameters:\narr (list): List of 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": "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_2 | {
"original_instruction": "Design a function that takes an array of positive integers and returns a new array containing only the prime numbers from the original array. If there are no prime numbers in the input array, the function should return an empty array.\n\nFor example:\n```javascript\nfindPrimes([2, 3, 4, 5, ... | 0.789969 | Taco_75253 | C | [
"is_prime",
"findPrimes"
] | 2 | [
[
"findPrimes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 18ad37cb226e1e2c55bbe318bc70d4dc495e8504 | 43956f955303bd578eaa0c5dff1f1a5e33fb59a8 | |||
v1.0 | complete | Taco | Taco_75284_C | def max_rectangle_area(grid, n, m):
""" Find the largest rectangular area in the grid that is free from obstacles where cars can be displayed.
>>> max_rectangle_area([
... "00010",
... "00110",
... "00000",
... "11000"], 4, 5)
6
>>> max_rectangle_area([
... "111",
... "... | def max_histogram_area(histogram):
stack = []
max_area = 0
index = 0
while index < len(histogram):
if not stack or histogram[stack[-1]] <= histogram[index]:
stack.append(index)
index += 1
else:
top_of_stack = stack.pop()
area = (histogram[... | from solution import max_rectangle_area
def test_example_1():
N, M = 4, 5
grid = [
"00010",
"00110",
"00000",
"11000"
]
assert max_rectangle_area(grid, N, M) == 6
def test_example_2():
N, M = 3, 3
grid = [
"111",
"111",
"111"
]
as... | [
{
"docstring": null,
"function_declaration": "def max_histogram_area(histogram):",
"function_name": "max_histogram_area",
"parameter_list": "(histogram)"
},
{
"docstring": null,
"function_declaration": "def max_rectangle_area(grid, n, m):",
"function_name": "max_rectangle_area",
... | [
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 maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n\n max_area = 0\n N, M = len(matrix), len(matrix[0])\n heights = [0]... | trial_gpt4o_2 | {
"original_instruction": "You are organizing a classic car exhibition and you need to plan the display area for the cars.\n\nThe exhibit area is represented as a 2D grid of dimensions N x M. Some areas in the grid are occupied by obstacles where cars cannot be placed. You need to find the largest rectangular area in... | 0.62405 | Taco_75284 | C | [
"max_histogram_area",
"max_rectangle_area",
"main"
] | 3 | [
[
"max_rectangle_area",
"max_histogram_area"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 683771b8b7eee849bf0b66127e3b0a7457255593 | e8c68edfccc482b65be720aebc705bd8211a9168 | |||
v1.0 | complete | Taco | Taco_75329_C | def find_next_palindromes(test_cases):
""" Finds the smallest palindromic number that is strictly greater than each integer in the given list of test cases.
>>> find_next_palindromes([123, 99, 678]) [131, 101, 686]
>>> find_next_palindromes([1, 10, 21, 33, 88]) [2, 11, 22, 44, 99]
""" | def is_palindrome(num):
return str(num) == str(num)[::-1]
def next_palindrome(n):
n += 1
while not is_palindrome(n):
n += 1
return n
def find_next_palindromes(test_cases):
results = []
for n in test_cases:
results.append(next_palindrome(n))
return results | from solution import find_next_palindromes
def test_find_next_palindromes_case1():
assert find_next_palindromes([123, 99, 678]) == [131, 101, 686]
def test_find_next_palindromes_case2():
assert find_next_palindromes([1, 10, 21, 33, 88]) == [2, 11, 22, 44, 99]
def test_find_next_palindromes_zero_case():
a... | [
{
"docstring": null,
"function_declaration": "def is_palindrome(num):",
"function_name": "is_palindrome",
"parameter_list": "(num)"
},
{
"docstring": null,
"function_declaration": "def next_palindrome(n):",
"function_name": "next_palindrome",
"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 next_palindrome(n):\n \"\"\"\n Returns the smallest palindromic number greater than n.\n \"\"\"\n def is_palindrome(x):\n s = str(x)\n ... | trial_gpt4o_2 | {
"original_instruction": "Alex is fascinated with palindromic numbers. A palindromic number reads the same backward as forward. For example, 121 is a palindrome, but 123 is not. Alex wants to find the smallest palindromic number that is greater than a given integer n.\n\nGiven a positive integer n, write a function ... | 0.745868 | Taco_75329 | C | [
"is_palindrome",
"next_palindrome",
"find_next_palindromes"
] | 3 | [
[
"find_next_palindromes",
"next_palindrome"
],
[
"next_palindrome",
"is_palindrome"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | ff77ae7e012f0ce30c47e87a6c853f777c9e4b56 | bf2594bf91f1c92539790df1340feabde47d9536 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.