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
instruct
Taco
Taco_94351_I
You are given a 2D grid of integers where each cell contains either a 0 or a 1. The grid has N rows and M columns. You need to find the largest rectangle containing only 1's and return its area. ------ Input Format ------ - The first line of input will contain two space-separated integers, N and M, representing the...
def maximalRectangle(matrix): if not matrix: return 0 max_area = 0 n = len(matrix) m = len(matrix[0]) heights = [0] * (m + 1) for row in matrix: for i in range(m): if row[i] == 0: heights[i] = 0 else: heights[i] += row[i] ...
import pytest from solution import find_largest_rectangle_area def test_sample_input_1(): input_str = "4 4\n1 0 1 0\n1 0 1 1\n1 1 1 1\n0 0 1 0" assert find_largest_rectangle_area(input_str) == 4 def test_single_row(): input_str = "1 4\n1 1 1 0" assert find_largest_rectangle_area(input_str) == 3 def t...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(input...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_histogram_area(heights):\n # Compute the maximum area of histogram\n stack = []\n max_area = 0\n index = 0\n\n while index < len(heights):\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00094351", "row_id": 94351, "seed_ids": "[14790]" }
0.78191
Taco_94351
I
[ "maximalRectangle", "parse_input", "find_largest_rectangle_area" ]
3
[ [ "find_largest_rectangle_area", "maximalRectangle" ], [ "find_largest_rectangle_area", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
3d26ab0657b289e6d3a99951ab3aec19d4c5f6db
7bb5e181af1e0b84f6d27df5ac9733509fc49df0
v1.0
instruct
Taco
Taco_94378_I
You are given a forest graph with $n$ nodes and $m$ edges. A forest is an undirected graph with no cycles. Your task is to determine the minimum number of edges required to convert the forest into a single connected tree. In other words, you need to connect all the nodes into one connected component ensuring there is ...
def find_connected_components(n, edges): """ Find the number of connected components in the forest graph. """ from collections import defaultdict, deque graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) visited = [False] * (n + 1) ...
from solution import min_edges_to_connect_all_nodes def test_case_1(): assert min_edges_to_connect_all_nodes(6, 3, [(1, 2), (2, 3), (4, 5)]) == 2 def test_case_2(): assert min_edges_to_connect_all_nodes(5, 0, []) == 4 def test_case_3(): assert min_edges_to_connect_all_nodes(4, 3, [(1, 2), (2, 3), (3, 4)]...
[ { "docstring": "Find the number of connected components in the forest graph.", "function_declaration": "def find_connected_components(n, edges):", "function_name": "find_connected_components", "parameter_list": "(n, edges)" }, { "docstring": "Calculate the minimum number of edges required to...
[ 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_connected_components(n, edges):\n \"\"\"\n Find the number of connected components in the forest graph.\n \"\"\"\n from collections import def...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00094378", "row_id": 94378, "seed_ids": "[10864]" }
0.686875
Taco_94378
I
[ "find_connected_components", "min_edges_to_connect_all_nodes" ]
2
[ [ "min_edges_to_connect_all_nodes", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fe7cac8e2484dfd85546f24bf4c8712e114d7a07
42e0bec6fa1928b09bc6781faaa32a3ab10e29c7
v1.0
instruct
Taco
Taco_94446_I
Real estate companies often provide developers with outlines of properties represented as buildings with varying heights. These heights are presented by skyline silhouettes, where each outline has multiple buildings with peak heights. Imagine a cityscape represented by a list of building outlines, where each building...
def simplify_skyline(buildings): """ This function simplifies the skyline silhouette by merging overlapping buildings while maintaining the highest height at any given x-coordinate. :param buildings: A list of tuples (left, right, height) representing the buildings. :return: A list of tuples (...
import pytest from solution import process_skyline_input def test_example_1(): input_data = "3\n1 3 4\n2 5 3\n6 8 5" expected_output = [(1, 5, 4), (6, 8, 5)] assert process_skyline_input(input_data) == expected_output def test_example_2(): input_data = "4\n1 2 1\n2 4 2\n3 5 3\n5 6 1" expected_outp...
[ { "docstring": "This function simplifies the skyline silhouette by merging overlapping buildings while \nmaintaining the highest height at any given x-coordinate.\n\n:param buildings: A list of tuples (left, right, height) representing the buildings.\n:return: A list of tuples (left, right, height) representing...
[ 0, 0, 0, 0, 0, 1, 1, 0, 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 merge_buildings(buildings):\n \"\"\"\n Merges overlapping or touching buildings and returns the simplified skyline silhouette.\n \"\"\"\n events = ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00094446", "row_id": 94446, "seed_ids": "[22984]" }
0.630362
Taco_94446
I
[ "simplify_skyline", "process_skyline_input" ]
2
[ [ "process_skyline_input", "simplify_skyline" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed731a14d75409f28600f9a6770e282b6f0470f7
18a2d3e63ae3ed6b2901266d1fe84f9ff5a33a80
v1.0
instruct
Taco
Taco_94458_I
Sara is fascinated by numbers and sequences. She recently discovered a special sequence called "Alternating Prime Sequence". In an Alternating Prime Sequence, every pair of consecutive numbers has different parity (one is odd and the other is even) and both numbers in the pair are prime. Sara wants to know if it's pos...
def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def can_split_to_alternating_prime_seq(T, test_cases): results = [] for i in range(T): N = test_cases[i][0] sequence = test_cases[i][1] ...
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 def test_can_split_to_alternating_prime_seq(): test_cases = [ (6, [3, 2, 5, 11, 7, 13]), (4, [4, 6, 8, 10]), (5, ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def can_split_to_alternating_prime_seq(T, test_cases):", "function_name": "can_split_to_alternating_prime_seq", "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00094458", "row_id": 94458, "seed_ids": "[4272]" }
0.640419
Taco_94458
I
[ "is_prime", "can_split_to_alternating_prime_seq" ]
2
[ [ "can_split_to_alternating_prime_seq", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0430e69ab470ecfd36c04325dd855dc5a57142b1
3b3ee22b305c1019a861f226778d791b7abb0daa
v1.0
instruct
Taco
Taco_94475_I
Petya loves palindromic sequences. He often plays with two sequences of numbers and tries to find common subsequences that form palindromes. Given two sequences of numbers, Petya wants to find the longest common palindromic subsequence (LCPS) between them. A subsequence is obtained by deleting some or none of the eleme...
def lcs(X, Y): """ Helper function to find the length of Longest Common Subsequence (LCS) of sequences X and Y. """ n = len(X) m = len(Y) L = [[0] * (m + 1) for i in range(n + 1)] for i in range(n + 1): for j in range(m + 1): if i == 0 or j == 0: L[i]...
from solution import longest_common_palindromic_subsequence def test_case_1(): assert longest_common_palindromic_subsequence([1, 2, 3, 4], [3, 2, 1, 3]) == 3 def test_case_2(): assert longest_common_palindromic_subsequence([1, 2, 3], [4, 5, 6]) == 0 def test_case_3(): assert longest_common_palindromic_su...
[ { "docstring": "Helper function to find the length of Longest Common Subsequence (LCS) of sequences X and Y.", "function_declaration": "def lcs(X, Y):", "function_name": "lcs", "parameter_list": "(X, Y)" }, { "docstring": "Returns the length of the Longest Common Palindromic Subsequence (LCP...
[ 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 lcps_length(n, seq1, m, seq2):\n \"\"\"\n Returns the length of the longest common palindromic subsequence of seq1 and seq2.\n \"\"\"\n # Create a ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00094475", "row_id": 94475, "seed_ids": "[11065]" }
0.668028
Taco_94475
I
[ "lcs", "longest_common_palindromic_subsequence" ]
2
[ [ "longest_common_palindromic_subsequence", "lcs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7c6eaaefae78a28b98dc84d001aa1448c7561716
544d29162274b7f9c0b37094e2fc38a6ec59ff22
v1.0
instruct
Taco
Taco_94479_I
Write a function `minimum_cost_to_connect_houses(n, pipes)` that finds the minimum cost to provide water to all houses. There are `n` houses and `m` pipes where each `pipe[i] = [house1, house2, cost]` denotes a pipe that can connect house1 and house2 with a cost. You need to construct a network of pipes to connect all ...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif rank[root_x] < ...
from solution import minimum_cost_to_connect_houses def test_example_case(): n = 4 pipes = [[1, 2, 1], [2, 3, 4], [3, 4, 2], [1, 4, 3]] assert minimum_cost_to_connect_houses(n, pipes) == 6 def test_disconnected_graph(): n = 3 pipes = [[1, 2, 5]] assert minimum_cost_to_connect_houses(n, pipes) ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimum_cost_to_connect_houses(n, pipes):\n \"\"\"\n Given n houses and a list of pipes with their costs, this function returns the minimum\n cost req...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00094479", "row_id": 94479, "seed_ids": "[7688]" }
0.562057
Taco_94479
I
[ "find", "union", "minimum_cost_to_connect_houses" ]
3
[ [ "minimum_cost_to_connect_houses", "find" ], [ "minimum_cost_to_connect_houses", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c4490db03b94393c19cbcfa47393094aa6287416
7106286666cb8a05ea1cb887139ebd271a63737a
v1.0
instruct
Taco
Taco_94542_I
You are given a linked list of integers. The linked list is considered circular if the last node points to the first node. Your task is to determine if a given linked list is circular or not. -----Input----- The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases. Each test case consis...
class ListNode: def __init__(self, x): self.val = x self.next = None def is_circular_linked_list(head): """ Function to check if a linked list is circular. :param head: ListNode, the head of the linked list :return: True if the linked list is circular, False otherwise """ i...
def test_is_circular_linked_list(): # Test case 1: Non-circular list head = create_linked_list([1, 2, 3, 4, 5]) assert not is_circular_linked_list(head), "Error in test case 1: Non-circular list" # Test case 2: Circular list head = create_linked_list([7, 8, 9]) current = head while curr...
[]
[ 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 ListNode:\n def __init__(self, value=0):\n self.value = value\n self.next = None\n\ndef is_circular_linked_list(head):\n \"\"\"\n Dete...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00094542", "row_id": 94542, "seed_ids": "[17589]" }
0.576701
Taco_94542
I
[ "is_circular_linked_list", "create_linked_list", "check_circular_linked_lists" ]
3
[ [ "check_circular_linked_lists", "create_linked_list" ], [ "check_circular_linked_lists", "is_circular_linked_list" ] ]
2
[]
false
[ "ListNode" ]
true
pytest
false
[]
true
bae20b4d5dbc4553951c71f71fda0d5329f4287a
1d92afe797c023cba58bec300e92fa0074cc72ed
v1.0
instruct
Taco
Taco_94568_I
Alice has recently learned about binary trees in her data structures class. She is given a binary tree and she would like to find out the maximum sum of values from the root node to any leaf node in this tree. Write a program to help Alice find this maximum sum. -----Input----- - The first line of the input contains a...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): if not nodes: return None tree_nodes = [None] * (len(nodes) + 1) for i, (val, left, right) in enumerate(nodes, 1): if tree_...
import pytest from solution import solve def test_single_node_tree(): assert solve([[(3, -1, -1)]]) == [3] def test_simple_tree(): assert solve([[(1, 2, 3), (2, -1, -1), (3, -1, -1)]]) == [4] def test_complex_tree(): nodes = [(5, 2, 3), (3, -1, -1), (4, 4, 5), (-10, -1, -1), (20, -1, -1)] assert solv...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00094568", "row_id": 94568, "seed_ids": "[15871]" }
0.677199
Taco_94568
I
[ "build_tree", "max_path_sum", "solve" ]
3
[ [ "solve", "build_tree" ], [ "solve", "max_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
1c2cc0651d84cfefca6e62424d88baa9c9f82998
2221e6482bf0eaafaeb23674a78d21c89f08a7fd
v1.0
instruct
Taco
Taco_94651_I
Write a program that determines the maximum flow in a given directed network graph \( G = (V, E) \) using the Edmonds-Karp algorithm. The graph represents a network of pipes where each edge \( (u, v) \) has a flow capacity \( c(u, v) \). The source vertex is always labeled as \( 1 \) and the sink vertex as \( n \). Co...
from collections import deque, defaultdict def bfs(graph, source, sink, parent): visited = set() queue = deque([source]) visited.add(source) while queue: u = queue.popleft() for v, capacity in graph[u].items(): if v not in visited and capacity > 0: queue.ap...
def test_edmonds_karp(): edges = [ (1, 2, 100), (1, 3, 100), (2, 3, 1), (2, 4, 100), (3, 4, 100) ] assert edmonds_karp(4, edges) == 200 def test_no_path(): edges = [ (1, 2, 100), (2, 3, 100) ] assert edmonds_karp(4, edges) == 0 def test_s...
[ { "docstring": null, "function_declaration": "def bfs(graph, source, sink, parent):", "function_name": "bfs", "parameter_list": "(graph, source, sink, parent)" }, { "docstring": null, "function_declaration": "def edmonds_karp(n, edges):", "function_name": "edmonds_karp", "paramet...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef bfs(graph, source, sink, parent):\n visited = set()\n queue = deque([source])\n visited.add(source)\n\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00094651", "row_id": 94651, "seed_ids": "[18887]" }
0.574604
Taco_94651
I
[ "bfs", "edmonds_karp" ]
2
[ [ "edmonds_karp", "bfs" ] ]
1
[]
false
[]
false
pytest
false
[]
true
da0d3f33f543e9781befe01f18ae089924d8855d
006bf99b40ee94ea9c28289c0acab292064cf7c8
v1.0
instruct
Taco
Taco_94673_I
A group of friends decided to play a game during a long car trip. The game consists of spotting license plates and noting down their numbers. However, there is a twist in the game: they are only interested in palindromic numbers, which are numbers that read the same backward as forward (e.g., 121 or 2002). Help the fr...
def is_palindrome(number): """ Check if a number is a palindrome. """ str_num = str(number) return str_num == str_num[::-1] def count_palindromic_plates(n, plates): """ Count the number of palindromic license plates. Args: n: The number of license plates. plates: List of in...
import pytest from solution import is_palindrome, count_palindromic_plates def test_is_palindrome(): assert is_palindrome(121) assert not is_palindrome(123) assert is_palindrome(454) assert not is_palindrome(567) assert is_palindrome(898) assert is_palindrome(0) def test_count_palindromic_plat...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Count the number of palindromic license plates.\n\nArgs:\nn: The number of license plates.\nplates: Lis...
[ 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 count_palindromic_plates(n, plates):\n \"\"\"\n Returns the count of palindromic license plate numbers in the list.\n \n Args:\n n : int : numbe...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00094673", "row_id": 94673, "seed_ids": "[13955]" }
0.676073
Taco_94673
I
[ "is_palindrome", "count_palindromic_plates" ]
2
[ [ "count_palindromic_plates", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
be7fb2150dd9676aedba1a5598317a864242171f
4dac9030fa8a8abfcc6900e743a5ed9af7d45e7d
v1.0
instruct
Taco
Taco_94699_I
Consider a tree (an undirected graph with no cycles) consisting of `n` nodes. Each node of the tree has a value assigned to it. Initially, all nodes have a value of 0. There are `q` operations of two types: 1. Update: Add a given value `x` to all nodes in the subtree rooted at node `u`. 2. Query: Report the value of n...
from collections import defaultdict import sys sys.setrecursionlimit(200000) def dfs(node, parent, adj, start, end, timer, flat_tree): timer[0] += 1 start[node] = timer[0] flat_tree[timer[0]] = node for neighbor in adj[node]: if neighbor != parent: dfs(neighbor, node, adj, star...
def test_process_tree_example(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] operations = [ (1, 2, 10), (2, 4), (1, 1, 5), (2, 3) ] assert process_tree(n, edges, operations) == [10, 5] def test_process_tree_single_node(): n = 1 edges = [] operations = ...
[ { "docstring": null, "function_declaration": "def dfs(node, parent, adj, start, end, timer, flat_tree):", "function_name": "dfs", "parameter_list": "(node, parent, adj, start, end, timer, flat_tree)" }, { "docstring": null, "function_declaration": "def process_tree(n, edges, operations):...
[ 1, 1 ]
2
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\nclass Tree:\n def __init__(self, n):\n self.n = n\n self.graph = defaultdict(list)\n self.val...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00094699", "row_id": 94699, "seed_ids": "[21203]" }
0.697115
Taco_94699
I
[ "dfs", "process_tree" ]
2
[ [ "process_tree", "dfs" ] ]
1
[]
false
[]
false
pytest
false
[]
true
13d088e06f22bf35d0f48b997035b32a19805b65
1207c9944bb3935e815216fca7379321a8b0df1d
v1.0
instruct
Taco
Taco_94702_I
____ # Definition **_Smith number_** is a composite number whose sum of digits is equal to the sum of the digits of its prime factors (excluding 1) written in radix 10. ____ # Task **_Given_** a number, **_Find if it is a Smith number or not_**. ____ # Warm-up (Highly recommended) # [Exploring Number Properties]...
def is_prime(n): """ Helper function to check if a number is prime. """ if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def prime_factors(n): """ Helper function to get the prime factors of a number. """ ...
from solution import smith_number def test_smith_number(): assert smith_number(22) == "Smith !!" assert smith_number(58) == "Smith !!" assert smith_number(85) == "Smith !!" def test_not_smith_number(): assert smith_number(13) == "Not !!" assert smith_number(29) == "Not !!" assert smith_number(...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to get the prime factors of a number.", "function_declaration": "def prime_factors(n):", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n retur...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00094702", "row_id": 94702, "seed_ids": "[16780]" }
0.558688
Taco_94702
I
[ "is_prime", "prime_factors", "sum_of_digits", "smith_number" ]
4
[ [ "smith_number", "is_prime" ], [ "smith_number", "prime_factors" ], [ "smith_number", "sum_of_digits" ] ]
3
[]
false
[]
false
pytest
true
[]
true
88c843da85718c4c523777d4c5ab708d8f510679
86d24f6800df58f7fe0f9552f6e89d8a8b6df978
v1.0
instruct
Taco
Taco_94715_I
A software company is developing a robotic vacuum cleaner. The robot moves on a 2D grid, where each cell can be either cleanable or a wall. The robot starts in a specific cell and must clean all reachable cleanable cells while avoiding walls. The robot can move in four directions: up, down, left, and right. However, t...
from collections import deque MOVE_UP = 'U' MOVE_DOWN = 'D' MOVE_LEFT = 'L' MOVE_RIGHT = 'R' DIR_VECTORS = [(0, 1, MOVE_RIGHT), (1, 0, MOVE_DOWN), (0, -1, MOVE_LEFT), (-1, 0, MOVE_UP)] def bfs_cleaning_route(n, m, grid, start): queue = deque([start]) visited = set() visited.add(start) moves = [] p...
def test_4x4_grid(): n, m = 4, 4 grid = [ "S...", ".#..", "..#.", "...." ] output = cleaning_robot_moves(n, m, grid) assert set(output).issubset({'U', 'D', 'L', 'R'}) assert len(output) >= 12 def test_no_cleanable_cells(): n, m = 2, 2 grid = [ "S#...
[ { "docstring": null, "function_declaration": "def bfs_cleaning_route(n, m, grid, start):", "function_name": "bfs_cleaning_route", "parameter_list": "(n, m, grid, start)" }, { "docstring": null, "function_declaration": "def cleaning_robot_moves(n, m, grid):", "function_name": "cleanin...
[ 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\n\ndef robot_cleaner(n, m, grid):\n # Directions represent movement: up, right, down, left\n directions = {'U': (-1, 0), 'R': (...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00094715", "row_id": 94715, "seed_ids": "[10243]" }
0.689212
Taco_94715
I
[ "bfs_cleaning_route", "cleaning_robot_moves" ]
2
[ [ "cleaning_robot_moves", "bfs_cleaning_route" ] ]
1
[]
false
[]
false
pytest
false
[]
true
574a8679cf79f8375961a74dbafd0b1384465270
a5d80dbb77c3919e139d03fc9b98a042ecebd010
v1.0
instruct
Taco
Taco_94728_I
The kingdom of Asyncum has a new fascination with prime numbers. The citizens have a peculiar interest in creating interesting sequences from primes. Recently, they started generating sequences where each element is the sum of the first $k$ prime numbers. Given an integer $n$, Asyncum wants to verify if a given number ...
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 find_k_for_sum_x(n, x): primes = [] ...
from solution import find_k_for_sum_x def test_example_1(): assert find_k_for_sum_x(20, 17) == 4 def test_example_2(): assert find_k_for_sum_x(100, 41) == 6 def test_example_3(): assert find_k_for_sum_x(50, 30) == -1 def test_small_x(): assert find_k_for_sum_x(10, 2) == 1 def test_large_n_small_x()...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_k_for_sum_x(n, x):", "function_name": "find_k_for_sum_x", "parameter_list": "(n, x)" } ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00094728", "row_id": 94728, "seed_ids": "[1501]" }
0.614024
Taco_94728
I
[ "is_prime", "find_k_for_sum_x" ]
2
[ [ "find_k_for_sum_x", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8952ee25809171c9a46ecef759c66f7bc5e79303
6e861295ab2b16a991eccc0bfc1c1c5cd1ffd623
v1.0
instruct
Taco
Taco_94738_I
You are given an N x N matrix filled with integers. Write a function to rotate the matrix 90 degrees clockwise. ------ Input Format ------ - First line contains a single integer T, the number of test cases. Then the test cases follow. - Each test case contains N+1 lines of input. - The first line of each test case co...
def rotate_matrix_90_clockwise(matrix): """ Rotates the given N x N matrix 90 degrees clockwise. """ N = len(matrix) rotated_matrix = [[0] * N for _ in range(N)] for i in range(N): for j in range(N): rotated_matrix[j][N-1-i] = matrix[i][j] return rotated_matrix ...
from solution import rotate_matrix_90_clockwise def test_rotate_3x3_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] rotated = rotate_matrix_90_clockwise(matrix) expected = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] assert rotated == expected def ...
[ { "docstring": "Rotates the given N x N matrix 90 degrees clockwise.", "function_declaration": "def rotate_matrix_90_clockwise(matrix):", "function_name": "rotate_matrix_90_clockwise", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def solve_input(input_dat...
[ 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 rotate_matrix_90_clockwise(matrix):\n \"\"\"\n Rotates the given N x N matrix 90 degrees clockwise.\n \"\"\"\n N = len(matrix)\n rotated_matrix ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00094738", "row_id": 94738, "seed_ids": "[19183]" }
0.714733
Taco_94738
I
[ "rotate_matrix_90_clockwise", "solve_input", "format_output", "rotate_matrices" ]
4
[ [ "rotate_matrices", "format_output" ], [ "rotate_matrices", "solve_input" ], [ "solve_input", "rotate_matrix_90_clockwise" ] ]
3
[ "solve_input", "format_output" ]
false
[]
false
pytest
true
[]
true
dff6d9c56e73bb5746517b477294861f473d6eee
0313cbf5fa74f392b31ff4c6a405472f45acca62
v1.0
instruct
Taco
Taco_94836_I
The city of Borgonia is known for its perfectly straight streets and excellent city planning. Recently, the city has been divided into a grid of square blocks, each block measuring 1 unit by 1 unit. The blocks are numbered from 1 to N, arranged in an N x N grid, starting from the top-left block (1,1). Each block can ha...
def build_prefix_sum(heights, N): prefix_sum = [[0] * (N + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, N + 1): prefix_sum[i][j] = ( heights[i-1][j-1] + prefix_sum[i-1][j] + prefix_sum[i][j-1] - pre...
from solution import build_prefix_sum, get_building_view_score, compute_building_view_scores def test_single_element_grid(): N = 1 Q = 1 heights = [[5]] queries = [(1, 1, 1, 1)] results = compute_building_view_scores(N, Q, heights, queries) assert results == [5] def test_3x3_grid(): N = 3 ...
[ { "docstring": null, "function_declaration": "def build_prefix_sum(heights, N):", "function_name": "build_prefix_sum", "parameter_list": "(heights, N)" }, { "docstring": null, "function_declaration": "def get_building_view_score(prefix_sum, r1, c1, r2, c2):", "function_name": "get_bu...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compute_building_view_scores(N, Q, heights, queries):\n # Precompute the prefix sums\n prefix_sums = [[0] * (N + 1) for _ in range(N + 1)]\n for i in ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00094836", "row_id": 94836, "seed_ids": "[16865]" }
0.731421
Taco_94836
I
[ "build_prefix_sum", "get_building_view_score", "compute_building_view_scores" ]
3
[ [ "compute_building_view_scores", "build_prefix_sum" ], [ "compute_building_view_scores", "get_building_view_score" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5a23224c03ca724d953c4f2a3c6a2199c0353ac1
901879894d5d2c0356c0709267b2c54769999778
v1.0
instruct
Taco
Taco_94857_I
This is a problem about safe-cracking. Limak is trying to open a safe that requires a 4-digit combination to unlock. You have to help him find the correct combination. A 4-digit combination means an integer from the interval [1000, 9999]. You can ask up to 15 queries about the digits of the combination. In each query...
import itertools # The main function which tries to guess the combination def safe_cracking(): possible_combinations = [str(x).zfill(4) for x in range(1000, 10000)] queries = 15 for _ in range(queries): guess = possible_combinations.pop(0) print(guess) a, b = map(int, input().split(...
from solution import is_valid_guess def test_is_valid_guess(): assert is_valid_guess('1234', '1243', 2, 2) == True assert is_valid_guess('1234', '5678', 0, 0) == True assert is_valid_guess('1234', '4321', 0, 4) == True assert is_valid_guess('1234', '1234', 4, 0) == True assert is_valid_guess('1234'...
[ { "docstring": null, "function_declaration": "def safe_cracking():", "function_name": "safe_cracking", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def is_valid_guess(guess, combination, a, b):", "function_name": "is_valid_guess", "parameter_list": "(gu...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_combination():\n import itertools\n from sys import stdin, stdout\n\n possible_combinations = [\"{:04d}\".format(x) for x in range(1000, 10000)]\...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00094857", "row_id": 94857, "seed_ids": "[14599]" }
0.529684
Taco_94857
I
[ "safe_cracking", "is_valid_guess" ]
2
[ [ "safe_cracking", "is_valid_guess" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4f4ddf3167cb7dfcf68adf5af5fa57059cf7a882
21db6fff2374a14ae7efbb30c12471c7ca2ac7dd
v1.0
instruct
Taco
Taco_94911_I
You are given an array of $N$ integers. The beauty of an array is defined as the sum of all the distinct prime numbers that appear in the array. Your task is to modify the array such that the total beauty is maximized. You can change any element of the array to any other integer value with the condition that the new va...
def get_primes_up_to_100(): """ Function to generate a list of prime numbers up to 100 """ sieve = [True] * 101 sieve[0] = sieve[1] = False for start in range(2, int(101**0.5) + 1): if sieve[start]: for multiple in range(start*start, 101, start): sieve[multipl...
import pytest from solution import maximize_beauty def test_get_primes_up_to_100(): from solution import get_primes_up_to_100 assert get_primes_up_to_100() == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] def test_maximize_beauty_sample_input(): T = 2 ...
[ { "docstring": "Function to generate a list of prime numbers up to 100", "function_declaration": "def get_primes_up_to_100():", "function_name": "get_primes_up_to_100", "parameter_list": "()" }, { "docstring": "Function to maximize the total beauty of the 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 is_prime(num):\n \"\"\" Helper function to check if a number is prime. \"\"\"\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00094911", "row_id": 94911, "seed_ids": "[11536]" }
0.649818
Taco_94911
I
[ "get_primes_up_to_100", "maximize_beauty" ]
2
[ [ "maximize_beauty", "get_primes_up_to_100" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a6c6402d5130ce44b6e2e43cbc4b2ca2772606ee
a73ab73bf02e25662902a64c212357c219d454c4
v1.0
instruct
Taco
Taco_95145_I
A company named Robotic Delivery Services (RDS) specializes in delivering parcels using autonomous robots. Each robot moves on a grid of city streets, represented by a 2D matrix where the value at each cell indicates whether that cell is passable (1 for passable, 0 for impassable). Each robot can move up, down, left, o...
from collections import deque def shortest_path(grid, start, end): m, n = len(grid), len(grid[0]) sx, sy = start dx, dy = end directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] queue = deque([(sx, sy, 0)]) visited = set() visited.add((sx, sy)) while queue: x, y, distance = queue...
from solution import shortest_path def test_shortest_path_case_1(): grid = [ [1, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 0, 0, 1, 1], [1, 1, 1, 0, 1], [1, 1, 1, 1, 1] ] start = (0, 0) end = (4, 4) assert shortest_path(grid, start, end) == 8 def test_shortest_path_...
[ { "docstring": null, "function_declaration": "def shortest_path(grid, start, end):", "function_name": "shortest_path", "parameter_list": "(grid, start, end)" }, { "docstring": null, "function_declaration": "def solve_rds_cases():", "function_name": "solve_rds_cases", "parameter_l...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(grid, start, goal):\n \"\"\"\n Finds the shortest path from start to goal in the given grid.\n :param g...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00095145", "row_id": 95145, "seed_ids": "[10719]" }
0.7314
Taco_95145
I
[ "shortest_path", "solve_rds_cases" ]
2
[ [ "solve_rds_cases", "shortest_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b6659b751a1420ef9fed35a59d78719571e73209
d9f267f4273b81a8eacea949ec5c94da1701cd6d
v1.0
instruct
Taco
Taco_95154_I
You are working on a mobile phone application which allows users to set reminders. One of the key functions of the app is to determine the next available reminder time slot for a given user. Each user has a predefined schedule where they can set reminders, and this schedule repeats weekly. Given the current time and t...
from datetime import datetime, timedelta def parse_time_string(time_str): days_of_week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] day, time = time_str.split() day_index = days_of_week.index(day) hour, minute = map(int, time.split(':')) return day_index, hour, m...
from solution import next_reminder def test_simple_case(): assert next_reminder("Thursday 16:35", ["Monday 14:00", "Wednesday 09:00", "Thursday 18:00", "Saturday 12:00", "Sunday 16:45"]) == "Thursday 18:00" def test_next_week_case(): assert next_reminder("Friday 20:00", ["Tuesday 08:00", "Friday 19:00", "Mond...
[ { "docstring": null, "function_declaration": "def parse_time_string(time_str):", "function_name": "parse_time_string", "parameter_list": "(time_str)" }, { "docstring": null, "function_declaration": "def next_reminder(current_time_str, slots):", "function_name": "next_reminder", "...
[ 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 datetime import datetime, timedelta\n\ndef get_next_reminder_time(current_time, N, schedule):\n # Days mapping to enable comparison\n days_to_num = {\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00095154", "row_id": 95154, "seed_ids": "[7141]" }
0.66203
Taco_95154
I
[ "parse_time_string", "next_reminder" ]
2
[ [ "next_reminder", "parse_time_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6348c6d5d7e93aadd2e6d42c61fc8085ca1c6565
fad9282f0c949e3d9e859d5cb096f6c00a372a4c
v1.0
instruct
Taco
Taco_95180_I
Create a function that accepts a list of integers and returns a new list containing only the prime numbers from the original list. The function takes a list of integers (input_list) as a parameter and should filter out the prime numbers. For example, given the list [2, 3, 4, 5, 10, 13, 15], the result should be [2, 3...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(input_list): """ Returns a new list containing only the pr...
from solution import filter_primes def test_filter_primes_all_primes(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_no_primes(): assert filter_primes([4, 6, 8, 9, 10]) == [] def test_filter_primes_mixed_numbers(): assert filter_primes([2, 3, 4, 5, 10, 13, 15]) == [2,...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the prime numbers from the original list.", "function_declaration": "def filter_primes(input_list):", "function_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n*...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00095180", "row_id": 95180, "seed_ids": "[6040]" }
0.637963
Taco_95180
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d3aa2acf3b9c7ab715bb6f3f2c18566191fe2b0b
3ebe1576220a0e028b01ff3038121521378c1986
v1.0
instruct
Taco
Taco_95232_I
You are given a list of integers. You can perform the following operations on the list: 1. Select any contiguous subarray. 2. Flip all the bits of each element in the subarray (i.e., change all 1s to 0s and all 0s to 1s). For example, consider the list [5, 7, 12], where 5 in binary is '101', 7 is '111', and 12 is '11...
def count_set_bits(x): """ Count the number of set bits (1s) in the binary representation of an integer. """ return bin(x).count('1') def min_operations_to_zero(arr): """ Returns the minimum number of operations required to reduce all elements in the list to 0. """ operations = 0 fo...
def test_count_set_bits(): assert count_set_bits(0) == 0 assert count_set_bits(1) == 1 assert count_set_bits(7) == 3 assert count_set_bits(12) == 2 def test_min_operations_to_zero_example_cases(): assert min_operations_to_zero([5, 7, 12]) == 7 # 5(2) + 7(3) + 12(2) = 7 assert min_operations_to_...
[ { "docstring": "Count the number of set bits (1s) in the binary representation of an integer.", "function_declaration": "def count_set_bits(x):", "function_name": "count_set_bits", "parameter_list": "(x)" }, { "docstring": "Returns the minimum number of operations required to reduce all elem...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_set_bits(x):\n \"\"\"\n Count the number of set bits (1s) in the binary representation of an integer.\n \"\"\"\n return bin(x).count('1')\n\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00095232", "row_id": 95232, "seed_ids": "[13814]" }
0.804348
Taco_95232
I
[ "count_set_bits", "min_operations_to_zero", "solve" ]
3
[ [ "min_operations_to_zero", "count_set_bits" ], [ "solve", "min_operations_to_zero" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f8bfa5c109c2cd0da7b1c5182d6effb09b63d345
e4f4a728ce2d07311ef845e4564e4572963f0c4d
v1.0
instruct
Taco
Taco_95338_I
Masha is playing a game where she has to move from the top-left corner to the bottom-right corner of a grid with `n` rows and `m` columns. She can only move right or down at each step. Additionally, there are certain cells in the grid designated as traps. If Masha steps on a trap, the game ends immediately. Her goal i...
def count_paths(n, m, traps): MOD = 1000000007 # Initialize the grid with False meaning no trap grid = [[False] * m for _ in range(n)] # Place the traps on the grid for x, y in traps: grid[x - 1][y - 1] = True # Initialize the dp array dp = [[0] * m for _ in range(n)] ...
def test_example_1(): input_string = "3 3\n1\n2 2" expected_output = 2 assert count_paths_from_input_string(input_string) == expected_output def test_example_2(): input_string = "3 3\n0" expected_output = 6 assert count_paths_from_input_string(input_string) == expected_output def test_no_traps...
[ { "docstring": null, "function_declaration": "def count_paths(n, m, traps):", "function_name": "count_paths", "parameter_list": "(n, m, traps)" }, { "docstring": null, "function_declaration": "def count_paths_from_input_string(input_string):", "function_name": "count_paths_from_input...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 1000000007\n\ndef count_paths(n, m, traps):\n # Create the grid\n grid = [[1] * m for _ in range(n)]\n \n # Mark the traps on the grid\n for x...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00095338", "row_id": 95338, "seed_ids": "[115]" }
0.770151
Taco_95338
I
[ "count_paths", "count_paths_from_input_string" ]
2
[ [ "count_paths_from_input_string", "count_paths" ] ]
1
[]
false
[]
false
pytest
false
[]
true
febc9080ce89604c65bcb2c69c2d8a31a3f8496e
0aab151bd29e4368fcfa5f63a35bcdb810d8120c
v1.0
instruct
Taco
Taco_95430_I
You are given a matrix of characters of size N x M. You need to determine if there's a path through the matrix that spells out the word "HELLO". You can start from any cell and you are allowed to move either horizontally, vertically, or diagonally in any of the 8 possible directions. The same cell cannot be used more t...
def is_path_for_hello(matrix, N, M): def dfs(x, y, idx): if idx == len(word): return True # Mark the current cell as visited temp = matrix[x][y] matrix[x][y] = None # Define the 8 possible directions directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1...
import pytest from solution import find_hello_path def test_path_exists(): N, M = 3, 4 grid = [ "HAPE", "ELLO", "KXYZ" ] assert find_hello_path(N, M, grid) == "YES" def test_no_path_exists(): N, M = 3, 3 grid = [ "HAP", "ELX", "XYZ" ] ...
[ { "docstring": null, "function_declaration": "def is_path_for_hello(matrix, N, M):", "function_name": "is_path_for_hello", "parameter_list": "(matrix, N, M)" }, { "docstring": null, "function_declaration": "def find_hello_path(N, M, grid):", "function_name": "find_hello_path", "p...
[ 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_valid(x, y, N, M):\n return 0 <= x < N and 0 <= y < M\n\ndef search(matrix, word, x, y, index, visited):\n if index == len(word):\n return True...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00095430", "row_id": 95430, "seed_ids": "[6338]" }
0.685426
Taco_95430
I
[ "is_path_for_hello", "find_hello_path" ]
2
[ [ "find_hello_path", "is_path_for_hello" ] ]
1
[]
false
[]
false
pytest
true
[]
true
45b274a4c65ea1005159383f477aae026f609311
4b51c486694bb4a7fb2cdd0e0b381ab54af3680d
v1.0
instruct
Taco
Taco_95431_I
A famous mathematician once discovered a fascinating property related to prime numbers and palindromes. He defined a special type of number called a "Prime Palindrome Number" (PPN). A PPN is a number that satisfies both of the following conditions: 1. The number is a prime number. 2. The number is a palindrome. Your t...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import find_prime_palindromes def test_sample_inputs(): inputs = [31, 45, 90, 0] expected_outputs = [101, 101, 101] assert find_prime_palindromes(inputs) == expected_outputs def test_single_inputs(): inputs = [4, 31, 45, 90] expected_outputs = [5, 101, 101, 101] assert find_prime...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def 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_0
{ "original_instruction": "", "prompt_id": "00095431", "row_id": 95431, "seed_ids": "[8822]" }
0.783534
Taco_95431
I
[ "is_prime", "is_palindrome", "find_smallest_ppn_greater_equal", "find_prime_palindromes" ]
4
[ [ "find_prime_palindromes", "find_smallest_ppn_greater_equal" ], [ "find_smallest_ppn_greater_equal", "is_palindrome" ], [ "find_smallest_ppn_greater_equal", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
04158b346e64979e40b6c4279822d98033ec8ac0
db7bd28c6160293f8634a5f990547fa50f9b39a5
v1.0
instruct
Taco
Taco_95497_I
Write a program that reads a list of strings and determines if each string in the list is a valid palindrome when ignoring non-alphanumeric characters and case. The program should return a list of boolean values indicating the validity of each string. Constraints * $1 \leq n \leq 100$ * $0 \leq $ the length of each s...
import re def is_valid_palindrome(s): """ Returns True if the string s is a valid palindrome when ignoring non-alphanumeric characters and case. """ # Use regex to filter out non-alphanumeric characters and convert to lowercase filtered_s = re.sub(r'[^A-Za-z0-9]', '', s).lower() # Check if the ...
from solution import validate_palindromes def test_validate_palindromes_example1(): assert validate_palindromes(3, ["A man, a plan, a canal, Panama!", "race a car", "No lemon, no melon"]) == [True, False, True] def test_validate_palindromes_example2(): assert validate_palindromes(2, ["Madam In Eden, I'm Adam"...
[ { "docstring": "Returns True if the string s is a valid palindrome when ignoring non-alphanumeric characters and case.", "function_declaration": "def is_valid_palindrome(s):", "function_name": "is_valid_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns a list of boolean values ...
[ 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 re\n\ndef is_palindrome(s):\n \"\"\"\n Checks if the given string is a palindrome, considering only\n alphanumeric characters and ignoring case.\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00095497", "row_id": 95497, "seed_ids": "[15308]" }
0.789687
Taco_95497
I
[ "is_valid_palindrome", "validate_palindromes" ]
2
[ [ "validate_palindromes", "is_valid_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
97d43a9a85ebaad9d7f0354487af22a2ca7ea24b
ed5f7d361d08cd8b358d6c9160d8ec541700341e
v1.0
instruct
Taco
Taco_95543_I
You are responsible for designing an efficient rail network for a newly developed city. The city consists of several distinct districts connected by a series of rail lines. Each district is represented as a node, and each direct rail line between two districts is represented as an edge with an associated weight signify...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: p...
def test_kruskal_mst(): districts = 4 rail_lines = [ (1, 2, 10), (2, 3, 15), (3, 4, 4), (4, 1, 6), (1, 3, 5) ] assert kruskal_mst(districts, rail_lines) == 19 def test_example_2(): districts = 3 rail_lines = [ (1, 2, 5), (2, 3, 4), ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_mst_total_cost(districts, rail_lines, edges):\n \"\"\"\n Uses Kruskal's algorithm to find the minimum spanning tree total travel time\n for the r...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00095543", "row_id": 95543, "seed_ids": "[9499]" }
0.717594
Taco_95543
I
[ "find", "union", "kruskal_mst", "calculate_minimum_spanning_tree" ]
4
[ [ "calculate_minimum_spanning_tree", "kruskal_mst" ], [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
e2e03eecce63a855c9e3c8e0069ffe39c9ae3e2f
8cf935579a3d00b78ebd328464c4c192d59b7fb0
v1.0
instruct
Taco
Taco_95555_I
A software company wants to optimize the loading of files on their cloud platform. They have multiple servers, each with a different processing power. Each file to be uploaded requires a certain amount of processing power. The goal is to distribute the files across the servers in a manner that minimizes the maximum pro...
def canDistributeLoad(load, servers, files): count = 0 current_load = 0 for file in files: if current_load + file <= load: current_load += file else: count += 1 current_load = file if current_load > load: return False ...
from solution import minimizedMaxProcessingLoad def test_small_input(): assert minimizedMaxProcessingLoad(3, [10, 20, 30, 40, 50]) == 60 def test_one_server(): assert minimizedMaxProcessingLoad(1, [10, 20, 30, 40, 50]) == 150 def test_equal_load(): assert minimizedMaxProcessingLoad(3, [10, 10, 10, 10, 10...
[ { "docstring": null, "function_declaration": "def canDistributeLoad(load, servers, files):", "function_name": "canDistributeLoad", "parameter_list": "(load, servers, files)" }, { "docstring": null, "function_declaration": "def minimizedMaxProcessingLoad(servers, files):", "function_n...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def canDistributeLoad(load, servers, files):\n count = 0\n current_load = 0\n \n for file in files:\n if current_load + file <= load:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00095555", "row_id": 95555, "seed_ids": "[19923]" }
0.639916
Taco_95555
I
[ "canDistributeLoad", "minimizedMaxProcessingLoad", "main" ]
3
[ [ "minimizedMaxProcessingLoad", "canDistributeLoad" ] ]
1
[]
false
[]
false
pytest
true
[]
true
693f137167a86544036dbf993d70c43010e5f3c8
dad3bb193e5cd260284d13ee2de92cb88b5b97a6
v1.0
instruct
Taco
Taco_95621_I
A: Binary Tree Balance Brian is learning about binary trees and is particularly interested in balanced binary trees. A binary tree is considered balanced if, for every node in the tree, the height of its left and right subtrees differ by at most one. Brian wants to write a program that determines whether a given binar...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def is_balanced(root): def check(node): if node is None: return 0, True left_height, left_balanced = check(node.left) right_height, right_balanced = check(node.righ...
from solution import is_tree_balanced_from_level_order def test_balanced_tree(): assert is_tree_balanced_from_level_order("1 2 3 4 5 # #") == True def test_unbalanced_tree(): assert is_tree_balanced_from_level_order("1 2 3 4 # # 5 6") == False def test_single_node_tree(): assert is_tree_balanced_from_lev...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef insert_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00095621", "row_id": 95621, "seed_ids": "[21356]" }
0.801277
Taco_95621
I
[ "is_balanced", "build_tree", "is_tree_balanced_from_level_order" ]
3
[ [ "is_tree_balanced_from_level_order", "build_tree" ], [ "is_tree_balanced_from_level_order", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
9a53c97fe121eda99f44b8219f4517adb3c3cbd4
bd9eabdaf1420e11c01adcdc884af2316e001920
v1.0
instruct
Taco
Taco_95639_I
------Read problems statements in Hindi, Mandarin chinese , Russian and Vietnamese as well. ------ Tara loves playing with numbers, especially arranging them in interesting patterns. One day, she stumbled upon an interesting pattern using prime numbers. She challenges you to write a program that finds the smallest pri...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def next_prime(n): if n <= 1: return 2 prime = n + 1 while not i...
from solution import solve def test_case_1(): assert solve([(10, 123)]) == [17] def test_case_2(): assert solve([(17, 456)]) == [34] def test_case_3(): assert solve([(1, 1000000000)]) == [2 + 1] # Prime after 1 is 2, Sum of digits of 1000000000 is 1 def test_case_4(): assert solve([(10, 0)]) == [11...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def next_prime(n):", "function_name": "next_prime", "parameter_list": "(n)" }, { "docstring": null, "...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if the given number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ret...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00095639", "row_id": 95639, "seed_ids": "[9920]" }
0.626292
Taco_95639
I
[ "is_prime", "next_prime", "sum_of_digits", "solve" ]
4
[ [ "next_prime", "is_prime" ], [ "solve", "next_prime" ], [ "solve", "sum_of_digits" ] ]
3
[]
false
[]
false
pytest
true
[]
true
ec4555b441ee15df6b09222335ac87a5ee582735
da46344f5221ff022997417141dff02a3d6f3251
v1.0
instruct
Taco
Taco_95728_I
Panda, fond of solving puzzles, comes across a large grid of numbers while traveling. The grid is a square matrix of size NxN, filled with non-negative integers. Panda is curious about the paths through this matrix from the top-left corner (1,1) to the bottom-right corner (N,N). However, there’s a twist: Panda is only ...
def max_path_sum_in_grid(test_cases): results = [] for grid in test_cases: n = len(grid) # Create a DP table to store the maximum sums dp = [[0] * n for _ in range(n)] # Initialize the top-left corner of the DP table dp[0][0] = grid[0][0] # ...
def test_max_path_sum_in_grid(): test_cases = [ [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ], [ [1, 2], [1, 1] ] ] assert max_path_sum_in_grid(test_cases) == [29, 4] def test_parse_input_string(): input_string = "2\n3\n1...
[ { "docstring": null, "function_declaration": "def max_path_sum_in_grid(test_cases):", "function_name": "max_path_sum_in_grid", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input_string(input_string):", "function_name": "parse_input_strin...
[ 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 max_path_sum_in_grid(test_cases):\n results = []\n \n for grid in test_cases:\n n = len(grid)\n # Create a DP table to store the maximum...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00095728", "row_id": 95728, "seed_ids": "[12302]" }
0.632799
Taco_95728
I
[ "max_path_sum_in_grid", "parse_input_string", "max_path_sum" ]
3
[ [ "max_path_sum", "max_path_sum_in_grid" ], [ "max_path_sum", "parse_input_string" ] ]
2
[]
false
[]
false
pytest
false
[]
true
7de9fe417af25b71be8433bab07f26a6272b2a58
7e53d143b8e9de64b1710dc0858553bd8fbef8a5
v1.0
instruct
Taco
Taco_95753_I
You are given a sequence `A` of `N` positive integers. You are allowed to remove exactly one integer from the sequence. After removing one integer, you want to know the maximum possible Greatest Common Divisor (GCD) of the remaining integers. Write a function that takes the sequence `A` and returns the maximum possibl...
import math from typing import List def compute_gcd(a: int, b: int) -> int: return math.gcd(a, b) def max_gcd_after_removal(N: int, A: List[int]) -> int: if N == 2: return max(A) prefix_gcd = [0] * (N + 1) suffix_gcd = [0] * (N + 1) for i in range(1, N + 1): prefix_gcd[i]...
import pytest from solution import compute_gcd, max_gcd_after_removal def test_compute_gcd(): assert compute_gcd(12, 15) == 3 assert compute_gcd(18, 24) == 6 assert compute_gcd(0, 5) == 5 assert compute_gcd(0, 0) == 0 def test_max_gcd_example_case(): assert max_gcd_after_removal(5, [12, 15, 18, 24...
[ { "docstring": null, "function_declaration": "def compute_gcd(a, b):", "function_name": "compute_gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def max_gcd_after_removal(N, A):", "function_name": "max_gcd_after_removal", "parameter_list": "(N, A...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef max_gcd_after_removing_one(N, A):\n \"\"\"\n Returns the maximum GCD after removing exactly one integer from...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00095753", "row_id": 95753, "seed_ids": "[17769]" }
0.658813
Taco_95753
I
[ "compute_gcd", "max_gcd_after_removal" ]
2
[ [ "max_gcd_after_removal", "compute_gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
84e13c7db2cc94d6ea0574542d964c056adb3dc8
1d862b616dc591f619a0694a565d104c72846e40
v1.0
instruct
Taco
Taco_95813_I
Roman loves prime numbers. He believes that using primes can make any number special. One day, he decided to play a game with primes and Fibonacci numbers. He wants to find the smallest prime number that can be added to a given Fibonacci number to transform it into another prime number. Your task is to help Roman with...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2 or 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 ...
from solution import smallest_prime_for_fibonacci def test_smallest_prime_for_fibonacci_example_1(): assert smallest_prime_for_fibonacci(8) == 3 def test_smallest_prime_for_fibonacci_example_2(): assert smallest_prime_for_fibonacci(21) == 2 def test_smallest_prime_for_fibonacci_edge_case_1(): assert smal...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a Fibonacci number F, find the smallest prime number that\ncan be added to F to make it a prime number.",...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n %...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00095813", "row_id": 95813, "seed_ids": "[3530]" }
0.644213
Taco_95813
I
[ "is_prime", "smallest_prime_for_fibonacci" ]
2
[ [ "smallest_prime_for_fibonacci", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
028a643e100edabc52e615007d7f1c82298fd996
9fde602d7d339a327437b750acc5fb53b1e0ee33
v1.0
instruct
Taco
Taco_95874_I
In a magical forest, there exists a special type of tree called the Roots Tree. The Roots Tree has a unique growth pattern where each node in the tree represents a magical root, and each edge between nodes represents a magical connection. To enhance the forest's magic, a wizard wants to increase the magical power of ...
from collections import defaultdict, deque def build_tree(edges, N): tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) return tree def is_balanced(tree, node, parent): heights = [] for child in tree[node]: if child != parent: # avoid going back...
def test_balanced_roots_tree_balanced(): N = 7 edges = [ (1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7) ] balanced_roots_tree(N, edges) # expects "YES" and prints the tree def test_balanced_roots_tree_unbalanced(): N = 4 edges = [ (1, 2)...
[ { "docstring": null, "function_declaration": "def build_tree(edges, N):", "function_name": "build_tree", "parameter_list": "(edges, N)" }, { "docstring": null, "function_declaration": "def is_balanced(tree, node, parent):", "function_name": "is_balanced", "parameter_list": "(tree...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def check_balanced_tree(N, edges):\n from collections import defaultdict, deque\n if N == 1:\n return \"YES\", []\n\n # Cr...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00095874", "row_id": 95874, "seed_ids": "[19672]" }
0.564408
Taco_95874
I
[ "build_tree", "is_balanced", "reorder_tree", "balanced_roots_tree" ]
4
[ [ "balanced_roots_tree", "build_tree" ], [ "balanced_roots_tree", "is_balanced" ], [ "balanced_roots_tree", "reorder_tree" ] ]
3
[]
false
[]
false
pytest
false
[]
true
79c52b59280f941186608426ce444bf611114d2d
48b8f017e3a9e393cf29bd2b7940d6da5c070c94
v1.0
instruct
Taco
Taco_95886_I
A palindrome is a string that reads the same forward and backward. Given a string `s`, you can remove at most one character from it. Your task is to determine whether you can create a palindrome by removing exactly one character from the string `s`. -----Input----- The input will be a single string `s` containing only...
def valid_palindrome_with_one_removal(s): def is_palindrome_range(i, j): return all(s[k] == s[j - k + i] for k in range(i, j // 2 + 1)) left, right = 0, len(s) - 1 while left < right: if s[left] != s[right]: # Check by removing either left character or right character ...
from solution import can_form_palindrome def test_can_form_palindrome(): assert can_form_palindrome("abca") == "YES" assert can_form_palindrome("abc") == "NO" assert can_form_palindrome("a") == "YES" assert can_form_palindrome("aa") == "YES" assert can_form_palindrome("racecar") == "YES" assert...
[ { "docstring": null, "function_declaration": "def valid_palindrome_with_one_removal(s):", "function_name": "valid_palindrome_with_one_removal", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome...
[ 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 valid_palindrome_with_one_removal(s):\n def is_palindrome_range(i, j):\n return all(s[k] == s[j - k + i] for k in range(i, j // 2 + 1))\n\n left, ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00095886", "row_id": 95886, "seed_ids": "[16208]" }
0.777145
Taco_95886
I
[ "valid_palindrome_with_one_removal", "can_form_palindrome" ]
2
[ [ "can_form_palindrome", "valid_palindrome_with_one_removal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
72959e43f25b69d9d405c45a88a42100daa30e35
fba1ffc2cc4906a22b70cbb22149b4668c275d05
v1.0
instruct
Taco
Taco_95894_I
Polycarp has an array of $n$ integers $a_1, a_2, \dots, a_n$. Polycarp wants to rearrange the array such that the absolute difference between any two adjacent elements is minimized. Your task is to help Polycarp find such an arrangement. Additionally, if there are multiple valid arrangements, return the one that is le...
def rearrange_array(t, test_cases): results = [] for i in range(t): n = test_cases[i][0] a = sorted(test_cases[i][1]) results.append(a) return results def format_results(results): return '\n'.join(' '.join(map(str, result)) for result in results) # Function to execute solution ...
def test_minimize_max_abs_difference(): # Test case 1 t, test_cases = 2, [(4, [10, 1, 3, 7]), (3, [4, 2, 5])] expected = "1 3 7 10\n2 4 5" assert minimize_max_abs_difference(t, test_cases) == expected # Test case 2 t, test_cases = 1, [(5, [5, 4, 3, 2, 1])] expected = "1 2 3 4 5" assert ...
[ { "docstring": null, "function_declaration": "def rearrange_array(t, test_cases):", "function_name": "rearrange_array", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def format_results(results):", "function_name": "format_results", "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 rearrange_min_abs_diff(t, cases):\n results = []\n for i in range(t):\n n = cases[i][0]\n arr = sorted(cases[i][1])\n results.append...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00095894", "row_id": 95894, "seed_ids": "[15460]" }
0.701962
Taco_95894
I
[ "rearrange_array", "format_results", "minimize_max_abs_difference" ]
3
[ [ "minimize_max_abs_difference", "format_results" ], [ "minimize_max_abs_difference", "rearrange_array" ] ]
2
[ "format_results" ]
false
[]
false
pytest
false
[]
true
067051c7eb0f3abb722c4eaf5f29de71f2d2fd5d
bf3de7eb32915bcddc1ec9319f32a102ff1cf6d1
v1.0
instruct
Taco
Taco_96026_I
You have been given several software projects to manage, each containing a list of tasks. Each task is represented by its dependencies, i.e., the tasks that need to be completed before it. The dependencies can be represented as a list of pairs (a, b), where 'a' depends on 'b' and must be done after 'b'. Write a progra...
from collections import defaultdict, deque def is_possible_to_complete_all_tasks(n, dependencies): """ Returns whether it is possible to complete all tasks without cyclic dependencies. """ graph = defaultdict(list) in_degree = [0] * (n + 1) for a, b in dependencies: graph[b].append...
from solution import check_projects def test_check_projects(): assert check_projects(2, [ (4, 2, [(1, 2), (3, 1)]), (3, 3, [(1, 2), (2, 3), (3, 1)]) ]) == ["Possible", "Impossible"] def test_no_dependencies(): assert check_projects(1, [(4, 0, [])]) == ["Possible"] def test_single_task(): ...
[ { "docstring": "Returns whether it is possible to complete all tasks without cyclic dependencies.", "function_declaration": "def is_possible_to_complete_all_tasks(n, dependencies):", "function_name": "is_possible_to_complete_all_tasks", "parameter_list": "(n, dependencies)" }, { "docstring":...
[ 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 can_complete_tasks(num_projects, projects):\n results = []\n\n for project in projects:\n n, m, depe...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096026", "row_id": 96026, "seed_ids": "[12637]" }
0.551556
Taco_96026
I
[ "is_possible_to_complete_all_tasks", "check_projects" ]
2
[ [ "check_projects", "is_possible_to_complete_all_tasks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5f253966d649b7265dff1f4374c5b53acdd75201
d7954a0302b8e647d83998687104cca34f90ca9c
v1.0
instruct
Taco
Taco_96062_I
You are given an array of integers of length n, and you are required to perform a series of queries on this array. Each query can be one of two types: 1. "1 x y": Update the element at index x to y. 2. "2 x y": Find the sum of the elements from index x to index y (inclusive). Write a program to handle these queries e...
class NumArray: def __init__(self, nums): self.n = len(nums) self.nums = nums self.bit = [0] * (self.n + 1) for i in range(self.n): self.add(i + 1, nums[i]) def add(self, index, value): while index <= self.n: self.bit[index] += value ...
import pytest from solution import solution def test_example_case(): n = 5 q = 5 array = [1, 2, 3, 4, 5] queries = [ (2, 1, 3), (1, 3, 10), (2, 1, 3), (2, 2, 5), (1, 5, 6) ] expected_output = [6, 13, 21] assert solution(n, q, array, queries) == expec...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class SegmentTree:\n def __init__(self, data):\n self.n = len(data)\n self.tree = [0] * (2 * self.n)\n self.build(data)\n \n def ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096062", "row_id": 96062, "seed_ids": "[22724]" }
0.703479
Taco_96062
I
[ "handle_queries", "solution" ]
2
[ [ "solution", "handle_queries" ] ]
1
[ "handle_queries" ]
false
[ "NumArray" ]
true
pytest
true
[]
true
2c544c47a3c915fdec8d33ac74b8135e87f91d98
2dac590b8878724c0a14a061382b0cec82abd342
v1.0
instruct
Taco
Taco_96091_I
You are given a matrix of size N x N where each cell contains an integer weight. You are required to find the minimum weight path sum from the top-left cell to the bottom-right cell of the matrix. You can only move right or down from a cell. Input: - The first line contains an integer T, the number of test cases. - Fo...
def min_path_sum(matrix): """ Returns the minimum path sum from the top-left cell to the bottom-right cell of the matrix. You can only move right or down from a cell. """ n = len(matrix) dp = [[0]*n for _ in range(n)] dp[0][0] = matrix[0][0] for i in range(1, n): dp[i][...
def test_parse_input(): input_str = "2\n2\n1 2\n3 4\n3\n1 2 3\n4 5 6\n7 8 9" expected_output = [ [ [1, 2], [3, 4] ], [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] ] assert parse_input(input_str) == expected_output def tes...
[ { "docstring": "Returns the minimum path sum from the top-left cell to the bottom-right cell of the matrix.\nYou can only move right or down from a cell.", "function_declaration": "def min_path_sum(matrix):", "function_name": "min_path_sum", "parameter_list": "(matrix)" }, { "docstring": nul...
[ 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 min_path_sum(matrix):\n N = len(matrix)\n if N == 0:\n return 0\n \n # Create a DP table\n dp = [[0] * N for _ in range(N)]\n \n # ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00096091", "row_id": 96091, "seed_ids": "[21534]" }
0.702811
Taco_96091
I
[ "min_path_sum", "solve_min_path_sum", "parse_input", "min_path_sum_driver" ]
4
[ [ "min_path_sum_driver", "parse_input" ], [ "min_path_sum_driver", "solve_min_path_sum" ], [ "solve_min_path_sum", "min_path_sum" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
1ee4342ad847202ec3a6376e6e00a631099aaf56
1814eda5cab527863b26f7ccba03e1dac6285d95
v1.0
instruct
Taco
Taco_96138_I
You are given a grid with dimensions n x m. Each cell in the grid can either be empty (represented by '.') or blocked (represented by '#'). Your task is to find the shortest path from the top-left corner of the grid (0, 0) to the bottom-right corner of the grid (n-1, m-1). You can move up, down, left, or right, but you...
def shortest_path(grid, n, m): from collections import deque # Directions (right, left, down, up) directions = [(0, 1), (0, -1), (1, 0), (-1, 0)] queue = deque([(0, 0, 1)]) # (row, col, path_length) while queue: r, c, length = queue.popleft() if r == n - 1 and c == m - 1: ...
from solution import process def test_no_path(): input_data = "2 2\n.#\n#.\n0 0" expected_output = "No path" assert process(input_data) == expected_output def test_short_path(): input_data = "2 3\n..#\n#..\n0 0" expected_output = "4" assert process(input_data) == expected_output def test_mult...
[ { "docstring": null, "function_declaration": "def shortest_path(grid, n, m):", "function_name": "shortest_path", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(inp...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef bfs_shortest_path(grid, n, m):\n # Directions for moving in the grid (right, down, left, up)\n directions = [(0, 1), (1,...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00096138", "row_id": 96138, "seed_ids": "[15702]" }
0.720602
Taco_96138
I
[ "shortest_path", "parse_input", "process" ]
3
[ [ "process", "parse_input" ], [ "process", "shortest_path" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
5e44e5b585bf69d3bcf6170629338849a20737c8
33f4df1d1fd41bf7bd1e34f09fb9ba51a9c92215
v1.0
instruct
Taco
Taco_96148_I
In a far-off land, a magical forest is filled with a wide variety of enchanted trees. Each tree has its own unique level of magical energy, and these trees are linked to each other in a vast network of connections. The forest is maintained by a group of wise wizards who have established a system of pathways to ensure t...
def is_possible(n, m, connections): if m == 0: return "Possible" from collections import defaultdict degrees = defaultdict(int) for u, v in connections: degrees[u] += 1 degrees[v] += 1 for degree in degrees.values(): if degree % 2 != 0: return "I...
def test_possible_case(): input_data = [ (4, 4), (1, 2), (2, 3), (3, 4), (4, 1), (0, 0) ] output = solve_magic_forest(input_data) assert output == ["Possible"] def test_impossible_case(): input_data = [ (3, 2), (2, 3), (1, 2), ...
[ { "docstring": null, "function_declaration": "def is_possible(n, m, connections):", "function_name": "is_possible", "parameter_list": "(n, m, connections)" }, { "docstring": null, "function_declaration": "def solve_magic_forest(input_data):", "function_name": "solve_magic_forest", ...
[ 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_possible_to_distribute_energy(n, m, connections):\n from collections import deque\n \n def is_bipartite(graph, n):\n color = [-1] * n\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00096148", "row_id": 96148, "seed_ids": "[14369]" }
0.585114
Taco_96148
I
[ "is_possible", "solve_magic_forest" ]
2
[ [ "solve_magic_forest", "is_possible" ] ]
1
[]
false
[]
false
pytest
false
[]
true
da5ab5605c015b82455d4a12472f1d808fcf468b
8fc1c64e2f7e98b7322a9e3964bb3c03e183e20c
v1.0
instruct
Taco
Taco_96149_I
You are given a grid of size $N \times M$ with some cells blocked. You need to determine the minimum steps required for a robot to move from the top-left corner of the grid (1, 1) to the bottom-right corner (N, M). The robot can only move up, down, left, or right and cannot move through blocked cells. ------ Input --...
from collections import deque def min_steps(grid, n, m): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] start = (0, 0) end = (n-1, m-1) if grid[0][0] == '#' or grid[n-1][m-1] == '#': return -1 queue = deque([(start, 0)]) visited = set([start]) while queue: (current_x...
import pytest from solution import robot_min_steps def test_example_case(): input_str = "5 6\n....#.\n.#..#.\n.#...#\n#..#..\n......" assert robot_min_steps(input_str) == 9 def test_unreachable_case(): input_str = "3 3\n.#.\n###\n.#." assert robot_min_steps(input_str) == -1 def test_blocked_start(): ...
[ { "docstring": null, "function_declaration": "def min_steps(grid, n, m):", "function_name": "min_steps", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def robot_min_steps(grid_str):", "function_name": "robot_min_steps", "parameter_list": "(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": "from collections import deque\n\ndef min_steps(N, M, grid):\n \"\"\"\n Calculates the minimum number of steps required for a robot to move from (1, 1) to (N,...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00096149", "row_id": 96149, "seed_ids": "[17100]" }
0.755346
Taco_96149
I
[ "min_steps", "robot_min_steps" ]
2
[ [ "robot_min_steps", "min_steps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
783502720e4737d68fae8ea5c9bad5ddadf13e72
b9ebeca90183f7390687c93066b884df4a7594e9
v1.0
instruct
Taco
Taco_96159_I
Given an array of integers, you are to sort the array such that all prime numbers appear before all non-prime numbers while maintaining the relative order of the primes and the non-primes. A prime number is an integer greater than 1 that has no positive divisors other than 1 and itself. For the purpose of this proble...
def is_prime(n): """ Helper function to determine if n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, sort_primes_before_non_primes def test_is_prime(): assert is_prime(1) == False assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(15) == False assert is_prime(17) == True def test_sort_...
[ { "docstring": "Helper function to determine if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sort the array such that prime numbers appear before non-prime numbers\nwhile maintaining relative order ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00096159", "row_id": 96159, "seed_ids": "[22950]" }
0.649435
Taco_96159
I
[ "is_prime", "sort_primes_before_non_primes" ]
2
[ [ "sort_primes_before_non_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9002363d2913e28b5b069546e6211ea76a04058f
39d6dd61e79a9eff7d8e49bf6b39d1f657a50d2d
v1.0
instruct
Taco
Taco_96163_I
A prime number is a natural number greater than 1 that has no divisors other than 1 and itself. A palindrome is a number that reads the same backward as forward, such as 121 or 1331. You are given an integer N. Your task is to find the smallest prime palindrome number greater than or equal to N. If multiple solutions ...
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 is_palindrome(num): return str(num) == str(num)[::-1] def smallest_prime_palindrome(N): while True: if is_palindrome(N) and is_prime(N...
import pytest from solution import solve, is_prime, is_palindrome, smallest_prime_palindrome def test_is_prime(): assert is_prime(2) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_is_palindrome(): assert is_palindrome(121) == True assert i...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring...
[ 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_palindrome(num):\n \"\"\"\n Checks if a number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef is_prime(num):\n \"\"\"\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00096163", "row_id": 96163, "seed_ids": "[9706]" }
0.80264
Taco_96163
I
[ "is_prime", "is_palindrome", "smallest_prime_palindrome", "solve" ]
4
[ [ "smallest_prime_palindrome", "is_palindrome" ], [ "smallest_prime_palindrome", "is_prime" ], [ "solve", "smallest_prime_palindrome" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8f4be0c708347a679b78f5457f5ae67889070caa
d6ebb77a2cb780e151d5d61c247b5fc60f420efd
v1.0
instruct
Taco
Taco_96167_I
Write a function that takes a list of integers as input and returns the largest integer `k` such that all integers in the list are divisible by `k` and `k` is greater than 1. ------ Input ------ A single line containing space-separated integers. ------ Output ------ Print a single integer which is the largest integ...
import math from functools import reduce def gcd(a, b): """ Calculates the greatest common divisor of a and b. """ while b: a, b = b, a % b return a def gcd_of_list(numbers): """ Calculates the greatest common divisor (gcd) of a list of numbers. """ return reduce(gcd, numbe...
from solution import largest_k_divisible def test_all_multiples(): assert largest_k_divisible([4, 8, 16, 32]) == 4 def test_common_multiple(): assert largest_k_divisible([5, 10, 15, 20]) == 5 def test_no_common_divisor_greater_than_one(): assert largest_k_divisible([7, 11, 13, 17]) == -1 def test_all_pr...
[ { "docstring": "Calculates the greatest common divisor of a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Calculates the greatest common divisor (gcd) of a list of numbers.", "function_declaration": "def gcd_of_li...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef largest_divisor(arr):\n \"\"\"\n Returns the largest integer k such that all integers in the list are divisi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096167", "row_id": 96167, "seed_ids": "[2590]" }
0.711517
Taco_96167
I
[ "gcd", "gcd_of_list", "largest_k_divisible" ]
3
[ [ "gcd_of_list", "gcd" ], [ "largest_k_divisible", "gcd_of_list" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fc0e02c712784e68302abe57a6457a94b4b7470c
fa2d242d1f8498e413b4c360acaebcd44bcb171a
v1.0
instruct
Taco
Taco_96179_I
You are given a list of integers. For each integer in the list, determine if it is a prime number. Replace each prime number with the string "Prime" and replace non-prime numbers with the string "Not Prime". Print the resulting list. Input The first line of input contains an integer n, the number of integers in the li...
def is_prime(num): """ Returns True if num is a prime number, else False. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def prime_replacement(int_list): """ Replaces prime numbers in the list wit...
from solution import is_prime, prime_replacement 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(1) == False assert is_prime(0) == False assert is_prime(1000) == False def test_prime_replacem...
[ { "docstring": "Returns True if num is a prime number, else False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Replaces prime numbers in the list with 'Prime' and non-prime numbers with 'Not Prime'.", "function...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, else False.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, i...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00096179", "row_id": 96179, "seed_ids": "[3938]" }
0.660785
Taco_96179
I
[ "is_prime", "prime_replacement" ]
2
[ [ "prime_replacement", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d0403701ac54979617e5d68363a44907caef65d0
84b8fcb323180ec27c50475ce6568b9f78f95fab
v1.0
instruct
Taco
Taco_96268_I
As a software developer, you are tasked with writing a filter function to process a list of numbers and return only the prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your function should receive a list of integers and return a new list consistin...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def filter_primes(numb...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(0) == Fals...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Filter the list and return only prime numbers.", "function_declaration": "def filter_primes(numbers):", "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(num):\n \"\"\"\n Determine whether a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n re...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00096268", "row_id": 96268, "seed_ids": "[17947]" }
0.661361
Taco_96268
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e250321a9b82c898991c6dead5d093edbb9de33
2cc0b58de36eb0476db6697f3628888e675419ae
v1.0
instruct
Taco
Taco_96276_I
*Professor X has decided to test his students on their ability to manipulate arrays. He requires them to solve the following problem:* Given an array of N integers and an integer K, determine the length of the longest subarray in which the sum of its elements is less than or equal to K. ------ Input Format ------ - ...
def longest_subarray_length(arr, N, K): """ Returns the length of the longest subarray with sum less than or equal to K. """ max_len = 0 current_sum = 0 start = 0 for end in range(N): current_sum += arr[end] while current_sum > K: current_sum -= arr[...
import pytest from solution import longest_subarray_length, solve, process_input def test_longest_subarray_length(): assert longest_subarray_length([1, 2, 3, 4, 5], 5, 10) == 4 assert longest_subarray_length([3, 1, 2, 1, 1, 1, 1, 1], 8, 15) == 8 assert longest_subarray_length([], 0, 10) == 0 assert lon...
[ { "docstring": "Returns the length of the longest subarray with sum less than or equal to K.", "function_declaration": "def longest_subarray_length(arr, N, K):", "function_name": "longest_subarray_length", "parameter_list": "(arr, N, K)" }, { "docstring": null, "function_declaration": "d...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_subarray_with_sum_at_most_k(test_cases):\n results = []\n for n, k, arr in test_cases:\n current_sum = 0\n start = 0\n max_l...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00096276", "row_id": 96276, "seed_ids": "[7550]" }
0.715391
Taco_96276
I
[ "longest_subarray_length", "solve", "process_input" ]
3
[ [ "solve", "longest_subarray_length" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
c9be57e04aab720224ad2ed99b24524763e6e3ff
8901d38678bbe3ae5c0dc469c634be48a596fa6e
v1.0
instruct
Taco
Taco_96388_I
In a distant kingdom, there is a unique numerical system used for communicating emergencies. The system consists of N numbers, and they need to be processed by a special machine for sending alerts. The system has certain rules for combining these numbers optimally to form the largest possible number. Given a list of N...
from functools import cmp_to_key def compare(a, b): if a + b > b + a: return -1 elif a + b < b + a: return 1 else: return 0 def largest_number(numbers): numbers = list(map(str, numbers)) numbers.sort(key=cmp_to_key(compare)) largest_num = ''.join(numbers) return lar...
from solution import process_test_cases def test_sample_input(): T = 3 test_cases = [ (3, [10, 2, 9]), (4, [3, 30, 34, 5]), (2, [12, 121]) ] expected_output = [ '9210', '534330', '12121' ] assert process_test_cases(T, test_cases) == expected_outpu...
[ { "docstring": null, "function_declaration": "def compare(a, b):", "function_name": "compare", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def largest_number(numbers):", "function_name": "largest_number", "parameter_list": "(numbers)" }, { ...
[ 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 largest_number(numbers):\n \"\"\"\n Given a list of integers, this function forms the largest possible number \n by concatenating the integers togethe...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096388", "row_id": 96388, "seed_ids": "[5721]" }
0.713839
Taco_96388
I
[ "compare", "largest_number", "process_test_cases" ]
3
[ [ "largest_number", "compare" ], [ "process_test_cases", "largest_number" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
4175117447d498e03911814cf4356dbada811c9d
25734cf9a37777e383ad4d89231bf7babf35fad0
v1.0
instruct
Taco
Taco_96397_I
In a distant land, there is a kingdom called CoderLand. In CoderLand, there are n cities connected by m bidirectional roads. Each road has an associated cost. The cities are numbered from 1 to n, and they desperately need a reliable transportation system for their growing economy. The King has decided to build a speci...
def find(parent, i): if parent[i] != i: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent...
from solution import minimal_cost_to_connect_all_cities def test_example1(): n = 4 m = 5 roads = [ (1, 2, 3), (1, 3, 1), (3, 2, 2), (2, 4, 4), (3, 4, 5) ] assert minimal_cost_to_connect_all_cities(n, m, roads) == 7 def test_example2(): n = 3 m = 3 ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00096397", "row_id": 96397, "seed_ids": "[14477]" }
0.712486
Taco_96397
I
[ "find", "union", "kruskal", "minimal_cost_to_connect_all_cities" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimal_cost_to_connect_all_cities", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
90f23ae7aeb8c22522b61051d1c460ebf5b9f4c7
c35abf002c1744f1ed099a3920f52fe9a4310cdc
v1.0
instruct
Taco
Taco_96412_I
Given a positive integer N, determine if the product of its digits is a prime number. A prime number is a number that is greater than 1 and has no positive divisors other than 1 and itself. Example 1: Input: N = 23 Output: 1 Explanation: The product of digits of 23 is 2 * 3 = 6. Since 6 is not a prime number, the outp...
def is_prime(num): 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 isDigitProductPrime(N): digits = [int(d) for d in str(N)] ...
from solution import isDigitProductPrime def test_example_1(): assert isDigitProductPrime(23) == 0 def test_example_2(): assert isDigitProductPrime(37) == 0 def test_example_3(): assert isDigitProductPrime(25) == 0 def test_single_digit_primes(): # 2, 3, 5, and 7 should all be prime assert i...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def isDigitProductPrime(N):", "function_name": "isDigitProductPrime", "parameter_list": "(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 is_prime(num):\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n return False\n for i in range(3...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00096412", "row_id": 96412, "seed_ids": "[21703]" }
0.611225
Taco_96412
I
[ "is_prime", "isDigitProductPrime" ]
2
[ [ "isDigitProductPrime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54a15e1e2c5db5474b8a27798386085fbebf0fba
d99575512ccd693e3baaa598fd7a0a59b16b47a6
v1.0
instruct
Taco
Taco_96506_I
In a certain kingdom, there are multiple towns connected by bidirectional roads. Each road has a travel cost associated with it. The kingdom has decided to implement a new policy for constructing roads to ensure that there is exactly one unique way to travel between any two towns following a minimum travel cost path. T...
def kruskal_mst(n, edges): def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xr...
def test_kruskal_mst(): test_cases = [ (4, 5, [(1, 2, 2), (1, 3, 5), (2, 3, 7), (2, 4, 8), (3, 4, 3)]), (4, 4, [(1, 2, 1), (2, 3, 1), (3, 4, 1), (1, 3, 2)]), (3, 3, [(1, 2, 4), (2, 3, 4), (1, 3, 2)]), (4, 5, [(1, 2, 3), (1, 3, 4), (1, 4, 5), (2, 3, 6), (3, 4, 7)]), (4, 0, [])...
[ { "docstring": null, "function_declaration": "def kruskal_mst(n, edges):", "function_name": "kruskal_mst", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def min_unique_path_costs(test_cases):", "function_name": "min_unique_path_costs", "parameter...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def minimum_unique_path_cost(n, m, edges):\n # Implementing Kruskal's Algorithm with Union-Find to find Minimum Spanning Tree (MST)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096506", "row_id": 96506, "seed_ids": "[12485]" }
0.790024
Taco_96506
I
[ "kruskal_mst", "min_unique_path_costs" ]
2
[ [ "min_unique_path_costs", "kruskal_mst" ] ]
1
[]
false
[]
false
pytest
false
[]
true
f39127ed33050e10559712a1f9092b56e77736f6
18eb364ef9bb8c9d0c362ab5c9fb837819aa0860
v1.0
instruct
Taco
Taco_96526_I
You are required to create a function named `matrix_transformations(matrix, sequence)` that will perform a series of transformations on a given matrix according to a sequence of commands. The function will receive two arguments: - `matrix`: A 2D list of integers, where each sublist represents a row of the matrix. - `s...
def transpose(matrix): return [list(row) for row in zip(*matrix)] def rotate_clockwise(matrix): return [list(row) for row in zip(*matrix[::-1])] def rotate_counterclockwise(matrix): return [list(row) for row in zip(*matrix)][::-1] def flip_horizontal(matrix): return [row[::-1] for row in matrix] def...
from solution import matrix_transformations def test_transpose(): matrix = [ [1, 2], [3, 4] ] sequence = ["transpose"] expected = [ [1, 3], [2, 4] ] assert matrix_transformations(matrix, sequence) == expected def test_rotate_clockwise(): matrix = [ [...
[ { "docstring": null, "function_declaration": "def transpose(matrix):", "function_name": "transpose", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def rotate_clockwise(matrix):", "function_name": "rotate_clockwise", "parameter_list": "(matrix)" }...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def transpose(matrix):\n return [list(row) for row in zip(*matrix)]\n\ndef rotate_clockwise(matrix):\n return [list(row) for row in zip(*matrix[::-1])]\n\nde...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00096526", "row_id": 96526, "seed_ids": "[5511]" }
0.510205
Taco_96526
I
[ "transpose", "rotate_clockwise", "rotate_counterclockwise", "flip_horizontal", "flip_vertical", "matrix_transformations" ]
6
[ [ "matrix_transformations", "flip_horizontal" ], [ "matrix_transformations", "flip_vertical" ], [ "matrix_transformations", "rotate_clockwise" ], [ "matrix_transformations", "rotate_counterclockwise" ], [ "matrix_transformations", "transpose" ] ]
5
[]
false
[]
false
pytest
true
[]
true
1f04461122cea506921c0b8be4ddeaa35eb91155
a08ab2bdd442daadabd9171ebf452e1f3a449795
v1.0
instruct
Taco
Taco_96532_I
A group of adventurers have ventured into a multi-leveled dungeon. Each level of the dungeon is represented as a grid of cells that can either be an empty cell, a wall, a staircase up, or a staircase down. The adventurers move through the dungeon following a set of given directions. The adventurers' goal is to explore...
from collections import deque def parse_input(): dungeons = [] while True: N = int(input()) if N == 0: break levels = [] for _ in range(N): R, C = map(int, input().split()) grid = [input().strip() for _ in range(R)] levels.append((...
def test_single_level_move_right(): result = can_escape_dungeon( 1, [(3, 3, ["S..", ".#.", "..E"])], 3, [("R", 2), ("D", 2)] ) assert result == "YES" def test_multiple_levels_no_exit(): result = can_escape_dungeon( 2, [ (3, 3, ["S..", ".#U",...
[ { "docstring": null, "function_declaration": "def parse_input():", "function_name": "parse_input", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def find_start_exit(level):", "function_name": "find_start_exit", "parameter_list": "(level)" }, { "d...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_explore_dungeon(dungeons):\n def valid_cell(level, row, col):\n return 0 <= level < len(dungeons) and 0 <= row < len(dungeons[level]) and 0 <= co...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00096532", "row_id": 96532, "seed_ids": "[13407]" }
0.654559
Taco_96532
I
[ "parse_input", "find_start_exit", "move_adventurers", "can_escape_dungeon", "main" ]
5
[ [ "can_escape_dungeon", "find_start_exit" ], [ "can_escape_dungeon", "move_adventurers" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
ebfc98d1541c974bc2010611a1a51214761eacf7
65e7f4bb5e842585ec13656d20c1d5f32f984ed0
v1.0
instruct
Taco
Taco_96552_I
Given an integer array `nums` and an integer `target`, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. A triplet is valid if it satisfies the condition: `a + b > c`, `a + c > b`, and `b + c > a`. ------ Input Format ------ - The first line co...
def count_valid_triplets(nums): """ Count the number of valid triplets that can form a triangle. """ nums.sort() n = len(nums) count = 0 for i in range(n-2): k = i + 2 for j in range(i+1, n-1): while (k < n and nums[i] + nums[j] > nums[k]): k += 1...
from solution import count_triangles, parse_input, format_output def test_count_triangles(): input_str = "2\n4 7\n2 2 3 4\n5 10\n1 2 3 4 5" test_cases = parse_input(input_str) results = count_triangles(test_cases) assert results == [3, 3] def test_parse_input(): input_str = "2\n4 7\n2 2 3 4\n...
[ { "docstring": "Count the number of valid triplets that can form a triangle.", "function_declaration": "def count_valid_triplets(nums):", "function_name": "count_valid_triplets", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def count_triangles(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 count_valid_triplets(nums):\n \"\"\"\n Count the number of valid triplets that can form a triangle.\n \"\"\"\n nums.sort()\n n = len(nums)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00096552", "row_id": 96552, "seed_ids": "[8150]" }
0.675301
Taco_96552
I
[ "count_valid_triplets", "count_triangles", "parse_input", "format_output" ]
4
[ [ "count_triangles", "count_valid_triplets" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
b3a89b8063234639a95f4aed329e51b55c1dbd75
978a2794bd4ab8760881df75c4b6337497926ad4
v1.0
instruct
Taco
Taco_96575_I
Consider a tree with N nodes, each uniquely labeled from 1 to N. A tree is defined as an acyclic connected graph. You are given the tree in the form of an adjacency list, where each node is associated with a list of its neighboring nodes. Create a program that can determine the maximum number of nodes that can be visi...
def dfs(node, parent, adj, dp): # Current node is either included or excluded in the independent set included, excluded = 1, 0 for child in adj[node]: if child != parent: child_included, child_excluded = dfs(child, node, adj, dp) included += child_excluded # If current node ...
import pytest from solution import max_independent_set def test_sample_input_1(): assert max_independent_set(5, [(1, 2), (1, 3), (3, 4), (3, 5)]) == 3 def test_sample_input_2(): assert max_independent_set(4, [(1, 2), (2, 3), (3, 4)]) == 2 def test_single_node(): assert max_independent_set(1, []) == 1 de...
[ { "docstring": null, "function_declaration": "def dfs(node, parent, adj, dp):", "function_name": "dfs", "parameter_list": "(node, parent, adj, dp)" }, { "docstring": null, "function_declaration": "def max_independent_set(N, edges):", "function_name": "max_independent_set", "param...
[ 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 dfs(node, parent, adj, dp):\n # Current node is either included or excluded in the independent set\n included, excluded = 1, 0\n for child in adj[node...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00096575", "row_id": 96575, "seed_ids": "[19394]" }
0.667767
Taco_96575
I
[ "dfs", "max_independent_set" ]
2
[ [ "max_independent_set", "dfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cca1b63ecc9e806bb1b3ee9bdf64b3695e47343e
abab31d843b7481738608bd841f711c323e6e523
v1.0
instruct
Taco
Taco_96643_I
Create a function that generates a list of all prime numbers under a given number N using the Sieve of Eratosthenes algorithm and then find the sum of these prime numbers. Provide the last 4 digits of this sum. Input Format A single line containing an integer N. 2 ≤ N ≤ 10^6 Output Format The last four digits of the ...
def sieve_of_eratosthenes(n): """ Implements the Sieve of Eratosthenes algorithm to find all prime numbers less than n. """ is_prime = [True] * n p = 2 while p * p < n: if is_prime[p]: for i in range(p * p, n, p): is_prime[i] = False p += 1 primes ...
from solution import sieve_of_eratosthenes, sum_of_primes_last_four_digits def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(2) == [] assert sieve_of_eratosthenes(11) == [2, 3, 5, 7] def test_sum_of_primes_last_four_digits(): assert sum_of_...
[ { "docstring": "Implements the Sieve of Eratosthenes algorithm to find all prime numbers less than n.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Calculates the sum of all primes less than n a...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_last_four_digits_primes(n):\n \"\"\"\n Returns the last four digits of the sum of all prime numbers less than n.\n \"\"\"\n if n < 2:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096643", "row_id": 96643, "seed_ids": "[25223]" }
0.584306
Taco_96643
I
[ "sieve_of_eratosthenes", "sum_of_primes_last_four_digits" ]
2
[ [ "sum_of_primes_last_four_digits", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
76d5bed63c35d7294b75248e1250fb57dd823e60
2833f92e21aa24682109b47c874fd66b3232ef15
v1.0
instruct
Taco
Taco_96660_I
**Problem Statement:** Shivam is learning about binary trees and traversal techniques. To test his understanding, his instructor gives him a binary tree and asks him to perform a unique traversal. The traversal to be performed is a combination of preorder and inorder traversal. He has to perform the following steps: ...
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def build_tree(nodes): if not nodes: return None node_map = {val: TreeNode(val) for val, _, _ in nodes if val != -1} for parent, left, right in...
from solution import TreeNode, build_tree, unique_traversal, process_test_cases, solution def test_build_tree(): nodes = [(1, 2, 3), (2, -1, -1), (3, 4, 5), (4, -1, -1), (5, -1, -1)] root = build_tree(nodes) assert root.value == 1 assert root.left.value == 2 assert root.right.value == 3 assert ...
[]
[ 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": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree(node_info):\n if not no...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00096660", "row_id": 96660, "seed_ids": "[6700]" }
0.682316
Taco_96660
I
[ "build_tree", "unique_traversal", "process_test_cases", "solution" ]
4
[ [ "process_test_cases", "build_tree" ], [ "process_test_cases", "unique_traversal" ], [ "solution", "process_test_cases" ] ]
3
[ "process_test_cases" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
a067977f470bb4045fc0117c5b06d2ff3a444ba1
3b133349f51ffad4389fd98842e055b1ae499306
v1.0
instruct
Taco
Taco_96665_I
Given a sequence of N integers, you need to find the length of the longest subsequence that is strictly increasing and consists only of prime numbers. For example, consider the sequence: 7 2 5 3 11 13 1 17 A strictly increasing subsequence composed exclusively of prime numbers is: 2 3 11 13 17. Its length is 5. ---...
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ 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(17) == True assert is_prime(1) == False assert is_prime(0) == False def test_longest_prime_increasing_subsequence_length(): assert longest_prime_increasing_subsequence_leng...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the length of the longest strictly increasing subsequence\nof prime numbers within the given seq...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096665", "row_id": 96665, "seed_ids": "[7439]" }
0.709679
Taco_96665
I
[ "is_prime", "longest_prime_increasing_subsequence_length" ]
2
[ [ "longest_prime_increasing_subsequence_length", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d9e489bd652d28678983c2f0f3c466831060839c
0f7db6f1dc410c313ffd2ce51fe01fab0d1fe0b8
v1.0
instruct
Taco
Taco_96671_I
Peter has been fascinated by prime numbers recently. He wants to test his understanding by creating a function to find the sum of all prime numbers up to a given number N. Additionally, to ensure his code's efficiency, he wants to limit the runtime by checking only up to the square root of N. Help Peter write the effic...
def sieve(n): is_prime = [True] * (n + 1) p = 2 while (p * p <= n): if is_prime[p] == True: for i in range(p * p, n + 1, p): is_prime[i] = False p += 1 primes = [] for p in range(2, n + 1): if is_prime[p]: primes.append(p) return pr...
from solution import process_test_cases def test_process_test_cases(): assert process_test_cases(2, [10, 20]) == [17, 77] assert process_test_cases(1, [2]) == [2] assert process_test_cases(3, [1, 4, 30]) == [0, 5, 129] assert process_test_cases(2, [0, 7]) == [0, 17] assert process_test_cases(1, [10...
[ { "docstring": null, "function_declaration": "def sieve(n):", "function_name": "sieve", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_sum(n):", "function_name": "prime_sum", "parameter_list": "(n)" }, { "docstring": null, "function...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096671", "row_id": 96671, "seed_ids": "[12251]" }
0.592224
Taco_96671
I
[ "sieve", "prime_sum", "process_test_cases" ]
3
[ [ "prime_sum", "sieve" ], [ "process_test_cases", "prime_sum" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
67ac4e786b35ec5df431be18ac4cc6904ef63bf5
90ed748100ff94500b5795395e702597702c1fd4
v1.0
instruct
Taco
Taco_96798_I
## Preface A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Checking if a number is prime can be computationally intensive, especially for large numbers. ## The Problem Create a function `is_prime` that checks if a given positive integer is a prime number. The ...
def is_prime(n): """ Checks if the number n is a prime number. Parameters: n (int): The number to check. Returns: bool: True if n is prime, False otherwise. """ if n <= 1: return False if n in (2, 3): return True if n % 2 == 0 or n % 3 == 0: return False...
from solution import is_prime, list_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(-5) == False assert is_prime(13) == True ...
[ { "docstring": "Checks if the number n is a prime number.\n\nParameters:\nn (int): The number to check.\n\nReturns:\nbool: True if n is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00096798", "row_id": 96798, "seed_ids": "[4482]" }
0.789052
Taco_96798
I
[ "is_prime", "list_primes" ]
2
[ [ "list_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5b253921f5878149fea4d7bb5024e55a44f27147
b36ee82594f4a7f9a0c6cdfb6132169589d617b1
v1.0
instruct
Taco
Taco_96840_I
Given a 2D matrix representing the availability of items in various stores, and a requirement list specifying the quantity of each type of item needed, find the minimum number of stores that must be visited to fulfill the requirement list. You do not need to buy all items from each store, only enough to meet the requir...
from itertools import combinations def can_fulfill_requirements(matrix, requirements, selected_stores): item_count = [0] * len(requirements) for store in selected_stores: for j in range(len(requirements)): item_count[j] += matrix[store][j] for i in range(len(requirements)): ...
from solution import min_stores def test_example_0(): matrix = [ [2, 0, 1], [1, 3, 1], [0, 3, 4] ] requirements = [1, 4, 2] assert min_stores(matrix, requirements) == 2 def test_example_1(): matrix = [ [2, 1, 1], [0, 0, 2], [3, 1, 1] ] requir...
[ { "docstring": null, "function_declaration": "def can_fulfill_requirements(matrix, requirements, selected_stores):", "function_name": "can_fulfill_requirements", "parameter_list": "(matrix, requirements, selected_stores)" }, { "docstring": null, "function_declaration": "def min_stores(ma...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef min_stores(matrix, requirements):\n n = len(matrix)\n m = len(matrix[0])\n \n # Check all combinations of sto...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096840", "row_id": 96840, "seed_ids": "[16896]" }
0.653379
Taco_96840
I
[ "can_fulfill_requirements", "min_stores" ]
2
[ [ "min_stores", "can_fulfill_requirements" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e267cd9c6afa6ad65c4bae313e160f981a08de92
b3441df884001f9f63062f4e8d33567ff2954df3
v1.0
instruct
Taco
Taco_96860_I
Given a string consisting of lowercase English letters, your task is to find out the number of ways to partition the string into contiguous substrings such that each substring is a palindrome. Since the number of ways can be large, return the result modulo $10^9 + 7$. ------ Input ------ The first line of the input ...
MOD = 10**9 + 7 def is_palindrome(s): return s == s[::-1] def count_palindromic_partitions(s): n = len(s) dp = [0] * (n + 1) dp[0] = 1 for i in range(1, n + 1): for j in range(i): if is_palindrome(s[j:i]): dp[i] = (dp[i] + dp[j]) % MOD return dp[n]
from solution import count_palindromic_partitions def test_single_character(): assert count_palindromic_partitions("a") == 1 def test_two_same_characters(): assert count_palindromic_partitions("aa") == 2 def test_two_different_characters(): assert count_palindromic_partitions("ab") == 1 def test_example...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def count_palindromic_partitions(s):", "function_name": "count_palindromic_partitions", "parameter_list...
[ 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": "MOD = 10**9 + 7\n\ndef count_palindromic_partitions(s):\n n = len(s)\n \n # Dynamic programming table to store palindromic substrings\n dp = [[False] *...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00096860", "row_id": 96860, "seed_ids": "[9570]" }
0.785686
Taco_96860
I
[ "is_palindrome", "count_palindromic_partitions" ]
2
[ [ "count_palindromic_partitions", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fddbd7d4f0049ba5961ad910224502a9c6575d1a
7cb23fbecf04b2a02c80ab73d06c6f2f48895926
v1.0
instruct
Taco
Taco_96885_I
You are given a list of jobs, each defined by a start time and an end time. Your goal is to determine the maximum number of non-overlapping jobs that can be scheduled. A job is represented by a pair of integers $(S, E)$, where $S$ is the start time and $E$ is the end time $(1 \le S < E \le 1000000)$. Two jobs $(S_1, E...
def max_non_overlapping_jobs(jobs): """ Determines the maximum number of non-overlapping jobs. """ # Sort jobs by their end time jobs.sort(key=lambda job: job[1]) # Initialize count of non-overlapping jobs count = 0 last_end_time = 0 for job in jobs: start, end = jo...
from solution import process_jobs_input, max_non_overlapping_jobs def test_example_1(): job_input = [ 4, (1, 3), (2, 4), (3, 5), (4, 6) ] assert process_jobs_input(job_input) == 2 def test_example_2(): job_input = [ 6, (1, 5), (2, 6), ...
[ { "docstring": "Determines the maximum number of non-overlapping jobs.", "function_declaration": "def max_non_overlapping_jobs(jobs):", "function_name": "max_non_overlapping_jobs", "parameter_list": "(jobs)" }, { "docstring": "Processes input list into a format suitable for the max_non_overl...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_non_overlapping_jobs(jobs):\n \"\"\"\n Returns the maximum number of non-overlapping jobs from the given list of jobs.\n \"\"\"\n # Sort jobs b...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00096885", "row_id": 96885, "seed_ids": "[13729]" }
0.703905
Taco_96885
I
[ "max_non_overlapping_jobs", "process_jobs_input" ]
2
[ [ "process_jobs_input", "max_non_overlapping_jobs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02f5c4cd3c2a3e76fc57d38d9159c80d4f6a48e8
17f2543ffe63cfab20420b413aba965f3fbc0a96
v1.0
instruct
Taco
Taco_96888_I
You are given a forest represented as an undirected graph with N nodes (1 through N) and M edges. Each node in the graph represents a tree, and each edge represents a path between two trees. Each path has a weight associated with it representing the difficulty of traversing that path. Your task is to prune the forest...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] = ro...
import io import sys from solution import minimum_spanning_tree def test_example_case(): input_data = """4 5 1 2 1 2 3 4 3 4 5 4 1 6 1 3 3""" expected_output = 9 captured_output = io.StringIO() sys.stdin = io.StringIO(input_data) sys.stdout = captured_output import solution solution.main()...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 0, 0, 1, 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 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_9
{ "original_instruction": "", "prompt_id": "00096888", "row_id": 96888, "seed_ids": "[24278]" }
0.77785
Taco_96888
I
[ "find", "union", "minimum_spanning_tree", "main" ]
4
[ [ "minimum_spanning_tree", "find" ], [ "minimum_spanning_tree", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
a5f43ec073fae0dcaae02b87007cb229865e08cd
c71d2fcbdb160da2bcc72fe248c618abb83fb1bc
v1.0
instruct
Taco
Taco_96902_I
A palindrome is a string that reads the same forwards and backwards. However, due to potential typographical errors or variations in input, a modified palindrome is defined as a string where at most one character can be removed to make it a palindrome. For example, "abca" can become "aca" by removing 'b', thus qualifyi...
def is_palindrome(s): return s == s[::-1] def is_modified_palindrome(s): left, right = 0, len(s) - 1 while left < right: if s[left] != s[right]: s_without_left = s[:left] + s[left + 1:] s_without_right = s[:right] + s[right + 1:] return is_palindrome(s_witho...
from solution import check_modified_palindromes def test_basic_cases(): assert check_modified_palindromes(3, ['abca', 'racecar', 'hello']) == ['YES', 'YES', 'NO'] def test_single_character(): assert check_modified_palindromes(1, ['a']) == ['YES'] def test_two_characters(): assert check_modified_palindr...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def is_modified_palindrome(s):", "function_name": "is_modified_palindrome", "parameter_list": "(s)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_modified_palindrome(s):\n \"\"\"\n Checks if the given string can be a modified palindrome by removing at most one character.\n \"\"\"\n def is_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096902", "row_id": 96902, "seed_ids": "[10438]" }
0.838057
Taco_96902
I
[ "is_palindrome", "is_modified_palindrome", "check_modified_palindromes" ]
3
[ [ "check_modified_palindromes", "is_modified_palindrome" ], [ "is_modified_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6a134d060116e35fbc05c80a762fd25866f6ea2b
c50270c177f632bf148c59707259dc6707beda7e
v1.0
instruct
Taco
Taco_96903_I
You are given a grid of size N x M with each cell containing a number. You need to find the largest sum of numbers from any subgrid. A subgrid is defined as any rectangular part of the grid including any cell, all cells in one row, or all cells in the entire grid. Input Format: First line gives T, number of test cases...
def max_subgrid_sum(grid): """ This function calculates the maximum sum of any subgrid in a given 2D grid. """ N = len(grid) M = len(grid[0]) max_sum = float('-inf') for left in range(M): temp = [0] * N for right in range(left, M): for i in rang...
import pytest from solution import max_subgrid_sum, max_subarray_sum, process_test_cases, parse_input def test_max_subgrid_sum(): grid = [ [1, 2], [-1, -3] ] assert max_subgrid_sum(grid) == 3 grid = [ [1, -2, 3], [4, 5, -6], [-7, 8, 9] ] assert max_subgr...
[ { "docstring": "This function calculates the maximum sum of any subgrid in a given 2D grid.", "function_declaration": "def max_subgrid_sum(grid):", "function_name": "max_subgrid_sum", "parameter_list": "(grid)" }, { "docstring": "Helper function to calculate the maximum sum of any subarray u...
[ 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_max_sum_subgrid(grid):\n def compute_kadane(arr):\n max_sum = float('-inf')\n current_sum = 0\n for num in arr:\n curre...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00096903", "row_id": 96903, "seed_ids": "[2182]" }
0.661198
Taco_96903
I
[ "max_subgrid_sum", "max_subarray_sum", "process_test_cases", "parse_input", "main" ]
5
[ [ "max_subgrid_sum", "max_subarray_sum" ], [ "process_test_cases", "max_subgrid_sum" ] ]
2
[ "process_test_cases", "parse_input" ]
false
[]
false
pytest
true
[]
true
3fc84a85240a111f6cd6e3125b0b7e72bc495144
9f690154f150ddecad94993cb7a82e70b714c67a
v1.0
instruct
Taco
Taco_96907_I
The year is 3030 and space exploration has reached its peak. The Galactic Council has decided to create a space highway system connecting various space stations scattered across the galaxy. The Council's objective is to ensure that every space station is reachable from any other space station. You have been given the...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank...
import pytest from solution import minimal_highway_cost def test_minimal_highway_cost_example(): n = 4 m = 5 highways = [ (1, 2, 5), (1, 3, 3), (4, 1, 6), (2, 4, 7), (3, 4, 4) ] assert minimal_highway_cost(n, m, highways) == 12 def test_minimal_highway_cost_...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\n\ndef union(parent, rank, x, y):\n x_root =...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00096907", "row_id": 96907, "seed_ids": "[19474]" }
0.625602
Taco_96907
I
[ "find", "union", "kruskal_mst", "minimal_highway_cost" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimal_highway_cost", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
abc4f42a6d70c413b4608d984946e10373c38b2d
b14c851dde35780c320a5e85acb9ed39e54866c0
v1.0
instruct
Taco
Taco_96928_I
Ravi is a forest guard and he has to patrol a rectangular grid-shaped forest. The forest is divided into cells, some of which may have obstacles (trees, rocks, etc.). Ravi starts his patrol from the top-left corner (0, 0) and aims to reach the bottom-right corner (n-1, m-1). Ravi can only move either right or down at ...
def unique_paths(grid): n = len(grid) m = len(grid[0]) if grid[0][0] == 1 or grid[n-1][m-1] == 1: return 0 dp = [[0] * m for _ in range(n)] dp[0][0] = 1 for i in range(n): for j in range(m): if grid[i][j] == 1: dp[i][j] = 0 else: ...
from solution import forest_paths def test_sample_case_1(): data = [ "2", "3 3", "0 0 0", "0 1 0", "0 0 0", "2 2", "0 1", "1 0" ] assert forest_paths(data) == [2, 0] def test_no_path(): data = [ "1", "3 3", "0 1 0"...
[ { "docstring": null, "function_declaration": "def unique_paths(grid):", "function_name": "unique_paths", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def process_input_output(data):", "function_name": "process_input_output", "parameter_list": "(data...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def unique_paths_with_obstacles(grid):\n if not grid or grid[0][0] == 1:\n return 0\n \n n, m = len(grid), len(grid[0])\n dp = [[0] * m for _ in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00096928", "row_id": 96928, "seed_ids": "[952]" }
0.7089
Taco_96928
I
[ "unique_paths", "process_input_output", "forest_paths" ]
3
[ [ "forest_paths", "process_input_output" ], [ "process_input_output", "unique_paths" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
88e04ac4e89e7044c48df43452bc7666c1d4f371
b8fcb706d406555f01bdf0974c7a4af08d7beaaf
v1.0
instruct
Taco
Taco_96966_I
In a faraway land called Metropolis, there are n metropolises connected by m bidirectional roads. Each metropolis has a unique index from 1 to n. The kingdom authorities are interested in strategic urban planning and want to build a new headquarter in a metropolis such that the maximum distance from the headquarter to ...
from collections import deque, defaultdict def find_best_metropolis(n, m, roads): if n == 1: return 1 # Build the graph using adjacency list graph = defaultdict(list) for u, v in roads: graph[u].append(v) graph[v].append(u) def bfs(start): distances = [-1] * (n...
def test_example_1(): assert build_and_solve("4 3\n1 2\n2 3\n2 4") == 2 def test_example_2(): assert build_and_solve("6 5\n1 2\n2 3\n3 4\n4 5\n4 6") == 3 def test_single_metropolis(): assert build_and_solve("1 0") == 1 def test_disjoint_graph(): # In case of a graph with multiple components, choose t...
[ { "docstring": null, "function_declaration": "def find_best_metropolis(n, m, roads):", "function_name": "find_best_metropolis", "parameter_list": "(n, m, roads)" }, { "docstring": null, "function_declaration": "def build_and_solve(input_data):", "function_name": "build_and_solve", ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef find_headquarter(n, m, roads):\n def bfs(start):\n distances = [-1] * (n + 1)\n distances[start]...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00096966", "row_id": 96966, "seed_ids": "[9977]" }
0.742526
Taco_96966
I
[ "find_best_metropolis", "build_and_solve" ]
2
[ [ "build_and_solve", "find_best_metropolis" ] ]
1
[]
false
[]
false
pytest
false
[]
true
114d7d75a736c294e5ff62824aaaf952b4cd20b7
6370943bc6cd42b261b01ad4e0a4cca6f50f9bd4
v1.0
instruct
Taco
Taco_96986_I
Alice is trapped in a maze of size N x M with various obstacles. The maze is described as a grid where each cell has one of the following values: - `S`: The starting point (Alice's current position). - `E`: The exit point. - `.`: An empty cell Alice can move to. - `#`: An obstacle that Alice cannot move through. Alic...
from collections import deque def min_energy_to_exit(N, M, E, maze): def is_within_bounds(x, y): return 0 <= x < N and 0 <= y < M # Locate the start (S) and end (E) points start = end = None for i in range(N): for j in range(M): if maze[i][j] == 'S': start =...
def test_case_1(): maze_input = [ "4 4 10", "S..#", ".#.#", ".#.E", "...." ] solve(maze_input) def test_case_2(): maze_input = [ "3 3 2", "S#.", ".#E", "###" ] solve(maze_input) def test_case_3(): maze_input = [ ...
[ { "docstring": null, "function_declaration": "def min_energy_to_exit(N, M, E, maze):", "function_name": "min_energy_to_exit", "parameter_list": "(N, M, E, maze)" }, { "docstring": null, "function_declaration": "def solve(maze_input):", "function_name": "solve", "parameter_list": ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_energy_to_exit(maze, N, M, E):\n \"\"\"\n Returns the minimum energy required to reach the exit or -1 if it's imposs...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00096986", "row_id": 96986, "seed_ids": "[14772]" }
0.752477
Taco_96986
I
[ "min_energy_to_exit", "solve" ]
2
[ [ "solve", "min_energy_to_exit" ] ]
1
[]
false
[]
false
pytest
false
[]
true
6b24055b16fec984d8afc1ac3c1cf04ebe8c76d6
46b9275d598768e4d6af02acfb6a4cb45e94f3e9
v1.0
instruct
Taco
Taco_97070_I
Alice is playing a game on a $n \times n$ grid, where $n$ is an odd integer. The grid cells are numbered from $1$ to $n^2$ in a spiral order. Starting from the top-left corner and moving inwards in a clockwise direction, the numbering proceeds until reaching the center of the grid. Alice can choose two positions, $i$ ...
def generate_spiral(n): spiral = [[0] * n for _ in range(n)] left, right = 0, n - 1 top, bottom = 0, n - 1 num = 1 while left <= right and top <= bottom: for i in range(left, right + 1): spiral[top][i] = num num += 1 top += 1 for i in range(top, bott...
def test_generate_spiral(): expected_5x5 = [ [1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9] ] assert generate_spiral(5) == expected_5x5 def test_find_position(): assert find_position(5, 1) == (0, 0) assert ...
[ { "docstring": null, "function_declaration": "def generate_spiral(n):", "function_name": "generate_spiral", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_position(n, num):", "function_name": "find_position", "parameter_list": "(n, num)" }, ...
[ 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_rook_move(n, test_cases):\n \"\"\"\n Determines if a rook can move from position i to position j on an n x n spiral grid.\n\n Parameters:\n n (...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097070", "row_id": 97070, "seed_ids": "[11143]" }
0.731468
Taco_97070
I
[ "generate_spiral", "find_position", "can_rook_move", "rook_moves" ]
4
[ [ "can_rook_move", "find_position" ], [ "find_position", "generate_spiral" ], [ "rook_moves", "can_rook_move" ] ]
3
[]
false
[]
false
pytest
false
[]
true
f610062bf7989342bd2af768172ecaa67ba713cb
83f31a08d8a3a6201161ea7a3d373a36412b9c1d
v1.0
instruct
Taco
Taco_97115_I
### Problem Description Prime numbers are fascinating because they cannot be created by multiplying two smaller numbers (other than 1 and the number itself). We often need to find all prime numbers up to a certain limit. For this problem, you will write a program to find all prime numbers up to a given integer and list...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
from solution import next_prime def test_next_prime_starting_at_prime(): assert next_prime(2) == 2 assert next_prime(3) == 3 assert next_prime(29) == 29 def test_next_prime_starting_in_between(): assert next_prime(0) == 2 assert next_prime(1) == 2 assert next_prime(10) == 11 assert next_pr...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the smallest prime number greater than or equal to n.", "function_declaration": "def next_prime...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return Tru...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097115", "row_id": 97115, "seed_ids": "[22020]" }
0.687067
Taco_97115
I
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
61acf4e65b75fa0af58babea77899b0f20006cb0
053891669870d53f77e2885a265ef1c7782fe3ea
v1.0
instruct
Taco
Taco_97144_I
In a mystical land, there exists an enchanted forest with unique plants. Each plant has a unique growth potential, represented as a series of numbers. The land's guardian, Elara, has a task for a brave coder: to determine which plants can provide a sequence of growths hitherto unseen by any in the land. The enchanted p...
def is_magical_plant(growth_potentials): """ Determines if a plant is magical by checking if there exists at least one contiguous subarray whose sum is even. """ for potential in growth_potentials: if potential % 2 == 0: return "MAGICAL" return "NOT MAGICAL" def enchanted_fo...
from solution import enchanted_forest def test_example_case_1(): n = 3 plants = [ [1, 2, 3], [1, 3, 5, 7], [6, -2] ] assert enchanted_forest(n, plants) == ["MAGICAL", "NOT MAGICAL", "MAGICAL"] def test_all_odd_numbers(): n = 2 plants = [ [1, 3, 5], [7, 9...
[ { "docstring": "Determines if a plant is magical by checking if there exists at least one\ncontiguous subarray whose sum is even.", "function_declaration": "def is_magical_plant(growth_potentials):", "function_name": "is_magical_plant", "parameter_list": "(growth_potentials)" }, { "docstring...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magical(plant_growth_potentials):\n \"\"\"\n Determines if a plant is magical by checking if there exists at least one contiguous subarray whose sum i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097144", "row_id": 97144, "seed_ids": "[20244]" }
0.571414
Taco_97144
I
[ "is_magical_plant", "enchanted_forest" ]
2
[ [ "enchanted_forest", "is_magical_plant" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fa2956d7807c4d4561283c217a0f19446a1cffe6
fd4beefe3b5e4116a5011710f414b264bf499ec3
v1.0
instruct
Taco
Taco_97208_I
In the city of Gridland, there are N buildings and M roads connecting them. Each road has a certain length in meters. Your task is to determine whether it is possible to choose a subset of roads such that all buildings are connected (i.e., there is a path between any two buildings) and the total length of the chosen su...
def kruskal_mst(N, edges): """ Function to find the Minimum Spanning Tree (MST) using Kruskal's algorithm. """ # Helper function to find the root of the set in disjoint set def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) ...
def test_sample_1(): N = 4 M = 5 roads = [ (1, 2, 10), (1, 3, 6), (1, 4, 5), (2, 3, 4), (3, 4, 2) ] assert min_total_road_length(N, M, roads) == 11 def test_sample_2(): N = 4 M = 2 roads = [ (1, 2, 5), (3, 4, 10) ] assert m...
[ { "docstring": "Function to find the Minimum Spanning Tree (MST) using Kruskal's algorithm.", "function_declaration": "def kruskal_mst(N, edges):", "function_name": "kruskal_mst", "parameter_list": "(N, edges)" }, { "docstring": "Main function to find the minimum total length of the roads to...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def kruskal_mst(N, edges):\n \"\"\"\n Function to find the Minimum Spanning Tree (MST) using Kruskal's algorithm.\n \"\"\"\n # Helper function to find ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00097208", "row_id": 97208, "seed_ids": "[14893]" }
0.746784
Taco_97208
I
[ "kruskal_mst", "min_total_road_length" ]
2
[ [ "min_total_road_length", "kruskal_mst" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7189d1efce318d29050f67cc28d022558d08cb1f
4ad63e20942b1e3abc598db81f3aaf0a15036ae0
v1.0
instruct
Taco
Taco_97300_I
The town of Algorithmsville has recently decided to build a network of communication towers to improve connectivity. Each tower can communicate with another tower if they are within a certain distance. The plan is to ensure that every pair of towers can communicate either directly or indirectly (i.e., via other towers)...
import math def calculate_distance(tower1, tower2): """ Function to calculate the Euclidean distance between two towers. """ return math.sqrt((tower1[0] - tower2[0]) ** 2 + (tower1[1] - tower2[1]) ** 2) def min_max_distance(tower_coords): """ Function to find the minimum value of the maximum d...
def test_calculate_distance(): assert math.isclose(calculate_distance((0, 0), (0, 2)), 2.0, rel_tol=1e-9) assert math.isclose(calculate_distance((0, 0), (3, 4)), 5.0, rel_tol=1e-9) assert math.isclose(calculate_distance((2, 2), (5, 6)), 5.0, rel_tol=1e-9) def test_min_max_distance_example1(): assert mi...
[ { "docstring": "Function to calculate the Euclidean distance between two towers.", "function_declaration": "def calculate_distance(tower1, tower2):", "function_name": "calculate_distance", "parameter_list": "(tower1, tower2)" }, { "docstring": "Function to find the minimum value of the maxim...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef distance(p1, p2):\n return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\n\ndef find(parent, i):\n if parent[i] == i:\n re...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097300", "row_id": 97300, "seed_ids": "[15458]" }
0.634005
Taco_97300
I
[ "calculate_distance", "min_max_distance", "main" ]
3
[ [ "min_max_distance", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
db84d7e3f0d2a17d51eaaebb9ad25fff62862e3d
a3ce2e062ace90dc741a3c1f18ebe0a5794476c3
v1.0
instruct
Taco
Taco_97396_I
A group of friends is organizing a scavenger hunt in a park. Each location in the park where an item could be hidden is represented as a node in a tree. The nodes are connected by bidirectional paths, and there is exactly one path between any two nodes (i.e., the park is represented as a tree). Each friend starts at a...
from collections import deque def bfs_farthest_node(start, adj): """ Perform BFS to find the farthest node from the start node and its distance. :param start: The starting node for BFS. :param adj: The adjacency list representation of the graph. :returns: A tuple (farthest_node, max_distance)....
from solution import find_tree_diameter def test_find_tree_diameter_case_1(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] assert find_tree_diameter(n, edges) == 3 def test_find_tree_diameter_case_2(): n = 4 edges = [(1, 2), (2, 3), (3, 4)] assert find_tree_diameter(n, edges) == 3 def test_...
[ { "docstring": "Perform BFS to find the farthest node from the start node and its distance.\n\n:param start: The starting node for BFS.\n:param adj: The adjacency list representation of the graph.\n:returns: A tuple (farthest_node, max_distance).", "function_declaration": "def bfs_farthest_node(start, adj):...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef calculate_tree_diameter(n, edges):\n if n == 1:\n return 0\n \n def bfs(start):\n dist = [...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097396", "row_id": 97396, "seed_ids": "[3836]" }
0.672145
Taco_97396
I
[ "bfs_farthest_node", "find_tree_diameter" ]
2
[ [ "find_tree_diameter", "bfs_farthest_node" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed6e37f52588c6bc215132a2ac8def3c2f956631
6940f48c177a9da9e2d55274b7b4659c05f0bb87
v1.0
instruct
Taco
Taco_97420_I
Given a grid of size N x M filled with lowercase English letters, Chef has to respond to Q queries. In each query, Chef is given a subgrid defined by its top-left coordinate (x1, y1) and bottom-right coordinate (x2, y2), and he needs to determine if any anagram of the string formed by concatenating all characters withi...
def is_palindrome_possible(subgrid_string): """ Determine if any anagram of the given string can be rearranged to form a palindrome. """ from collections import Counter count = Counter(subgrid_string) odd_count = sum(1 for c in count.values() if c % 2 != 0) return odd_count <= 1 d...
from solution import chef_responses def test_single_query(): T = 1 test_cases = [ (4, 4, ["abcd", "efgh", "ijkl", "mnop"], 1, [(1, 1, 4, 4)]) ] assert chef_responses(T, test_cases) == ["NO"] def test_multiple_queries(): T = 1 test_cases = [ (4, 4, ["abcd", "efgh", "ijkl", "...
[ { "docstring": "Determine if any anagram of the given string can be rearranged to form a palindrome.", "function_declaration": "def is_palindrome_possible(subgrid_string):", "function_name": "is_palindrome_possible", "parameter_list": "(subgrid_string)" }, { "docstring": null, "function_...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_palindrome(subgrid_string):\n \"\"\"\n This function returns True if any anagram of the subgrid_string can be\n rearranged to form a palindro...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097420", "row_id": 97420, "seed_ids": "[3077]" }
0.738538
Taco_97420
I
[ "is_palindrome_possible", "process_queries", "chef_responses" ]
3
[ [ "chef_responses", "process_queries" ], [ "process_queries", "is_palindrome_possible" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
a01e56e5020018e880e9ca00563a0804ab102b8f
00df5417b28b6bed53424291b369760615c40ade
v1.0
instruct
Taco
Taco_97449_I
You are given a balanced binary search tree (BST) with N nodes. Your task is to find and print the median value of all the nodes in the BST. The median of a set of numbers is the middle number when the numbers are sorted in order. If there is an even number of elements, the median is the average of the two middle num...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def insert_level_order(arr, root, i, n): if i < n: temp = TreeNode(arr[i]) root = temp root.left = insert_level_order(arr, root.left, 2 * i + 1, n) root.right = ins...
def test_single_node(): assert process_cases([(1, [10])]) == [10.0] def test_two_nodes(): assert process_cases([(2, [1, 3])]) == [2.0] def test_odd_number_of_nodes(): assert process_cases([(3, [3, 1, 4])]) == [3.0] def test_even_number_of_nodes(): assert process_cases([(4, [4, 2, 6, 1])]) == [3.0] d...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bst_median(t, test_cases):\n \"\"\"\n Given a number of test cases, and for each test case, a binary search tree with N nodes, \n the function returns...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097449", "row_id": 97449, "seed_ids": "[6403]" }
0.568508
Taco_97449
I
[ "insert_level_order", "in_order_traversal", "median_of_bst", "process_cases", "solve" ]
5
[ [ "median_of_bst", "in_order_traversal" ], [ "median_of_bst", "insert_level_order" ], [ "process_cases", "median_of_bst" ], [ "solve", "process_cases" ] ]
4
[ "process_cases" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
3352e1d80e199f033aba623a5716ed30c9fb51d5
de327b9f1c33c121c940c906bafa13bfe2bb0c2c
v1.0
instruct
Taco
Taco_97450_I
You are given an array of `n` integers. Divide this array into two non-empty parts such that the sum of the elements in the first part and the sum of the elements in the second part are as close as possible. -----Input----- The first line of the input contains an integer `n` (2 ≤ n ≤ 100,000) — the number of elements...
def min_diff_partition(arr): """ This function takes a list of integers and returns the minimum absolute difference between the sum of two non-empty partitions of the array. """ total_sum = sum(arr) n = len(arr) # To find the subset with sum closest to total_sum / 2 dp = [0] * (tota...
from solution import find_min_absolute_difference def test_min_diff_partition_example_1(): assert find_min_absolute_difference(4, [3, 1, 4, 2]) == 0 def test_min_diff_partition_example_2(): assert find_min_absolute_difference(5, [1, 2, 3, 4, 5]) == 1 def test_min_diff_partition_single_element(): # As per...
[ { "docstring": "This function takes a list of integers and returns the minimum absolute difference\nbetween the sum of two non-empty partitions of the array.", "function_declaration": "def min_diff_partition(arr):", "function_name": "min_diff_partition", "parameter_list": "(arr)" }, { "docst...
[ 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 min_diff_partition(arr):\n \"\"\"\n This function takes a list of integers and returns the minimum absolute difference\n between the sum of two non-em...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00097450", "row_id": 97450, "seed_ids": "[14095]" }
0.760535
Taco_97450
I
[ "min_diff_partition", "find_min_absolute_difference" ]
2
[ [ "find_min_absolute_difference", "min_diff_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cb9f2545623e68f59fd4cc1e8d29986b51418dd4
e355d44066cc5975f60c2c01c8daf4f7fdb15434
v1.0
instruct
Taco
Taco_97487_I
Sarah is an avid reader and loves collecting books. She has recently purchased several books and wants to organize them on her shelves. Sarah arranges her books in a very specific way: each book has a certain height, and she wants all the books on the same shelf to be sorted in non-decreasing order of their heights, wi...
def maximize_books_on_shelves(book_heights, shelf_capacities): """ Returns the maximum number of books that can be placed on the shelves. """ book_heights.sort() shelf_capacities.sort(reverse=True) total_books = 0 i = 0 for capacity in shelf_capacities: placed_books = 0...
from solution import organize_books def test_example_case(): assert organize_books(5, [4, 5, 3, 2, 8], 2, [3, 2]) == 5 def test_single_shelf(): assert organize_books(5, [4, 5, 3, 2, 8], 1, [4]) == 4 def test_shelves_with_lower_capacity(): assert organize_books(5, [4, 5, 3, 2, 8], 2, [2, 1]) == 3 def tes...
[ { "docstring": "Returns the maximum number of books that can be placed on the shelves.", "function_declaration": "def maximize_books_on_shelves(book_heights, shelf_capacities):", "function_name": "maximize_books_on_shelves", "parameter_list": "(book_heights, shelf_capacities)" }, { "docstrin...
[ 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 maximize_books_on_shelves(n, book_heights, m, shelf_capacities):\n # Sort the books in non-decreasing order of their heights.\n book_heights.sort()\n\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097487", "row_id": 97487, "seed_ids": "[5058]" }
0.7129
Taco_97487
I
[ "maximize_books_on_shelves", "organize_books" ]
2
[ [ "organize_books", "maximize_books_on_shelves" ] ]
1
[]
false
[]
false
pytest
true
[]
true
22e7047dcae60b947af5ca967f1818077908927a
801bb62af9589310c4f6086afd7c42ad4a22d0f0
v1.0
instruct
Taco
Taco_97492_I
A company has a system that schedules interviews for job applicants. Each applicant has a preferred time slot, but due to overlapping decisions, some applicants might have conflicts. Your task is to determine the maximum number of non-overlapping time slots that can be assigned to applicants. Given a list of tuples wh...
def max_non_overlapping_intervals(test_cases): """ For each test case, find the maximum number of non-overlapping intervals. Args: test_cases: List of tuples, where each tuple contains: an integer N (number of applicants) and a list of tuples of integers (start, end)...
def test_max_non_overlapping_intervals(): data = "2\n3\n1 3\n2 4\n3 5\n4\n1 2\n2 3\n3 4\n4 5" expected_output = "2\n4" assert run_interview_scheduling(data) == expected_output def test_single_interval(): data = "1\n1\n0 5" expected_output = "1" assert run_interview_scheduling(data) == expected_...
[ { "docstring": "For each test case, find the maximum number of non-overlapping intervals.\n\nArgs:\ntest_cases: List of tuples, where each tuple contains:\n an integer N (number of applicants)\n and a list of tuples of integers (start, end) for each applicant's time slot.\n\nReturns:\nList...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_non_overlapping_intervals(t, cases):\n \"\"\"\n Determines the maximum number of non-overlapping intervals for each test case.\n \n Parameters:...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097492", "row_id": 97492, "seed_ids": "[16651]" }
0.705232
Taco_97492
I
[ "max_non_overlapping_intervals", "process_input", "process_output", "run_interview_scheduling" ]
4
[ [ "run_interview_scheduling", "max_non_overlapping_intervals" ], [ "run_interview_scheduling", "process_input" ], [ "run_interview_scheduling", "process_output" ] ]
3
[ "process_input" ]
false
[]
false
pytest
false
[]
true
1887b197b96c2a1c8c24b254f448400731c73972
a152fe9ae713785e5488fc54af8cc23a252838c4
v1.0
instruct
Taco
Taco_97534_I
Chef is interested in organizing a friendly competition among cooks. Each cook must prepare and submit a unique recipe. Each recipe is described using a distinct combination of ingredients. Every ingredient in a recipe is represented as a letter in the recipe string. Chef wants each recipe to be aesthetically pleasing....
MOD = 1000000007 def factorial(n): if n == 0 or n == 1: return 1 return n * factorial(n - 1) def count_aesthetically_pleasing_recipes(n, m): if m == 1: return n elif m > n: return 0 else: return (n * (factorial(n - 1) // factorial(n - m))) % MOD
from solution import count_aesthetically_pleasing_recipes def test_case_1(): assert count_aesthetically_pleasing_recipes(3, 2) == 6 def test_case_2(): assert count_aesthetically_pleasing_recipes(4, 3) == 24 def test_case_3(): assert count_aesthetically_pleasing_recipes(1, 1) == 1 def test_case_4(): ...
[ { "docstring": null, "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_aesthetically_pleasing_recipes(n, m):", "function_name": "count_aesthetically_pleasing_recipes", "par...
[ 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 = 1000000007\n\ndef aesthetically_pleasing_recipes(n, m):\n if m == 1:\n return n % MOD\n\n dp = [[0] * n for _ in range(m)]\n for i in range(n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097534", "row_id": 97534, "seed_ids": "[15024]" }
0.634859
Taco_97534
I
[ "factorial", "count_aesthetically_pleasing_recipes" ]
2
[ [ "count_aesthetically_pleasing_recipes", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d5558fff9c1861247908b7dad26aacf228506013
67c70e471a79f98526a68e2816795e190706c3f7
v1.0
instruct
Taco
Taco_97567_I
Anton is a librarian and he wants to organize the books in his library. He has exactly n books and each book has a unique ISBN number ranging from 1 to n. To make the library more accessible, he wants to start by arranging the books in such a way that all the books with prime ISBN numbers are at the beginning, followed...
def is_prime(num): """ Returns True if num is a prime number, False otherwise. """ 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...
from solution import organize_books def test_organize_books_example_1(): assert organize_books(5, [3, 1, 4, 2, 5]) == [3, 2, 5, 1, 4] def test_organize_books_example_2(): assert organize_books(6, [6, 3, 4, 7, 1, 5]) == [3, 7, 5, 6, 4, 1] def test_organize_books_single_prime(): assert organize_books(1, [2...
[ { "docstring": "Returns True if num is a prime number, False otherwise.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the list of books organized with prime ISBNs first,\nfollowed by non-prime ISBNs.", "f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097567", "row_id": 97567, "seed_ids": "[1856]" }
0.694058
Taco_97567
I
[ "is_prime", "organize_books" ]
2
[ [ "organize_books", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
87c3915e8f37b004024cc45c98e1033c9db02dc3
be105e0aa71a5522fbb418d06abc67c3e00ff033
v1.0
instruct
Taco
Taco_97587_I
You are given a string consisting of lowercase English letters and some target words. Your task is to check how many times all the target words can be simultaneously extracted from the given string, maintaining their order each time. When a word is extracted, its letters are no longer available for extraction. The targ...
from collections import Counter def can_extract(s, target_words): """ Checks if all target words can be extracted simultaneously from string s and returns how many times this extraction is possible. """ s_counter = Counter(s) target_counters = [Counter(word) for word in target_words] min_e...
from solution import maximum_extractions def test_basic_case(): s = "abacabacaba" target_words = ["ab", "ca", "ac"] assert maximum_extractions(s, target_words) == 2 def test_no_extractions_possible(): s = "abcdef" target_words = ["gh", "ij", "kl"] assert maximum_extractions(s, target_words) ==...
[ { "docstring": "Checks if all target words can be extracted simultaneously from string s\nand returns how many times this extraction is possible.", "function_declaration": "def can_extract(s, target_words):", "function_name": "can_extract", "parameter_list": "(s, target_words)" }, { "docstri...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef can_extract_once(s_counter, word_counter):\n for char, count in word_counter.items():\n if s_counter[char] < count...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097587", "row_id": 97587, "seed_ids": "[10075]" }
0.746902
Taco_97587
I
[ "can_extract", "maximum_extractions" ]
2
[ [ "maximum_extractions", "can_extract" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e6bb8d2d6618ff6c17273f127617b35dbb7846c
72b7f4a91b507167b35d56e6c41509f1554ebad6
v1.0
instruct
Taco
Taco_97606_I
The task is to complete the merge() function which is used to implement Merge Sort. Example 1: Input: N = 5 arr[] = {12, 11, 13, 5, 6} Output: 5 6 11 12 13 Example 2: Input: N = 6 arr[] = {38, 27, 43, 3, 9, 82} Output: 3 9 27 38 43 82 Your Task: You don't have to read input or print anything. Your task is to complete...
def merge(arr, l, m, r): """ Merges two subarrays of arr. First subarray is arr[l..m] Second subarray is arr[m+1..r] """ n1 = m - l + 1 n2 = r - m # create temp arrays L = [0] * n1 R = [0] * n2 # Copy data to temp arrays L[] and R[] for i in range(n1): L[i] = ar...
from solution import mergeSort def test_mergeSort_example1(): arr = [12, 11, 13, 5, 6] mergeSort(arr, 0, len(arr) - 1) assert arr == [5, 6, 11, 12, 13] def test_mergeSort_example2(): arr = [38, 27, 43, 3, 9, 82] mergeSort(arr, 0, len(arr) - 1) assert arr == [3, 9, 27, 38, 43, 82] def test_mer...
[ { "docstring": "Merges two subarrays of arr.\nFirst subarray is arr[l..m]\nSecond subarray is arr[m+1..r]", "function_declaration": "def merge(arr, l, m, r):", "function_name": "merge", "parameter_list": "(arr, l, m, r)" }, { "docstring": "Main function that sorts arr[l..r] using merge()", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge(arr, left, mid, right):\n n1 = mid - left + 1\n n2 = right - mid\n \n # Create temp arrays\n L = [0] * n1\n R = [0] * n2\n \n # C...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097606", "row_id": 97606, "seed_ids": "[132]" }
0.683521
Taco_97606
I
[ "merge", "mergeSort" ]
2
[ [ "mergeSort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e4f7e9753a907f426f4a287594e1b913f9cfc25d
d98d5cd3a7feeef162ca6c0f7eab3456dd6325e9
v1.0
instruct
Taco
Taco_97613_I
Implement a File Merge Operation. Input: First line contains T - Number of test cases. Each test case contains two positive integers N and M followed by a list of N integers and a list of M integers. Output: Output a single sorted list for each test case. Constraints: 1 ≤ T ≤ 200 1 ≤ N, M ≤ 100 -1000 ≤ integer va...
def merge_and_sort_arrays(test_cases): results = [] for case in test_cases: N, M, list1, list2 = case merged_list = list1 + list2 merged_list.sort() results.append(merged_list) return results def parse_input(input_str): input_lines = input_str.strip().split('\n') T =...
def test_file_merge_operation(): input_data = "2\n3 3\n12 11 5\n6 2 14\n4 4\n-1 0 1 0\n3 -4 2 5" expected_output = "2 5 6 11 12 14\n-4 -1 0 0 1 2 3 5" assert file_merge_operation(input_data) == expected_output def test_single_case_all_negative(): input_data = "1\n3 3\n-12 -11 -5\n-6 -2 -14" expecte...
[ { "docstring": null, "function_declaration": "def merge_and_sort_arrays(test_cases):", "function_name": "merge_and_sort_arrays", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parame...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sorted_lists(test_cases):\n \"\"\"\n Merges and sorts lists from given test cases.\n \n :param test_cases: List of tuples, each containing tw...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097613", "row_id": 97613, "seed_ids": "[10997]" }
0.529785
Taco_97613
I
[ "merge_and_sort_arrays", "parse_input", "format_output", "file_merge_operation" ]
4
[ [ "file_merge_operation", "format_output" ], [ "file_merge_operation", "merge_and_sort_arrays" ], [ "file_merge_operation", "parse_input" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
766814ea4508f93f5478408815ca6e6f0995075b
65335b06a13277f6d4e0ae330a64c2e48623364b
v1.0
instruct
Taco
Taco_97652_I
Paul loves playing with numbers, and his current interest is in palindromes. He wants to know the number of palindrome integers within a given range [L, R] inclusive. A palindrome integer is a number that remains the same when its digits are reversed (e.g., 121, 1331). Input: - The first line contains a single inte...
def is_palindrome(n): """ Returns True if n is a palindrome, otherwise False. """ str_n = str(n) return str_n == str_n[::-1] def count_palindromes_in_range(T, ranges): """ For each range [L, R] in ranges, count the number of palindrome integers. Parameters: T (int): Number of t...
def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(1331) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True def test_count_palindromes_in_range(): assert count_palindromes_in_range(2, [(1, 10), (100, 200)]) =...
[ { "docstring": "Returns True if n is a palindrome, otherwise False.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "For each range [L, R] in ranges, count the number of palindrome integers.\n\nParameters:\nT (int...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Checks if a given number n is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef count_palindromes(L, R):\n...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00097652", "row_id": 97652, "seed_ids": "[14857]" }
0.710861
Taco_97652
I
[ "is_palindrome", "count_palindromes_in_range", "main" ]
3
[ [ "count_palindromes_in_range", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
false
[]
true
60235e28c7125df203a7c4678ed6554ae6330ba0
e2b354c494b970038052b776f26a4cd5508d94cb
v1.0
instruct
Taco
Taco_97669_I
Given two integers N and M, output the first M terms of the sequence S where each term is the sum of digits of the previous term starting from N. For example, if N is 123, the first term is the sum of digits of 123, which is 6. The second term is the sum of digits of 6, which is still 6, and so on. -----Constraints-...
def sum_of_digits(num): """ Helper function to calculate the sum of digits of a number. """ return sum(int(digit) for digit in str(num)) def sequence_of_sums(N, M): """ Generate the first M terms of the sequence where each term is the sum of digits of the previous term starting from N. """ ...
from solution import sequence_of_sums def test_case_1(): assert sequence_of_sums(123, 5) == [6, 6, 6, 6, 6] def test_case_2(): assert sequence_of_sums(987654321, 3) == [45, 9, 9] def test_case_3(): assert sequence_of_sums(1, 1) == [1] def test_case_4(): assert sequence_of_sums(99999999, 2) == [72, 9...
[ { "docstring": "Helper function to calculate the sum of digits of a number.", "function_declaration": "def sum_of_digits(num):", "function_name": "sum_of_digits", "parameter_list": "(num)" }, { "docstring": "Generate the first M terms of the sequence where each term is the sum of digits of t...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(num):\n \"\"\"\n Helper function to calculate the sum of digits of a number.\n \"\"\"\n return sum(int(digit) for digit in str(num))\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00097669", "row_id": 97669, "seed_ids": "[21180]" }
0.68578
Taco_97669
I
[ "sum_of_digits", "sequence_of_sums" ]
2
[ [ "sequence_of_sums", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c9e0554664aff1fea5f9e7e8634dee99529aa814
f1e33f92e0588fb89f02a5a9408e5b92e51a523c
v1.0
instruct
Taco
Taco_97696_I
Ravi is a math enthusiast who likes to play with prime numbers. One day, he decided to combine his love for prime numbers and programming. He designed a challenge in which, given a positive integer `N`, he needs to find the smallest prime number greater than `N`. Your task is to create a function called `nextPrime()`...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += ...
from solution import nextPrime def test_nextPrime_basic(): assert nextPrime(10) == 11 assert nextPrime(14) == 17 assert nextPrime(20) == 23 def test_nextPrime_edge_cases(): assert nextPrime(1) == 2 assert nextPrime(2) == 3 assert nextPrime(3) == 5 def test_nextPrime_large_number(): assert...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the smallest prime number greater than N.", "function_declaration": "def nextPrime(N):", "function_name": "ne...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097696", "row_id": 97696, "seed_ids": "[24787]" }
0.616617
Taco_97696
I
[ "is_prime", "nextPrime" ]
2
[ [ "nextPrime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
499fc5fa0fb5c8e83ad6f0585be28e76bb8b5a6c
eb1dfe0579777a29ae0f6ba66ed8d0bbb79fc1c4
v1.0
instruct
Taco
Taco_97748_I
Write a function that takes an integer input n and returns a list of all integers from 1 to n that are palindromes. A palindrome is a number that reads the same forwards and backwards, such as 121 or 454. Your function should efficiently identify palindromic numbers within the given range and must handle a moderately l...
def is_palindrome(num): """Helper function to check if a given number is a palindrome.""" return str(num) == str(num)[::-1] def find_palindromes(n): """ Returns a list of all palindrome numbers from 1 to n. """ return [i for i in range(1, n + 1) if is_palindrome(i)]
from solution import find_palindromes def test_find_palindromes_small_range(): assert find_palindromes(10) == [1, 2, 3, 4, 5, 6, 7, 8, 9] def test_find_palindromes_medium_range(): assert find_palindromes(50) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44] def test_find_palindromes_large_range(): assert fi...
[ { "docstring": "Helper function to check if a given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Returns a list of all palindrome numbers from 1 to n.", "function_declaration": ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(number):\n \"\"\"\n Helper function to check if a number is a palindrome.\n \"\"\"\n return str(number) == str(number)[::-1]\n\ndef p...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097748", "row_id": 97748, "seed_ids": "[2375]" }
0.706545
Taco_97748
I
[ "is_palindrome", "find_palindromes" ]
2
[ [ "find_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ae8272e4e76e8ae58f2921eeed479b7d0015fac
1053e14d17df4b33c71e5d069756793de44d2a5a
v1.0
instruct
Taco
Taco_97755_I
Problem Balan, a renowned chef, is creating a new recipe that involves multiple ingredients. Given a list of ingredients and their quantities in grams, Balan wants to standardize the recipe so that all ingredient quantities are scaled down by their greatest common divisor (GCD). Your task is to help Balan prepare the ...
import math from functools import reduce def gcd(a, b): """ Returns the greatest common divisor of a and b. """ while b: a, b = b, a % b return a def gcd_of_list(numbers): """ Returns the gcd of a list of numbers. """ return reduce(gcd, numbers) def standardized_recipe_qua...
from solution import gcd, gcd_of_list, standardized_recipe_quantities def test_gcd(): assert gcd(54, 24) == 6 assert gcd(17, 13) == 1 assert gcd(100, 25) == 25 assert gcd(1, 0) == 1 def test_gcd_of_list(): assert gcd_of_list([12, 15, 18, 24, 30]) == 3 assert gcd_of_list([35, 49, 63, 91, 98, 12...
[ { "docstring": "Returns the greatest common divisor of a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the gcd of a list of numbers.", "function_declaration": "def gcd_of_list(numbers):", "function_nam...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef compute_gcd(x, y):\n \"\"\"\n Helper function to compute the GCD of two numbers.\n \"\"\"\n while y:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00097755", "row_id": 97755, "seed_ids": "[16255]" }
0.674352
Taco_97755
I
[ "gcd", "gcd_of_list", "standardized_recipe_quantities" ]
3
[ [ "gcd_of_list", "gcd" ], [ "standardized_recipe_quantities", "gcd_of_list" ] ]
2
[]
false
[]
false
pytest
true
[]
true
dd41ef2208238fb22613390ef30db6e709ebd6b8
c698b7e7e1c73845c318b12a464010d5fa20e93e
v1.0
instruct
Taco
Taco_97888_I
The kingdom of Varantine has decided to build a new road network to connect its cities. The kingdom has n cities and needs to lay down exactly n-1 roads to ensure all cities are connected with the minimum total road length. Each road connects exactly two cities and has a certain length, and they want to minimize the to...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif r...
import pytest from solution import min_cost_to_connect_cities def test_example1(): assert min_cost_to_connect_cities(4, 5, [(1, 2, 1), (2, 3, 2), (3, 4, 3), (1, 3, 2), (1, 4, 3)]) == 6 def test_example2(): assert min_cost_to_connect_cities(3, 1, [(1, 2, 4)]) == -1 def test_single_city(): assert min_cost_...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, ran...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097888", "row_id": 97888, "seed_ids": "[6018]" }
0.777319
Taco_97888
I
[ "find", "union", "min_cost_to_connect_cities" ]
3
[ [ "min_cost_to_connect_cities", "find" ], [ "min_cost_to_connect_cities", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
f6188089bc294874b3e7c88c86ae5f59cf803976
3cdd4297a9490363131d7154a5d30a3563bc48c9
v1.0
instruct
Taco
Taco_97895_I
A new company called "Delivery Heroes" wants to optimize their package delivery routes. They operate in a city represented as a grid where intersections are connected by roads in a bidirectional manner. The company wants to start their delivery from their headquarters and return to it, covering each road exactly once t...
def is_eulerian_circuit_possible(n, m, edges): if n == 0: return "No" from collections import defaultdict graph = defaultdict(list) degree = [0] * (n + 1) for u, v in edges: graph[u].append(v) graph[v].append(u) degree[u] += 1 degree[v] += 1 ...
import pytest from solution import delivery_heroes_input_manager def test_case_1(): input_data = [ (4, 4), (1, 2), (2, 3), (3, 4), (4, 1), (3, 2), (1, 2), (2, 3), (5, 4), (1, 2), (2, 3), (3, 1), (4, 5), ...
[ { "docstring": null, "function_declaration": "def is_eulerian_circuit_possible(n, m, edges):", "function_name": "is_eulerian_circuit_possible", "parameter_list": "(n, m, edges)" }, { "docstring": null, "function_declaration": "def delivery_heroes_input_manager(input_list):", "functio...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_eulerian_circuit_possible(n, m, edges):\n from collections import defaultdict, deque\n\n if n == 0:\n return \"No\"\n \n if m == 0:\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00097895", "row_id": 97895, "seed_ids": "[1150]" }
0.65177
Taco_97895
I
[ "is_eulerian_circuit_possible", "delivery_heroes_input_manager" ]
2
[ [ "delivery_heroes_input_manager", "is_eulerian_circuit_possible" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a8768d3f1df40418a1970c1a7ad4388a9b2a0a1d
37596f50c2987e685f6fda222aac27f42d515d98
v1.0
instruct
Taco
Taco_97939_I
A company organizes a marathon event every year and needs help to determine the number of participants who have completed the course within different time brackets. The marathon track is M kilometers long, and each participant's finish time (in hours) is recorded. Write a function that categorizes participants into var...
def categorize_finishers(times): """ Categorizes participants into various time brackets and counts the number of participants in each bracket. :param times: List of finish times. :return: Dictionary with count of participants in each category. """ brackets = { "Less than 2 hours": 0, ...
import pytest from solution import categorize_finishers, marathon_results def test_categorize_finishers(): times = [1.5, 3.2, 4.5, 2.9, 1.8] result = categorize_finishers(times) assert result["Less than 2 hours"] == 2 assert result["2 hours to 4 hours"] == 2 assert result["More than 4 hours"] == 1 ...
[ { "docstring": "Categorizes participants into various time brackets and counts the number of participants in each bracket.\n\n:param times: List of finish times.\n:return: Dictionary with count of participants in each category.", "function_declaration": "def categorize_finishers(times):", "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": "def categorize_finish_times(m, n, finish_times):\n \"\"\"\n Categorizes the finish times into the defined time brackets\n\n Parameters:\n m (int): Leng...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00097939", "row_id": 97939, "seed_ids": "[14782]" }
0.596598
Taco_97939
I
[ "categorize_finishers", "marathon_results" ]
2
[ [ "marathon_results", "categorize_finishers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fa652736f05627f2034835a4266cc8825cdb5da2
eb2b793a2535b30de521cb1fc49c64864afbc507
v1.0
instruct
Taco
Taco_98137_I
You are given the task of organizing a sequence of events such that each event's requirements are satisfied. Each event has a name and a list of preceding events that must be completed before it can start. Here's how you should handle this: -----Input----- The input starts with a single integer n (1 ≤ n ≤ 100), repres...
def find_event_sequence(n, events): from collections import defaultdict, deque # Step 1: Parse input and build the graph event_graph = defaultdict(list) indegree = {event: 0 for event in events} for event, precedents in events.items(): if precedents: for prerequisite in pre...
from solution import organize_events def test_simple_case(): n = 4 event_list = [ "EventA -", "EventB EventA", "EventC EventA", "EventD EventB EventC" ] assert organize_events(n, event_list) == 'EventA EventB EventC EventD' def test_impossible_case(): n = 3 even...
[ { "docstring": null, "function_declaration": "def find_event_sequence(n, events):", "function_name": "find_event_sequence", "parameter_list": "(n, events)" }, { "docstring": null, "function_declaration": "def organize_events(n, event_list):", "function_name": "organize_events", "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef order_events(n, events):\n # Step 1: Create a graph and a dictionary to keep track of in-degrees\n graph = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00098137", "row_id": 98137, "seed_ids": "[14174]" }
0.570439
Taco_98137
I
[ "find_event_sequence", "organize_events" ]
2
[ [ "organize_events", "find_event_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2d290f0e76ea90469b3bd5845fe7ea1c7add8228
cb34a33b4e6a448f2608eca8b125b258af2e8eb0
v1.0
instruct
Taco
Taco_98149_I
A wealthy philanthropist wants to support promising startups by providing seed funding. He decides to adopt a system where the total amount he will spend is determined by a sequence of checks. Each check can only endorse an integer value that is a power of 2 (e.g., 1, 2, 4, 8, 16, ...). However, he wants to minimize th...
def min_checks(T): """ Calculates the minimum number of checks required to achieve the given total amount T. Each check can endorse an amount that is a power of 2. """ checks = 0 while T > 0: highest_power_of_2 = 1 << (T.bit_length() - 1) T -= highest_power_of_2 checks +=...
from solution import min_checks, process_checks def test_min_checks(): assert min_checks(23) == 4 assert min_checks(37) == 3 assert min_checks(1024) == 1 assert min_checks(0) == 0 assert min_checks(1) == 1 assert min_checks(2) == 1 assert min_checks(3) == 2 # 2 + 1 assert min_checks(16...
[ { "docstring": "Calculates the minimum number of checks required to achieve the given total amount T.\nEach check can endorse an amount that is a power of 2.", "function_declaration": "def min_checks(T):", "function_name": "min_checks", "parameter_list": "(T)" }, { "docstring": "Processes mu...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_checks(total_amount):\n \"\"\"\n Return the minimum number of checks needed to endorse exactly the specified amount.\n Each check can only endorse...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00098149", "row_id": 98149, "seed_ids": "[2479]" }
0.625573
Taco_98149
I
[ "min_checks", "process_checks" ]
2
[ [ "process_checks", "min_checks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6bc5c9f6a470a3b579af7f4254fa0888b285b78b
02dbc6cc1a9b9c647ebb6aa1912cd3098b11a3a5
v1.0
instruct
Taco
Taco_98150_I
Square Grid of Primes You are given an `n x n` grid. Each cell in the grid should be filled with a number such that the number is prime and no two adjacent cells (horizontally, vertically, or diagonally) contain the same prime number. Write a program that generates a valid grid for given `n`. A prime number is a natu...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def generate_primes(n): pr...
import pytest from solution import generate_prime_grid def test_generate_prime_grid_1x1(): expected_output = [[2]] assert generate_prime_grid(1) == expected_output def test_generate_prime_grid_2x2(): result = generate_prime_grid(2) assert len(result) == 2 assert all(len(row) == 2 for row in result...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def generate_primes(n):", "function_name": "generate_primes", "parameter_list": "(n)" }, { "docstring...
[ 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 if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00098150", "row_id": 98150, "seed_ids": "[17852]" }
0.648448
Taco_98150
I
[ "is_prime", "generate_primes", "generate_prime_grid", "print_grid" ]
4
[ [ "generate_prime_grid", "generate_primes" ], [ "generate_primes", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b83b0776909b6578e6bc76c491108d59b53efb9d
68dfa4c0e00a8f04b51be29bfa94c2749a8a40db
v1.0
instruct
Taco
Taco_98221_I
In a mysterious forest, Marauders and Guardians roam through a grid. Guardians always protect the Marauders they encounter within a certain range. Each Marauder seeks to be protected by at least one Guardian. The Marauders and Guardians can move between adjacent cells that share a side. The forest contains obstacles th...
from collections import deque def bfs(forest, starts, n, m): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] dist = [[float('inf')] * m for _ in range(n)] q = deque() for start in starts: r, c, t = start q.append((r, c, t)) dist[r][c] = 0 while q: r, c, t = q.popleft...
import pytest from solution import min_time_to_protect_all_marauders def test_example_1(): n = 4 m = 4 marauders = 2 guardians = 2 forest = [ "....", ".#..", "..#.", "...." ] p = 2 marauder_locs = [(0, 0, 1), (2, 2, 2)] guardian_locs = [(1, 1, 1), (3,...
[ { "docstring": null, "function_declaration": "def bfs(forest, starts, n, m):", "function_name": "bfs", "parameter_list": "(forest, starts, n, m)" }, { "docstring": null, "function_declaration": "def min_time_to_protect_all_marauders(n, m, marauders, guardians, forest, p, marauder_locs, g...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\nimport sys\n\ndef minimal_protection_time(grid, marauders, guardians, n, m, p):\n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00098221", "row_id": 98221, "seed_ids": "[21500]" }
0.647744
Taco_98221
I
[ "bfs", "min_time_to_protect_all_marauders" ]
2
[ [ "min_time_to_protect_all_marauders", "bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
173e186525ad99cdf979797d21fbad6227904c8a
addc08ce07d8dbcfce26e3e1faeaa159ad76af7c
v1.0
instruct
Taco
Taco_98273_I
A team of M scientists is working in a well-organized research facility with state-of-the-art equipment. Each scientist can either collaborate or work independently on various projects. You're given an M x M matrix where the element at position (i, j) indicates the effectiveness of scientist i collaborating with scient...
from itertools import permutations def total_effectiveness(order, matrix): total = 0 for i in range(len(order)): for j in range(len(order)): total += matrix[order[i]][order[j]] return total def optimal_order(matrix): M = len(matrix) all_orders = permutations(range(M)) max_e...
import pytest from solution import solve, total_effectiveness, optimal_order def test_single_case(): T = 1 test_cases = [(3, [[1, 2, 3], [4, 5, 6], [7, 8, 9]])] expected = ["0 1 2"] assert solve(T, test_cases) == expected def test_multiple_cases(): T = 2 test_cases = [ (3, [[1, 2, 3], ...
[ { "docstring": null, "function_declaration": "def total_effectiveness(order, matrix):", "function_name": "total_effectiveness", "parameter_list": "(order, matrix)" }, { "docstring": null, "function_declaration": "def optimal_order(matrix):", "function_name": "optimal_order", "par...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef calculate_effectiveness_order(matrix, order):\n n = len(matrix)\n total_effectiveness = 0\n for i in range(n-1):...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00098273", "row_id": 98273, "seed_ids": "[19552]" }
0.632491
Taco_98273
I
[ "total_effectiveness", "optimal_order", "solve" ]
3
[ [ "optimal_order", "total_effectiveness" ], [ "solve", "optimal_order" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b64ab70e7c46c7ef97e91c2ca1f4bf18682e6a87
210c42056d614ebb4503163f555cb1c4cfd48ff3