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_34611_I
John is working on implementing a sorting algorithm. He is fascinated by heaps and heap sort particularly caught his interest. However, John is having trouble understanding how to construct a valid max heap from an unsorted array. Help John by writing a function to transform any given unsorted array into a max heap. A ...
def max_heapify(arr, n, i): """ To heapify a subtree rooted with node i which is an index in arr[]. n is the size of the heap. """ largest = i left = 2 * i + 1 right = 2 * i + 2 # See if left child of root exists and is greater than root if left < n and arr[left] > arr[largest]: ...
from solution import build_max_heap def is_valid_max_heap(arr): """ Helper function to verify if the array is a valid max heap. """ n = len(arr) for i in range(n // 2): left = 2 * i + 1 right = 2 * i + 2 if left < n and arr[i] < arr[left]: return False if...
[ { "docstring": "To heapify a subtree rooted with node i which is an index in arr[].\nn is the size of the heap.", "function_declaration": "def max_heapify(arr, n, i):", "function_name": "max_heapify", "parameter_list": "(arr, n, i)" }, { "docstring": "Function to build a Max-Heap from the gi...
[ 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_heapify(arr, N, i):\n \"\"\"\n Function to heapify a subtree rooted with node i which is an index in arr[].\n N is the size of heap.\n \"\"\"\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00034611", "row_id": 34611, "seed_ids": "[5755]" }
0.522906
Taco_34611
I
[ "max_heapify", "build_max_heap" ]
2
[ [ "build_max_heap", "max_heapify" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4cb4e7c46dd31069b551ccd82b938173ed8840c5
289fcd7290bf8f8aa4149f868211a1490a8e164f
v1.0
instruct
Taco
Taco_34659_I
Sam is building a new library system for an online bookstore. Each book in the library will be uniquely identified by an International Standard Book Number (ISBN). Each ISBN in this system is a 13-digit number, but to prevent errors in storing and accessing these ISBNs, Sam wants to validate them using a specific check...
def validate_isbn(isbn): """ Validates a single ISBN-13 number. :param isbn: A 13-digit string representing the ISBN number. :return: A string "valid" if the ISBN is valid, otherwise "invalid". """ total_sum = 0 for i, digit in enumerate(isbn): n = int(digit) if i % 2 =...
from solution import validate_isbn, validate_isbns def test_single_valid_isbn(): assert validate_isbn("9780470059029") == "valid" assert validate_isbn("9781593275846") == "valid" def test_single_invalid_isbn(): assert validate_isbn("1234567890123") == "invalid" assert validate_isbn("9780470059028") ==...
[ { "docstring": "Validates a single ISBN-13 number.\n\n:param isbn: A 13-digit string representing the ISBN number.\n:return: A string \"valid\" if the ISBN is valid, otherwise \"invalid\".", "function_declaration": "def validate_isbn(isbn):", "function_name": "validate_isbn", "parameter_list": "(isb...
[ 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 validate_isbn(isbn):\n \"\"\"\n Validates a single ISBN-13 number.\n\n :param isbn: A 13-digit string representing the ISBN number.\n :return: A st...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00034659", "row_id": 34659, "seed_ids": "[16581]" }
0.553074
Taco_34659
I
[ "validate_isbn", "validate_isbns" ]
2
[ [ "validate_isbns", "validate_isbn" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f4eb305462a08eaefeb2df65e66c326c40fa3616
882e87199863f6a06018a04de8498ea7f0f18962
v1.0
instruct
Taco
Taco_34686_I
In a city, there are n intersections connected by m bidirectional roads. Each road has a length in minutes it takes to travel. The city is planning to construct a new train line to expedite transportation. The train line consists of two stations, each located at one of the intersections. Citizens can travel from any ...
import heapq def dijkstra(n, graph, start): distances = [float('inf')] * n distances[start] = 0 queue = [(0, start)] while queue: current_dist, u = heapq.heappop(queue) if current_dist > distances[u]: continue for v, weight in graph[u]: ...
from solution import minimize_diameter def test_example_case(): n = 6 m = 7 edges = [ (1, 2, 4), (2, 3, 3), (3, 4, 5), (1, 5, 8), (5, 6, 6), (4, 6, 1), (3, 6, 4) ] assert minimize_diameter(n, m, edges) == 8 def test_small_case(): n = 2 ...
[ { "docstring": null, "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def calculate_diameter_with_train_station(n, roads):", "function_name": "calculate_diamet...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n \"\"\"\n Perform Dijkstra's algorithm to find shortest paths from start node to all other nodes.\n \"\"\"...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00034686", "row_id": 34686, "seed_ids": "[5806]" }
0.732598
Taco_34686
I
[ "dijkstra", "calculate_diameter_with_train_station", "minimize_diameter" ]
3
[ [ "calculate_diameter_with_train_station", "dijkstra" ], [ "minimize_diameter", "calculate_diameter_with_train_station" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e6cd0db4d75c6a45e2be9025cbf49ee1c0926b00
4d776ed80c63cf7c00d2963ba612375f4d883969
v1.0
instruct
Taco
Taco_34712_I
You are given a list of integers where each integer represents the height of a building. The buildings form a row and are placed next to each other. A building with a greater height blocks the view of buildings to its right that are shorter. Your task is to determine the number of buildings that have a view of the suns...
def count_sunset_view_buildings(buildings): """ Returns the number of buildings that have a view of the sunset. """ max_height = 0 count = 0 # Loop through buildings from right to left for height in reversed(buildings): if height > max_height: count += 1 max_h...
def test_count_sunset_view_buildings(): assert count_sunset_view_buildings([3, 7, 8, 3, 6, 1]) == 3 assert count_sunset_view_buildings([1, 2, 3, 4, 5]) == 1 assert count_sunset_view_buildings([5, 4, 3, 2, 1]) == 5 assert count_sunset_view_buildings([10, 20, 30, 40]) == 1 assert count_sunset_view_bui...
[ { "docstring": "Returns the number of buildings that have a view of the sunset.", "function_declaration": "def count_sunset_view_buildings(buildings):", "function_name": "count_sunset_view_buildings", "parameter_list": "(buildings)" }, { "docstring": null, "function_declaration": "def su...
[ 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_sunset_view_buildings(buildings):\n \"\"\"\n Returns the number of buildings that have a view of the sunset.\n \"\"\"\n max_height = 0\n c...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00034712", "row_id": 34712, "seed_ids": "[24272]" }
0.793095
Taco_34712
I
[ "count_sunset_view_buildings", "sunset_views", "process_input_and_output" ]
3
[ [ "process_input_and_output", "sunset_views" ], [ "sunset_views", "count_sunset_view_buildings" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d134e861a4f14fa06559a98ffafebb0f4f3bdf1f
5e03d4862f51abd9fa96feed9b56ff181eac8b16
v1.0
instruct
Taco
Taco_34714_I
Emma loves solving puzzles and one day she stumbled upon an interesting puzzle involving letters and words. Given an initial and a target word, the goal is to transform the initial word into the target word by changing one letter at a time. Each intermediate word formed in this process must be a valid English word, and...
from collections import deque def is_one_letter_different(word1, word2): """ Check if the two words differ by exactly one letter. """ count = 0 for a, b in zip(word1, word2): if a != b: count += 1 if count > 1: return False return count == 1 def min_tran...
def test_min_transformations_possible(): assert min_transformations("hit", "cog", ["hot", "dot", "dog", "lot", "log", "cog"]) == 4 def test_min_transformations_impossible(): assert min_transformations("apple", "radar", ["grape", "tiger", "sugar", "lemon", "radar"]) == -1 def test_min_transformations_no_steps_...
[ { "docstring": "Check if the two words differ by exactly one letter.", "function_declaration": "def is_one_letter_different(word1, word2):", "function_name": "is_one_letter_different", "parameter_list": "(word1, word2)" }, { "docstring": null, "function_declaration": "def min_transformat...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_one_letter_different(word1, word2):\n \"\"\"\n Check if the two words differ by exactly one letter.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00034714", "row_id": 34714, "seed_ids": "[18063]" }
0.690632
Taco_34714
I
[ "is_one_letter_different", "min_transformations" ]
2
[ [ "min_transformations", "is_one_letter_different" ] ]
1
[]
false
[]
false
pytest
false
[]
true
96fdf0c2701dfcc43ae18cf59d1150843252292a
914ec78665e2c99f2d4ac46b058dba03ccb52e3e
v1.0
instruct
Taco
Taco_34753_I
You are given a binary tree. Implement a function that converts this binary tree into its mirror image. The mirror of a binary tree is another binary tree with left and right children of all non-leaf nodes interchanged. Write a function `mirror_tree(root)` where: - `root` is the root of the given binary tree. ### Inp...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def mirror_tree(root): if root is None: return None # Swap left and right subtrees root.left, root.right = root.right, root.left # Mirror th...
from solution import mirror_tree, pre_order_traversal, build_tree_from_string, handle_tests def test_single_node(): root = build_tree_from_string("1") mirrored_root = mirror_tree(root) assert pre_order_traversal(mirrored_root) == [1] def test_simple_tree(): root = build_tree_from_string("1(2)(3)") ...
[]
[ 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 typing import Optional\n\nclass TreeNode:\n def __init__(self, val: int = 0, left: 'TreeNode' = None, right: 'TreeNode' = None):\n self.val = val\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00034753", "row_id": 34753, "seed_ids": "[381]" }
0.594745
Taco_34753
I
[ "mirror_tree", "pre_order_traversal", "build_tree_from_string", "handle_tests" ]
4
[ [ "handle_tests", "build_tree_from_string" ], [ "handle_tests", "mirror_tree" ], [ "handle_tests", "pre_order_traversal" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
d98ba157a0f80d6970abade1001a8bc7a51166e0
93d423f0be743b6963e31a79d95b68e8da7decc9
v1.0
instruct
Taco
Taco_34784_I
Celebrity Problem Imagine you are at a party with `n` people and among them, there may be a celebrity. A celebrity is defined as someone who is known by everyone but knows no one else at the party. You are given a helper function `knows(a, b)` that returns: - `True` if person `a` knows person `b` - `False` otherwise....
def findCelebrity(n): # Helper function `knows(a, b)` is assumed to be provided by the system. You should not implement it. # Step 1: Identify a potential candidate for being the celebrity candidate = 0 for i in range(1, n): if knows(candidate, i): candidate = i # Step ...
import pytest from solution import findCelebrity # Mocking the `knows` function using pytest's monkeypatch feature def test_findCelebrity_with_celebrity(monkeypatch): def knows(a, b): # Example setup with 4 people and person 2 as the celebrity known_relations = { (0, 1): True, (0, 2): T...
[ { "docstring": null, "function_declaration": "def findCelebrity(n):", "function_name": "findCelebrity", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def knows(a, b):", "function_name": "knows", "parameter_list": "(a, b)" } ]
[ 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 findCelebrity(n: int) -> int:\n \"\"\"\n Returns the index of the celebrity if there is one, otherwise returns -1.\n \"\"\"\n # Assume the first pe...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00034784", "row_id": 34784, "seed_ids": "[4455]" }
0.507834
Taco_34784
I
[ "findCelebrity", "knows" ]
2
[ [ "findCelebrity", "knows" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3ca82af9bfa1baf5ddfd909dbf9ceb034d8ef3a0
05aa78d40ac084ebc22533a61bceb30c0e4806c6
v1.0
instruct
Taco
Taco_34787_I
You are given an array A of N integers. Your task is to remove exactly one integer from the array such that the sum of the remaining elements is divisible by N-1. If multiple such integers exist, output the minimum value among them. If there is no such integer, output -1. ------ Input Format ------ - The first line ...
def find_minimum_to_remove(arr): n = len(arr) total_sum = sum(arr) if total_sum % (n - 1) == 0: return min(arr) for num in arr: if (total_sum - num) % (n - 1) == 0: return num return -1 def process_test_cases(test_cases): results = [] for n, arr in test_cases: ...
from solution import find_minimum_to_remove, process_test_cases, input_processing def test_find_minimum_to_remove(): assert find_minimum_to_remove([1, 2, 3, 4]) == 1 assert find_minimum_to_remove([1, -1, 1, -1, 2]) == 2 assert find_minimum_to_remove([2, 2, 2]) == 2 def test_find_minimum_to_remove_no_solut...
[ { "docstring": null, "function_declaration": "def find_minimum_to_remove(arr):", "function_name": "find_minimum_to_remove", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def process_test_cases(test_cases):", "function_name": "process_test_cases", "par...
[ 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 min_removal_to_divisible(arr):\n N = len(arr)\n total_sum = sum(arr)\n \n possible_removals = [x for x in arr if (total_sum - x) % (N - 1) == 0]\n ...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00034787", "row_id": 34787, "seed_ids": "[13378]" }
0.756184
Taco_34787
I
[ "find_minimum_to_remove", "process_test_cases", "input_processing" ]
3
[ [ "process_test_cases", "find_minimum_to_remove" ] ]
1
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
162831f5cde6faf8040dc0398874ebe793ccea42
4b9df6d5f551b4b19283c8547fb97642501d0652
v1.0
instruct
Taco
Taco_34844_I
Given a string containing only digits, generate all possible valid IP addresses that can be obtained by inserting three dots into the string. A valid IP address consists of exactly four integers (each between 0 and 255, inclusive) separated by dots, where the string must not contain any leading zeros unless the integer...
def is_valid(segment): """ Check if a segment of the IP address is valid. """ if len(segment) > 1 and segment[0] == '0': return False return 0 <= int(segment) <= 255 def generate_ip_addresses(s): """ Generate all valid IP addresses from a given string of digits. """ def back...
from solution import generate_ip_addresses, process_cases, is_valid def test_is_valid(): assert is_valid("255") assert not is_valid("256") assert is_valid("0") assert not is_valid("00") assert is_valid("1") assert not is_valid("01") assert is_valid("10") def test_generate_ip_addresses_case...
[ { "docstring": "Check if a segment of the IP address is valid.", "function_declaration": "def is_valid(segment):", "function_name": "is_valid", "parameter_list": "(segment)" }, { "docstring": "Generate all valid IP addresses from a given string of digits.", "function_declaration": "def g...
[ 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 restore_ip_addresses(s):\n def is_valid(segment):\n if not segment:\n return False\n if len(segment) > 1 and segment[0] == '0':\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00034844", "row_id": 34844, "seed_ids": "[10813]" }
0.532388
Taco_34844
I
[ "is_valid", "generate_ip_addresses", "process_cases" ]
3
[ [ "generate_ip_addresses", "is_valid" ], [ "process_cases", "generate_ip_addresses" ] ]
2
[ "process_cases" ]
false
[]
false
pytest
true
[]
true
1b38bf3ebb44de5547c9ca7f6f7ba53c04cf1612
d31179ae32cc7a43b843a2dd5c19603062afe2ab
v1.0
instruct
Taco
Taco_34845_I
In a futuristic city, a new transportation system called TelePort has been introduced, which allows people to instantly travel between special nodes placed at various coordinates on an infinite 2D grid. The system is controlled by a central computer that tracks the status of each node. A special maintenance team has ...
import math from collections import deque def calculate_distance(node1, node2): return math.sqrt((node1[0] - node2[0]) ** 2 + (node1[1] - node2[1]) ** 2) def max_time_to_report_issue(n, r, t, coordinates): if n == 1: return 0 if t >= 0 else -1 graph = {i: [] for i in range(n)} for i in range(...
from solution import max_time_to_report_issue def test_example_1(): n = 4 r = 5 t = 10 coordinates = [(0, 0), (3, 4), (-3, -4), (6, 8)] assert max_time_to_report_issue(n, r, t, coordinates) == 2 def test_example_2(): n = 3 r = 2 t = 5 coordinates = [(0, 0), (5, 5), (-1, -1)] as...
[ { "docstring": null, "function_declaration": "def calculate_distance(node1, node2):", "function_name": "calculate_distance", "parameter_list": "(node1, node2)" }, { "docstring": null, "function_declaration": "def max_time_to_report_issue(n, r, t, coordinates):", "function_name": "max...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom collections import deque\n\ndef time_to_report_issue(n, r, t, nodes):\n def euclidean_distance(node1, node2):\n return math.sqrt((node1...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00034845", "row_id": 34845, "seed_ids": "[960]" }
0.631187
Taco_34845
I
[ "calculate_distance", "max_time_to_report_issue" ]
2
[ [ "max_time_to_report_issue", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86156b59cf7b71bbafd6b0354406770313e85407
6d33da670fe0f2ecf918125614b4a2fda994c023
v1.0
instruct
Taco
Taco_34856_I
Gretta is a roboticist participating in RoboCon, a competition for autonomous robots. In the competition, each robot needs to navigate through a grid from the top-left corner to the bottom-right corner. However, there are obstacles scattered across the grid that the robots need to avoid. The grid is represented as a m...
def count_paths(grid, n, m): """ Returns the number of distinct paths from the top-left corner to the bottom-right corner of the grid. """ if grid[0][0] == '#' or grid[n-1][m-1] == '#': return 0 dp = [[0] * m for _ in range(n)] dp[0][0] = 1 # Start position for i in range(n): ...
from solution import distinct_paths def test_example_1(): grid = [ ['.', '.', '.'], ['.', '#', '.'], ['.', '.', '.'] ] assert distinct_paths(3, 3, grid) == 2 def test_example_2(): grid = [ ['.', '#', '.'], ['#', '.', '#'], ['.', '.', '.'] ] asser...
[ { "docstring": "Returns the number of distinct paths from the top-left corner to the bottom-right corner of the grid.", "function_declaration": "def count_paths(grid, n, m):", "function_name": "count_paths", "parameter_list": "(grid, n, m)" }, { "docstring": null, "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 num_paths(grid, n, m):\n # Use dynamic programming to compute the number of paths\n if grid[0][0] == '#' or grid[n-1][m-1] == '#':\n return 0\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00034856", "row_id": 34856, "seed_ids": "[7868]" }
0.736591
Taco_34856
I
[ "count_paths", "distinct_paths" ]
2
[ [ "distinct_paths", "count_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ebd35523146147c432cd3ad88b20e42890fa7dbe
89ae97aadaa3399cc1e94310a6d84d9735d38bc8
v1.0
instruct
Taco
Taco_34936_I
You are given an undirected graph represented as an adjacency list, with vertices numbered from 1 to N and M edges. Your task is to determine if there exists a path in this graph that visits exactly K distinct edges and returns to the starting vertex. If such a path exists, output "YES", otherwise output "NO". -----...
def can_find_k_edge_cycle(n, m, edges, k): from collections import defaultdict import itertools graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) def dfs(current, visited_edges, path_len, start): if path_len == k and current == ...
def test_sample1(): input_data = "5 6\n1 2\n1 3\n2 3\n3 4\n4 5\n5 1\n5\n" assert solve(input_data) == "YES" def test_sample2(): input_data = "4 3\n1 2\n2 3\n3 4\n3\n" assert solve(input_data) == "NO" def test_no_possible_cycle(): input_data = "3 3\n1 2\n2 3\n3 1\n4\n" assert solve(input_data) ...
[ { "docstring": null, "function_declaration": "def can_find_k_edge_cycle(n, m, edges, k):", "function_name": "can_find_k_edge_cycle", "parameter_list": "(n, m, edges, k)" }, { "docstring": null, "function_declaration": "def solve(input_data):", "function_name": "solve", "parameter...
[ 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_cycle(N, M, edges, K):\n from collections import defaultdict, deque\n\n def dfs(vertex, start, depth, visited, current_path):\n if depth == K...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00034936", "row_id": 34936, "seed_ids": "[7835]" }
0.767127
Taco_34936
I
[ "can_find_k_edge_cycle", "solve" ]
2
[ [ "solve", "can_find_k_edge_cycle" ] ]
1
[]
false
[]
false
pytest
false
[]
true
501ef4f18fd1dee4980f06150c9ec51a4295244b
e1c838a7028f11b7d7feaf85cf2e73a2d0f9ce91
v1.0
instruct
Taco
Taco_35023_I
You are given a list of integers, the task is to find the largest number that can be formed by combining the integers. Example 1: Input: [3, 30, 34, 5, 9] Output: 9534330 Your Task: You don't need to read input or print anything. Your task is to complete the function largestNumber() which takes a list of integers as ...
from functools import cmp_to_key def compare(x, y): # Compare two numbers by concatenating them in both possible orders if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largestNumber(nums): """ Returns the largest number that can be formed by ...
from solution import largestNumber def test_single_number(): assert largestNumber([10]) == "10" def test_two_numbers(): assert largestNumber([10, 2]) == "210" def test_multiple_numbers(): assert largestNumber([3, 30, 34, 5, 9]) == "9534330" def test_leading_zeros(): assert largestNumber([0, 0, 0]) =...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Returns the largest number that can be formed by combining the integers.", "function_declaration": "def largestNumber(nums):", "function_name":...
[ 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 functools import cmp_to_key\n\ndef compare(x, y):\n # Compare two numbers as strings in both possible orders\n if x + y > y + x:\n return -1\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035023", "row_id": 35023, "seed_ids": "[830]" }
0.646504
Taco_35023
I
[ "compare", "largestNumber" ]
2
[ [ "largestNumber", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
58068e91085b409bbb7b4524d8867e66e4c8ec98
a8bbc244cf219c144a3c46aa73c3bed4db050ccf
v1.0
instruct
Taco
Taco_35043_I
You are tasked with developing a logistics program for a small-scale delivery company. The company has `n` warehouses, each located at unique coordinates on a 2D plane, and `m` delivery tasks. Each delivery task involves transporting goods from one warehouse to another. The company wants to minimize the total travel d...
import math def calculate_distance(x1, y1, x2, y2): """ Calculate Euclidean distance between two points (x1, y1) and (x2, y2). """ return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def minimum_total_travel_distance(n, m, warehouses, tasks): """ Calculate the total minimum travel distance for a...
def test_calculate_distance(): assert math.isclose(calculate_distance(0, 0, 3, 4), 5.0) assert math.isclose(calculate_distance(1, 1, 4, 5), 5.0) assert math.isclose(calculate_distance(-1, -1, -4, -5), 5.0) def test_minimum_total_travel_distance(): n = 3 m = 3 warehouses = [(0, 0), (2, 2), (5, 5...
[ { "docstring": "Calculate Euclidean distance between two points (x1, y1) and (x2, y2).", "function_declaration": "def calculate_distance(x1, y1, x2, y2):", "function_name": "calculate_distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": "Calculate the total minimum travel distan...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_total_travel_distance(n, m, warehouses, deliveries):\n def distance(x1, y1, x2, y2):\n return abs(x1 - x2) + abs(y1 - y2)\n \n total_distan...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035043", "row_id": 35043, "seed_ids": "[10619]" }
0.723045
Taco_35043
I
[ "calculate_distance", "minimum_total_travel_distance", "logistics_min_travel_distance" ]
3
[ [ "logistics_min_travel_distance", "minimum_total_travel_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ff69f7e57f356f83bbbda3c2f40a315c5e009842
905b526ae6dc61f074c40ba5fbefbc4c992533e9
v1.0
instruct
Taco
Taco_35100_I
Liam and Noah are playing a game with arrays! The game's rules are as follows: The game starts with an array of $n$ integers. Liam always moves first and they take alternating turns. The first player with no available move loses the game. During each move, the player selects any number of elements from the array (at l...
from math import gcd from functools import reduce def calculate_gcd_of_list(num_list): return reduce(gcd, num_list) def determine_winner(t, games): results = [] for game in games: n, arr = game if len(arr) == 1: # When there is only one element, that single element's GCD i...
from solution import determine_winner def test_single_game(): assert determine_winner(1, [(3, [2, 3, 4])]) == ["NOAH"] assert determine_winner(1, [(4, [5, 10, 15, 20])]) == ["LIAM"] def test_multiple_games(): games = [ (3, [2, 3, 4]), (4, [5, 10, 15, 20]) ] assert determine_winner(...
[ { "docstring": null, "function_declaration": "def calculate_gcd_of_list(num_list):", "function_name": "calculate_gcd_of_list", "parameter_list": "(num_list)" }, { "docstring": null, "function_declaration": "def determine_winner(t, games):", "function_name": "determine_winner", "p...
[ 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 collections import defaultdict\n\ndef game_winner(t, games):\n \"\"\"\n Determine the winner for each game.\n \n Arguments:\n t --...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035100", "row_id": 35100, "seed_ids": "[6060]" }
0.749277
Taco_35100
I
[ "calculate_gcd_of_list", "determine_winner", "main" ]
3
[ [ "determine_winner", "calculate_gcd_of_list" ] ]
1
[]
false
[]
false
pytest
true
[]
true
99a42ecad8a8c8280019df0e4fbbf7fed687a6a0
13daebcb4056497f76b4c33e83a4913f1fd85e99
v1.0
instruct
Taco
Taco_35143_I
The city of Byteburg has recently implemented a new offline bus ticket system. Each bus stop in the city is numbered with a non-negative integer and provides tickets that can be collected by travelers. Travelers can pick up their journey from any bus stop and reach any other bus stop by taking a bus from one stop to an...
def find_connected_components(n, routes): """ Finds the connected components in the graph represented by the bus stops and routes """ from collections import defaultdict, deque # Create a graph as an adjacency list graph = defaultdict(list) for u, v in routes: graph[u].append(v)...
def test_min_additional_routes_to_connect(): assert min_additional_routes_to_connect(5, 3, [(0, 1), (1, 2), (3, 4)]) == 1 assert min_additional_routes_to_connect(4, 2, [(0, 1), (2, 3)]) == 1 assert min_additional_routes_to_connect(6, 0, []) == 5 assert min_additional_routes_to_connect(1, 0, []) == 0 ...
[ { "docstring": "Finds the connected components in the graph represented by the bus stops and routes", "function_declaration": "def find_connected_components(n, routes):", "function_name": "find_connected_components", "parameter_list": "(n, routes)" }, { "docstring": "Returns the minimum numb...
[ 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 needed_routes_to_connect_all_bus_stops(N, M, routes):\n \"\"\"\n Determines the minimum number of additional routes needed to make all bus stops connecte...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035143", "row_id": 35143, "seed_ids": "[20727]" }
0.731067
Taco_35143
I
[ "find_connected_components", "min_additional_routes_to_connect" ]
2
[ [ "min_additional_routes_to_connect", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0c82283639dc70ce9bfaaed79fe615ba63b2a582
52eaf228aed32596809fff19780fdc9a16b369aa
v1.0
instruct
Taco
Taco_35156_I
In a desk organizer, Anna has a set of index cards, each with a unique integer written on it. She loves sorting them efficiently using a custom sorting algorithm. The sorting algorithm she uses can be defined as follows: Given an array of integers, the custom sort arranges the integers in ascending order. However, be...
def count_divisors(x): """ Returns the number of distinct divisors of x. """ count = 0 for i in range(1, int(x ** 0.5) + 1): if x % i == 0: count += 1 if i != x // i: count += 1 return count def custom_sort(arr): """ Custom sort based on t...
from solution import sort_index_cards def test_sort_index_cards_case1(): assert sort_index_cards(5, [2, 3, 4, 6, 5]) == [2, 3, 5, 4, 6] def test_sort_index_cards_case2(): assert sort_index_cards(4, [12, 15, 10, 8]) == [8, 10, 15, 12] def test_sort_index_cards_single_element(): assert sort_index_cards(1, ...
[ { "docstring": "Returns the number of distinct divisors of x.", "function_declaration": "def count_divisors(x):", "function_name": "count_divisors", "parameter_list": "(x)" }, { "docstring": "Custom sort based on the count of divisors.", "function_declaration": "def custom_sort(arr):", ...
[ 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 num_divisors(n):\n \"\"\"\n Calculates the number of distinct divisors of a given integer n.\n \"\"\"\n count = 0\n for i in rang...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035156", "row_id": 35156, "seed_ids": "[987]" }
0.686389
Taco_35156
I
[ "count_divisors", "custom_sort", "sort_index_cards" ]
3
[ [ "custom_sort", "count_divisors" ], [ "sort_index_cards", "custom_sort" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c308e6e3089afbf9b943d94329890484efa30e80
65a29ac00e56785261005839874f437efb93b9e6
v1.0
instruct
Taco
Taco_35246_I
You are an avid explorer and have come across a hidden valley with multiple ancient ruins. Each ruin has treasures you can collect, but the path to each ruin is treacherous with traps that slow your progress. Your goal is to collect all treasures from each ruin while minimizing the overall time spent traversing the va...
from itertools import permutations def compute_travel_time(path, ruins, start): """ Compute the travel time for a given path starting from `start`. """ def manhattan_dist(p1, p2): return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]) total_time, current_pos, collected_weight = 0, start, 0 ...
import pytest from solution import optimal_ruins_visiting_order def test_case_1(): m, n = 5, 5 ruins = {(2, 3): 10, (4, 4): 20, (1, 1): 5, (3, 2): 15, (4, 1): 25} start = (3, 3) result = optimal_ruins_visiting_order(m, n, ruins, start).split() assert set((int(result[i]), int(result[i+1])) for i in ...
[ { "docstring": "Compute the travel time for a given path starting from `start`.", "function_declaration": "def compute_travel_time(path, ruins, start):", "function_name": "compute_travel_time", "parameter_list": "(path, ruins, start)" }, { "docstring": "Determines the optimal order to visit ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef calculate_distance(start, end):\n \"\"\"\n Calculate Manhattan distance between two grid points.\n \"\"\"\n return abs(start[0]...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00035246", "row_id": 35246, "seed_ids": "[7120]" }
0.628645
Taco_35246
I
[ "compute_travel_time", "optimal_ruins_visiting_order", "main" ]
3
[ [ "optimal_ruins_visiting_order", "compute_travel_time" ] ]
1
[]
false
[]
false
pytest
true
[]
true
55a24a0f2a8807db9ca63df90569d649bb63a2d8
35c67cb574253a3cecdee96e43f2fe46e707a05e
v1.0
instruct
Taco
Taco_35247_I
The kingdom of Graphlandia is planning to build a new transportation network of roads connecting its cities. The kingdom has decided to use a system of weighted, undirected edges to represent the roads, where each edge connects two distinct cities and has a certain cost associated with it. You are given a list of citi...
def find_parent(parent, i): if parent[i] == i: return i return find_parent(parent, parent[i]) def union(parent, rank, x, y): root_x = find_parent(parent, x) root_y = find_parent(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root...
def test_input_1(): n, m = 4, 5 edges = [ (1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 3, 6), (1, 4, 7) ] assert min_cost_to_connect_all_cities(n, m, edges) == 12 def test_input_2(): n, m = 3, 3 edges = [ (1, 2, 1), (2, 3, 2), (3, 1, 3) ...
[ { "docstring": null, "function_declaration": "def find_parent(parent, i):", "function_name": "find_parent", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_parent(parent, i):\n if parent[i] == i:\n return i\n return find_parent(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = fi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00035247", "row_id": 35247, "seed_ids": "[13629]" }
0.73219
Taco_35247
I
[ "find_parent", "union", "kruskal", "min_cost_to_connect_all_cities" ]
4
[ [ "kruskal", "find_parent" ], [ "kruskal", "union" ], [ "min_cost_to_connect_all_cities", "kruskal" ], [ "union", "find_parent" ] ]
4
[]
false
[]
false
pytest
false
[]
true
d07a18aa844d2406b8a35bb6fe9bb5cfaf82f8b3
ebed8ff70e974232214f805311f61ea97615d0b8
v1.0
instruct
Taco
Taco_35253_I
Given a positive integer N. The problem is to print the next smallest integer greater than N which is a prime and contains only prime digits (2, 3, 5, 7). Example 1: Input: N = 10 Output: 23 Explanation: The next prime number after 10 is 11. However, 11 contains the digit 1, which is not a prime digit. Hence, we look...
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 has_only_prime_digits(num)...
def test_findNextPrimeWithPrimeDigits_case1(): assert findNextPrimeWithPrimeDigits(10) == 23 def test_findNextPrimeWithPrimeDigits_case2(): assert findNextPrimeWithPrimeDigits(30) == 37 def test_findNextPrimeWithPrimeDigits_case3(): assert findNextPrimeWithPrimeDigits(2) == 3 def test_findNextPrimeWithPr...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def has_only_prime_digits(num):", "function_name": "has_only_prime_digits", "parameter_list": "(num)" }, ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n 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_0
{ "original_instruction": "", "prompt_id": "00035253", "row_id": 35253, "seed_ids": "[8352]" }
0.597416
Taco_35253
I
[ "is_prime", "has_only_prime_digits", "findNextPrimeWithPrimeDigits" ]
3
[ [ "findNextPrimeWithPrimeDigits", "has_only_prime_digits" ], [ "findNextPrimeWithPrimeDigits", "is_prime" ] ]
2
[]
false
[]
false
pytest
false
[]
true
ea6ce821039b4acede544a932cb55c3050b03851
962e655b0838cc106b50aa2ff0702a802c1c83c2
v1.0
instruct
Taco
Taco_35274_I
You are given a railway timetable containing train schedules for various routes. Each route is identified by its start and end stations, along with an array of departure times for the train from the start station. You are tasked with writing a program that answers queries about the earliest possible departure time fr...
def next_train_schedule(routes, queries): """ This function finds the next train schedule based on the provided routes and queries. :param routes: Dictionary with key as (start, end) tuple and value as list of departure times. :param queries: List of (start, end, departure time) tuples. :return...
def test_process_input(): input_data = """3 A B 5 5 15 25 35 55 B C 4 60 120 180 240 A C 3 100 200 300 3 A B 10 A C 50 B C 80""" expected_routes = { ('A', 'B'): [5, 15, 25, 35, 55], ('B', 'C'): [60, 120, 180, 240], ('A', 'C'): [100, 200, 300], } expected_queries = [('A', 'B', 10)...
[ { "docstring": "This function finds the next train schedule based on the provided routes and queries.\n\n:param routes: Dictionary with key as (start, end) tuple and value as list of departure times.\n:param queries: List of (start, end, departure time) tuples.\n:return: List of earliest possible departure time...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_next_train(N, routes, Q, queries):\n timetable = {}\n \n for i in range(N):\n start, end, T = routes[i][:3]\n departure_times = rou...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035274", "row_id": 35274, "seed_ids": "[16099]" }
0.79209
Taco_35274
I
[ "next_train_schedule", "process_input", "find_next_trains" ]
3
[ [ "find_next_trains", "next_train_schedule" ], [ "find_next_trains", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
ff30f3165d6039748deb4cdebc443c3bb3015aac
1dd99b7998f4d5bbc411ef828b7d170e9ab9c00d
v1.0
instruct
Taco
Taco_35311_I
Given a list of numbers, find the subset with the maximum possible sum that does not exceed a given target sum. If there are multiple subsets with the maximum sum, return the one with the fewest elements. If there are still multiple subsets, return the lexicographically smallest subset. ------ Input Format ------ - ...
from itertools import combinations def max_subset_sum(numbers, target): """ Finds the subset with the maximum possible sum that does not exceed the target sum. Returns the subset with the fewest elements or lexicographically smallest if there are ties. """ n = len(numbers) best_sum = 0 best...
from solution import max_subset_sum def test_example_1(): assert max_subset_sum([1, 2, 3, 4], 10) == [1, 2, 3, 4] def test_example_2(): assert max_subset_sum([4, 5, 2, 1, 3], 10) == [1, 4, 5] def test_example_3(): assert max_subset_sum([8, 7, 6], 15) == [7, 8] def test_example_small_sum(): assert ma...
[ { "docstring": "Finds the subset with the maximum possible sum that does not exceed the target sum.\nReturns the subset with the fewest elements or lexicographically smallest if there are ties.", "function_declaration": "def max_subset_sum(numbers, target):", "function_name": "max_subset_sum", "para...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef find_max_subset(n, target, elements):\n \"\"\"\n Returns the subset with the maximum possible sum that does not exc...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035311", "row_id": 35311, "seed_ids": "[8753]" }
0.693431
Taco_35311
I
[ "max_subset_sum", "solve" ]
2
[ [ "solve", "max_subset_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c09494efeccad9c7dd8f286743ce34aea2c4ed1
f0ce40fcb4119683a3c37b83c0885025d1803244
v1.0
instruct
Taco
Taco_35368_I
A gardener is arranging flower pots of different heights into a sequence. Given a list of integers representing the heights of the flower pots, the gardener has a rule that only after arranging them in non-decreasing order can she start planting flowers in them. However, she can perform an operation: choose any two adj...
def merge_and_count(arr, temp_arr, left, mid, right): i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 # Conditions are checked to ensure that i doesn't exceed mid and j doesn't exceed right ...
def test_minimum_swaps_to_sort(): assert minimum_swaps_to_sort([5, 1, 3, 2, 4]) == 5 assert minimum_swaps_to_sort([1, 2, 3, 4, 5]) == 0 assert minimum_swaps_to_sort([5, 4, 3, 2, 1]) == 10 assert minimum_swaps_to_sort([2, 3, 8, 6, 1]) == 5 assert minimum_swaps_to_sort([1]) == 0 assert minimum_swa...
[ { "docstring": null, "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, right):", "function_name": "merge_and_count", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_arr, left, r...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_inversions(arr):\n \"\"\"\n Returns the number of inversions in the array.\n \"\"\"\n def merge_and_count(arr, temp_arr, left, mid, right):\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035368", "row_id": 35368, "seed_ids": "[11356]" }
0.703705
Taco_35368
I
[ "merge_and_count", "merge_sort_and_count", "minimum_swaps_to_sort", "main" ]
4
[ [ "merge_sort_and_count", "merge_and_count" ], [ "minimum_swaps_to_sort", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3d857293d71c31c56e5740c97205df964cb57fa8
dd89d9a7a99b185303f11f376c10581e3f22b778
v1.0
instruct
Taco
Taco_35409_I
The kingdom of CodeLand is constructing a new irrigation system. There are M farms connected by a network of N pipes. Each pipe can transport water in both directions and has a certain capacity, indicating the maximum amount of water it can transport per second. You are given a list of Q irrigation plans. Each plan co...
from collections import defaultdict import heapq def dijkstra_capacity(graph, start, end, required_capacity): """Find the maximum possible capacity from start to end using a modified Dijkstra's algorithm.""" max_capacity = {node: -1 for node in graph} max_capacity[start] = float('inf') priority_queue =...
from solution import irrigation_system def test_irrigation_system(): M, N = 4, 5 pipes = [ (1, 2, 30), (1, 3, 40), (2, 3, 10), (2, 4, 20), (3, 4, 50), ] Q = 3 irrigation_plans = [ (1, 4, 30), (1, 3, 35), (2, 4, 25), ] assert ir...
[ { "docstring": "Find the maximum possible capacity from start to end using a modified Dijkstra's algorithm.", "function_declaration": "def dijkstra_capacity(graph, start, end, required_capacity):", "function_name": "dijkstra_capacity", "parameter_list": "(graph, start, end, required_capacity)" }, ...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef can_irrigate(m, n, pipes, q, plans):\n graph = {}\n for u, v, capacity in pipes:\n if u not in graph:\n graph[u] = []\n...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00035409", "row_id": 35409, "seed_ids": "[1964]" }
0.694176
Taco_35409
I
[ "dijkstra_capacity", "irrigation_system" ]
2
[ [ "irrigation_system", "dijkstra_capacity" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f877d0abbd467dd583a794cc8e96af6ade461fec
8cc1fc079c979e30052a72717f9010b291020446
v1.0
instruct
Taco
Taco_35436_I
Write a function `SumOfDivided(list)` that takes in a list of positive integers and returns a list of lists where each sublist contains a prime number and the sum of all the integers in the input list that are divisible by that prime number. For example: ```python list = [12, 15] SumOfDivided(list) # [[2, 12], [3, 27]...
import math from collections import defaultdict 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 Tru...
from solution import SumOfDivided def test_SumOfDivided_basic(): assert SumOfDivided([12, 15]) == [[2, 12], [3, 27], [5, 15]] def test_SumOfDivided_single_number(): assert SumOfDivided([30]) == [[2, 30], [3, 30], [5, 30]] def test_SumOfDivided_prime_only(): assert SumOfDivided([2, 3, 5, 7]) == [[2, 2], [...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": null,...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00035436", "row_id": 35436, "seed_ids": "[12466]" }
0.609007
Taco_35436
I
[ "is_prime", "prime_factors", "SumOfDivided" ]
3
[ [ "SumOfDivided", "is_prime" ], [ "SumOfDivided", "prime_factors" ] ]
2
[]
false
[]
false
pytest
true
[]
true
13e852ebd628296def49ae9e1614b4dbb2d3ad56
80a99cff1d7e5aac000b8a1312c8e8b8c17a0d09
v1.0
instruct
Taco
Taco_35478_I
problem In a town where there are several roads, Amy wants to deliver mail from the post office to specific houses. The houses are numbered from 1 to N and the post office is located at house 1. Amy has information about the time it takes to travel between some pairs of houses and must choose a route that ensures she ...
import heapq def prim_mst(graph, n): """ Prim's Algorithm to find the minimum spanning tree (MST) of a graph. :param graph: adjacency list representing graph. :param n: number of nodes in the graph. :return: total weight of the minimum spanning tree. """ min_heap = [(0, 1)] # (weight,...
from solution import min_total_travel_time def test_example(): assert min_total_travel_time(5, 6, [(1, 2, 4), (1, 3, 2), (3, 4, 3), (2, 4, 5), (2, 5, 6), (4, 5, 1)]) == 10 def test_no_additional_path(): assert min_total_travel_time(2, 1, [(1, 2, 5)]) == 5 def test_additional_complexity(): assert min_tota...
[ { "docstring": "Prim's Algorithm to find the minimum spanning tree (MST) of a graph.\n\n:param graph: adjacency list representing graph.\n:param n: number of nodes in the graph.\n:return: total weight of the minimum spanning tree.", "function_declaration": "def prim_mst(graph, n):", "function_name": "pr...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef prim_mst(graph, n):\n \"\"\"\n Prim's Algorithm to find the minimum spanning tree (MST) of a graph.\n \n :param graph: adjacency li...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00035478", "row_id": 35478, "seed_ids": "[23194]" }
0.757923
Taco_35478
I
[ "prim_mst", "min_total_travel_time" ]
2
[ [ "min_total_travel_time", "prim_mst" ] ]
1
[]
false
[]
false
pytest
true
[]
true
12bef9cda9f0a505a0244cd9167277ee75124e76
c2911e969b7d27203d6e62136583a27a70fbfdbe
v1.0
instruct
Taco
Taco_35542_I
Optimal Festival Stalls Charlie is setting up stalls for a festival in a city that consists of n intersections and n-1 bidirectional roads, forming a tree structure. Charlie wants to set up k stalls, each offering a specific type of product, denoted by pi (1 ≤ pi ≤ k). He wants each stall to be positioned at one inter...
from collections import deque, defaultdict def bfs_distances(tree, start, n): distances = [-1] * (n + 1) queue = deque([start]) distances[start] = 0 while queue: node = queue.popleft() for neighbor in tree[node]: if distances[neighbor] == -1: distances[neigh...
def test_optimal_festival_stalls(): n = 6 k = 3 p = [1, 1, 2] roads = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6)] assert optimal_festival_stalls(n, k, p, roads) == 4 def test_single_intersection(): n = 1 k = 1 p = [1] roads = [] assert optimal_festival_stalls(n, k, p, roa...
[ { "docstring": null, "function_declaration": "def bfs_distances(tree, start, n):", "function_name": "bfs_distances", "parameter_list": "(tree, start, n)" }, { "docstring": null, "function_declaration": "def optimal_festival_stalls(n, k, p, roads):", "function_name": "optimal_festival...
[ 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 min_sum_of_distances(n, k, products, roads):\n def bfs(start):\n distances = [-1] * n\n distance...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00035542", "row_id": 35542, "seed_ids": "[24420]" }
0.617101
Taco_35542
I
[ "bfs_distances", "optimal_festival_stalls" ]
2
[ [ "optimal_festival_stalls", "bfs_distances" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d565c90122c0397968f289a09edb4fb069bf41ff
b064b74b4bd80553b3ab0c9d694248f2c323f31b
v1.0
instruct
Taco
Taco_35571_I
You are given a binary tree. Your task is to write a function to check if the tree is a full binary tree or not. A full binary tree is a tree in which every node has either 0 or 2 children. Input: The input contains the elements of the binary tree in level order traversal where -1 represents a null node. For example, ...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def is_full_binary_tree(root): if root is None: return True # If a node has one child, it's not a full binary tree if (root.left is None and root.right is not None) or (root...
from solution import check_full_binary_tree def test_full_binary_tree(): assert check_full_binary_tree([1, 2, 3, -1, -1, 4, 5]) == "Yes" def test_not_full_binary_tree_with_one_child(): assert check_full_binary_tree([1, 2, 3, 4, -1]) == "No" def test_single_node_tree(): assert check_full_binary_tree([1]) ...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef insert_level_order(arr, roo...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035571", "row_id": 35571, "seed_ids": "[23186]" }
0.71212
Taco_35571
I
[ "is_full_binary_tree", "build_tree_from_level_order", "check_full_binary_tree" ]
3
[ [ "check_full_binary_tree", "build_tree_from_level_order" ], [ "check_full_binary_tree", "is_full_binary_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
4bbbc39755595e2e8a7f13d808c507e850f460f7
3d6d492cc18d14f257b8671306edece0cd8f4e5a
v1.0
instruct
Taco
Taco_35608_I
Given a linked list, the task is to reverse every alternate K nodes (where K is an integer) in the linked list and return its modified form. Example 1: Input: head = [1, 2, 3, 4, 5, 6, 7, 8, 9] K = 3 Output: [3, 2, 1, 4, 5, 6, 9, 8, 7] Explanation: The linked list elements are in the following order: - 1, 2, 3 are rev...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reverse_alternate_k_nodes(head: ListNode, k: int) -> ListNode: def reverse(head, k): prev, curr = None, head while k and curr: nxt = curr.next curr.next = prev ...
from solution import ListNode, reverse_alternate_k_nodes def list_to_linked_list(elements): dummy = ListNode(0) curr = dummy for element in elements: curr.next = ListNode(element) curr = curr.next return dummy.next def linked_list_to_list(head): elements = [] while head: ...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef reverse_alternate_k_nodes(head: ListNode, k: in...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00035608", "row_id": 35608, "seed_ids": "[3580]" }
0.590421
Taco_35608
I
[ "reverse_alternate_k_nodes", "reverse_skip_k_nodes" ]
2
[ [ "reverse_alternate_k_nodes", "reverse_skip_k_nodes" ], [ "reverse_skip_k_nodes", "reverse_alternate_k_nodes" ] ]
2
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
e5e054b94ba484aa641b12bbbf3eabae49c89d95
53a10fbbefccd5165d11dba95958e05d7a128a83
v1.0
instruct
Taco
Taco_35616_I
A city has $n$ intersections connected by one-way streets. Each street has a travel time associated with it. Unfortunately, due to heavy rainfall, certain streets may become flooded and need to be avoided. Given the travel time of streets and the pairs of intersections where streets might be flooded, find the minimum t...
import heapq def dijkstra(graph, source, destination, banned_edges): n = len(graph) visited = [False] * n min_time = [float('inf')] * n min_time[source] = 0 heap = [(0, source)] while heap: curr_time, u = heapq.heappop(heap) if visited[u]: continue ...
def test_min_travel_time_basic(): n = 5 m = 7 k = 2 streets = [(1, 2, 4), (1, 3, 2), (2, 4, 5), (3, 4, 8), (3, 5, 10), (4, 5, 2), (5, 4, 9)] flood_prone = [(2, 3), (4, 5)] s, d = 1, 5 assert min_travel_time(n, m, k, streets, flood_prone, s, d) == 12 def test_min_travel_time_no_path(): n...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, source, destination, banned_edges):", "function_name": "dijkstra", "parameter_list": "(graph, source, destination, banned_edges)" }, { "docstring": null, "function_declaration": "def min_travel_time(n, m, k, streets, flood...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef find_minimum_travel_time(n, m, k, streets, flooded_streets, start, destination):\n # Creating an adjacency list for the graph\n adjacency...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035616", "row_id": 35616, "seed_ids": "[10158]" }
0.746226
Taco_35616
I
[ "dijkstra", "min_travel_time" ]
2
[ [ "min_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
166b7013bc797e26740378e242e2abf28564b086
7099e8756fd4ad04f364d09b15d78708124d4766
v1.0
instruct
Taco
Taco_35620_I
You are given an integer `n` and `n` pairs of integers. For each pair `(a_i, b_i)`, you should print all unique prime numbers that are in the range `[a_i, b_i]` inclusive. If no prime numbers exist in that range, print `-1` for that pair. ### Input - The first line contains a single integer `n` (1 ≤ n ≤ 100). - The ne...
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 find_primes_in_range(a, b)...
from solution import is_prime, find_primes_in_range, process_input def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(17) == True assert...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def find_primes_in_range(a, b):", "function_name": "find_primes_in_range", "parameter_list": "(a, b)" }, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n ret...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035620", "row_id": 35620, "seed_ids": "[24266]" }
0.766649
Taco_35620
I
[ "is_prime", "find_primes_in_range", "process_input" ]
3
[ [ "find_primes_in_range", "is_prime" ], [ "process_input", "find_primes_in_range" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
b3ba1cfda0193b642fe30a4ea17e2564073f6632
bfe473fda5aef1d7350eb3389362f7c14bced98e
v1.0
instruct
Taco
Taco_35623_I
In a remote village, the inhabitants decided to construct a road network connecting their village with a nearby city. The village can be thought of as a grid of n×n blocks, and there are m proposed road segments they can build to connect some pairs of blocks. Each road segment connects two blocks and has a certain cons...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[r...
def test_min_construction_cost(): assert min_construction_cost(4, 5, [ (1, 2, 1, 10), (2, 3, 2, 15), (3, 4, 3, 10), (1, 3, 2, 20), (2, 4, 3, 30) ]) == 35 assert min_construction_cost(3, 3, [ (1, 2, 1, 10), (2, 3, 2, 5), (1, 3, 3, 20) ]) ==...
[ { "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 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00035623", "row_id": 35623, "seed_ids": "[2261]" }
0.706628
Taco_35623
I
[ "find", "union", "min_construction_cost" ]
3
[ [ "min_construction_cost", "find" ], [ "min_construction_cost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
ad9a8f57da9fbab1e3ab956987f345f9c42d32ef
9390d07433e1911440078fe42be2a0e14eabb680
v1.0
instruct
Taco
Taco_35685_I
Define a transformation to convert a given binary tree into a doubly linked list. Each node in the doubly linked list must contain the same value as the corresponding node in the binary tree. The doubly linked list should be arranged in such a way that it follows the in-order traversal sequence of the binary tree. Your...
class TreeNode: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right class DLLNode: def __init__(self, value): self.value = value self.prev = None self.next = None def tree_to_dll(root): def inorder(node, p...
def test_tree_to_dll_1(): input_data = """5 10 5 15 5 -1 7 7 -1 -1 15 12 20 12 -1 -1 20 -1 -1""" expected_output = [5, 7, 10, 12, 15, 20] assert tree_to_dll_from_input(input_data) == expected_output def test_tree_to_dll_2(): input_data = """3 1 -1 2 2 -1 3 3 -1 -1""" expected_output = [1, 2, 3] ...
[]
[ 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, value, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\nclass D...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00035685", "row_id": 35685, "seed_ids": "[5674]" }
0.568848
Taco_35685
I
[ "tree_to_dll", "build_tree", "tree_to_dll_from_input" ]
3
[ [ "tree_to_dll_from_input", "build_tree" ], [ "tree_to_dll_from_input", "tree_to_dll" ] ]
2
[]
false
[ "TreeNode", "DLLNode" ]
true
pytest
false
[]
true
adcbf3b67ee3df3767fa1e8f619cf550d72423a7
c60a653b20420e9cdeda78e8abd4e4d0c91dc9ca
v1.0
instruct
Taco
Taco_35729_I
You are given N integers. You need to merge these integers into a single integer by concatenating their string representations such that the resulting number is the largest possible. You should return the final concatenated number as a string, ensuring no leading zeros are present. Input Format: First line gives T, nu...
from functools import cmp_to_key def compare(x, y): if x + y > y + x: return -1 else: return 1 def largest_concatenated_number(test_cases): results = [] for case in test_cases: N, numbers = case str_nums = sorted(map(str, numbers), key=cmp_to_key(compare)) resul...
from solution import largest_concatenated_number, parse_input def test_largest_concatenated_number_case1(): input_text = "2\n2\n3\n30\n3\n9\n92\n5" test_cases = parse_input(input_text) result = largest_concatenated_number(test_cases) assert result == ["330", "9925"] def test_single_test_case(): in...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_concatenated_number(test_cases):", "function_name": "largest_concatenated_number", "parameter_lis...
[ 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 functools import cmp_to_key\n\ndef compare_numbers(a, b):\n if a + b > b + a:\n return -1\n else:\n return 1\n\ndef largest_concatenated_n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035729", "row_id": 35729, "seed_ids": "[2182]" }
0.697149
Taco_35729
I
[ "compare", "largest_concatenated_number", "parse_input" ]
3
[ [ "largest_concatenated_number", "compare" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
25b093455cead1b65674efd4d5e43bfeb15d4b5a
29e33a07a2dacdc8c51c08619a43cf79a6ae72d7
v1.0
instruct
Taco
Taco_35740_I
In a vast labyrinthine dungeon, Raaneth the explorer encounters a set of magical gates that only open for prime numbers. Each gate requires a sequence of operations to transform the starting number into a prime to proceed to the next chamber. Raaneth can perform the following operations to the starting number: - Add 1...
import math from collections import deque def is_prime(n): """ Returns True if n is a prime number, else False """ 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...
from solution import min_operations_to_prime def test_min_operations_case_1(): assert min_operations_to_prime(10, 20) == 3 def test_min_operations_case_2(): assert min_operations_to_prime(14, 17) == 2 def test_min_operations_case_3(): assert min_operations_to_prime(2, 3) == 1 def test_min_operations_cas...
[ { "docstring": "Returns True if n is a prime number, else False", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the minimum number of operations to transform s into a prime number\ngreater than or equal to t.", ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef is_prime(n):\n \"\"\" \n Check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00035740", "row_id": 35740, "seed_ids": "[15763]" }
0.630652
Taco_35740
I
[ "is_prime", "min_operations_to_prime" ]
2
[ [ "min_operations_to_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6a890b1a6938061ef5f037bd31432ef8616716ba
294032edf07033606ab57dd769af0d77b1baf6fa
v1.0
instruct
Taco
Taco_35787_I
Kevin is participating in an obstacle race and has to jump over hurdles placed along a straight path. There are N hurdles in a row, and each hurdle has a specific height given in an array of size N. Kevin can jump one hurdle at a time, but he has a unique jumping style: he always jumps over the smallest possible hurdle...
def count_hurdle_jumps(test_cases): results = [] for hurdles in test_cases: jumps = 0 n = len(hurdles) if n == 0: results.append(jumps) continue min_hurdle = min(hurdles) current_index = hurdles.index(min_hurdle) while current_in...
def test_parse_input(): input_string = "2\n5 1 2 3 4 5\n4 2 1 2 1\n" expected = [ [1, 2, 3, 4, 5], [2, 1, 2, 1] ] assert parse_input(input_string) == expected def test_count_hurdle_jumps(): test_cases = [ [1, 2, 3, 4, 5], [2, 1, 2, 1] ] expected = [1, 2] ...
[ { "docstring": null, "function_declaration": "def count_hurdle_jumps(test_cases):", "function_name": "count_hurdle_jumps", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "parameter...
[ 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_jumps(n, hurdles):\n \"\"\"\n Returns the number of jumps Kevin makes before he can no longer continue.\n \"\"\"\n if n == 0:\n return ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00035787", "row_id": 35787, "seed_ids": "[18091]" }
0.681435
Taco_35787
I
[ "count_hurdle_jumps", "parse_input", "process" ]
3
[ [ "process", "count_hurdle_jumps" ], [ "process", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
5941dc5bb3d6f0f738b7d3f0d40925e4eec9f711
9ee9d8cd48e071359807bd0cf6c2035957444fdc
v1.0
instruct
Taco
Taco_35800_I
The ancient city of Bytown has a unique transportation system consisting of $n$ bus lines. Each bus line is described by two points $(x_i, y_i)$ and $(u_i, v_i)$, which represent two ends of the bus line in a 2D plane. Your task is to determine the minimum number of bus lines you need to take to travel from a starting ...
from collections import deque from typing import List, Tuple def is_intersect(p1, p2, p3, p4) -> bool: """ Returns True if line segments p1p2 and p3p4 intersect. Points are represented as tuples (x, y) """ def orientation(p, q, r): val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1]...
def test_min_buses(): assert min_buses((0, 0), (10, 10), [((0, 0), (5, 5)), ((5, 5), (10, 10)), ((5, 0), (10, 5)), ((0, 10), (10, 0))]) == 2 assert min_buses((0, 0), (10, 10), [((0, 0), (1, 1)), ((2, 2), (3, 3))]) == -1 assert min_buses((0, 0), (5, 5), [((0, 0), (5, 5)), ((2, 2), (3, 3))]) == 1 assert m...
[ { "docstring": "Returns True if line segments p1p2 and p3p4 intersect.\nPoints are represented as tuples (x, y)", "function_declaration": "def is_intersect(p1, p2, p3, p4):", "function_name": "is_intersect", "parameter_list": "(p1, p2, p3, p4)" }, { "docstring": null, "function_declarati...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_bus_lines(sx, sy, dx, dy, bus_lines):\n from collections import deque, defaultdict\n def intersect(x1, y1, x2, y2, x3, y3, x4, y4):\n def on_s...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035800", "row_id": 35800, "seed_ids": "[10605]" }
0.767367
Taco_35800
I
[ "is_intersect", "build_graph", "min_buses" ]
3
[ [ "build_graph", "is_intersect" ], [ "min_buses", "build_graph" ], [ "min_buses", "is_intersect" ] ]
3
[]
false
[]
false
pytest
false
[]
true
b83a65fcde40d1cef1bc91b3b4d82fb5b2cbf642
368fd5f2522e4fe37ef9c244120ec1a9370cb5af
v1.0
instruct
Taco
Taco_35813_I
Create a function `merge_and_sort` that takes two lists of integers as inputs and returns a single list that combines the elements of both input lists sorted in non-decreasing order. You are not allowed to use the built-in `sorted()` function or any other built-in sort functions. ### Input The function will take two l...
def merge_and_sort(list1, list2): """ Merges two lists and returns a sorted list without using built-in sort functions. """ # Merge the two lists merged_list = list1 + list2 # Implement Merge Sort return merge_sort(merged_list) def merge_sort(arr): """ Sorts the given list using Mer...
from solution import merge_and_sort def test_merge_and_sort_basic(): assert merge_and_sort([1, 4, 5], [2, 3, 6]) == [1, 2, 3, 4, 5, 6] def test_merge_and_sort_with_negative(): assert merge_and_sort([-1, 2, 4], [1, 0, -3, 5]) == [-3, -1, 0, 1, 2, 4, 5] def test_merge_and_sort_identical_elements(): assert ...
[ { "docstring": "Merges two lists and returns a sorted list without using built-in sort functions.", "function_declaration": "def merge_and_sort(list1, list2):", "function_name": "merge_and_sort", "parameter_list": "(list1, list2)" }, { "docstring": "Sorts the given list using Merge Sort algo...
[ 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_and_sort(list1, list2):\n \"\"\"\n Merges two lists and returns a sorted list in non-decreasing order.\n Does not use built-in sorted() or any b...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035813", "row_id": 35813, "seed_ids": "[18482]" }
0.581551
Taco_35813
I
[ "merge_and_sort", "merge_sort" ]
2
[ [ "merge_and_sort", "merge_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e7ba6f19fb9bb5ec5800d135b3298cef165d4ac
b0dc220aa3369963abaacc7e541e410c948c50ba
v1.0
instruct
Taco
Taco_35814_I
You are given a balanced binary search tree (BST) with n nodes and a target value x. The tree consists of nodes with unique integer values. Your task is to find the node in the BST that has the minimum absolute difference with the given target value x. If there are multiple nodes with the same minimum absolute differen...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None 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.righ...
from solution import closest_value_in_bst def test_case_1(): n = 7 values = [4, 2, 6, 1, 3, 5, 7] x = 4 assert closest_value_in_bst(n, values, x) == 4 def test_case_2(): n = 7 values = [10, 5, 15, 2, 7, 12, 17] x = 13 assert closest_value_in_bst(n, values, x) == 12 def test_case_3(): ...
[]
[ 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, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef insert_level_order(arr, roo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035814", "row_id": 35814, "seed_ids": "[24968]" }
0.636986
Taco_35814
I
[ "insert_level_order", "find_closest_value", "closest_value_in_bst" ]
3
[ [ "closest_value_in_bst", "find_closest_value" ], [ "closest_value_in_bst", "insert_level_order" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
b242708fdbad2bbf288987aa470bcf97dab57b09
ff14d9ab79425043f7a3de881b9c500bb6a62bb8
v1.0
instruct
Taco
Taco_35836_I
You are given an integer $n$. We define a function $f(x)$ which returns the sum of digits of a non-negative integer $x$. Your task is to find the minimum number of operations required to reduce $n$ to a single-digit number. In one operation, you can replace $n$ with $f(n)$. For example, if $n = 38$, the sequence of op...
def sum_of_digits(x): return sum(int(digit) for digit in str(x)) def min_operations_to_single_digit(n): if n < 10: return 0 operations = 0 while n >= 10: n = sum_of_digits(n) operations += 1 return operations
from solution import min_operations_to_single_digit def test_single_digit_number(): assert min_operations_to_single_digit(5) == 0 def test_double_digit_number(): assert min_operations_to_single_digit(38) == 2 def test_large_number_all_zeros(): assert min_operations_to_single_digit(1000000) == 1 def test...
[ { "docstring": null, "function_declaration": "def sum_of_digits(x):", "function_name": "sum_of_digits", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def min_operations_to_single_digit(n):", "function_name": "min_operations_to_single_digit", "parameter_...
[ 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_digits(n):\n \"\"\"\n Returns the sum of digits of a given non-negative integer n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035836", "row_id": 35836, "seed_ids": "[764]" }
0.68817
Taco_35836
I
[ "sum_of_digits", "min_operations_to_single_digit" ]
2
[ [ "min_operations_to_single_digit", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1df32bb5c8361dbdcfda3fac937a56d40fb8e3c7
80b70660f0c683bb290ee8685840ebd46b2740e7
v1.0
instruct
Taco
Taco_35873_I
Given a list of non-negative integers, arrange them in such a way that they form the largest possible number. Example 1: Input: N = 3 arr = [54, 546, 548, 60] Output: 6054854654 Explanation: By arranging the elements in such a way to form the largest possible number, we get 6054854654. Example 2: Input: N = 3 arr = [...
from functools import cmp_to_key def compare(x, y): # Comparator function to decide the order if x + y > y + x: return -1 else: return 1 def largestNumber(arr): """ Given a list of non-negative integers, arranges them in such a way that they form the largest possible number. ""...
from solution import largestNumber def test_example1(): arr = [54, 546, 548, 60] assert largestNumber(arr) == '6054854654' def test_example2(): arr = [1, 34, 3, 98, 9, 76, 45, 4] assert largestNumber(arr) == '998764543431' def test_single_element(): arr = [1] assert largestNumber(arr) == ...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Given a list of non-negative integers, arranges them in such a way that they form the largest possible number.", "function_declaration": "def large...
[ 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 functools import cmp_to_key\n\ndef compare(a, b):\n \"\"\"\n Custom comparator function to decide the order of numbers.\n \"\"\"\n if a + b > b + ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035873", "row_id": 35873, "seed_ids": "[11827]" }
0.692211
Taco_35873
I
[ "compare", "largestNumber" ]
2
[ [ "largestNumber", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1724e8192721054f0691e08a285f0b986557cff9
1f71b6ca8b90bd11f4b1bbbcd8717409a738a55a
v1.0
instruct
Taco
Taco_35876_I
You are given a sequence of N integers, and an integer K. Your task is to find the Kth smallest element in the sequence using the Quickselect algorithm. Example: Input: N = 6 sequence = [7, 10, 4, 3, 20, 15] K = 3 Output: 7 Explanation: The 3rd smallest element in the array [7, 10, 4, 3, 20, 15] is 7. Example 2: Inpu...
def partition(arr, low, high): pivot = arr[high] i = low for j in range(low, high): if arr[j] <= pivot: arr[i], arr[j] = arr[j], arr[i] i += 1 arr[i], arr[high] = arr[high], arr[i] return i def quickselect(arr, low, high, k): if low == high: return arr[lo...
from solution import find_kth_smallest def test_find_kth_smallest(): assert find_kth_smallest(6, [7, 10, 4, 3, 20, 15], 3) == 7 assert find_kth_smallest(5, [7, 10, 4, 20, 15], 4) == 15 assert find_kth_smallest(6, [1, 2, 3, 4, 5, 6], 6) == 6 assert find_kth_smallest(6, [6, 5, 4, 3, 2, 1], 1) == 1 as...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quickselect(arr, low, high, k):", "function_name": "quickselect", "parameter_list...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def partition(arr, low, high):\n pivot = arr[high]\n i = low\n for j in range(low, high):\n if arr[j] <= pivot:\n arr[i], arr[j] = arr[j...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035876", "row_id": 35876, "seed_ids": "[2161]" }
0.545725
Taco_35876
I
[ "partition", "quickselect", "find_kth_smallest" ]
3
[ [ "find_kth_smallest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7f31c9e609778d920d276ce06e366eccf1516d7c
16cf5becb8e612376ab6ddd8a4487f96d86a7a00
v1.0
instruct
Taco
Taco_35918_I
Problem You are tasked with developing a streaming service's recommendation system. The service maintains a list of movie genres and every user has a list of their preferred genres. Your job is to identify which genres are the most popular among the users. Sample Input The first input line contains a single integer `n...
def get_genre_popularity(user_preferences): """ This function takes in a list of user preferences where each user preference is a list containing genres they like. It returns the genre popularity sorted by popularity and then lexicographically in case of ties. """ from collections import defau...
import pytest from solution import get_genre_popularity, parse_input, recommendation_system def test_get_genre_popularity(): user_preferences = [ ["3", "action", "comedy", "drama"], ["2", "action", "horror"], ["4", "comedy", "drama", "thriller", "action"], ["1", "thriller"], ...
[ { "docstring": "This function takes in a list of user preferences where each user preference \nis a list containing genres they like. It returns the genre popularity sorted \nby popularity and then lexicographically in case of ties.", "function_declaration": "def get_genre_popularity(user_preferences):", ...
[ 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 popular_genres(n, user_genres):\n from collections import defaultdict\n \n genre_count = defaultdict(int)\n \n for genres in user_genres:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00035918", "row_id": 35918, "seed_ids": "[20941]" }
0.550757
Taco_35918
I
[ "get_genre_popularity", "parse_input", "recommendation_system" ]
3
[ [ "recommendation_system", "get_genre_popularity" ], [ "recommendation_system", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
6e1d819b38d749e4b0753bf439fc98b5d4dd6332
58bf4cac9883e6096f48052aca10f667e809dd7c
v1.0
instruct
Taco
Taco_35948_I
Detecting Cycles in a Directed Graph Alice is working on optimizing routes for a package delivery service. She needs to ensure that there are no cycles in the system of routes, to avoid scenarios where packages could end up in a never-ending loop. Alice has tasked you with writing a program to detect if a cycle exists...
def has_cycle(V, edges): from collections import defaultdict # Create adjacency list graph = defaultdict(list) for u, v in edges: graph[u].append(v) visited = [False] * V rec_stack = [False] * V def dfs(v): visited[v] = True rec_stack[v] = True ...
from solution import detect_cycle_in_graph def test_sample_input_1(): V = 4 E = 4 edges = [(0, 1), (1, 2), (2, 3), (3, 1)] assert detect_cycle_in_graph(V, E, edges) == "YES" def test_sample_input_2(): V = 4 E = 3 edges = [(0, 1), (1, 2), (2, 3)] assert detect_cycle_in_graph(V, E, edges...
[ { "docstring": null, "function_declaration": "def has_cycle(V, edges):", "function_name": "has_cycle", "parameter_list": "(V, edges)" }, { "docstring": null, "function_declaration": "def detect_cycle_in_graph(V, E, edges):", "function_name": "detect_cycle_in_graph", "parameter_li...
[ 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 has_cycle(V, edges):\n from collections import defaultdict\n \n # Create adjacency list\n graph = defaultdict(list)\n for u, v in edges:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00035948", "row_id": 35948, "seed_ids": "[11061]" }
0.74663
Taco_35948
I
[ "has_cycle", "detect_cycle_in_graph" ]
2
[ [ "detect_cycle_in_graph", "has_cycle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7503a9ef7da426f1f660dbac23023ab889255848
928e7d7d99ab60973e35a90774164736159f69f3
v1.0
instruct
Taco
Taco_35995_I
Junior Programmer wants to collect as many stars as possible. They are given an array representing the number of stars collected at each stage in a game. However, they can only collect stars from non-adjacent stages to avoid penalties. Determine the maximum number of stars Junior Programmer can collect by following the...
def max_stars_per_case(stars): """ Returns the maximum number of stars that can be collected by following the non-adjacent stages rule. """ N = len(stars) if N == 0: return 0 elif N == 1: return stars[0] elif N == 2: return max(stars[0], stars[1]) dp = [...
from solution import max_stars_per_case, max_stars def test_max_stars_per_case(): assert max_stars_per_case([1, 2, 9, 4]) == 10 assert max_stars_per_case([3, 2, 5, 10, 7]) == 15 assert max_stars_per_case([]) == 0 assert max_stars_per_case([0]) == 0 assert max_stars_per_case([5]) == 5 assert max...
[ { "docstring": "Returns the maximum number of stars that can be collected \nby following the non-adjacent stages rule.", "function_declaration": "def max_stars_per_case(stars):", "function_name": "max_stars_per_case", "parameter_list": "(stars)" }, { "docstring": "Returns the maximum number ...
[ 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_stars(T, test_cases):\n def max_non_adjacent_sum(stars):\n incl = 0\n excl = 0\n for star in stars:\n new_excl = max(exc...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00035995", "row_id": 35995, "seed_ids": "[3695]" }
0.671866
Taco_35995
I
[ "max_stars_per_case", "max_stars", "process_input" ]
3
[ [ "max_stars", "max_stars_per_case" ], [ "process_input", "max_stars" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
c3937673b45e8a0cbd2294da03a7b94ab08e75f2
4f6f5caaeefeb162caf55fe2c2051e648527bbf5
v1.0
instruct
Taco
Taco_36170_I
## Problem Description You will be given a string and a series of queries. Each query will specify the starting and ending positions within the string, and you have to determine if the substring within that range forms a palindrome. -----Brute-Force:----- For each query, extract the substring from the given range and...
def is_palindrome_brute_force(s, L, R): """ Checks if the substring s[L:R+1] is a palindrome using brute force. """ substring = s[L:R+1] return substring == substring[::-1] def preprocess_dp(s): """ Preprocesses the string to find all palindromic substrings using dynamic programming. Re...
def test_is_palindrome_brute_force(): assert is_palindrome_brute_force("bananas", 0, 2) == False assert is_palindrome_brute_force("bananas", 2, 4) == True assert is_palindrome_brute_force("bananas", 1, 5) == True assert is_palindrome_brute_force("racecar", 0, 6) == True assert is_palindrome_brute_fo...
[ { "docstring": "Checks if the substring s[L:R+1] is a palindrome using brute force.", "function_declaration": "def is_palindrome_brute_force(s, L, R):", "function_name": "is_palindrome_brute_force", "parameter_list": "(s, L, R)" }, { "docstring": "Preprocesses the string to find all palindro...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome_brute_force(s, l, r):\n \"\"\"\n Function to check if a substring s[l:r+1] is a palindrome using brute force.\n \"\"\"\n substring = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036170", "row_id": 36170, "seed_ids": "[8305]" }
0.865134
Taco_36170
I
[ "is_palindrome_brute_force", "preprocess_dp", "is_palindrome_dp", "solve_palindrome_queries" ]
4
[ [ "solve_palindrome_queries", "is_palindrome_brute_force" ], [ "solve_palindrome_queries", "is_palindrome_dp" ], [ "solve_palindrome_queries", "preprocess_dp" ] ]
3
[]
false
[]
false
pytest
false
[]
true
85b3142a590bf68f4cf3b1f080d90414ffef6754
4ddd95c2cdedc2e7efe5be178fc45e20cbf289d6
v1.0
instruct
Taco
Taco_36180_I
The Queen of a distant kingdom is passionate about prime numbers. She calls her Royal Mathematician and gives him a challenging task. She wants him to take two integers, A and B, and find out the sum of all prime numbers between A and B (inclusive). The task must be completed accurately so the Royal Mathematician seeks...
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 is_prime, sum_of_primes_in_range, solve_prime_sum def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(11) def test_sum_of_primes_in_range(): assert sum_of...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers between A and B (inclusive).", "function_declaration": "def sum_of_pri...
[ 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 Helper function to check if a number is prime.\n Returns True if 'n' is a prime number, otherwise False.\n \"\"\"\n if n...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00036180", "row_id": 36180, "seed_ids": "[8444]" }
0.646997
Taco_36180
I
[ "is_prime", "sum_of_primes_in_range", "solve_prime_sum" ]
3
[ [ "solve_prime_sum", "sum_of_primes_in_range" ], [ "sum_of_primes_in_range", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
96f9e1ac454df5e74708c7cdc926bc3fbf3f43cd
070c86f7e9e726c0d54296df8cdf5915212b595a
v1.0
instruct
Taco
Taco_36215_I
You are given a list of employees in a company. Each employee has a manager, except the CEO who has no manager. The company wants to create an organizational chart displaying the hierarchy. Given: 1. `n` - Number of employees (1 ≤ n ≤ 1000) 2. A list of `n` lines where each line contains two strings: `Employee Manager...
def create_org_chart(n, employee_manager_pairs): from collections import defaultdict # Dictionary to hold the hierarchy hierarchy = defaultdict(list) # Variable to hold the CEO ceo = None # Build the hierarchy and determine the CEO for employee, manager in employee_manager_pairs: ...
from solution import format_org_chart def test_example_case(): n = 8 pairs = [ ("Alice", "None"), ("Bob", "Alice"), ("Charlie", "Alice"), ("David", "Bob"), ("Eve", "Bob"), ("Frank", "Charlie"), ("Grace", "Charlie"), ("Heidi", "David"), ] o...
[ { "docstring": null, "function_declaration": "def create_org_chart(n, employee_manager_pairs):", "function_name": "create_org_chart", "parameter_list": "(n, employee_manager_pairs)" }, { "docstring": null, "function_declaration": "def format_org_chart(n, employee_manager_pairs):", "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 build_org_chart(n, employee_manager_pairs):\n from collections import defaultdict\n\n # Build the hierarchy tree\n hierarchy = defaultdict(list)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036215", "row_id": 36215, "seed_ids": "[15036]" }
0.521619
Taco_36215
I
[ "create_org_chart", "format_org_chart" ]
2
[ [ "format_org_chart", "create_org_chart" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3aec6abd03673bc06eab04887c25c13f13e61fff
127bf088309d1d4a358ac1162a38066606b92375
v1.0
instruct
Taco
Taco_36232_I
Julia is working on a task related to the concept of prime factorization. She needs to implement a function that finds the smallest prime factor for each number in a given list. A prime factor of a given integer n is any prime number that divides n without leaving a remainder. The smallest prime factor (spf) of a numbe...
def smallest_prime_factor(n): """ Function that returns the smallest prime factor of n """ if n <= 1: return None if n % 2 == 0: return 2 factor = 3 while factor * factor <= n: if n % factor == 0: return factor factor += 2 return n def find_sm...
from solution import find_smallest_prime_factors def test_find_smallest_prime_factors(): assert find_smallest_prime_factors([30, 45, 13, 100, 27]) == [2, 3, 13, 2, 3] assert find_smallest_prime_factors([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] assert find_smallest_prime_factors([6, 15, 21, 25, 49]) == [2, 3, 3...
[ { "docstring": "Function that returns the smallest prime factor of n", "function_declaration": "def smallest_prime_factor(n):", "function_name": "smallest_prime_factor", "parameter_list": "(n)" }, { "docstring": "Given a list of positive integers, returns a new list where each element \nis 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 smallest_prime_factor(n):\n \"\"\"\n Returns the smallest prime factor of the given number n.\n \"\"\"\n if n <= 1:\n return None\n if n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036232", "row_id": 36232, "seed_ids": "[1545]" }
0.709184
Taco_36232
I
[ "smallest_prime_factor", "find_smallest_prime_factors" ]
2
[ [ "find_smallest_prime_factors", "smallest_prime_factor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c413df07c00931a98a4180e28ce22ec9878689ea
5e1741c3895319d8358894c3378d5eb91d7609f7
v1.0
instruct
Taco
Taco_36240_I
In a certain country, there are n cities connected by n-1 bidirectional roads such that there is a unique path between any two cities (i.e., the cities form a tree). Each road has a certain travel time associated with it. The capital of the country is city 1. A pandemic has broken out, and the government wants to ensu...
from collections import defaultdict, deque def min_trips_to_deliver_supplies(n, x, roads): graph = defaultdict(list) for u, v, t in roads: graph[u].append((v, t)) graph[v].append((u, t)) distance_from_capital = [0] * (n + 1) visited = [False] * (n + 1) def bfs(source)...
import pytest from solution import minimum_number_of_trips def test_example_1(): n = 5 x = 10 roads = [(1, 2, 5), (1, 3, 3), (3, 4, 7), (4, 5, 2)] assert minimum_number_of_trips(n, x, roads) == 2 def test_example_2(): n = 6 x = 15 roads = [(1, 2, 4), (2, 3, 6), (2, 4, 5), (1, 5, 3), (5, 6,...
[ { "docstring": null, "function_declaration": "def min_trips_to_deliver_supplies(n, x, roads):", "function_name": "min_trips_to_deliver_supplies", "parameter_list": "(n, x, roads)" }, { "docstring": null, "function_declaration": "def minimum_number_of_trips(n, x, roads):", "function_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": "import heapq\n\ndef minimum_trips(n, x, roads):\n from collections import defaultdict\n\n # build the graph\n graph = defaultdict(list)\n for u, v, t i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00036240", "row_id": 36240, "seed_ids": "[17463]" }
0.80957
Taco_36240
I
[ "min_trips_to_deliver_supplies", "minimum_number_of_trips" ]
2
[ [ "minimum_number_of_trips", "min_trips_to_deliver_supplies" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7038a1518bca4db7a1906a8ec8c427452158bbda
f1ecba8f1b903be8aba5aa7d0f09242035dbaecb
v1.0
instruct
Taco
Taco_36264_I
In a simulated computer science competition, participants were asked to identify the first missing positive integer in a given list of integers. Little Sarah found this intriguing and decided to practice more on this problem. The task is to implement a function to find the smallest positive integer that doesn't occur ...
def first_missing_positive(nums): """ Finds the first missing positive integer from the list. """ n = len(nums) # Step 1: Mark non-positive and out of range elements for i in range(n): if nums[i] <= 0 or nums[i] > n: nums[i] = n + 1 # Step 2: Use the index as a ...
def test_find_first_missing_positive(): assert find_first_missing_positive(5, [3, 4, -1, 1, 2]) == 5 assert find_first_missing_positive(3, [1, 2, 0]) == 3 assert find_first_missing_positive(4, [7, 8, 9, 11, 12]) == 1 assert find_first_missing_positive(4, [1, 2, 3, 4]) == 5 assert find_first_missing_...
[ { "docstring": "Finds the first missing positive integer from the list.", "function_declaration": "def first_missing_positive(nums):", "function_name": "first_missing_positive", "parameter_list": "(nums)" }, { "docstring": "Wrapper function to get the required format of input and output.", ...
[ 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 first_missing_positive(N, arr):\n \"\"\"\n Finds the smallest missing positive integer in a given list of integers.\n \n Parameters:\n N (int): ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036264", "row_id": 36264, "seed_ids": "[10495]" }
0.692113
Taco_36264
I
[ "first_missing_positive", "find_first_missing_positive" ]
2
[ [ "find_first_missing_positive", "first_missing_positive" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e11a67cc18b31a668353014b9fac7aca0ccc10dc
7cfd89ec765cf72087af934150ece83badf80a64
v1.0
instruct
Taco
Taco_36286_I
In a distant land called Arrangia, numbers follow a distinctive pattern. The people of Arrangia believe in symmetry and balance, and hence, their favorite numbers are the ones which remain the same when reversed (also known as palindromic numbers). The king of Arrangia, in a bid to promote mathematical curiosity, has p...
def is_palindrome(num): """ Check if a number is a palindrome. A number is a palindrome if it reads the same forwards and backwards. """ return str(num) == str(num)[::-1] def count_palindromes(l, r): """ Count the number of palindromic numbers between l and r inclusive. """ count = ...
def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True assert is_palindrome(12321) == True def test_count_palindromes(): assert count_palindromes(1, 10) == 9 assert count_palindromes(100...
[ { "docstring": "Check if a number is a palindrome.\nA number is a palindrome if it reads the same forwards and backwards.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Count the number of palindromic number...
[ 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_palindromic_number(n):\n \"\"\"\n Checks if a number is palindromic.\n \"\"\"\n str_n = str(n)\n return str_n == str_n[::-1]\n\ndef count_pal...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036286", "row_id": 36286, "seed_ids": "[15729]" }
0.740662
Taco_36286
I
[ "is_palindrome", "count_palindromes", "palindromic_numbers" ]
3
[ [ "count_palindromes", "is_palindrome" ], [ "palindromic_numbers", "count_palindromes" ] ]
2
[]
false
[]
false
pytest
false
[]
true
4ddcf94be6c198ccbc0bc69774167691548c323b
a243336f671ec3dbae04c5b918ad88d967c8c5c5
v1.0
instruct
Taco
Taco_36328_I
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Alice loves playing with numbers. Today, she has decided to play a game with GCD (Greatest Common Divisor) and LCM (Least Common Multiple). Given two positive integers, she will compute both their GCD and LCM. Alice then keeps track of the n...
import math def gcd(a, b): """ Computes the Greatest Common Divisor of a and b using the Euclidean algorithm. """ return math.gcd(a, b) def lcm(a, b): """ Computes the Least Common Multiple of a and b. """ return abs(a * b) // gcd(a, b) def num_digits(n): """ Computes the numb...
import pytest from solution import gcd, lcm, num_digits, absolute_difference_gcd_lcm_digits, process_test_cases def test_gcd(): assert gcd(12, 15) == 3 assert gcd(7, 9) == 1 assert gcd(100000000000, 1000000000000) == 100000000000 def test_lcm(): assert lcm(12, 15) == 60 assert lcm(7, 9) == 63 ...
[ { "docstring": "Computes the Greatest Common Divisor of a and b using the Euclidean algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Computes the Least Common Multiple of a and b.", "function_declaration": "def l...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_digit_diff(T, test_cases):\n results = []\n for i in range(T):\n A, B = test_cases[i]\n gcd_val = math.gcd(A, B)\n...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00036328", "row_id": 36328, "seed_ids": "[23967]" }
0.58909
Taco_36328
I
[ "gcd", "lcm", "num_digits", "absolute_difference_gcd_lcm_digits", "process_test_cases" ]
5
[ [ "absolute_difference_gcd_lcm_digits", "gcd" ], [ "absolute_difference_gcd_lcm_digits", "lcm" ], [ "absolute_difference_gcd_lcm_digits", "num_digits" ], [ "lcm", "gcd" ], [ "process_test_cases", "absolute_difference_gcd_lcm_digits" ] ]
5
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
6ca9fa53036aaa75e95cc2d874d59658ead6b6eb
951b9afcbfc8a02ffcb84951ad563da0d3643b00
v1.0
instruct
Taco
Taco_36351_I
Write a program that takes an integer X as input and determines whether it can be expressed as the sum of two prime numbers. If it can, print one such pair of prime numbers. If there are multiple pairs, print any one of them. If no such pair exists, print "Not possible". SAMPLE INPUT 26 SAMPLE OUTPUT 3 23 SAMPLE INP...
def is_prime(n): """ Returns True if n is a prime number; otherwise, returns False. """ 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 F...
from solution import is_prime, find_prime_pair def test_is_prime(): # Testing edge cases assert is_prime(0) == False assert is_prime(1) == False # Testing small prime numbers assert is_prime(2) == True assert is_prime(3) == True # Testing small non-prime numbers assert is_prime(4) == Fa...
[ { "docstring": "Returns True if n is a prime number; otherwise, returns False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a pair of prime numbers (p1, p2) such that p1 + p2 = X or \"Not possible\" if no such p...
[ 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 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_4
{ "original_instruction": "", "prompt_id": "00036351", "row_id": 36351, "seed_ids": "[14337]" }
0.703342
Taco_36351
I
[ "is_prime", "find_prime_pair" ]
2
[ [ "find_prime_pair", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2bc4ae73daaaf56684136946bc4fc3337ef93a2d
2e86641097ac70e263abd36fd5a741f367940746
v1.0
instruct
Taco
Taco_36576_I
In the kingdom of Avalon, there are numerous castles connected by roads. Some of these roads are in dire need of repair. The king has a list of all the roads and their respective repair costs. The king wants to connect all the castles in such a way that the total repair cost is minimized. Formally, the kingdom can be ...
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] > ...
from solution import minimum_repair_cost def test_example_case(): assert minimum_repair_cost(4, 4, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 1, 6)]) == 12 def test_disconnected_graph(): assert minimum_repair_cost(4, 2, [(1, 2, 3), (3, 4, 4)]) == "IMPOSSIBLE" def test_single_node(): assert minimum_repair_...
[ { "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, 1, 1, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def 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_6
{ "original_instruction": "", "prompt_id": "00036576", "row_id": 36576, "seed_ids": "[17749]" }
0.690185
Taco_36576
I
[ "find", "union", "kruskal", "minimum_repair_cost" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_repair_cost", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
a18ecdf28a988e22e4fd91ceed85cd77ae7c2734
07a277ed563a7658f392958e83cdaf3593c820fe
v1.0
instruct
Taco
Taco_36608_I
You are given $N$ points in a 2D plane. You need to determine if there exists a straight line in this plane such that all the given points lie on that line. Input Format The first line contains an integer $N$. The next $N$ lines each contain two integers $x$ and $y$ which specify the coordinates of a point. Constr...
def are_points_collinear(points): """ Determines if all points lie on a single straight line. :param points: List of tuples representing points (x, y) :return: "YES" if all points are collinear, "NO" otherwise """ if len(points) <= 2: return "YES" def slope(p1, p2): if ...
from solution import check_collinearity def test_single_point(): assert check_collinearity(1, [(0, 0)]) == "YES" def test_two_points(): assert check_collinearity(2, [(0, 0), (1, 1)]) == "YES" def test_three_collinear_points(): assert check_collinearity(3, [(1, 2), (2, 3), (3, 4)]) == "YES" def test_...
[ { "docstring": "Determines if all points lie on a single straight line.\n\n:param points: List of tuples representing points (x, y)\n:return: \"YES\" if all points are collinear, \"NO\" otherwise", "function_declaration": "def are_points_collinear(points):", "function_name": "are_points_collinear", ...
[ 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 are_points_collinear(points):\n \"\"\"\n Returns \"YES\" if all the given points lie on the same straight line, otherwise \"NO\".\n \"\"\"\n def sl...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036608", "row_id": 36608, "seed_ids": "[2393]" }
0.682139
Taco_36608
I
[ "are_points_collinear", "check_collinearity" ]
2
[ [ "check_collinearity", "are_points_collinear" ] ]
1
[]
false
[]
false
pytest
true
[]
true
039d73c9273eec664d761d1c83ac05da540430d9
75846a4599662144006580d7a0258a84ad2bcf2d
v1.0
instruct
Taco
Taco_36674_I
Cindria is an advanced planet where the inhabitants have evolved a unique way to communicate numbers via a series of lights. Each light can be turned on or off to represent a binary number. However, due to their rapid technological advancement, they've started using a modified version of binary arithmetic which include...
def gamma_operation(B): return ''.join('1' if bit == '0' else '0' for bit in B) def perform_gamma_operations(T, cases): result = [] for i in range(T): N, L, M, B = cases[i] B = int(B, 2) # Convert the binary string to decimal number for _ in range(N): gamma_B =...
from solution import perform_gamma_operations def test_case_1(): T = 2 cases = [(1, 10, 5, '0110'), (2, 15, 1, '0011')] result = perform_gamma_operations(T, cases) assert result == ["Case #1: 1001", "Case #2: 0011"] def test_case_2(): T = 1 cases = [(5, 20, 0, '0101')] result = perform_gam...
[ { "docstring": null, "function_declaration": "def gamma_operation(B):", "function_name": "gamma_operation", "parameter_list": "(B)" }, { "docstring": null, "function_declaration": "def perform_gamma_operations(T, cases):", "function_name": "perform_gamma_operations", "parameter_l...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gamma_operation(binary_str):\n # Flip the bits: '0' to '1' and '1' to '0'\n return ''.join('1' if bit == '0' else '0' for bit in binary_str)\n\ndef solve...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036674", "row_id": 36674, "seed_ids": "[7920]" }
0.566366
Taco_36674
I
[ "gamma_operation", "perform_gamma_operations" ]
2
[ [ "perform_gamma_operations", "gamma_operation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e61cfebe01bb043fe01a604e0e60527de58ec1be
7ef5e9aeade9ad7b5100420083970c63ce58b9fb
v1.0
instruct
Taco
Taco_36760_I
Write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list, preserving their original order. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. If the input list is empty, or contains no prime numb...
def is_prime(n): """ Checks if n is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True def filter_primes(numbers): ...
from solution import filter_primes, is_prime def test_is_prime(): assert is_prime(2) is True assert is_prime(3) is True assert is_prime(4) is False assert is_prime(5) is True assert is_prime(1) is False assert is_prime(0) is False assert is_prime(-1) is False assert is_prime(11) is True...
[ { "docstring": "Checks if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and returns a new list containing only the prime numbers.", "function_declaration": "def filter_pr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036760", "row_id": 36760, "seed_ids": "[13029]" }
0.678316
Taco_36760
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
89c9562787861698fd1b34d95b38dd178d1c1813
673eb64be749432ab683d2df2a6f58955f371f06
v1.0
instruct
Taco
Taco_36771_I
Given an array of integers, find the longest subarray with the maximum number of distinct elements. The goal is to return the subarray itself and not its length. If there are multiple such subarrays with the same length, return the one that appears first. INPUT: The first line contains an integer T, the number of test...
def find_longest_subarray_with_max_distinct_elements(arr): """ Finds the longest subarray with the maximum number of distinct elements. If there are multiple such subarrays with the same length, it returns the one that appears first. """ start = 0 max_len = 0 max_subarray = [] eleme...
from solution import subarray_with_max_distinct def test_single_test_case(): T = 1 test_cases = [ [1, 2, 1, 3, 4, 2, 3] ] expected = [ [1, 2, 1, 3, 4] ] assert subarray_with_max_distinct(T, test_cases) == expected def test_multiple_possible_subarrays(): T = 1 test_cases...
[ { "docstring": "Finds the longest subarray with the maximum number of distinct elements.\nIf there are multiple such subarrays with the same length, \nit returns the one that appears first.", "function_declaration": "def find_longest_subarray_with_max_distinct_elements(arr):", "function_name": "find_lon...
[ 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 longest_subarray_max_distinct(arr):\n \"\"\"\n Finds the longest subarray with the maximum number of distinct elements.\n \"\"\"\n l = 0\n longe...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00036771", "row_id": 36771, "seed_ids": "[22955]" }
0.774105
Taco_36771
I
[ "find_longest_subarray_with_max_distinct_elements", "solve", "subarray_with_max_distinct" ]
3
[ [ "solve", "find_longest_subarray_with_max_distinct_elements" ], [ "subarray_with_max_distinct", "solve" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e56fa4ca91616cb8f12b3c52418fb3c359630574
3fc053304973e7caf44df352665dd5bdeb0b876c
v1.0
instruct
Taco
Taco_36815_I
Dexter is fascinated by palindromes and has devised a unique game involving them. He provides a number and asks you to determine if any rearrangement of its digits can form a palindrome. If it's possible to form at least one palindrome by rearranging the digits, print "YES". Otherwise, print "NO". For example, given t...
def can_rearrange_palindrome(test_cases): results = [] for number in test_cases: digit_count = [0] * 10 for digit in number: digit_count[int(digit)] += 1 odd_count = sum(1 for count in digit_count if count % 2 == 1) if odd_count > 1: ...
from solution import answer_queries def test_single_digit(): assert answer_queries(1, ["5"]) == ["YES"] def test_even_digit_counts(): assert answer_queries(1, ["1221"]) == ["YES"] def test_odd_digit_counts(): assert answer_queries(1, ["12321"]) == ["YES"] def test_no_possible_palindrome(): assert an...
[ { "docstring": null, "function_declaration": "def can_rearrange_palindrome(test_cases):", "function_name": "can_rearrange_palindrome", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def answer_queries(n, numbers):", "function_name": "answer_queries"...
[ 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 can_form_palindrome(n, numbers):\n results = []\n \n # helper function to determine if the number can form a palindrome\n def can_rearrange_to_pali...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036815", "row_id": 36815, "seed_ids": "[14313]" }
0.705097
Taco_36815
I
[ "can_rearrange_palindrome", "answer_queries" ]
2
[ [ "answer_queries", "can_rearrange_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c9cce38155935878f664f448b016bb95bfc6a86d
a5f4f017e28a7a400f6652e0dbd9b512b90cf4c6
v1.0
instruct
Taco
Taco_36825_I
You are given a binary tree where each node contains an integer value. The binary tree is represented as a list of integers in level-order traversal where `null` represents the absence of a node. Your task is to find the maximum sum of values in any path from the root node to a leaf node. A path is defined as any sequ...
from typing import List, Optional class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(level_order: List[Optional[int]]) -> Optional[TreeNode]: if not level_order or level_order[0] is None: return No...
import pytest from solution import max_path_sum def test_max_path_sum_example_1(): assert max_path_sum(6, [1, 2, 3, None, 5, None, None]) == 8 def test_max_path_sum_example_2(): assert max_path_sum(3, [1, 2, 3]) == 4 def test_max_path_sum_single_node(): assert max_path_sum(1, [1]) == 1 def test_max_path...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef build_tree_from_list(level):\n if ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036825", "row_id": 36825, "seed_ids": "[12976]" }
0.664837
Taco_36825
I
[ "build_tree", "max_sum_root_to_leaf", "max_path_sum" ]
3
[ [ "max_path_sum", "build_tree" ], [ "max_path_sum", "max_sum_root_to_leaf" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
40605d30cb2cc8e09e7431c902f5767af0245ba6
8051fe08defdf782ffc3e34f6b925534ecf7991d
v1.0
instruct
Taco
Taco_36829_I
**Problem Statement:** In a distant land, there is an ancient custom of arranging words in a special sequence based on a unique transformation. Each letter in the word is rotated "k" positions forward in the alphabet, with letters wrapping around as necessary. For example, if the letter 'a' is rotated 3 positions for...
def transform_word(word, k): """ Rotates each character in the word by k positions forward in the alphabet. """ transformed = ''.join(chr((ord(char) - ord('a') + k) % 26 + ord('a')) for char in word) return transformed def process_test_cases(test_cases): results = [] for word, k in test_cas...
import pytest from solution import transform_word, process_test_cases, transform_and_evaluate def test_transform_word(): assert transform_word('abcd', 3) == 'defg' assert transform_word('xyz', 2) == 'zab' assert transform_word('a', 1) == 'b' assert transform_word('z', 1) == 'a' def test_process_test_...
[ { "docstring": "Rotates each character in the word by k positions forward in the alphabet.", "function_declaration": "def transform_word(word, k):", "function_name": "transform_word", "parameter_list": "(word, k)" }, { "docstring": null, "function_declaration": "def process_test_cases(te...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_character(c, k):\n \"\"\"\n Rotate single character `c` by `k` positions in the alphabet.\n \"\"\"\n return chr(((ord(c) - ord('a') + k) % 2...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00036829", "row_id": 36829, "seed_ids": "[6141]" }
0.705591
Taco_36829
I
[ "transform_word", "process_test_cases", "transform_and_evaluate" ]
3
[ [ "process_test_cases", "transform_word" ], [ "transform_and_evaluate", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
ee460a04b813d9a690cefe08318ff247b5880927
b157310705fbcb44f605e2d6d06885d506c09f5e
v1.0
instruct
Taco
Taco_36844_I
You have been hired to design a playlist system for a music streaming application. You need to handle user requests to perform operations on their playlists. Each playlist contains a list of songs identified by their unique IDs. Your task is to implement the following operations: 1. Add a new song to a playlist at a ...
from bisect import insort def add_song(playlist, x, pos): """ Adds song ID x to the playlist at position pos. """ playlist.insert(pos, x) def remove_song(playlist, x): """ Removes a song with ID x from the playlist. """ playlist.remove(x) def find_median(playlist): """ Finds t...
def test_add_song(): playlist = [1, 3, 5] add_song(playlist, 4, 2) assert playlist == [1, 3, 4, 5] def test_remove_song(): playlist = [2, 6, 7, 9] remove_song(playlist, 7) assert playlist == [2, 6, 9] def test_find_median_odd(): playlist = [1, 3, 4, 7, 9] assert find_median(playlist) =...
[ { "docstring": "Adds song ID x to the playlist at position pos.", "function_declaration": "def add_song(playlist, x, pos):", "function_name": "add_song", "parameter_list": "(playlist, x, pos)" }, { "docstring": "Removes a song with ID x from the playlist.", "function_declaration": "def r...
[ 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 add_song(playlist, song_id, position):\n \"\"\"\n Add song_id to the playlist at the specified position.\n \"\"\"\n playlist.insert(position, song_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036844", "row_id": 36844, "seed_ids": "[997]" }
0.594545
Taco_36844
I
[ "add_song", "remove_song", "find_median", "process_queries" ]
4
[ [ "process_queries", "add_song" ], [ "process_queries", "find_median" ], [ "process_queries", "remove_song" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
0eb3caecb17b4bfa9e6e0165e96e4c1fd1993a07
a16dc42975af446f7ce44b78d676e1bf2e5ea18e
v1.0
instruct
Taco
Taco_36865_I
In a company, each employee is assigned a performance score from 0 to 100. Based on this score, the employee is rated as follows: - POOR: If the score is less than 40. - AVERAGE: If the score is greater than or equal to 40 but less than 60. - GOOD: If the score is greater than or equal to 60 but less than 80. - EXCELLE...
def determine_rating(score): """ Returns the rating based on the performance score. """ if score < 40: return "POOR" elif score < 60: return "AVERAGE" elif score < 80: return "GOOD" else: return "EXCELLENT" def performance_ratings(n, scores): """ Give...
def test_determine_rating(): assert determine_rating(35) == "POOR" assert determine_rating(89) == "EXCELLENT" assert determine_rating(42) == "AVERAGE" assert determine_rating(77) == "GOOD" assert determine_rating(63) == "GOOD" assert determine_rating(40) == "AVERAGE" assert determine_rating(...
[ { "docstring": "Returns the rating based on the performance score.", "function_declaration": "def determine_rating(score):", "function_name": "determine_rating", "parameter_list": "(score)" }, { "docstring": "Given the number of employees and their scores, returns their ratings.", "funct...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def employee_rating(num_employees, scores):\n \"\"\"\n Returns the rating of employees based on their performance scores.\n \n Parameters:\n num_emp...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036865", "row_id": 36865, "seed_ids": "[5606]" }
0.712571
Taco_36865
I
[ "determine_rating", "performance_ratings" ]
2
[ [ "performance_ratings", "determine_rating" ] ]
1
[]
false
[]
false
pytest
false
[]
true
871fe85b462a8140a75f2d67cadb813c262db610
b930fa014fcc8f2bb3ccbd2159eb6fd3d5bc313b
v1.0
instruct
Taco
Taco_36894_I
A company wants to secure its information by encrypting data using a special technique. They need a program that takes a string and shifts each character by a fixed number of positions in the alphabet. If the shift goes past 'z', it wraps around to 'a'. -----Input:----- - First-line will contain $T$, the number of tes...
def shift_string(s, k): """ Shifts each character in the string `s` by `k` positions in the alphabet. """ result = [] for char in s: if 'a' <= char <= 'z': # Ensuring the character is a lowercase letter shifted = ord(char) + k if shifted > ord('z'): s...
import pytest from solution import shift_string, encrypt_strings, process_input_output def test_shift_string(): assert shift_string("abc", 2) == "cde" assert shift_string("xyz", 3) == "abc" assert shift_string("hello", 5) == "mjqqt" assert shift_string("zebra", 1) == "afcsb" assert shift_string("az...
[ { "docstring": "Shifts each character in the string `s` by `k` positions in the alphabet.", "function_declaration": "def shift_string(s, k):", "function_name": "shift_string", "parameter_list": "(s, k)" }, { "docstring": "Encrypts each string in `test_cases` by shifting characters according ...
[ 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 encrypt_string(s, k):\n \"\"\"\n Encrypts the string s by shifting each character by k positions in the alphabet.\n \n Parameters:\n s (str): Th...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00036894", "row_id": 36894, "seed_ids": "[4880]" }
0.703425
Taco_36894
I
[ "shift_string", "encrypt_strings", "process_input_output" ]
3
[ [ "encrypt_strings", "shift_string" ], [ "process_input_output", "encrypt_strings" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
ad4f9a4cae747658457aabd702d4566e28c9f243
c73035ee887ed4bc367eb049929cd6ff86657ed7
v1.0
instruct
Taco
Taco_36914_I
A bakery shop keeps track of their daily sales and orders in a log. Each entry in the log records a sale or an order of a particular item. The shop needs your help to compute the difference in total sales revenue and predicted revenue for each item at the end of the day. The shop sells various items, and each item has...
def sales_vs_orders_difference(N, M, item_prices, log): """ Calculate the difference between total sales revenue and predicted revenue for each item. Args: N: int - The number of log entries. M: int - The number of different items sold by the shop. item_prices: dict - A dictionary with item...
def test_sales_vs_orders_difference(): N = 5 M = 2 item_prices_list = ["croissant 5", "muffin 3"] logs = [ "+ croissant 20", "- croissant 10", "+ muffin 5", "- muffin 8", "+ croissant 30" ] expected_output = "croissant 200\nmuffin -9" actual_output = ...
[ { "docstring": "Calculate the difference between total sales revenue and predicted revenue for each item.\n\nArgs:\nN: int - The number of log entries.\nM: int - The number of different items sold by the shop.\nitem_prices: dict - A dictionary with item names as keys and their price per unit as values.\nlog: li...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_revenue_difference(log_entries, prices):\n sales_revenue = {}\n predicted_revenue = {}\n \n for item_name in prices:\n sales_reven...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036914", "row_id": 36914, "seed_ids": "[9570]" }
0.681087
Taco_36914
I
[ "sales_vs_orders_difference", "format_output", "bakery_sales_vs_orders" ]
3
[ [ "bakery_sales_vs_orders", "format_output" ], [ "bakery_sales_vs_orders", "sales_vs_orders_difference" ] ]
2
[ "format_output" ]
false
[]
false
pytest
false
[]
true
2493839e6e0e6f020da893c170715cc596df804a
e91f01adef3d6bcb300163342385166f04040cdb
v1.0
instruct
Taco
Taco_36918_I
Given two positive integers N and M, you need to find the N-th multiple of the smallest prime factor (excluding 1) of M. The smallest prime factor of a number is the smallest number greater than 1 that divides it without leaving a remainder. For example, the smallest prime factor of 10 is 2, for 15 it is 3, and for 28...
def smallest_prime_factor(n): """ Returns the smallest prime factor of n. """ if n % 2 == 0: return 2 for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return i return n def nth_multiple_of_smallest_prime_factor(N, M): """ Returns the N-th multiple of t...
from solution import smallest_prime_factor, nth_multiple_of_smallest_prime_factor def test_smallest_prime_factor(): assert smallest_prime_factor(75) == 3 assert smallest_prime_factor(29) == 29 assert smallest_prime_factor(50) == 2 assert smallest_prime_factor(1_000_000) == 2 assert smallest_prime_f...
[ { "docstring": "Returns the smallest prime factor of n.", "function_declaration": "def smallest_prime_factor(n):", "function_name": "smallest_prime_factor", "parameter_list": "(n)" }, { "docstring": "Returns the N-th multiple of the smallest prime factor of M.", "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 smallest_prime_factor(M):\n \"\"\"\n Returns the smallest prime factor of M.\n \"\"\"\n if M % 2 == 0:\n return 2\n for i in range(3, int...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036918", "row_id": 36918, "seed_ids": "[4689]" }
0.645544
Taco_36918
I
[ "smallest_prime_factor", "nth_multiple_of_smallest_prime_factor" ]
2
[ [ "nth_multiple_of_smallest_prime_factor", "smallest_prime_factor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
714bbab238a44772edc2e3e048c272099d560b20
150d325098cb4a20fa5093c03b704f3218f01bf3
v1.0
instruct
Taco
Taco_36950_I
In a forest, there are N trees positioned on an infinite grid. Each tree's location is represented as (X_i, Y_i). You are given Q queries. Each query consists of two integers (A, B) which represent the position of a house in the forest. For each query, find the Euclidean distance to the nearest tree and print it. Com...
import math def nearest_tree_distance(trees, queries): results = [] for (A, B) in queries: min_dist = float('inf') for (X, Y) in trees: dist = math.sqrt((X - A) ** 2 + (Y - B) ** 2) if dist < min_dist: min_dist = dist results.append(min_dist)...
import math from solution import nearest_tree_distance, format_distances def test_nearest_tree_distance_1(): trees = [(1, 2), (4, 6), (7, 8)] queries = [(2, 3), (5, 5)] results = nearest_tree_distance(trees, queries) expected = [math.sqrt(2), math.sqrt(2)] assert results == expected def test_neare...
[ { "docstring": null, "function_declaration": "def nearest_tree_distance(trees, queries):", "function_name": "nearest_tree_distance", "parameter_list": "(trees, queries)" }, { "docstring": null, "function_declaration": "def format_distances(distances):", "function_name": "format_dista...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nimport sys\n\ndef minimum_distance_to_trees(trees, queries):\n results = []\n for (a, b) in queries:\n min_distance = float('inf')\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00036950", "row_id": 36950, "seed_ids": "[13764]" }
0.745682
Taco_36950
I
[ "nearest_tree_distance", "format_distances", "process_input" ]
3
[ [ "process_input", "format_distances" ], [ "process_input", "nearest_tree_distance" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
9db4e12c43856895ba6e160e4609b7d938bce06d
d8d8beb7dd1b8ca1e313862be1a4bfe22ee469c6
v1.0
instruct
Taco
Taco_36964_I
Write a function that finds the smallest number that is divisible by each of a list of given numbers. The function should take a list of integers as input and return the smallest positive integer that is evenly divisible by all the integers in the list. For instance, the smallest number that is divisible by both 4 and...
from math import gcd from functools import reduce def lcm(a, b): """ Compute the least common multiple of two numbers a and b. """ return a * b // gcd(a, b) def smallest_divisible_number(numbers): """ Return the smallest positive integer that is evenly divisible by all the integers in the list...
from solution import lcm, smallest_divisible_number def test_lcm(): assert lcm(4, 5) == 20 assert lcm(7, 3) == 21 assert lcm(10, 6) == 30 def test_smallest_divisible_number(): assert smallest_divisible_number([4, 5]) == 20 assert smallest_divisible_number([1, 2, 3]) == 6 assert smallest_divisi...
[ { "docstring": "Compute the least common multiple of two numbers a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Return the smallest positive integer that is evenly divisible by all the integers in the list.", "fu...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef lcm(a, b):\n \"\"\"\n Returns the least common multiple of a and b.\n \"\"\"\n return abs(a * b) // ma...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00036964", "row_id": 36964, "seed_ids": "[6712]" }
0.65814
Taco_36964
I
[ "lcm", "smallest_divisible_number" ]
2
[ [ "smallest_divisible_number", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef1f9194f97bb3128b7f84f3dc0e9f8e915fd0b0
c6ccde9c3f8b412716f2d002fc1f16e8b80596cc
v1.0
instruct
Taco
Taco_36994_I
Robin loves playing around with numbers. One day, he came across an interesting problem involving prime numbers and wanted to solve it. He needs your help to find the smallest prime number that is larger than a given number. Given an integer $X$, your task is to help Robin find the smallest prime number that is strictl...
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 smallest_prime_greater_than(x): num = ...
from solution import is_prime, smallest_prime_greater_than, find_smallest_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(25) == False def test_smallest_prime_greater_than(): assert smalle...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def smallest_prime_greater_than(x):", "function_name": "smallest_prime_greater_than", "parameter_list": "(x)" }...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from sympy import nextprime\n\ndef smallest_prime_greater_than_x(T, cases):\n \"\"\"\n For each number X in cases, find the smallest prime number greater tha...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00036994", "row_id": 36994, "seed_ids": "[49]" }
0.581417
Taco_36994
I
[ "is_prime", "smallest_prime_greater_than", "find_smallest_primes" ]
3
[ [ "find_smallest_primes", "smallest_prime_greater_than" ], [ "smallest_prime_greater_than", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
51118d47dce5d62d3310c13023a7bc131d2cada4
33a3bad2c36488ee4e096888f8b6d519d3ce98c4
v1.0
instruct
Taco
Taco_37011_I
Chef has recently started learning about number theory and came across the concept of Harshad numbers (or Niven numbers). A Harshad number is an integer that is divisible by the sum of its digits. Chef gets curious and decides to find all Harshad numbers within a given range [A, B] inclusive. Write a program to help C...
def sum_of_digits(n): return sum(int(digit) for digit in str(n)) def is_harshad(number): return number % sum_of_digits(number) == 0 def find_harshad_numbers(a, b): harshad_numbers = [] for num in range(a, b + 1): if is_harshad(num): harshad_numbers.append(num) if harshad_number...
from solution import find_harshad_numbers def test_example_case(): assert find_harshad_numbers(10, 20) == [10, 12, 18, 20] def test_no_harshad_number(): assert find_harshad_numbers(11, 11) == ["NO"] def test_single_harshad_number(): assert find_harshad_numbers(18, 18) == [18] def test_all_single_digit_n...
[ { "docstring": null, "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_harshad(number):", "function_name": "is_harshad", "parameter_list": "(number)" }, { "doc...
[ 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 get_digit_sum(n):\n \"\"\"\n Helper function to calculate the sum of digits of a number.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\nd...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00037011", "row_id": 37011, "seed_ids": "[21119]" }
0.686181
Taco_37011
I
[ "sum_of_digits", "is_harshad", "find_harshad_numbers", "main" ]
4
[ [ "find_harshad_numbers", "is_harshad" ], [ "is_harshad", "sum_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
796e48e59756c5a1dbc363264a3ae796aeb17159
40d272d1504dc446ad0c8478c543f12e850420a2
v1.0
instruct
Taco
Taco_37028_I
Jane loves playing with strings. She has a special operation that she can perform on any string called "character swapping". The operation involves choosing any two distinct indices in the string and swapping the characters at those indices. Jane wonders how many different strings she can create by using this operation...
def count_unique_permutations(string): from math import factorial from collections import Counter # Calculate the frequency of each character freq = Counter(string) # Calculate the total number of permutations as factorial of the length of the string total_permutations = factorial(len(stri...
def test_count_unique_permutations(): assert count_unique_permutations("abc") == 6 assert count_unique_permutations("aaa") == 1 assert count_unique_permutations("aba") == 3 assert count_unique_permutations("aabb") == 6 assert count_unique_permutations("abcd") == 24 assert count_unique_permutatio...
[ { "docstring": null, "function_declaration": "def count_unique_permutations(string):", "function_name": "count_unique_permutations", "parameter_list": "(string)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": ...
[ 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 math import factorial\nfrom collections import Counter\n\ndef unique_permutations(s):\n \"\"\"\n Returns the number of unique permutations that can be f...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00037028", "row_id": 37028, "seed_ids": "[19063]" }
0.718098
Taco_37028
I
[ "count_unique_permutations", "solve", "process_input_output" ]
3
[ [ "process_input_output", "solve" ], [ "solve", "count_unique_permutations" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
false
[]
true
ed5cf84411a6c105fb472b0b0d0ca2fbe0283184
f59df857b5e39f98466a9809a80c0b4559309030
v1.0
instruct
Taco
Taco_37117_I
Twilight Sparkle is organizing a book fair in Equestria. She has decided to group the books into different categories, and each category will have a separate shelf. Each shelf can hold books based on a specific criterion of book height. The criterion is as follows: A shelf can hold books whose heights either form an ar...
def is_arithmetic_progression(arr): if len(arr) < 2: return True arr.sort() d = arr[1] - arr[0] for i in range(2, len(arr)): if arr[i] - arr[i-1] != d: return False return True def is_geometric_progression(arr): if len(arr) < 2: return True arr.sort() ...
def test_no_initial_books(): assert can_form_shelf([]) == True def test_single_initial_book(): assert can_form_shelf([1]) == True def test_arithmetic_progression(): assert can_form_shelf([3, 1, 2, 4]) == True def test_invalid_arithmetic_progression(): assert can_form_shelf([1, 2, 3, 5]) == False def...
[ { "docstring": null, "function_declaration": "def is_arithmetic_progression(arr):", "function_name": "is_arithmetic_progression", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def is_geometric_progression(arr):", "function_name": "is_geometric_progression...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_arithmetic_progression(arr):\n if len(arr) < 2:\n return True\n arr.sort()\n d = arr[1] - arr[0]\n for i in range(2, len(arr)):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00037117", "row_id": 37117, "seed_ids": "[3057]" }
0.603342
Taco_37117
I
[ "is_arithmetic_progression", "is_geometric_progression", "can_form_shelf", "main" ]
4
[ [ "can_form_shelf", "is_arithmetic_progression" ], [ "can_form_shelf", "is_geometric_progression" ] ]
2
[]
false
[]
false
pytest
false
[]
true
78c0c041409faa2de210e49a0b20a7a29d07bf1b
72510e03a410b2160ef9b02d693823bff552c69a
v1.0
instruct
Taco
Taco_37198_I
You are given a list of n teams participating in a relay race, where each team has k members that need to complete their segment of the race one after another. The order in which team members complete their segments is predefined for each team. Given the completion times of each member of each team, calculate the total...
def calculate_race_times(n, k, times): """ Calculates the total time taken by each team to complete the race. Parameters: - n (int): Number of teams - k (int): Number of members in each team - times (list): A list of lists where each inner list contains the completion times of the te...
from solution import relay_race, calculate_race_times def test_single_team_single_member(): assert relay_race(1, 1, [[5]]) == [5] def test_multiple_teams_single_member(): assert relay_race(3, 1, [[5], [10], [7]]) == [5, 10, 7] def test_multiple_teams_multiple_members(): assert relay_race(3, 4, [[5, 4, 7,...
[ { "docstring": "Calculates the total time taken by each team to complete the race.\n\nParameters:\n- n (int): Number of teams\n- k (int): Number of members in each team\n- times (list): A list of lists where each inner list contains the \n completion times of the team members of a team\n\nReturns:\n- list: A l...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_team_total_times(n, k, team_times):\n \"\"\"\n Calculate the total race time for each team.\n \n Args:\n n : int : Number of teams\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00037198", "row_id": 37198, "seed_ids": "[16745]" }
0.650579
Taco_37198
I
[ "calculate_race_times", "relay_race" ]
2
[ [ "relay_race", "calculate_race_times" ] ]
1
[]
false
[]
false
pytest
true
[]
true
91347454d13342ea33a2979b149ac1f9021c0f6d
02bd94334564861a685ed7c2597bb38a7c872566
v1.0
instruct
Taco
Taco_37211_I
There are $M$ employees in a company, each assigned to one of $T$ different teams. For each team $j$ ($1 \le j \le T$), each employee $i$ in team $j$ has an efficiency score $e_{i,j}$, which is a positive integer. The management wants to select exactly one employee from each team such that the sum of the selected emplo...
from itertools import product def min_efficiency_sum(M, T, X, efficiencies): # Generate all possible combinations of choosing one employee from each team combinations = list(product(*efficiencies)) min_sum = float('inf') for combination in combinations: combination_sum = sum(combination) ...
from solution import min_efficiency_sum def test_example(): M, T, X = 3, 2, 5 efficiencies = [ [3, 2, 4], [1, 5, 2] ] assert min_efficiency_sum(M, T, X, efficiencies) == 5 def test_not_possible(): M, T, X = 3, 2, 10 efficiencies = [ [3, 2, 4], [1, 5, 2] ] ...
[ { "docstring": null, "function_declaration": "def min_efficiency_sum(M, T, X, efficiencies):", "function_name": "min_efficiency_sum", "parameter_list": "(M, T, X, efficiencies)" }, { "docstring": null, "function_declaration": "def read_input_and_solve():", "function_name": "read_inpu...
[ 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 itertools import product\n\ndef min_efficiency_sum(M, T, X, efficiencies):\n # Generate all possible combinations of selecting one employee from each team\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00037211", "row_id": 37211, "seed_ids": "[15664]" }
0.701457
Taco_37211
I
[ "min_efficiency_sum", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "min_efficiency_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
125ebb327e323437e5bde7c4b059bf30a02caf66
1eb0af73651cc9f013d2a8877cac27d45bd8caea
v1.0
instruct
Taco
Taco_37268_I
A Smooth Number is an integer n that has all its prime factors less than or equal to a given threshold k. For example, if k = 7, then 42 is a Smooth Number because its prime factors (2, 3, and 7) are all ≤ 7, whereas 44 is not because it has a prime factor 11 which is > 7. Write a program to determine if the integer ...
def is_smooth_number(n, k): def prime_factors(num): i = 2 factors = set() while i * i <= num: if num % i: i += 1 else: num //= i factors.add(i) if num > 1: factors.add(num) return factors ...
from solution import smooth_number def test_smooth_number_sample(): assert smooth_number(42, 7) == "YES" assert smooth_number(44, 7) == "NO" def test_smooth_number_large_k(): assert smooth_number(999999, 100) == "YES" def test_smooth_number_small_prime(): assert smooth_number(2, 2) == "YES" asser...
[ { "docstring": null, "function_declaration": "def is_smooth_number(n, k):", "function_name": "is_smooth_number", "parameter_list": "(n, k)" }, { "docstring": null, "function_declaration": "def smooth_number(n, k):", "function_name": "smooth_number", "parameter_list": "(n, k)" }...
[ 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_smooth_number(n, k):\n \"\"\"\n Determines if the integer n is a Smooth Number for a given threshold k.\n \n Args:\n n (int): The integer to ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00037268", "row_id": 37268, "seed_ids": "[2836]" }
0.494
Taco_37268
I
[ "is_smooth_number", "smooth_number" ]
2
[ [ "smooth_number", "is_smooth_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9c9c67381f641c7a3328e0648756f342c80f5698
cfc6cf2c526dc1e90762ad4b3c53b20072e65664
v1.0
instruct
Taco
Taco_37272_I
Max is learning about prime numbers and he is fascinated by prime pairs. A prime pair is defined as two prime numbers $(p, q)$ where $p < q$. He is particularly interested in finding prime pairs whose sum is a specific number $t$. A prime number is a natural number greater than $1$ that is not a product of two smaller...
def sieve_of_eratosthenes(max_num): """ Generates a list of booleans where True denotes that the index is a prime number. """ sieve = [True] * (max_num + 1) sieve[0] = sieve[1] = False # 0 and 1 are not primes p = 2 while p * p <= max_num: if sieve[p]: for i in range(p *...
from solution import has_prime_pair_sum def test_prime_pair_sum_yes(): assert has_prime_pair_sum(10) == "YES" assert has_prime_pair_sum(14) == "YES" assert has_prime_pair_sum(28) == "YES" assert has_prime_pair_sum(100) == "YES" def test_prime_pair_sum_no(): assert has_prime_pair_sum(11) == "NO" ...
[ { "docstring": "Generates a list of booleans where True denotes that the index is a prime number.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Returns 'YES' if there exist two prime...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00037272", "row_id": 37272, "seed_ids": "[8294]" }
0.744109
Taco_37272
I
[ "sieve_of_eratosthenes", "has_prime_pair_sum" ]
2
[ [ "has_prime_pair_sum", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
efe1c126873b04902a9ed841116cb77bd7b66b75
b8b2010e15996ebe57ea98104f505159b24aaffc
v1.0
instruct
Taco
Taco_37281_I
In a far away galaxy, there exists a planet called Bitland where people are fascinated by binary numbers. Bitlandians love converting numbers to their binary forms and playing with their bits. One day, a Bitlandian scientist discovered a new interesting property called "bit palindrome". A binary number is called a "bi...
def is_bit_palindrome(num): """ Check if the binary representation of num is a palindrome """ binary_rep = bin(num)[2:] # Convert to binary and remove '0b' prefix return binary_rep == binary_rep[::-1] def count_bit_palindromes(n): """ Count bit palindromes between 1 and n inclusive. ""...
from solution import is_bit_palindrome, count_bit_palindromes def test_is_bit_palindrome(): assert is_bit_palindrome(1) == True # '1' assert is_bit_palindrome(2) == False # '10' assert is_bit_palindrome(3) == True # '11' assert is_bit_palindrome(4) == False # '100' assert is_bit_palindrome(5) =...
[ { "docstring": "Check if the binary representation of num is a palindrome", "function_declaration": "def is_bit_palindrome(num):", "function_name": "is_bit_palindrome", "parameter_list": "(num)" }, { "docstring": "Count bit palindromes between 1 and n inclusive.", "function_declaration":...
[ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_bit_palindromes(n):\n \"\"\"\n Returns the number of bit palindromes between 1 and n inclusive.\n \"\"\"\n def is_bit_palindrome(num):\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00037281", "row_id": 37281, "seed_ids": "[19546]" }
0.691671
Taco_37281
I
[ "is_bit_palindrome", "count_bit_palindromes" ]
2
[ [ "count_bit_palindromes", "is_bit_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
114e54bd00256c6251445b06263d71b6facea781
49782b0f5e1a800c2dd7637d02ccdd11e147d165
v1.0
instruct
Taco
Taco_37345_I
In a certain city, there is a unique way to build apartment blocks. Each apartment block is planned as a rectangular grid of rooms. The height (number of floors) and width (number of rooms per floor) have their own constraints. The height of the apartment block must be a divisible factor of a given integer `H`, and the...
def get_factors(n): """ Returns a list of all factors of the given integer n. """ factors = set() for i in range(1, int(n**0.5) + 1): if n % i == 0: factors.add(i) factors.add(n // i) return factors def max_rooms_dimensions(H, W): """ Returns the dimensio...
from solution import get_factors, max_rooms_dimensions def test_get_factors(): assert get_factors(1) == {1} assert get_factors(12) == {1, 2, 3, 4, 6, 12} assert get_factors(18) == {1, 2, 3, 6, 9, 18} def test_max_rooms_dimensions(): assert max_rooms_dimensions(12, 18) == (12, 18) assert max_rooms_...
[ { "docstring": "Returns a list of all factors of the given integer n.", "function_declaration": "def get_factors(n):", "function_name": "get_factors", "parameter_list": "(n)" }, { "docstring": "Returns the dimensions of the apartment block that maximize the number of rooms.", "function_d...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef max_apartment_block(H, W):\n \"\"\"\n Returns the dimensions of the apartment block that maximize the number of rooms\n by finding the ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00037345", "row_id": 37345, "seed_ids": "[7320]" }
0.651416
Taco_37345
I
[ "get_factors", "max_rooms_dimensions" ]
2
[ [ "max_rooms_dimensions", "get_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
67f8c7d46448c81072c725f00f9fe01e6f438a7b
a37bf5ee52b2c788afbf27aa01e74fbbfe4ce963
v1.0
instruct
Taco
Taco_37348_I
Given an array of integers, you are going to remove exactly one element from the array so that the standard deviation of the remaining elements becomes as small as possible. The standard deviation of a dataset is a measure of how much the elements in the dataset deviate from the mean. For a dataset of n elements, the ...
import math def calculate_std_dev(arr): n = len(arr) mean = sum(arr) / n variance = sum((x - mean) ** 2 for x in arr) / n return math.sqrt(variance) def min_std_dev_after_removal(arr): n = len(arr) if n <= 1: return 0 original_std_dev = calculate_std_dev(arr) min_std_dev =...
from solution import min_std_dev_after_removal def test_min_std_dev_example_1(): assert min_std_dev_after_removal([1, 2, 3, 4, 5]) == 1.118034 def test_min_std_dev_example_2(): assert min_std_dev_after_removal([10, 10, 10, 10]) == 0.000000 def test_min_std_dev_example_3(): assert min_std_dev_after_remova...
[ { "docstring": null, "function_declaration": "def calculate_std_dev(arr):", "function_name": "calculate_std_dev", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def min_std_dev_after_removal(arr):", "function_name": "min_std_dev_after_removal", "parame...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef minimum_std_dev(n, arr):\n def std_dev(remaining):\n mean = sum(remaining) / len(remaining)\n variance = sum((x - mean) ** 2 fo...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00037348", "row_id": 37348, "seed_ids": "[1459]" }
0.669799
Taco_37348
I
[ "calculate_std_dev", "min_std_dev_after_removal" ]
2
[ [ "min_std_dev_after_removal", "calculate_std_dev" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81b6071b8147556a37e8cfe881dcf214af6606b3
faecc4b22b943c98af5d249180633893b4ef3c1c
v1.0
instruct
Taco
Taco_37407_I
You are a developer working on a complex multi-tier application that communicates with several back-end services. One of your tasks is to ensure the reliability and efficiency of communication with these services by implementing a retry mechanism. The retry mechanism should attempt to resend the request a certain numbe...
class TransientError(Exception): pass def send_request() -> str: # Simulates sending a request to a service. from random import randint if randint(0, 1) == 0: raise TransientError("Transient error occurred") else: return "Success" def send_with_retry(max_retries: int) -> str: "...
from solution import TransientError, send_request, send_with_retry def test_send_with_retry_success_first_try(monkeypatch): def mock_send_request(): return "Success" monkeypatch.setattr('solution.send_request', mock_send_request) assert send_with_retry(3) == "Success" def test_send_with_retry_succ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TransientError(Exception):\n pass\n\ndef send_request() -> str:\n # Simulates sending a request to a service.\n from random import randint\n if r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00037407", "row_id": 37407, "seed_ids": "[15890]" }
0.476085
Taco_37407
I
[ "send_request", "send_with_retry" ]
2
[ [ "send_with_retry", "send_request" ] ]
1
[]
false
[ "TransientError" ]
true
pytest
true
[]
true
f13dc32a6d090a22fe83d2c0cdac5d9c8e4cf5a0
847f696f4d198f1d83942595c2178fbe27ed6039
v1.0
instruct
Taco
Taco_37413_I
Alice loves solving puzzles, and her latest obsession is word puzzles. She got a list of N words and wants to create a word ladder puzzle out of them. A word ladder is a sequence of words where each word in the sequence differs from the previous word by exactly one character (e.g., CAT -> COT -> DOT -> DOG). Given N w...
from collections import deque def is_adjacent(word1, word2): """ Returns True if word1 and word2 differ by exactly one character. """ difference_count = 0 for c1, c2 in zip(word1, word2): if c1 != c2: difference_count += 1 if difference_count > 1: return Fals...
def test_shortest_word_ladder_length(): words = ["hot", "dot", "dog", "lot", "log"] assert shortest_word_ladder_length(words, "hot", "dog") == 3 def test_no_ladder_exists(): words = ["hot", "dot", "dog", "lot", "log"] assert shortest_word_ladder_length(words, "hot", "logx") == -1 def test_single_step_...
[ { "docstring": "Returns True if word1 and word2 differ by exactly one character.", "function_declaration": "def is_adjacent(word1, word2):", "function_name": "is_adjacent", "parameter_list": "(word1, word2)" }, { "docstring": "Returns the length of the shortest word ladder from start to end....
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_word_ladder_length(N, words, start, end):\n def word_differs_by_one(w1, w2):\n count = sum(1 for a, b in zi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00037413", "row_id": 37413, "seed_ids": "[10973]" }
0.535887
Taco_37413
I
[ "is_adjacent", "shortest_word_ladder_length" ]
2
[ [ "shortest_word_ladder_length", "is_adjacent" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ae112b5373d04f18dd52a777bd85503f1cd353c8
fec1369b0da338eb1f6b4f4ec3df10dd4f0c589b
v1.0
instruct
Taco
Taco_37447_I
You are given a set of images each represented as a 2D grid of characters. The grid consists of characters `B`, `W` and `X` where `B` represents a black pixel, `W` represents a white pixel, and `X` represents a boundary pixel which should not be changed. Your task is to determine the number of isolated black regions (c...
def count_isolated_black_regions(datasets): def dfs(grid, x, y, m, n, visited): stack = [(x, y)] directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] while stack: cx, cy = stack.pop() for dx, dy in directions: nx, ny = cx + dx, cy + dy ...
def test_parse_input(): input_str = "2\n5 5\nX W W W X\nW B B W W\nW B W W W\nW W W X W\nX W W W X\n3 4\nX W W X\nW B W W\nX W B X\n" expected_datasets = [ ((5, 5), [ ['X','W','W','W','X'], ['W','B','B','W','W'], ['W','B','W','W','W'], ['W','W','W','X','W'...
[ { "docstring": null, "function_declaration": "def count_isolated_black_regions(datasets):", "function_name": "count_isolated_black_regions", "parameter_list": "(datasets)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_isolated_black_regions(datasets):\n def dfs(grid, x, y, m, n, visited):\n stack = [(x, y)]\n directions = [(0, 1), (1, 0), (0, -1), (-1,...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00037447", "row_id": 37447, "seed_ids": "[18648]" }
0.607478
Taco_37447
I
[ "count_isolated_black_regions", "parse_input", "count_isolated_black_regions_from_input" ]
3
[ [ "count_isolated_black_regions_from_input", "count_isolated_black_regions" ], [ "count_isolated_black_regions_from_input", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
fd0700a42c04c90e6f774f1fe2b5ef2162b80835
a80a373e1dd8739e6de00ad9a9e5b12325a00518
v1.0
instruct
Taco
Taco_37468_I
A company is interested in optimizing their transportation routes by evaluating the shortest possible route between their warehouses. Their system can be represented using a weighted, undirected graph where nodes represent warehouses and edges represent the transportation routes, with weights indicating the distance. ...
import heapq def dijkstra(adj_matrix, start, dest): n = len(adj_matrix) start -= 1 dest -= 1 # Distance from start to all other nodes distances = [float('inf')] * n distances[start] = 0 # Priority Queue to store (distance, node) pq = [(0, start)] while pq: cur...
def test_shortest_path(): assert shortest_path(4, [[0, 10, 15, 0], [10, 0, 0, 20], [15, 0, 0, 30], [0, 20, 30, 0]], 1, 4) == 30 assert shortest_path(4, [[0, 10, 20, 0], [10, 0, 0, 15], [20, 0, 0, 10], [0, 15, 10, 0]], 1, 4) == 25 assert shortest_path(3, [[0, 10, 0], [10, 0, 20], [0, 20, 0]], 1, 3) == 30 ...
[ { "docstring": null, "function_declaration": "def dijkstra(adj_matrix, start, dest):", "function_name": "dijkstra", "parameter_list": "(adj_matrix, start, dest)" }, { "docstring": null, "function_declaration": "def shortest_path(num_warehouses, adj_matrix, start, dest):", "function_n...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(adj_matrix, start, dest):\n n = len(adj_matrix)\n start -= 1\n dest -= 1\n \n # Distance from start to all other nodes\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00037468", "row_id": 37468, "seed_ids": "[24177]" }
0.690654
Taco_37468
I
[ "dijkstra", "shortest_path" ]
2
[ [ "shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
75989d34619ca3fec3ebab773eb8b92a999b4ecb
5d109e2b408403a6b9b06cc21f6e9f3f1b9e8a95
v1.0
instruct
Taco
Taco_37576_I
Alex loves numbers and he recently learned about prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Alex is now curious about pairs of prime numbers that have a certain interesting property: the difference between them is exactly 2. These pairs are kn...
def sieve_of_eratosthenes(n): """ Generates a list of booleans indicating whether each number <= n is prime. """ primes = [True] * (n + 1) p = 2 while (p * p <= n): if primes[p]: for i in range(p * p, n + 1, p): primes[i] = False p += 1 primes[0], ...
from solution import count_twin_primes def test_twin_primes_below_10(): assert count_twin_primes(10) == 2 def test_twin_primes_below_5(): assert count_twin_primes(5) == 1 def test_twin_primes_below_2(): assert count_twin_primes(2) == 0 def test_twin_primes_below_20(): assert count_twin_primes(20) ==...
[ { "docstring": "Generates a list of booleans indicating whether each number <= n is prime.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Counts the number of twin prime pairs (p1, p2) such that ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_twin_primes(n):\n \"\"\"\n Function to count the number of twin prime pairs where both elements are less than or equal to n.\n \"\"\"\n if n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00037576", "row_id": 37576, "seed_ids": "[15746]" }
0.737487
Taco_37576
I
[ "sieve_of_eratosthenes", "count_twin_primes" ]
2
[ [ "count_twin_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eef67014a906f5ce0c28ade4342e8d1665aac898
822b58ae8f80bdad190ce1982e18201399a25b25
v1.0
instruct
Taco
Taco_37594_I
You are given a binary search tree (BST) with `N` nodes. Each node has a unique integer value. Your task is to determine if the tree forms a valid BST and, if not, determine the minimal changes required to make it a valid BST by either deleting or modifying nodes. A valid BST is defined as: 1. The left subtree of a no...
class TreeNode: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def is_bst(node, min_value, max_value): if node is None: return True if node.value <= min_value or node.value >= max_value: return False retur...
from solution import TreeNode, is_bst, to_tree_structure, minimal_bst_correction def test_is_bst(): # Valid BST example root = TreeNode(10, TreeNode(5), TreeNode(15)) assert is_bst(root, float('-inf'), float('inf')) == True # Invalid BST example invalid_root = TreeNode(10, TreeNode(5, right=TreeNo...
[]
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_bst(tree_data):\n def is_bst(node_index, min_val, max_val):\n if node_index == -1:\n return True\n value, left_child, righ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00037594", "row_id": 37594, "seed_ids": "[22409]" }
0.606433
Taco_37594
I
[ "is_bst", "to_tree_structure", "minimal_bst_correction" ]
3
[ [ "minimal_bst_correction", "is_bst" ], [ "minimal_bst_correction", "to_tree_structure" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
8d828e9c4ca4d3d0894901614af6cbe44c5b99ae
33b6aa1059543920d301af5d4366e32ed42c16cb
v1.0
instruct
Taco
Taco_37620_I
A newly formed scientific expedition team has discovered a special type of plants in the dense forests of Amazon. These plants have an unusual property. Each plant has a unique height, and they grow in clusters. The team has decided to study the growth pattern of these plants over several days. The team recorded the h...
def find_max_cluster(plants): """ Finds the maximum cluster of plants where no plant is taller than another plant that appeared earlier on either day. """ # Sort the plants by their heights on the first day plants_sorted_day1 = sorted(plants, key=lambda x: x[0]) # Get only the heights of the...
def test_find_max_cluster_case1(): plants = [(1, 2), (2, 3), (3, 1)] assert find_max_cluster(plants) == 2 def test_find_max_cluster_case2(): plants = [(1, 3), (2, 2), (3, 4), (4, 1)] assert find_max_cluster(plants) == 2 def test_find_max_cluster_case3(): plants = [(1, 4), (2, 3), (3, 2), (4, 1)] ...
[ { "docstring": "Finds the maximum cluster of plants where no plant is taller\nthan another plant that appeared earlier on either day.", "function_declaration": "def find_max_cluster(plants):", "function_name": "find_max_cluster", "parameter_list": "(plants)" }, { "docstring": null, "func...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_cluster(n, heights):\n # Sort plants based on height on first day; if equal, sort based on second day height\n heights.sort(key=lambda x: (x[0], x[1]...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00037620", "row_id": 37620, "seed_ids": "[12420]" }
0.615266
Taco_37620
I
[ "find_max_cluster", "longest_increasing_subsequence", "main" ]
3
[ [ "find_max_cluster", "longest_increasing_subsequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c7e71fb1f895a7ba7d9ed012548dcd9dde8cc8fb
827bc553d2304a8a4b0781e2573020e69d8b150d
v1.0
instruct
Taco
Taco_37664_I
Tom is fascinated by symmetrical numbers. A symmetrical number is one that remains the same when its digits are reversed. Given an integer, Tom wants to determine the number of steps it takes to make it symmetrical by repeatedly adding the reverse of the number to itself. For example: - Starting with 56, the process w...
def reverse_number(n): return int(str(n)[::-1]) def make_symmetrical(n): steps = 0 while n != reverse_number(n): n += reverse_number(n) steps += 1 return steps, n
from solution import make_symmetrical def test_already_symmetrical(): assert make_symmetrical(1331) == (0, 1331) def test_single_step(): assert make_symmetrical(56) == (1, 121) def test_multiple_steps(): assert make_symmetrical(87) == (4, 4884) def test_single_step_large(): assert make_symmetrical(1...
[ { "docstring": null, "function_declaration": "def reverse_number(n):", "function_name": "reverse_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def make_symmetrical(n):", "function_name": "make_symmetrical", "parameter_list": "(n)" } ]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def reverse_number(n):\n return int(str(n)[::-1])\n\ndef make_symmetrical(n):\n steps = 0\n while n != reverse_number(n):\n n += reverse_number(n)\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00037664", "row_id": 37664, "seed_ids": "[24341]" }
0.577815
Taco_37664
I
[ "reverse_number", "make_symmetrical" ]
2
[ [ "make_symmetrical", "reverse_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ccf69d184b402292be20a1ad428228e97a7e26b2
550b839b7af0fd2211197058445cec378927831d
v1.0
instruct
Taco
Taco_37694_I
Alice loves playing with square matrices and enjoys transposing them. Recently, she encountered a matrix and wanted to determine if it is symmetric with respect to its main diagonal (i.e., the matrix should be equal to its transpose). However, Alice needs your help to automate this process. Can you help her verify if a...
def is_symmetric(matrix): """ Determines if the given matrix is symmetric. :param matrix: A 2D list representing the matrix :return: "YES" if the matrix is symmetric, otherwise "NO" """ n = len(matrix) for i in range(n): for j in range(i, n): if matrix[i][j] != matri...
import pytest from solution import is_symmetric def test_symmetric_matrix(): matrix = [ [1, 2, 3], [2, 4, 5], [3, 5, 6] ] assert is_symmetric(matrix) == "YES" def test_non_symmetric_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] assert is...
[ { "docstring": "Determines if the given matrix is symmetric.\n\n:param matrix: A 2D list representing the matrix\n:return: \"YES\" if the matrix is symmetric, otherwise \"NO\"", "function_declaration": "def is_symmetric(matrix):", "function_name": "is_symmetric", "parameter_list": "(matrix)" }, ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_symmetric(matrix):\n \"\"\"\n Checks if the given matrix is symmetric with respect to its main diagonal.\n \"\"\"\n n = len(matrix)\n for i i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00037694", "row_id": 37694, "seed_ids": "[21806]" }
0.457223
Taco_37694
I
[ "is_symmetric", "read_matrix_and_check_symmetry" ]
2
[ [ "read_matrix_and_check_symmetry", "is_symmetric" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ea022466c9d120b265b9e812a4e2f29bd518ed84
b0c6574ee8cffb763f854a26f791e97b92788ae0
v1.0
instruct
Taco
Taco_37721_I
Anna loves playing with dominoes. She has a set of $n$ dominoes, and each domino is represented as a tuple of two integers $(a, b)$. Anna wants to arrange all the dominoes in a line such that if she places a domino with values $(a_i, b_i)$ next to domino with values $(a_j, b_j)$, then at least one number from $(a_i, b_...
def arrange_dominoes(dominoes): from collections import defaultdict, deque # Create adjacency list and count degrees adj = defaultdict(list) degree = defaultdict(int) for a, b in dominoes: adj[a].append(b) adj[b].append(a) degree[a] += 1 degree[b] += 1 ...
def test_example_1(): assert is_possible_to_arrange(3, [(1, 2), (2, 3), (3, 4)]) == [(1, 2), (2, 3), (3, 4)] def test_example_2(): assert is_possible_to_arrange(3, [(1, 2), (3, 4), (5, 6)]) == "No" def test_example_3(): assert is_possible_to_arrange(4, [(1, 2), (2, 3), (4, 5), (3, 4)]) == [(1, 2), (2, 3),...
[ { "docstring": null, "function_declaration": "def arrange_dominoes(dominoes):", "function_name": "arrange_dominoes", "parameter_list": "(dominoes)" }, { "docstring": null, "function_declaration": "def is_possible_to_arrange(n, dominoes):", "function_name": "is_possible_to_arrange", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def arrange_dominoes(dominoes):\n from collections import defaultdict, deque\n \n # Create adjacency list and count degrees\n adj = defaultdict(list)\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00037721", "row_id": 37721, "seed_ids": "[2963]" }
0.578075
Taco_37721
I
[ "arrange_dominoes", "is_possible_to_arrange" ]
2
[ [ "is_possible_to_arrange", "arrange_dominoes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a1f1da78a8f9d7cadb725bd3c7f823a45d3462cd
3fb8a5514c31e0f7e452e5aea61a6d8e8b56f4af
v1.0
instruct
Taco
Taco_37866_I
Emma is working on text transformation and needs to implement a function that will shift every alphabetical character in a given string by a specified number of places in the alphabet. She needs your help to write code for this. The function should handle both uppercase and lowercase letters. If the shift takes the ch...
def shift_character(c, shift): """ Shift a single character by the given number of positions in the alphabet. Wrap around if the end of the alphabet is reached. """ if 'a' <= c <= 'z': return chr((ord(c) - ord('a') + shift) % 26 + ord('a')) elif 'A' <= c <= 'Z': return chr((ord(c...
from solution import process_test_cases def test_example_cases(): t = 3 test_cases = [ ("abc", 1), ("XYZ", 3), ("Hello, World!", 5) ] results = process_test_cases(t, test_cases) assert results == ["bcd", "ABC", "Mjqqt, Btwqi!"] def test_no_shift(): t = 2 test_cases ...
[ { "docstring": "Shift a single character by the given number of positions in the alphabet.\nWrap around if the end of the alphabet is reached.", "function_declaration": "def shift_character(c, shift):", "function_name": "shift_character", "parameter_list": "(c, shift)" }, { "docstring": "Tra...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def shift_character(c, shift):\n \"\"\"\n Shift a single character by the given number of positions in the alphabet.\n Wrap around if the end of the alpha...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00037866", "row_id": 37866, "seed_ids": "[14771]" }
0.732151
Taco_37866
I
[ "shift_character", "transform_string", "process_test_cases" ]
3
[ [ "process_test_cases", "transform_string" ], [ "transform_string", "shift_character" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
5396d6e744de181548136f413b8b0686a4f5c693
f5a8b87fa7795113b4ab75a1ffe2343311f6767f
v1.0
instruct
Taco
Taco_37886_I
Given a list of `n` cities connected by `n-1` bi-directional roads, you are provided with `q` queries. Each query provides you with two cities and asks for the shortest path length between them in terms of the number of edges. Cities are numbered from `1` to `n`. For example, if `n=5` and the roads are defined as pair...
from collections import defaultdict, deque def preprocess(n, edges): """Preprocess the graph to calculate the distance between all pairs of cities.""" adj = defaultdict(list) for u, v in edges: adj[u].append(v) adj[v].append(u) def bfs(start): """Perform BFS to calculate sh...
def test_shortest_paths_case_1(): n = 5 edges = [(1, 2), (1, 3), (3, 4), (3, 5)] queries = [(2, 4), (4, 5), (1, 3)] expected = [3, 2, 1] assert shortest_paths(n, edges, queries) == expected def test_shortest_paths_case_2(): n = 3 edges = [(1, 2), (1, 3)] queries = [(1, 2), (1, 3), (2, 3...
[ { "docstring": "Preprocess the graph to calculate the distance between all pairs of cities.", "function_declaration": "def preprocess(n, edges):", "function_name": "preprocess", "parameter_list": "(n, edges)" }, { "docstring": "Respond to each query by calculating the shortest path using pre...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef preprocess_tree(tree, n):\n parent = [-1] * (n + 1)\n depth = [-1] * (n + 1)\n def bfs(start):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00037886", "row_id": 37886, "seed_ids": "[23011]" }
0.836824
Taco_37886
I
[ "preprocess", "shortest_paths" ]
2
[ [ "shortest_paths", "preprocess" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1f13270ccb73f4d0fab6cb98a14ee222be9ef81e
7bd10903f5908f209cdea0ff028e3ae9bb557e78
v1.0
instruct
Taco
Taco_37902_I
Consider a graph with `n` nodes and `m` edges. Each node is numbered from 1 to `n`. You are given the edges of the graph, where each edge connects two nodes `u` and `v`. There are also `k` pairs of nodes, and for each pair, you need to determine if there exists a path between these two nodes. You are given T test case...
def find(x, parent): if parent[x] != x: parent[x] = find(parent[x], parent) return parent[x] def union(x, y, parent, rank): rootX = find(x, parent) rootY = find(y, parent) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[rootX...
def test_solution(): T = 1 test_cases = [ { "graph": (4, 4), "edges": [(1, 2), (2, 3), (3, 4), (4, 1)], "queries": (2, [(1, 3), (1, 4)]) } ] expected_output = ["YES", "YES"] assert graph_connectivity(T, test_cases) == expected_output def tes...
[ { "docstring": null, "function_declaration": "def find(x, parent):", "function_name": "find", "parameter_list": "(x, parent)" }, { "docstring": null, "function_declaration": "def union(x, y, parent, rank):", "function_name": "union", "parameter_list": "(x, y, parent, rank)" }, ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(x, parent):\n if parent[x] != x:\n parent[x] = find(parent[x], parent)\n return parent[x]\n\ndef union(x, y, parent, rank):\n rootX = find...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00037902", "row_id": 37902, "seed_ids": "[15810]" }
0.780285
Taco_37902
I
[ "find", "union", "solve", "graph_connectivity" ]
4
[ [ "graph_connectivity", "solve" ], [ "solve", "find" ], [ "solve", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
d53a7bf1293889057d713222f3d17206f81369ba
252e42eaf5ee0bd991b209783b8356c616c497cc
v1.0
instruct
Taco
Taco_37905_I
Blackjack Card Total You need to write a program to calculate the total value of a set of cards in a simplified version of Blackjack. In this version, the cards have the following values: - Number cards (2 through 10) have their face value. - Face cards (Jack, Queen, King) are all worth 10. - An Ace can be worth ei...
def card_value(card): """ Returns the blackjack value of a given card. """ if card in ['Jack', 'Queen', 'King']: return 10 elif card == 'Ace': return 1 # Start with Ace as 1, calculate 11 later if possible else: return int(card) def blackjack_total(cards): """ Ca...
import pytest from solution import card_value, blackjack_total, process_input def test_card_value(): assert card_value('2') == 2 assert card_value('10') == 10 assert card_value('Jack') == 10 assert card_value('Queen') == 10 assert card_value('King') == 10 assert card_value('Ace') == 1 def test...
[ { "docstring": "Returns the blackjack value of a given card.", "function_declaration": "def card_value(card):", "function_name": "card_value", "parameter_list": "(card)" }, { "docstring": "Calculates the highest possible total value of the given set of cards \nin blackjack without exceeding ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_blackjack_total(cards):\n \"\"\"\n Calculate the total value of a set of cards in a simplified version of Blackjack.\n cards: list of str ->...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00037905", "row_id": 37905, "seed_ids": "[21646]" }
0.628895
Taco_37905
I
[ "card_value", "blackjack_total", "process_input" ]
3
[ [ "blackjack_total", "card_value" ], [ "process_input", "blackjack_total" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
8cbb0588e56c5afcd1c83bbfc24f381892815178
451801f9b9a6ea007d37eaef9cce9033dd125707
v1.0
instruct
Taco
Taco_37928_I
Array Subset Sum Given an array of integers and a target sum, determine if there exists a subset within the array that sums exactly to the target sum. Input The first line contains an integer, $n$, the number of elements in the array. The second line contains $n$ integers separated by spaces, representing the elemen...
def is_subset_sum(arr, n, T): """ Determines if there exists a subset of `arr` that sums exactly to `T`. Parameters: arr (list of int): The list of integers. n (int): The number of elements in the list. T (int): The target sum. Returns: str: "YES" if a subset with sum T exists,...
from solution import array_subset_sum def test_sample_input_1(): input_text = "5\n1 2 3 4 5\n9" assert array_subset_sum(input_text) == "YES" def test_sample_input_2(): input_text = "3\n-1 1 0\n2" assert array_subset_sum(input_text) == "NO" def test_sample_input_3(): input_text = "4\n15 -7 -3 8\n8...
[ { "docstring": "Determines if there exists a subset of `arr` that sums exactly to `T`.\n\nParameters:\narr (list of int): The list of integers.\nn (int): The number of elements in the list.\nT (int): The target sum.\n\nReturns:\nstr: \"YES\" if a subset with sum T exists, otherwise \"NO\".", "function_decla...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subset_sum_possible(n, arr, target):\n \"\"\"\n Determines if there exists a subset of elements in arr that sums exactly to target.\n \n Paramet...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00037928", "row_id": 37928, "seed_ids": "[17549]" }
0.683057
Taco_37928
I
[ "is_subset_sum", "array_subset_sum" ]
2
[ [ "array_subset_sum", "is_subset_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2fc5f1cb79cfe160c88a0ff5aa3c6a218da84b80
81844af8a38093a2c97656f86b19a2722707123f
v1.0
instruct
Taco
Taco_37937_I
The city's public transportation system has recently started to track the movement of its buses. Each bus has a unique ID and reports its location (x, y) coordinates at regular intervals. A transportation manager wants to find the bus that has traveled the highest distance over a given period. You need to help him by w...
import math from collections import defaultdict def calculate_distance(x1, y1, x2, y2): return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def find_bus_with_highest_distance(reports): bus_positions = defaultdict(list) bus_distances = defaultdict(float) for report in reports: bus_id, x, y = rep...
def test_calculate_distance(): assert math.isclose(calculate_distance(0, 0, 3, 4), 5.0) assert math.isclose(calculate_distance(1, 1, 4, 5), 5.0) assert math.isclose(calculate_distance(0, 0, 0, 5), 5.0) assert math.isclose(calculate_distance(0, 5, 5, 5), 5.0) assert math.isclose(calculate_distance(5,...
[ { "docstring": null, "function_declaration": "def calculate_distance(x1, y1, x2, y2):", "function_name": "calculate_distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def find_bus_with_highest_distance(reports):", "function_name": "find_b...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom collections import defaultdict\n\ndef calculate_distance(x1, y1, x2, y2):\n \"\"\"\n Calculate the Euclidean distance between two points (x...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00037937", "row_id": 37937, "seed_ids": "[9386]" }
0.752934
Taco_37937
I
[ "calculate_distance", "find_bus_with_highest_distance", "main" ]
3
[ [ "find_bus_with_highest_distance", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d52de2d99f9fadf787005ae02081e4e307cfed20
af7ee80d061488215d88869dfd61862f1a0068a0
v1.0
instruct
Taco
Taco_37942_I
Given an integer n, write a program to generate a list of lists where each inner list contains the first 'i' prime numbers, for i ranging from 1 to n. Example 1: Input: 4 Output: [[2], [2, 3], [2, 3, 5], [2, 3, 5, 7]] Your Task: You don't need to input anything. Complete the function generatePrimeLists() which takes ...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def generate_prime_numbers(n): """ Helper function to generate the first n prim...
from solution import generatePrimeLists def test_generate_prime_lists_1(): assert generatePrimeLists(1) == [[2]] def test_generate_prime_lists_2(): assert generatePrimeLists(2) == [[2], [2, 3]] def test_generate_prime_lists_3(): assert generatePrimeLists(3) == [[2], [2, 3], [2, 3, 5]] def test_generate_...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Helper function to generate the first n prime numbers.", "function_declaration": "def generate_prime_nu...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num < 2:\n return False\n for i in range(2, int(nu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00037942", "row_id": 37942, "seed_ids": "[3820]" }
0.63227
Taco_37942
I
[ "is_prime", "generate_prime_numbers", "generatePrimeLists" ]
3
[ [ "generatePrimeLists", "generate_prime_numbers" ], [ "generate_prime_numbers", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3cfb3abc1244a0ed9022e21e8dd48d67717fc2e0
660d056ef9c6cc9bb1ab5d630b62a8b1a8bf269c
v1.0
instruct
Taco
Taco_38059_I
Paul loves playing with sequences of numbers. One day, he discovered a fascinating pattern in certain integer sequences and decided to test it by writing a program. However, Paul is not very comfortable with coding, so he asked for your help. Given an integer sequence, your task is to transform it using the pattern di...
def sum_of_digits(n): while n >= 10 or n <= -10: n = sum(int(digit) for digit in str(abs(n))) return n if n >= 0 else -n def transform_sequence(sequences): transformed = [] for sequence in sequences: transformed_seq = [sum_of_digits(num) for num in sequence] transformed.append(t...
def test_sum_of_digits(): assert sum_of_digits(12) == 3 assert sum_of_digits(45) == 9 assert sum_of_digits(-23) == 5 assert sum_of_digits(908) == 8 assert sum_of_digits(320) == 5 assert sum_of_digits(155) == 2 assert sum_of_digits(-9) == 9 assert sum_of_digits(81) == 9 assert sum_of_...
[ { "docstring": null, "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def transform_sequence(sequences):", "function_name": "transform_sequence", "parameter_list": "(sequenc...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def digit_sum(n):\n \"\"\"\n Helper function to find the sum of digits of a number until it becomes a single-digit number.\n \"\"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00038059", "row_id": 38059, "seed_ids": "[3067]" }
0.704346
Taco_38059
I
[ "sum_of_digits", "transform_sequence", "parse_input_and_transform" ]
3
[ [ "parse_input_and_transform", "transform_sequence" ], [ "transform_sequence", "sum_of_digits" ] ]
2
[ "parse_input_and_transform" ]
false
[]
false
pytest
false
[]
true
b7453411537c63320ecf8e5eb2929dc7d51f08ab
fab1aa0cc99557ad11a9f170df2576c527fde4a7
v1.0
instruct
Taco
Taco_38063_I
Given an n x n grid filled with integers, where n is always odd, your task is to determine if it's possible to make the grid a magic square by rotating any rows or columns. A grid is considered a magic square if the sum of each row, column, and both diagonals are equal. You can rotate a row or column in a cyclic manner...
def is_magic_square_possible(grid): n = len(grid) def row_sum(row): return sum(grid[row]) def col_sum(col): return sum(grid[row][col] for row in range(n)) def diag1_sum(): return sum(grid[i][i] for i in range(n)) def diag2_sum(): return sum(grid[i][n-1-i] for ...
def test_magic_square_possible(): assert check_magic_square_possible(3, [ [8, 1, 6], [3, 5, 7], [4, 9, 2] ]) == "YES" assert check_magic_square_possible(3, [ [8, 1, 6], [3, 5, 9], [4, 9, 2] ]) == "NO" assert check_magic_square_possible(1, [ [...
[ { "docstring": null, "function_declaration": "def is_magic_square_possible(grid):", "function_name": "is_magic_square_possible", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def check_magic_square_possible(n, grid):", "function_name": "check_magic_squar...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magic_square_possible(grid):\n n = len(grid)\n \n def row_sum(row):\n return sum(grid[row])\n\n def col_sum(col):\n return sum(gri...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00038063", "row_id": 38063, "seed_ids": "[25205]" }
0.634408
Taco_38063
I
[ "is_magic_square_possible", "check_magic_square_possible" ]
2
[ [ "check_magic_square_possible", "is_magic_square_possible" ] ]
1
[]
false
[]
false
pytest
false
[]
true
632cbf50eb05b69921a8465065979a1ef5bf68f6
e4fa3cf17f8f8178ac8122fbda57cad9f2cbfd9f
v1.0
instruct
Taco
Taco_38082_I
Given an array of integers, you need to find the maximum product of any three numbers in the array. If the array contains fewer than three elements, print 'NO SOLUTION'. The product of a group of integers is the result of multiplying them together. INPUT: The first line of the input contains an integer T, the number...
def max_product_of_three(arr): """ Returns the maximum product of any three numbers in the array. If the array contains fewer than three elements, returns 'NO SOLUTION'. """ n = len(arr) if n < 3: return 'NO SOLUTION' arr.sort() # The maximum product can be the product ...
def test_max_product_of_three(): assert max_product_of_three([10, 3, 5, 6, 20]) == 1200 assert max_product_of_three([-10, -10, 5, 2, 1, 0]) == 500 assert max_product_of_three([1, 2]) == 'NO SOLUTION' assert max_product_of_three([1, 2, 3]) == 6 assert max_product_of_three([]) == 'NO SOLUTION' ass...
[ { "docstring": "Returns the maximum product of any three numbers in the array.\nIf the array contains fewer than three elements, returns 'NO SOLUTION'.", "function_declaration": "def max_product_of_three(arr):", "function_name": "max_product_of_three", "parameter_list": "(arr)" }, { "docstri...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_product_of_three(arr):\n \"\"\"\n Returns the maximum product of any three numbers in the array.\n If the array contains fewer than three elements...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00038082", "row_id": 38082, "seed_ids": "[10382]" }
0.744592
Taco_38082
I
[ "max_product_of_three", "find_max_product_of_three", "parse_input", "print_output" ]
4
[ [ "find_max_product_of_three", "max_product_of_three" ] ]
1
[ "parse_input", "print_output" ]
false
[]
false
pytest
false
[]
true
d37d0dd50a1005019a39fc84f40fcd09fefca90d
84a06e22592fb44cb8a40948cbb62c643101778d