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_63129_I
Chef is learning about pangrams and he wants to test his knowledge. A pangram is a sentence that contains every letter of the alphabet at least once. You are given a set of sentences. For each sentence, you need to determine whether it is a pangram or not. -----Input----- - The first line of the input contains a sing...
def is_pangram(sentence): """ Check if a given sentence is a pangram. :param sentence: str :return: bool """ alphabet_set = set('abcdefghijklmnopqrstuvwxyz') sentence_set = set(sentence.lower()) return alphabet_set.issubset(sentence_set) def check_pangrams(sentences): """ Determ...
from solution import is_pangram, check_pangrams def test_is_pangram(): assert is_pangram("The quick brown fox jumps over the lazy dog") == True assert is_pangram("Hello world") == False assert is_pangram("Pack my box with five dozen liquor jugs") == True assert is_pangram("") == False assert is_pan...
[ { "docstring": "Check if a given sentence is a pangram.\n:param sentence: str\n:return: bool", "function_declaration": "def is_pangram(sentence):", "function_name": "is_pangram", "parameter_list": "(sentence)" }, { "docstring": "Determine if each sentence in the list is a pangram.\n:param se...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_pangram(sentence):\n \"\"\"\n Determines if a sentence is a pangram.\n \n Parameters:\n sentence (str): The sentence to check.\n \n Ret...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00063129", "row_id": 63129, "seed_ids": "[18487]" }
0.539327
Taco_63129
I
[ "is_pangram", "check_pangrams" ]
2
[ [ "check_pangrams", "is_pangram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6b5f9278f6be40fc4f381cc6c0a7133f54c7c6cc
80851b1513299c33c6d97c368f6f2fc1a71a631d
v1.0
instruct
Taco
Taco_63144_I
The city of Algoland is planning a new public transportation system. The project involves rotating buses servicing multiple routes. Each bus follows a circular route which it completes in a fixed amount of time. The transportation department wants to analyze the synchronization of bus arrivals at the central station du...
from math import gcd from functools import reduce def lcm(a, b): return a * b // gcd(a, b) def lcm_multiple(numbers): return reduce(lcm, numbers, 1) def count_simultaneous_arrivals(D, bus_times): """ Returns the number of times all buses arrive at the central station simultaneously in a day. ...
from solution import main def test_sample_cases(): test_cases = [ (60, [15, 20]), # Sample Input 1 (100, [30, 40, 50]) # Sample Input 2 ] results = main(test_cases) assert results == [2, 1] def test_one_bus(): test_cases = [ (60, [15]), # Each 15 minutes in an hour, 5 in...
[ { "docstring": null, "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def lcm_multiple(numbers):", "function_name": "lcm_multiple", "parameter_list": "(numbers)" }, { "docstring":...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef gcd(a, b):\n \"\"\"Returns the Greatest Common Divisor of a and b using the Euclidean algorithm.\"\"\"\n whi...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00063144", "row_id": 63144, "seed_ids": "[5807]" }
0.741566
Taco_63144
I
[ "lcm", "lcm_multiple", "count_simultaneous_arrivals", "main" ]
4
[ [ "count_simultaneous_arrivals", "lcm_multiple" ], [ "lcm_multiple", "lcm" ] ]
2
[]
false
[]
false
pytest
true
[]
true
329cbda2df0619564f66fba74515e687855b0b4e
e40eafe32105de2c82abb7860b011f54b6caced3
v1.0
instruct
Taco
Taco_63251_I
Sarah loves palindromic numbers (numbers that read the same forward and backward) and primes (numbers greater than 1 that have no divisors other than 1 and themselves). She wonders if it's possible to find such numbers within a given range. Help Sarah by writing a program that can determine all palindromic primes betwe...
def is_palindrome(number): """ Check if a number is a palindrome. """ return str(number) == str(number)[::-1] def sieve_of_eratosthenes(limit): """ Generates a list of prime numbers up to 'limit' using the Sieve of Eratosthenes. """ is_prime = [True] * (limit + 1) p = 2 while p ...
from solution import is_palindrome, sieve_of_eratosthenes, palindromic_primes_in_range def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(11) == True assert is_palindrome(1) == True assert is_palindrome(10) == False def test_sieve_of...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Generates a list of prime numbers up to 'limit' using the Sieve of Eratosthenes.", "function_declar...
[ 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_palindrome(num):\n return str(num) == str(num)[::-1]\n\ndef is_prime(num):\n if num <= 1:\n return False\n if num == 2:\n return True...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00063251", "row_id": 63251, "seed_ids": "[698]" }
0.583238
Taco_63251
I
[ "is_palindrome", "sieve_of_eratosthenes", "palindromic_primes_in_range" ]
3
[ [ "palindromic_primes_in_range", "is_palindrome" ], [ "palindromic_primes_in_range", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
80a4de163096ba83a65235ef68271b5b3562e654
7c953b9b2806ecea4cd8838b70f20733c5ce51fb
v1.0
instruct
Taco
Taco_63334_I
Riya is organizing a charity walkathon and she wants to print badges for all the participants. Each participant has a unique ID number from 1 to M and provides a string with their first name and last name. Riya wants to optimize the printing format so that each name is printed in the shortest way possible while ensurin...
def generate_badges(test_cases): from collections import defaultdict results = [] for test_case in test_cases: M, participants = test_case id_name_dict = {} unique_badges = defaultdict(list) # To store all attempted and successful short names for unique constraints final_b...
def test_single_case(): input_data = "1\n3\n1 John Doe\n2 Jane Doe\n3 Jack Doe" expected_output = "1 JDoe\n2 JaDoe\n3 JacDoe" assert charity_walkathon_badge(input_data) == expected_output def test_multiple_cases(): input_data = """2 3 1 John Doe 2 Jane Doe 3 Jack Doe 2 1 Alice B...
[ { "docstring": null, "function_declaration": "def generate_badges(test_cases):", "function_name": "generate_badges", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def unique_badges(T, test_cases):\n results = []\n for case in test_cases:\n M, participants = case\n unique_names = {}\n for participan...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00063334", "row_id": 63334, "seed_ids": "[23425]" }
0.620145
Taco_63334
I
[ "generate_badges", "parse_input", "parse_output", "charity_walkathon_badge" ]
4
[ [ "charity_walkathon_badge", "generate_badges" ], [ "charity_walkathon_badge", "parse_input" ], [ "charity_walkathon_badge", "parse_output" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
9d33699b3ff2f84c2da788e583d6239998d6d677
6d9b9e8b2eaf3cfc21cea71ad2ece76a53eee01d
v1.0
instruct
Taco
Taco_63404_I
Chris is fascinated by Fibonacci numbers and has recently come across a new challenge. He wants to write a program that generates the nth Fibonacci number efficiently. The Fibonacci sequence is defined as follows: \[ F(0) = 0 \] \[ F(1) = 1 \] \[ F(n) = F(n-1) + F(n-2) \text{ for } n \geq 2 \] Chris wants you to...
MOD = 10**9 + 7 def matrix_multiply(A, B, mod=MOD): """ Multiplies two 2x2 matrices A and B under modulo. """ return [ [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % mod, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % mod], [(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod, (A[1][0] * B[0][1] + A[1...
from solution import solve_fibonacci_cases def test_single_case(): assert solve_fibonacci_cases([0]) == [0] def test_base_cases(): assert solve_fibonacci_cases([0, 1]) == [0, 1] def test_small_cases(): assert solve_fibonacci_cases([10]) == [55] assert solve_fibonacci_cases([2, 3, 4]) == [1, 2, 3] de...
[ { "docstring": "Multiplies two 2x2 matrices A and B under modulo.", "function_declaration": "def matrix_multiply(A, B, mod=MOD):", "function_name": "matrix_multiply", "parameter_list": "(A, B, mod=MOD)" }, { "docstring": "Computes the power of a matrix to the nth power under modulo.", "f...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci_modulo(n, MOD=10**9 + 7):\n \"\"\"\n Computes the nth Fibonacci number modulo MOD.\n \"\"\"\n if n == 0:\n return 0\n if n == 1...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00063404", "row_id": 63404, "seed_ids": "[22658]" }
0.673
Taco_63404
I
[ "matrix_multiply", "matrix_power", "fibonacci_mod", "solve_fibonacci_cases" ]
4
[ [ "fibonacci_mod", "matrix_power" ], [ "matrix_power", "matrix_multiply" ], [ "solve_fibonacci_cases", "fibonacci_mod" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e9fcf5c61a478251a527aba5d400a4a96b253f49
af695c5f2e1aa8fe9d73332c203919cf17dc966d
v1.0
instruct
Taco
Taco_63429_I
Marcus is learning about binary trees and wants to write a program to check if a given binary tree is a Binary Search Tree (BST). A BST is defined as a binary tree in which for each node: - The value of all the nodes in the left subtree is less than the value of the current node. - The value of all the nodes in the ri...
class TreeNode: def __init__(self, value, left=-1, right=-1): self.value = value self.left = left self.right = right def is_bst_helper(tree, node_idx, min_val, max_val): if node_idx == -1: return True node = tree[node_idx] if not (min_val < node.value < max_val): ...
from solution import check_bst def test_single_node(): assert check_bst([(10, -1, -1)]) == "YES" def test_two_nodes_right_child(): assert check_bst([(10, -1, 1), (20, -1, -1)]) == "YES" def test_two_nodes_left_child(): assert check_bst([(10, 1, -1), (5, -1, -1)]) == "YES" def test_three_nodes_valid_bst(...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value, left, right):\n self.value = value\n self.left = left\n self.right = right\n\ndef is_bst_util(n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00063429", "row_id": 63429, "seed_ids": "[20067]" }
0.652514
Taco_63429
I
[ "is_bst_helper", "is_bst", "build_tree", "check_bst" ]
4
[ [ "check_bst", "build_tree" ], [ "check_bst", "is_bst" ], [ "is_bst", "is_bst_helper" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
077c3ca0ce0faba8077bfdbfc2cb84981816eaee
1ab4933044e58e45a1189adec6d800135de92db4
v1.0
instruct
Taco
Taco_63474_I
Write a function that takes a list of integers as input and returns the list with only the prime numbers from the original list. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. For example, 2, 3, 5, 7, and 11 are prime numbers. For example: ```python input_list =...
def is_prime(n): """ Determines whether a given number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import filter_primes def test_filter_primes_with_mixed_list(): assert filter_primes([4, 5, 6, 7, 8]) == [5, 7] def test_filter_primes_with_all_prime_numbers(): assert filter_primes([2, 3, 5, 7, 11]) == [2, 3, 5, 7, 11] def test_filter_primes_with_no_prime_numbers(): assert filter_primes([4,...
[ { "docstring": "Determines whether a given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters the prime numbers from the input list.", "function_declaration": "def filter_primes(input_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 is_prime(n):\n \"\"\"\n Determines whether a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00063474", "row_id": 63474, "seed_ids": "[3852]" }
0.668557
Taco_63474
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7d4f556515748154fbc8ce20b88bfd83bbbb099d
15997aed172dbcde9ef6690d783e2cb819cd81e2
v1.0
instruct
Taco
Taco_63485_I
You are given a rectangular grid of size n x m. Each cell in the grid contains either a 0 or a 1. A cell containing a 1 is considered to be a part of a building, and a cell containing a 0 is considered to be open land. Your goal is to find the largest rectangular area consisting entirely of buildings (1's) within the g...
def largestRectangleArea(heights): """ This function calculates the area of the largest rectangle in a histogram given by heights. """ stack = [] max_area = 0 heights.append(0) # Add a zero height to flush out remaining rectangles for i, h in enumerate(heights): while stack and heig...
import pytest from solution import maximalRectangle def test_example_case(): grid = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert maximalRectangle(grid) == 6 def test_all_zeros(): grid = [ [0, 0], [0, 0] ] assert m...
[ { "docstring": "This function calculates the area of the largest rectangle in a histogram given by heights.", "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "parameter_list": "(heights)" }, { "docstring": "This function calculates the a...
[ 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 maximalRectangle(matrix):\n \"\"\"\n Returns the area of the largest rectangle containing only 1's in a binary matrix.\n \"\"\"\n if not matrix:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063485", "row_id": 63485, "seed_ids": "[16008]" }
0.687671
Taco_63485
I
[ "largestRectangleArea", "maximalRectangle" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
94151ef48d5a4e2dec633c87d8b9bf9b80aa7fac
35ea65ce29a8c35397f11d015b42cb9a8b567490
v1.0
instruct
Taco
Taco_63503_I
### Road Construction Cost Minimization A country consists of n cities and m roads connecting them. Each road has a certain cost to travel. The government wants to construct a high-speed railway network such that every city is reachable from any other city using this network. The construction cost of building the rail...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] = r...
def test_minimum_construction_cost_example1(): n = 4 m = 5 roads = [ (1, 2, 3), (2, 3, 4), (3, 4, 5), (1, 4, 1), (1, 3, 2) ] assert minimum_construction_cost(n, m, roads) == 6 def test_minimum_construction_cost_example2(): n = 3 m = 1 roads = [ ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00063503", "row_id": 63503, "seed_ids": "[8010]" }
0.753647
Taco_63503
I
[ "find", "union", "minimum_construction_cost" ]
3
[ [ "minimum_construction_cost", "find" ], [ "minimum_construction_cost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
471042079eb9c3b06bb6b0788e7752a497d8999d
dd5aa1a5c2e5e438cd2917ae21cb01485ba5cc21
v1.0
instruct
Taco
Taco_63555_I
In a coding competition, Alice and Bob are having fun with palindromes. A palindrome is a string that reads the same forward and backward. Alice has a special interest in numbers that form palindromes. Alice is given an integer and she wants to find out the smallest palindrome greater than or equal to the number she i...
def next_palindrome(n): """ Finds the smallest palindrome greater than or equal to the given number. """ def is_palindrome(x): s = str(x) return s == s[::-1] while not is_palindrome(n): n += 1 return n def find_next_palindromes(numbers): results = [] for num...
from solution import next_palindrome, find_next_palindromes def test_next_palindrome_exact_palindrome(): assert next_palindrome(121) == 121 def test_next_palindrome_non_palindrome(): assert next_palindrome(123) == 131 def test_find_next_palindromes_single(): assert find_next_palindromes([132]) == [141] ...
[ { "docstring": "Finds the smallest palindrome greater than or equal to the given number.", "function_declaration": "def next_palindrome(n):", "function_name": "next_palindrome", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_next_palindromes(numbers):",...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(num):\n \"\"\"\n Helper function to check if a number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef next_palin...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063555", "row_id": 63555, "seed_ids": "[23036]" }
0.809505
Taco_63555
I
[ "next_palindrome", "find_next_palindromes" ]
2
[ [ "find_next_palindromes", "next_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dc5aed764603b591f4b75ab04b5b1ebedcca8d30
2815af3c9700598d65f39a1bae3ccca30c9cbc39
v1.0
instruct
Taco
Taco_63578_I
Given an array of positive integers representing the number of pages in different notebooks, and a positive integer k, which represents the number of students, divide the notebooks among the k students in such a way that the maximum number of pages assigned to a student is minimized. Each student must be assigned at le...
def is_valid_distribution(pages, n, k, max_pages_per_student): required_students = 1 current_pages = 0 for i in range(n): if current_pages + pages[i] > max_pages_per_student: required_students += 1 current_pages = pages[i] if required_students > k: ...
from solution import find_minimized_max_pages def test_example_case(): assert find_minimized_max_pages(4, [12, 34, 67, 90], 2) == 113 def test_single_student_multiple_notebooks(): assert find_minimized_max_pages(3, [10, 20, 30], 1) == 60 def test_single_notebook_multiple_students(): assert find_minimized...
[ { "docstring": null, "function_declaration": "def is_valid_distribution(pages, n, k, max_pages_per_student):", "function_name": "is_valid_distribution", "parameter_list": "(pages, n, k, max_pages_per_student)" }, { "docstring": null, "function_declaration": "def find_minimized_max_pages(...
[ 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_valid_distribution(pages, n, k, max_pages_per_student):\n required_students = 1\n current_pages = 0\n\n for i in range(n):\n if current_page...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00063578", "row_id": 63578, "seed_ids": "[15753]" }
0.688037
Taco_63578
I
[ "is_valid_distribution", "find_minimized_max_pages" ]
2
[ [ "find_minimized_max_pages", "is_valid_distribution" ] ]
1
[]
false
[]
false
pytest
true
[]
true
237d042bf9eb21b1dfbc5a53a603a613282ef81f
1f2477a24b6a1d35cbd0f6b204d31e076df36226
v1.0
instruct
Taco
Taco_63590_I
Your task is to develop a program that helps in clustering a list of distances. Given a list of distances between various points, you need to divide them into clusters such that the maximum distance within any cluster is minimized. The clusters must maintain the order of the distances as in the original list. Input T...
def can_partition(distances, max_distance): current_sum = 0 for distance in distances: if current_sum + distance <= max_distance: current_sum += distance else: if distance > max_distance: return False current_sum = distance return True def...
import pytest from solution import find_minimized_max_distance def test_case_1(): n = 6 distances = [1, 5, 2, 4, 8, 3] assert find_minimized_max_distance(n, distances) == 8 def test_case_2(): n = 4 distances = [1, 2, 3, 100] assert find_minimized_max_distance(n, distances) == 100 def test_cas...
[ { "docstring": null, "function_declaration": "def can_partition(distances, max_distance):", "function_name": "can_partition", "parameter_list": "(distances, max_distance)" }, { "docstring": null, "function_declaration": "def find_minimized_max_distance(n, distances):", "function_name...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimized_max_distance(n, distances):\n \"\"\"\n Divides the list of distances into clusters such that the maximum distance within any cluster is minimiz...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00063590", "row_id": 63590, "seed_ids": "[25214]" }
0.6403
Taco_63590
I
[ "can_partition", "find_minimized_max_distance" ]
2
[ [ "find_minimized_max_distance", "can_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b6d3e022415eab25dceca2c80b8fb1e65704c9a
9a94ddff58a62de221a2a460f9e8acb81f0efed6
v1.0
instruct
Taco
Taco_63595_I
You are given a binary tree where each node contains a positive integer value. Your task is to rearrange the tree such that each node in the tree contains the sum of its original value and the original values of all its descendant nodes (i.e., all nodes in its subtree). A subtree of a node is defined as the node itsel...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(adjacency_list): if not adjacency_list: return None nodes = {} for val, left, right in adjacency_list: if val not in nodes: ...
import pytest from solution import rearrange_tree def test_rearrange_tree(): input_tree = [(5, 2, 3), (2, 0, 0), (3, 4, 0), (4, 0, 0)] expected_output = [(14, 2, 7), (2, 0, 0), (7, 4, 0), (4, 0, 0)] assert rearrange_tree(input_tree) == expected_output def test_single_node_tree(): input_tree = [(1, 0, ...
[]
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00063595", "row_id": 63595, "seed_ids": "[22006]" }
0.64979
Taco_63595
I
[ "build_tree", "tree_to_adjacency_list", "update_subtree_sum", "rearrange_tree" ]
4
[ [ "rearrange_tree", "build_tree" ], [ "rearrange_tree", "tree_to_adjacency_list" ], [ "rearrange_tree", "update_subtree_sum" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
49b5c724424e5b7e689ac9206952d6e62a7d915e
2ce3e0ad9c99498724afe601694761fc5bcc4f80
v1.0
instruct
Taco
Taco_63604_I
You are given a list of integers and your task is to find the largest prime factor for each integer in the list. The list can have up to 10^5 integers, each ranging from 1 to 10^9. After determining the largest prime factor for each number, output them in the same order they were given. Example 1: Input: 5 10 15 21 2...
def largest_prime_factor(n): if n <= 1: return 1 max_prime = -1 while n % 2 == 0: max_prime = 2 n //= 2 for i in range(3, int(n**0.5) + 1, 2): while n % i == 0: max_prime = i n //= i if n > 2: max_prime = n return max_prime def lar...
from solution import largestPrimeFactors def test_largest_prime_factors_single_elements(): assert largestPrimeFactors([10]) == [5] assert largestPrimeFactors([15]) == [5] assert largestPrimeFactors([21]) == [7] assert largestPrimeFactors([29]) == [29] assert largestPrimeFactors([49]) == [7] ass...
[ { "docstring": null, "function_declaration": "def largest_prime_factor(n):", "function_name": "largest_prime_factor", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def largestPrimeFactors(numbers):", "function_name": "largestPrimeFactors", "parameter_li...
[ 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 largest_prime_factor(n):\n if n <= 1:\n return n\n\n max_prime = -1\n\n while n % 2 == 0:\n max_prime = 2\n n //= 2\n\n for i ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063604", "row_id": 63604, "seed_ids": "[7715]" }
0.756081
Taco_63604
I
[ "largest_prime_factor", "largestPrimeFactors" ]
2
[ [ "largestPrimeFactors", "largest_prime_factor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
454b1cdac4e00283a6a94d23e59ec26e2d29480b
69cf8a5bbc1aa87d46f8b8b0eed9b479f2ddfd43
v1.0
instruct
Taco
Taco_63616_I
You are given a list of integers. In one operation, you can pick any two integers from the list and replace each of them with their average. The new values should still be integers. The task is to determine if you can make all integers in the list equal in some number of operations. For example, if you have the intege...
def can_make_all_elements_equal(test_cases): def gcd(x, y): while y: x, y = y, x % y return x results = [] for case in test_cases: n, arr = case if n == 1: results.append("YES") continue common_gcd = arr[0] for num in arr[...
from solution import can_make_all_elements_equal def test_example_cases(): test_cases = [ (4, [3, 3, 6, 12]), (2, [5, 10]), (3, [30, 60, 90]), ] assert can_make_all_elements_equal(test_cases) == ["YES", "YES", "YES"] def test_single_element(): test_cases = [ (1, [1]), ...
[ { "docstring": null, "function_declaration": "def can_make_all_elements_equal(test_cases):", "function_name": "can_make_all_elements_equal", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "parameter_list"...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_make_all_equal(t, test_cases):\n results = []\n for i in range(t):\n n = test_cases[i][0]\n a = test_cases[i][1]\n \n if ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063616", "row_id": 63616, "seed_ids": "[11458]" }
0.674665
Taco_63616
I
[ "can_make_all_elements_equal", "solve" ]
2
[ [ "solve", "can_make_all_elements_equal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b90c10deac1c162f827ab0c2b312e0cf51e41f2
a06004a63964b92cd0b08f271da54b2ee595c7d5
v1.0
instruct
Taco
Taco_63632_I
In a 2D grid of size n x m, you are given the initial position of a robot starting at (sr, sc). The robot can only move up, down, left, or right, but cannot move onto blocked cells (denoted by '*'). Open cells are represented by '.'. Your objective is to guide the robot to reach a destination position (dr, dc) using t...
from collections import deque def min_movements(n, m, sr, sc, dr, dc, grid): """ Function to find the minimum number of movements required for the robot to reach the destination (dr, dc) from (sr, sc). Return -1 if it is impossible. """ # Converting positions from 1-based index to 0-based index ...
from solution import find_min_movements_to_destination def test_sample_case(): input_string = """5 5 1 1 5 5 ..... .*... ..... ...*. .....""" assert find_min_movements_to_destination(input_string) == 8 def test_no_possible_path(): input_string = """3 3 1 1 3 3 ..* .*. *..""" assert find_min_movements_...
[ { "docstring": "Function to find the minimum number of movements required for the robot to reach the destination (dr, dc) from (sr, sc).\nReturn -1 if it is impossible.", "function_declaration": "def min_movements(n, m, sr, sc, dr, dc, grid):", "function_name": "min_movements", "parameter_list": "(n...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_moves(n, m, sr, sc, dr, dc, grid):\n # Convert input positions to 0-indexed.\n sr -= 1\n sc -= 1\n dr -= 1\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00063632", "row_id": 63632, "seed_ids": "[22943]" }
0.770887
Taco_63632
I
[ "min_movements", "find_min_movements_to_destination" ]
2
[ [ "find_min_movements_to_destination", "min_movements" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54993e6981f775344721b01765f19c6833cf10d7
c51c2aedcabd75c58f65fd18faa25a24db80848b
v1.0
instruct
Taco
Taco_63643_I
Given a binary search tree (BST) of N nodes, your task is to complete the function convertToSortedDLL() that converts the BST into a sorted doubly linked list (in-place). The left pointer of the tree node should act as a previous pointer in the doubly linked list and the right pointer should act as the next pointer. I...
class TreeNode: def __init__(self, data): self.data = data self.left = None self.right = None class DoublyLinkedListNode: def __init__(self, data): self.data = data self.prev = None self.next = None def bst_insert(root, key): if root is None: return ...
import pytest def test_convert_single_node(): values = [10] bst_root = build_bst_from_list(values) dll_head = convertToSortedDLL(bst_root) assert print_dll(dll_head) == [10] def test_convert_multiple_nodes(): values = [4, 2, 1, 3, 6, 5, 7] bst_root = build_bst_from_list(values) dll_head = ...
[]
[ 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, data):\n self.data = data\n self.left = None\n self.right = None\n\nclass DoublyLinkedListNode:\n d...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00063643", "row_id": 63643, "seed_ids": "[4406]" }
0.480865
Taco_63643
I
[ "bst_insert", "convertToSortedDLL", "print_dll", "build_bst_from_list" ]
4
[ [ "build_bst_from_list", "bst_insert" ] ]
1
[]
false
[ "TreeNode", "DoublyLinkedListNode" ]
true
pytest
false
[]
true
e752bb28c054915c6641a8773151cb88b7873162
242fd1bc62ddc8cb3072e4545d4fe2f786059613
v1.0
instruct
Taco
Taco_63683_I
# Description: You are given an array of integers `arr`. Your task is to find the sum of all the prime numbers present in the array. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Implement a function `sumOfPrimes(arr)` that takes an array of integers `arr` a...
def is_prime(n): """ Helper function to check if a number is a 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 ...
from solution import sumOfPrimes def test_example_cases(): assert sumOfPrimes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17 assert sumOfPrimes([11, 13, 17, 23, 29, 31, 37, 41, 43, 47]) == 292 assert sumOfPrimes([4, 6, 8, 10, 12]) == 0 def test_no_primes(): assert sumOfPrimes([0, 1, -3, 4, 15]) == 0 def test...
[ { "docstring": "Helper function to check if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the array.", "function_declaration": "def sumOfPrimes(arr):", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063683", "row_id": 63683, "seed_ids": "[5434]" }
0.632734
Taco_63683
I
[ "is_prime", "sumOfPrimes" ]
2
[ [ "sumOfPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
542cc309a1317be5386fd7c2cc3ddf7d27c15889
4bfaef6349b69831a5f60a71455ca99625bc87ac
v1.0
instruct
Taco
Taco_63788_I
Write a program that finds the largest rectangular sub-matrix with elements that are all odd numbers within a given matrix. The size of the matrix is provided, and the program should identify the largest rectangle (by area) where all elements are odd numbers. Input The input consists of a single dataset in the follo...
def largest_odd_submatrix_area(matrix): n = len(matrix) m = len(matrix[0]) # Convert the matrix into a 0/1 matrix where 1 represents odd number and 0 represents even number bin_matrix = [[1 if matrix[i][j] % 2 != 0 else 0 for j in range(m)] for i in range(n)] max_area = 0 # Store the maxi...
from solution import largest_odd_submatrix_area, parse_input def test_single_element_matrix(): matrix = parse_input("1 1\n1") assert largest_odd_submatrix_area(matrix) == 1 matrix = parse_input("1 1\n2") assert largest_odd_submatrix_area(matrix) == 0 def test_all_odd_matrix(): matrix = parse_i...
[ { "docstring": null, "function_declaration": "def largest_odd_submatrix_area(matrix):", "function_name": "largest_odd_submatrix_area", "parameter_list": "(matrix)" }, { "docstring": "Helper function to determine the largest rectangle area in histogram. ", "function_declaration": "def lar...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_odd_submatrix(matrix):\n def is_odd(x):\n return x % 2 != 0\n\n n = len(matrix)\n m = len(matrix[0])\n \n odd_matrix = [[is_odd(m...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063788", "row_id": 63788, "seed_ids": "[827]" }
0.637625
Taco_63788
I
[ "largest_odd_submatrix_area", "largest_rectangle_area", "parse_input" ]
3
[ [ "largest_odd_submatrix_area", "largest_rectangle_area" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
9914482316905c5a40a7a9c13665200cb124f25d
6bfd0ef01d29ff8a9d3fa86a7be7b67c6d6becb1
v1.0
instruct
Taco
Taco_63798_I
Given a positive integer $n$, you are required to find out if $n$ can be expressed as a sum of three distinct prime numbers. Constraints $1 \leq n \leq 5000$ Input Format First and only line of the input will contain an integer $n$. Output Format Output "YES" if $n$ can be expressed as a sum of three distinct pri...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6...
from solution import find_three_primes_sum def test_case_1(): assert find_three_primes_sum(23) == "YES" def test_case_2(): assert find_three_primes_sum(7) == "NO" def test_case_3(): assert find_three_primes_sum(10) == "YES" def test_case_4(): assert find_three_primes_sum(18) == "YES" def test_case_...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determine if the number n can be expressed as the sum of three distinct primes.", "function_declaration": "def find_three_...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n retur...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00063798", "row_id": 63798, "seed_ids": "[646]" }
0.636454
Taco_63798
I
[ "is_prime", "find_three_primes_sum" ]
2
[ [ "find_three_primes_sum", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e874ddf1115b268a9c5a28dcf6ea46cac25dc8c8
151d2789aa75d1e40efaffcb0f9b4c9be7f15e2f
v1.0
instruct
Taco
Taco_63799_I
Given a matrix of size n*m, implement a function that rotates the matrix 90 degrees clockwise. Input: The first line contains two integers n and m, representing the number of rows and columns of the matrix. The next n lines contain m integers each, representing the elements of the matrix. Output: Return the matrix af...
def rotate_matrix_90_degrees_clockwise(matrix): """ Rotates the given n*m matrix 90 degrees clockwise. Parameters: matrix (list of list of int): 2D list representing the matrix to be rotated. Returns: list of list of int: The rotated matrix. """ n = len(matrix) m = len(matr...
from solution import rotate_matrix_90_degrees_clockwise, rotate_matrix def test_rotate_square_matrix(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected_output = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] assert rotate_matrix_90_degrees_clockwise(matrix...
[ { "docstring": "Rotates the given n*m matrix 90 degrees clockwise.\n\nParameters:\nmatrix (list of list of int): 2D list representing the matrix to be rotated.\n\nReturns:\nlist of list of int: The rotated matrix.", "function_declaration": "def rotate_matrix_90_degrees_clockwise(matrix):", "function_nam...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_matrix_90_clockwise(matrix):\n \"\"\"\n Rotates a given n*m matrix 90 degrees clockwise.\n \n Args:\n matrix (list of list of int): The o...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00063799", "row_id": 63799, "seed_ids": "[12662]" }
0.577005
Taco_63799
I
[ "rotate_matrix_90_degrees_clockwise", "rotate_matrix" ]
2
[ [ "rotate_matrix", "rotate_matrix_90_degrees_clockwise" ] ]
1
[]
false
[]
false
pytest
true
[]
true
afa0d2e70b76b585f2c0e7e86d409f9a7bdd5b97
28ae54e26c4a03016eb996ef1504812081071d95
v1.0
instruct
Taco
Taco_63807_I
A programming competition is being held where participants are to solve a maze game. The maze is represented by a 2D grid where empty cells are represented by a dot `.` and obstacles are represented by a hash sign `#`. The goal is to find the minimum number of steps required to move from the start position `(Sx, Sy)` t...
from collections import deque def min_steps(maze, Sx, Sy, Ex, Ey): N = len(maze) M = len(maze[0]) if maze[Sx][Sy] == '#' or maze[Ex][Ey] == '#': return -1 directions = [(0, 1), (0, -1), (1, 0), (-1, 0)] visited = [[False] * M for _ in range(N)] queue = deque([(Sx, Sy, 0)]) ...
def test_min_steps_in_clear_path(): maze = [ ".....", ".....", ".....", ".....", "....." ] result = solve_maze(5, 5, maze, (0, 0, 4, 4)) assert result == 8 def test_min_steps_with_obstacles(): maze = [ ".....", ".###.", "..#..", ...
[ { "docstring": null, "function_declaration": "def min_steps(maze, Sx, Sy, Ex, Ey):", "function_name": "min_steps", "parameter_list": "(maze, Sx, Sy, Ex, Ey)" }, { "docstring": null, "function_declaration": "def solve_maze(N, M, maze_lines, start_end_positions):", "function_name": "so...
[ 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 min_steps(maze, Sx, Sy, Ex, Ey):\n N = len(maze)\n M = len(maze[0])\n \n if maze[Sx][Sy] == '#' or maze[Ex][Ey] ==...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00063807", "row_id": 63807, "seed_ids": "[25004]" }
0.790437
Taco_63807
I
[ "min_steps", "solve_maze" ]
2
[ [ "solve_maze", "min_steps" ] ]
1
[]
false
[]
false
pytest
false
[]
true
be520489e757b8a63ac5ce541afc1bdf16cce8aa
7edae871ab0fa89477794e3b2278b32604ca3db2
v1.0
instruct
Taco
Taco_63905_I
You are given a sequence of numbers, and you need to find a contiguous subsequence which, when its elements are summed, yields the highest possible value. You need to implement a function that returns this maximum sum. **Input** A single line that contains space-separated integers representing the sequence `a1, a2, ....
def max_subarray_sum(sequence): """ Returns the maximum sum of a contiguous subsequence in the given sequence. """ max_current = max_global = sequence[0] for num in sequence[1:]: max_current = max(num, max_current + num) if max_current > max_global: max_global = max_...
from solution import solve def test_example_case(): assert solve("-2 1 -3 4 -1 2 1 -5 4") == 6 def test_all_negative_numbers(): assert solve("-1 -2 -3 -4") == -1 def test_single_element(): assert solve("5") == 5 assert solve("-5") == -5 def test_all_positive_numbers(): assert solve("1 2 3 4 5") ...
[ { "docstring": "Returns the maximum sum of a contiguous subsequence in the given sequence.", "function_declaration": "def max_subarray_sum(sequence):", "function_name": "max_subarray_sum", "parameter_list": "(sequence)" }, { "docstring": null, "function_declaration": "def solve(input_str...
[ 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_subarray_sum(sequence):\n \"\"\"\n Given a sequence of integers, return the maximum sum of a contiguous subsequence.\n \"\"\"\n # Convert the s...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00063905", "row_id": 63905, "seed_ids": "[8700]" }
0.781912
Taco_63905
I
[ "max_subarray_sum", "solve" ]
2
[ [ "solve", "max_subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d9d807a9df15c8e75e0a4a8a0b803e6a5575aaff
744b296933cc267e4dae720c09f309c381561fc3
v1.0
instruct
Taco
Taco_63957_I
Detecting a cycle in a graph is a fundamental problem in computer science. A cycle in a graph is a path that starts and ends at the same vertex. For this problem, you will be given an undirected graph, and your task is to determine whether the graph has any cycles. Input The first line contains an integer `T` (1 ≤ T ≤...
def has_cycle(graph, N): visited = [False] * N parent = [-1] * N def dfs(v): visited[v] = True for neighbor in graph[v]: if not visited[neighbor]: parent[neighbor] = v if dfs(neighbor): return True elif parent[v] !=...
import pytest from solution import main, graph_input_parser, detect_cycles def test_parser(): input_string = "2\n3 3\n0 1\n1 2\n2 0\n4 2\n0 1\n2 3\n" expected_output = [(3, 3, [(0, 1), (1, 2), (2, 0)]), (4, 2, [(0, 1), (2, 3)])] assert graph_input_parser(input_string) == expected_output def test_detect_cy...
[ { "docstring": null, "function_declaration": "def has_cycle(graph, N):", "function_name": "has_cycle", "parameter_list": "(graph, N)" }, { "docstring": null, "function_declaration": "def detect_cycles(test_cases):", "function_name": "detect_cycles", "parameter_list": "(test_cases...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def has_cycle(graph, node, visited, parent):\n \"\"\"\n Helper function to detect cycle using DFS.\n \"\"\"\n visited[node] = True\n \n for neigh...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00063957", "row_id": 63957, "seed_ids": "[7782]" }
0.748938
Taco_63957
I
[ "has_cycle", "detect_cycles", "graph_input_parser", "main" ]
4
[ [ "detect_cycles", "has_cycle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0bd046b976932c24404dbd57dd87030b12417d69
cee6c40f51fb61e7c11f6daae788c48d00326a3a
v1.0
instruct
Taco
Taco_64020_I
----- Statement ----- Given an array `arr` of integers and an integer `k`, rotate the array to the right by `k` steps, where `k` is non-negative. You are required to perform the rotation in-place with O(1) extra space complexity. -----Input----- The first line contains two integers n and k (1 ≤ n ≤ 1000, 0 ≤ k ≤ 1000...
def rotate_array(arr, k): """ Rotates the array `arr` to the right by `k` steps in-place. """ n = len(arr) k = k % n # In case k is larger than n reverse(arr, 0, n - 1) reverse(arr, 0, k - 1) reverse(arr, k, n - 1) def reverse(arr, start, end): """ Reverses the elements of `arr...
from solution import rotate_array def test_rotate_array_sample(): arr = [1, 2, 3, 4, 5] rotate_array(arr, 2) assert arr == [4, 5, 1, 2, 3] def test_rotate_array_no_rotation(): arr = [1, 2, 3, 4, 5] rotate_array(arr, 0) assert arr == [1, 2, 3, 4, 5] def test_rotate_array_full_rotation(): a...
[ { "docstring": "Rotates the array `arr` to the right by `k` steps in-place.", "function_declaration": "def rotate_array(arr, k):", "function_name": "rotate_array", "parameter_list": "(arr, k)" }, { "docstring": "Reverses the elements of `arr` from index `start` to index `end` in-place.", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_array(arr, k):\n \"\"\"\n Rotates the array `arr` to the right by `k` steps in-place.\n \"\"\"\n n = len(arr)\n k = k % n # In case k is...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00064020", "row_id": 64020, "seed_ids": "[9916]" }
0.580227
Taco_64020
I
[ "rotate_array", "reverse" ]
2
[ [ "rotate_array", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8acfa87b5da25a8d4f652a48ae5e298093781e5e
8877fc8d41d8ef0915af43fc2cf280c977716d49
v1.0
instruct
Taco
Taco_64027_I
The Dessert Chef is arranging a display of cakes on a rectangular grid for a bakery competition. Each cell in the grid can hold exactly one cake. All the cakes are either plain or with icing. However, the competition rules stipulate that no two cakes of the same type should be placed next to each other, horizontally, v...
def create_cake_grid(m, n): """ Creates a m x n grid with cakes ('P' for plain, 'I' for icing) such that no two cakes of the same type are adjacent horizontally, vertically, or diagonally. Args: m (int): Number of rows n (int): Number of columns Returns: List[List[str]]: m x n grid rep...
from solution import create_cake_grid def test_cake_grid_2x2(): grid = create_cake_grid(2, 2) assert grid == [['P', 'I'], ['I', 'P']] or grid == [['I', 'P'], ['P', 'I']] def test_cake_grid_3x3(): grid = create_cake_grid(3, 3) assert grid == [['P', 'I', 'P'], ['I', 'P', 'I'], ['P', 'I', 'P']] or \ ...
[ { "docstring": "Creates a m x n grid with cakes ('P' for plain, 'I' for icing) such that no two cakes\nof the same type are adjacent horizontally, vertically, or diagonally.\n\nArgs:\nm (int): Number of rows\nn (int): Number of columns\n\nReturns:\nList[List[str]]: m x n grid represented as a list of lists", ...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def create_cake_grid(m, n):\n \"\"\"\n Creates a m x n grid with cakes ('P' for plain, 'I' for icing) such that no two cakes\n of the same type are adjace...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00064027", "row_id": 64027, "seed_ids": "[913]" }
0.697508
Taco_64027
I
[ "create_cake_grid", "print_cake_grid" ]
2
[ [ "print_cake_grid", "create_cake_grid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c89af7d5a6b181c58e54b53ffbdb83c01c0e924d
e8cce8f03534eabca0e1bb273d783a856b7306a6
v1.0
instruct
Taco
Taco_64110_I
Danielle has a special math puzzle for her friend Alex. She is giving a list of numbers and wants Alex to find the greatest common divisor (GCD) of all these numbers. However, Danielle added a twist: she encrypted the list by reversing the digits of each number before giving it to Alex. Alex has to first reverse the di...
import math from functools import reduce def reverse_digits(n): return int(str(n)[::-1]) def gcd_of_list(lst): return reduce(math.gcd, lst) def solve_puzzle(test_cases): results = [] for case in test_cases: L, nums = case original_nums = [reverse_digits(num) for num in nums] g...
from solution import reverse_digits, gcd_of_list, solve_puzzle def test_reverse_digits(): assert reverse_digits(321) == 123 assert reverse_digits(987) == 789 assert reverse_digits(100) == 1 def test_gcd_of_list(): assert gcd_of_list([123, 134, 932]) == 1 assert gcd_of_list([789, 654]) == 3 ass...
[ { "docstring": null, "function_declaration": "def reverse_digits(n):", "function_name": "reverse_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def gcd_of_list(lst):", "function_name": "gcd_of_list", "parameter_list": "(lst)" }, { "docst...
[ 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": "from math import gcd\nfrom functools import reduce\n\ndef reverse_number(num):\n \"\"\"\n Reverses the digits of an integer.\n \"\"\"\n return int(str(...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00064110", "row_id": 64110, "seed_ids": "[4921]" }
0.584899
Taco_64110
I
[ "reverse_digits", "gcd_of_list", "solve_puzzle" ]
3
[ [ "solve_puzzle", "gcd_of_list" ], [ "solve_puzzle", "reverse_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
25b84e380b0668057af76912f454ae23644f3c05
68111101d18b9bcfedc029b592120fe0490e5c1d
v1.0
instruct
Taco
Taco_64122_I
# Task Implement a function that calculates the minimum number of steps required for a king to move from one position to another on an 8x8 chessboard. The king can move horizontally, vertically, or diagonally all by one square per move. ## Input/Output - `[input]` string `start` The starting position of the king on...
def chess_position_to_coords(position): """ Convert a chess position in standard notation to coordinates. 'a1' -> (0, 0) 'h8' -> (7, 7) """ col = ord(position[0]) - ord('a') row = int(position[1]) - 1 return (col, row) def min_king_moves(start, end): """ Calculate the minimum nu...
def test_chess_position_to_coords(): assert chess_position_to_coords("a1") == (0, 0) assert chess_position_to_coords("h8") == (7, 7) assert chess_position_to_coords("d4") == (3, 3) assert chess_position_to_coords("b2") == (1, 1) def test_min_king_moves(): assert min_king_moves("a1", "b3") == 2 ...
[ { "docstring": "Convert a chess position in standard notation to coordinates.\n'a1' -> (0, 0)\n'h8' -> (7, 7)", "function_declaration": "def chess_position_to_coords(position):", "function_name": "chess_position_to_coords", "parameter_list": "(position)" }, { "docstring": "Calculate the mini...
[ 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 position_to_coords(position):\n \"\"\"\n Converts a chess position in standard notation to 0-indexed coordinates.\n \"\"\"\n file, rank = position\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064122", "row_id": 64122, "seed_ids": "[4954]" }
0.66153
Taco_64122
I
[ "chess_position_to_coords", "min_king_moves" ]
2
[ [ "min_king_moves", "chess_position_to_coords" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5e85db4ab486b468737596c2eb5f3abd0f1f8c7f
c30890a0d2dd61794906a7611877e241a7b966d6
v1.0
instruct
Taco
Taco_64147_I
Design a function that takes an integer `n` and returns a list of all integers in the range `[1, n]` (inclusive) that are palindromic and which have prime digits only. A palindromic number is one that reads the same forward and backward (e.g., 121 or 1331). Prime digits include 2, 3, 5, and 7. **Example** ```python 1...
def is_palindromic(num): """ Helper function to determine if a number is palindromic. """ s = str(num) return s == s[::-1] def has_prime_digits_only(num): """ Helper function to determine if a number contains only prime digits (2, 3, 5, 7). """ prime_digits = {'2', '3', '5', '7'} ...
from solution import palindromic_prime_digit_numbers def test_no_palindromic_prime_digit_numbers(): assert palindromic_prime_digit_numbers(0) == [] assert palindromic_prime_digit_numbers(1) == [] assert palindromic_prime_digit_numbers(8) == [2, 3, 5, 7] def test_all_one_digit_palindromic_prime_digit_numbe...
[ { "docstring": "Helper function to determine if a number is palindromic.", "function_declaration": "def is_palindromic(num):", "function_name": "is_palindromic", "parameter_list": "(num)" }, { "docstring": "Helper function to determine if a number contains only prime digits (2, 3, 5, 7).", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindromic(num):\n \"\"\"\n Returns True if the number is palindromic, otherwise False.\n \"\"\"\n return str(num) == str(num)[0:][::-1]\n\ndef...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064147", "row_id": 64147, "seed_ids": "[8013]" }
0.666482
Taco_64147
I
[ "is_palindromic", "has_prime_digits_only", "palindromic_prime_digit_numbers" ]
3
[ [ "palindromic_prime_digit_numbers", "has_prime_digits_only" ], [ "palindromic_prime_digit_numbers", "is_palindromic" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8f86ed5127061fadd4a32eb8a856f2b51826cc8f
83380f33af9b1a75bbd6c0918e6e97f4e6e37e96
v1.0
instruct
Taco
Taco_64191_I
Given a list of integers, an inversion is a pair of indices (i, j) such that i < j and list[i] > list[j]. Your task is to find the number of inversions in the given list. ### Input - The first line contains a single integer N (1 ≤ N ≤ 100,000) — the length of the list. - The second line contains N integers — the eleme...
def merge_count_split_inv(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 while i <= mid and j <= right: if arr[i] <= arr[j]: temp_arr[k] = arr[i...
from solution import count_inversions def test_example_1(): assert count_inversions([2, 3, 8, 6, 1]) == 5 def test_example_2(): assert count_inversions([1, 2, 3, 4]) == 0 def test_example_3(): assert count_inversions([3, 1, 2]) == 2 def test_single_element(): assert count_inversions([1]) == 0 def t...
[ { "docstring": null, "function_declaration": "def merge_count_split_inv(arr, temp_arr, left, mid, right):", "function_name": "merge_count_split_inv", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def merge_sort_and_count(arr, temp_...
[ 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_count_split_inv(arr, temp_arr, left, right):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064191", "row_id": 64191, "seed_ids": "[14531]" }
0.789295
Taco_64191
I
[ "merge_count_split_inv", "merge_sort_and_count", "count_inversions" ]
3
[ [ "count_inversions", "merge_sort_and_count" ], [ "merge_sort_and_count", "merge_count_split_inv" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5ef033e4c8fa81d4fd5c93169fd0281fb2c91fff
b1315e437f2a024636a72eee3052c778ecd0c25f
v1.0
instruct
Taco
Taco_64270_I
Develop a program to find out if it is possible to create a sequence of unique pairs (x, y) such that they satisfy the rules given below. You are provided with a list of pairs (x, y), and you need to determine if these pairs can be rearranged into a sequence where each consecutive pair in the sequence satisfies either ...
def is_possible_sequence(pairs): from collections import defaultdict, deque if not pairs: return "Possible" graph_x = defaultdict(list) graph_y = defaultdict(list) for x, y in pairs: graph_x[x].append(y) graph_y[y].append(x) visited = set() need_to_visit = deque([...
def test_is_possible_sequence(): input_data = """2 3 1 2 2 2 3 2 4 1 1 2 2 3 1 4 2""" expected_output = "Possible\nNot Possible" assert main(input_data) == expected_output def test_single_pair(): input_data = "1\n1\n1 1" expected_output = "Possible" assert main(input_data) == exp...
[ { "docstring": null, "function_declaration": "def is_possible_sequence(pairs):", "function_name": "is_possible_sequence", "parameter_list": "(pairs)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve", "parameter_list": "(test_cases...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef can_form_sequence(pairs):\n adjacency_list_x = defaultdict(list)\n adjacency_list_y = defaultdict(list)\n \n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064270", "row_id": 64270, "seed_ids": "[8477]" }
0.721519
Taco_64270
I
[ "is_possible_sequence", "solve", "parse_input", "main" ]
4
[ [ "solve", "is_possible_sequence" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
8745fad0036c0f691b4c8ca5eac6b6281f629094
049d4a2cdb8ab4d292c64f6bc449f7d1e1ed724c
v1.0
instruct
Taco
Taco_64278_I
A scientist is analyzing the growth of bacteria in a petri dish. The petri dish is represented by a grid of cells, each of which can either be empty (denoted by 0) or contain a bacteria colony (denoted by 1). The growth follows these rules: 1. Any cell with exactly three neighboring colonies will be populated in the n...
def get_next_state(grid, n, m): """ Calculate the next state of the grid based on the growth rules. """ def get_neighbors_count(x, y): directions = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] count = 0 for dx, dy in directions: nx, ny = x + ...
from solution import simulate_growth def test_simulate_growth_one_generation(): initial_grid = [ [0, 1, 0], [0, 1, 0], [0, 1, 0] ] expected_output = [ [0, 0, 0], [1, 1, 1], [0, 0, 0] ] assert simulate_growth(3, 3, 1, initial_grid) == expected_output ...
[ { "docstring": "Calculate the next state of the grid based on the growth rules.", "function_declaration": "def get_next_state(grid, n, m):", "function_name": "get_next_state", "parameter_list": "(grid, n, m)" }, { "docstring": "Simulate the growth of the bacteria for k generations.", "fu...
[ 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 get_neighbors_count(grid, x, y):\n \"\"\"\n Returns the count of neighboring colonies for the cell at position (x, y).\n \"\"\"\n count = 0\n di...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064278", "row_id": 64278, "seed_ids": "[23464]" }
0.562604
Taco_64278
I
[ "get_next_state", "simulate_growth" ]
2
[ [ "simulate_growth", "get_next_state" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20ffb54cd37ed6b37cbb7f2038bec55a46aeb507
747de36f3f9285410eccf91a261ad061d0b10084
v1.0
instruct
Taco
Taco_64327_I
Zara is exploring a mysterious number sequence. Given a string S made up of digits (0-9), determine if there is a way to partition S into one or more parts such that each part is a power of 2 (e.g., 1, 2, 4, 8, 16, 32, ...). Each power of 2 must appear at least once in its complete form in the partition, and parts can...
def is_power_of_two(n): """ Helper function to check if a given number n is a power of 2. """ # Convert number to int, if not valid return False try: num = int(n) except ValueError: return False # Check if number is a power of two return num > 0 and (num & (num - 1))...
def test_is_power_of_two(): assert is_power_of_two("1") == True assert is_power_of_two("2") == True assert is_power_of_two("4") == True assert is_power_of_two("8") == True assert is_power_of_two("16") == True assert is_power_of_two("32") == True assert is_power_of_two("64") == True asser...
[ { "docstring": "Helper function to check if a given number n is a power of 2.", "function_declaration": "def is_power_of_two(n):", "function_name": "is_power_of_two", "parameter_list": "(n)" }, { "docstring": "Function to check if string S can be partitioned into parts where each part is a 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": "def is_power_of_two(num):\n \"\"\"\n This function checks if the given number is a power of 2.\n Leading zeros are also considered invalid unless the numb...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064327", "row_id": 64327, "seed_ids": "[23058]" }
0.642066
Taco_64327
I
[ "is_power_of_two", "can_partition_to_powers_of_two", "mysterious_number_sequence" ]
3
[ [ "can_partition_to_powers_of_two", "is_power_of_two" ], [ "mysterious_number_sequence", "can_partition_to_powers_of_two" ] ]
2
[]
false
[]
false
pytest
false
[]
true
e7884641c46ffc930a723fd411bda148b195dfba
7b6bdc55a900bf9b50efcc297c80de5f3b27ce81
v1.0
instruct
Taco
Taco_64352_I
Write a program to solve the Sudoku puzzle by filling in empty cells. A Sudoku solution must satisfy all the following rules: 1. Each of the digits 1-9 must occur exactly once in each row. 2. Each of the digits 1-9 must occur exactly once in each column. 3. Each of the digits 1-9 must occur exactly once in each of the ...
def solveSudoku(board): """ Solves the Sudoku puzzle by filling in empty cells. """ solve(board) def solve(board): empty = find_empty(board) if not empty: return True row, col = empty for num in range(1, 10): if is_valid(board, str(num), row, col): board...
from solution import solveSudoku def test_sudoku_solved(): board = [["5","3",".",".","7",".",".",".","."], ["6",".",".","1","9","5",".",".","."], [".","9","8",".",".",".",".","6","."], ["8",".",".",".","6",".",".",".","3"], ["4",".",".","8",".","3",".",".","1"], ...
[ { "docstring": "Solves the Sudoku puzzle by filling in empty cells.", "function_declaration": "def solveSudoku(board):", "function_name": "solveSudoku", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def solve(board):", "function_name": "solve", "par...
[ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 ]
5
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solveSudoku(board):\n \"\"\"\n Solves the Sudoku puzzle by filling the empty cells.\n The board is modified in-place.\n\n :param board: List[List[s...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00064352", "row_id": 64352, "seed_ids": "[2462]" }
0.58428
Taco_64352
I
[ "solveSudoku", "solve", "find_empty", "is_valid" ]
4
[ [ "solve", "find_empty" ], [ "solve", "is_valid" ], [ "solveSudoku", "solve" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c5461f69568f5bd0334ba5845ecf6b30cf0c8420
f85003cc72428d7d95d586796a3b2f278ba0520e
v1.0
instruct
Taco
Taco_64367_I
An island nation is exploring the feasibility of establishing a new transportation network consisting of bridges connecting various islands. Each island has several landmarks, and there are various potential bridge locations connecting these landmarks. The goal is to determine the minimum cost required to connect all t...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: p...
from solution import min_bridge_cost def test_min_bridge_cost_example(): n = 4 m = 5 bridges = [ (0, 1, 1), (0, 2, 2), (0, 3, 3), (1, 2, 4), (2, 3, 5) ] assert min_bridge_cost(n, m, bridges) == 6 def test_min_bridge_cost_single_bridge(): n = 2 m = 1 ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 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_bridge_cost(n, m, bridges):\n \"\"\"\n Determines the minimum cost required to connect all islands with a system of bridges.\n\n Parameters:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064367", "row_id": 64367, "seed_ids": "[8132]" }
0.775704
Taco_64367
I
[ "find", "union", "min_bridge_cost" ]
3
[ [ "min_bridge_cost", "find" ], [ "min_bridge_cost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
f5b366e7f0f11bc24a619a6028cb802410c41dde
03809f7bf47d0d6260809d49011f369c5bd45722
v1.0
instruct
Taco
Taco_64370_I
Given a list of strings, determine if it is possible to rearrange the characters of each string to form a palindrome. A palindrome is a word that reads the same backward as forward, such as "radar" or "level". Input: The first line of input gives a single integer t, the number of test cases. Each test case starts with...
def can_form_palindrome(s): """ Helper function to check if a given string can be rearranged to form a palindrome. """ from collections import Counter # Count occurrences of each character count = Counter(s) # A string can form a palindrome if at most one character has an odd count...
from solution import can_all_strings_form_palindrome, parse_input def test_multiple_cases(): input_data = """2 3 civic ivicc hello 2 racecar level""" test_cases = parse_input(input_data) assert can_all_strings_form_palindrome(test_cases) == ["NO", "YES"] def test_empty_string()...
[ { "docstring": "Helper function to check if a given string can be rearranged to form a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": "Determines if all strings in each test case can be re...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_palindrome(s):\n \"\"\"\n Checks if it's possible to rearrange the characters of the string to form a palindrome.\n \"\"\"\n from collecti...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064370", "row_id": 64370, "seed_ids": "[24217]" }
0.804762
Taco_64370
I
[ "can_form_palindrome", "can_all_strings_form_palindrome", "parse_input" ]
3
[ [ "can_all_strings_form_palindrome", "can_form_palindrome" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
2c966f67b95c3fe775ed3017bf02967776064efc
b8f37d61f9d8245a102cbc1f44124b087b2a448b
v1.0
instruct
Taco
Taco_64452_I
Mallika owns an art studio and has a collection of unique paintings. To manage her inventory, she assigns a unique ID to each painting. One day, a potential buyer asks her to provide a list of IDs of paintings that are palindromes. A palindromic ID reads the same backward as forward. Given the list of painting IDs, he...
def is_palindrome(s): """ Check if a string is a palindrome. """ return s == s[::-1] def find_palindromic_ids(test_cases): """ For each test case, find the painting IDs that are palindromes. """ results = [] for case in test_cases: N, ids = case palindromic_ids = [pi...
from solution import find_palindromic_ids, is_palindrome def test_single_palindrome(): test_cases = [(1, ["12321"])] expected = [["12321"]] assert find_palindromic_ids(test_cases) == expected def test_multiple_palindromes(): test_cases = [(5, ["12321", "abcba", "notpalindrome", "1234321", "hello"])] ...
[ { "docstring": "Check if a string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "For each test case, find the painting IDs that are palindromes.", "function_declaration": "def find_palindrom...
[ 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_palindrome(s):\n \"\"\"\n Helper function to check if a given string is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef find_palindromic_ids...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064452", "row_id": 64452, "seed_ids": "[11017]" }
0.739494
Taco_64452
I
[ "is_palindrome", "find_palindromic_ids" ]
2
[ [ "find_palindromic_ids", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0339210f98897fc0acadbea91160c2547634473a
027add44f056fa2a36918b175c7dd34ec0c37cfd
v1.0
instruct
Taco
Taco_64459_I
Emma is working on a system where she needs to parse commands from a log. Each command is composed of three parts: an action, a subject, and an optional object. The possible actions are "MOVE", "REMOVE", and "COPY". The subjects are always single words composed of uppercase alphabets only. The optional objects, if pres...
def is_valid_command(command): """ Check if the given command is valid based on the rules: 1. Must start with an action (MOVE, REMOVE, COPY) followed by a space and a subject. 2. Optionally it can have an object after another space. 3. Should not have more than three parts (action, subject, object)....
from solution import validate_commands def test_validate_commands_all_valid(): commands = [ "MOVE BOX", "REMOVE BOX CHAIR", "COPY BOOK SHELF" ] assert validate_commands(3, commands) == ["VALID", "VALID", "VALID"] def test_validate_commands_invalid_format(): commands = [ ...
[ { "docstring": "Check if the given command is valid based on the rules:\n1. Must start with an action (MOVE, REMOVE, COPY) followed by a space and a subject.\n2. Optionally it can have an object after another space.\n3. Should not have more than three parts (action, subject, object).", "function_declaration...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def validate_commands(n, logs):\n valid_actions = {\"MOVE\", \"REMOVE\", \"COPY\"}\n valid_results = []\n \n for log in logs:\n parts = log.spli...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00064459", "row_id": 64459, "seed_ids": "[19398]" }
0.54623
Taco_64459
I
[ "is_valid_command", "validate_commands" ]
2
[ [ "validate_commands", "is_valid_command" ] ]
1
[]
false
[]
false
pytest
true
[]
true
507c69bda491aa26955706e0f3ea88f0d28de056
36413342ae50e34d4d5f634c6acddd4331bc47cc
v1.0
instruct
Taco
Taco_64481_I
Alex the Mathematician is studying a special sequence of numbers defined as follows: - The sequence starts with any non-negative integer. - The next number in the sequence is found by summing the squares of its digits. The process is repeated until the sequence either reaches the number 1, or it loops endlessly inste...
def is_happy_number(n: int) -> bool: """ Determines if the number n is a happy number. """ def get_next(number): total_sum = 0 while number > 0: number, digit = divmod(number, 10) total_sum += digit ** 2 return total_sum seen = set() while n !...
from solution import is_happy_number, check_numbers def test_is_happy_number(): assert is_happy_number(19) == True assert is_happy_number(20) == False assert is_happy_number(7) == True assert is_happy_number(1) == True assert is_happy_number(2) == False def test_check_numbers(): assert che...
[ { "docstring": "Determines if the number n is a happy number.", "function_declaration": "def is_happy_number(n):", "function_name": "is_happy_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def check_numbers(numbers):", "function_name": "check_number...
[ 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_happy_number(n):\n \"\"\"\n Check whether a number is a happy number.\n \"\"\"\n def get_next_number(num):\n total_sum = 0\n while...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00064481", "row_id": 64481, "seed_ids": "[18801]" }
0.617588
Taco_64481
I
[ "is_happy_number", "check_numbers" ]
2
[ [ "check_numbers", "is_happy_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
385c9c461564c66d6a9acb1dc5cb3ad41b0266ed
88398f49b198940d4bbf5d237cd533368159d102
v1.0
instruct
Taco
Taco_64519_I
You are given an array of N integers. For each integer in the array, you have to determine whether it can be expressed as a product of two distinct prime numbers. If an integer can be expressed as such a product, output "YES", otherwise output "NO". Constraints: * 1 \leq N \leq 10^5 * 1 \leq A[i] \leq 10^6 Input: * T...
def sieve_of_eratosthenes(max_num): """ Sieve of Eratosthenes to find all prime numbers up to max_num. """ is_prime = [True] * (max_num + 1) p = 2 while p * p <= max_num: if is_prime[p]: for i in range(p * p, max_num + 1, p): is_prime[i] = False p += 1...
from solution import sieve_of_eratosthenes, can_be_expressed_as_product_of_two_distinct_primes, check_numbers def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_can_be_expressed_as_product_of_two_distinct...
[ { "docstring": "Sieve of Eratosthenes to find all prime numbers up to max_num.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Check if a number can be expressed as a product of two di...
[ 0, 0, 0, 0, 1, 0, 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 sieve_of_eratosthenes(max_num):\n \"\"\"\n Generate a list of prime numbers up to max_num using the Sieve of Eratosthenes algorithm.\n \"\"\"\n is_...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00064519", "row_id": 64519, "seed_ids": "[12467]" }
0.67996
Taco_64519
I
[ "sieve_of_eratosthenes", "can_be_expressed_as_product_of_two_distinct_primes", "check_numbers", "main" ]
4
[ [ "check_numbers", "can_be_expressed_as_product_of_two_distinct_primes" ], [ "check_numbers", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b3248a97556ba7eab59d4f7fd6876eabbc521818
22d88e2ba2c6c19fe8e1750f6d8adcfd79a1c4b0
v1.0
instruct
Taco
Taco_64609_I
You are given a prefix expression (Polish notation) in the form of a string. Your task is to evaluate the expression and print its value. A prefix expression is evaluated using the following rules: 1. The operator comes before its operands. 2. The evaluation is performed from right to left. The allowed operators are...
def evaluate_prefix_expression(expression): """ Evaluates a single prefix expression. """ stack = [] operators = {'+', '-', '*', '/'} # Split the expression by space and reverse it to process it right to left tokens = expression.split()[::-1] for token in tokens: if tok...
from solution import evaluate_prefix_expression, evaluate_prefix_expressions, process_input def test_evaluate_prefix_expression(): assert evaluate_prefix_expression('+ 3 4') == 7 assert evaluate_prefix_expression('- * 10 20 30') == 170 assert evaluate_prefix_expression('/ 100 5') == 20 assert evaluate_...
[ { "docstring": "Evaluates a single prefix expression.", "function_declaration": "def evaluate_prefix_expression(expression):", "function_name": "evaluate_prefix_expression", "parameter_list": "(expression)" }, { "docstring": "Evaluates multiple prefix expressions.", "function_declaration...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def evaluate_prefix(expression):\n \"\"\"\n Evaluates a single prefix expression and returns the result.\n \"\"\"\n tokens = expression.split()\n to...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064609", "row_id": 64609, "seed_ids": "[1273]" }
0.585439
Taco_64609
I
[ "evaluate_prefix_expression", "evaluate_prefix_expressions", "process_input" ]
3
[ [ "evaluate_prefix_expressions", "evaluate_prefix_expression" ], [ "process_input", "evaluate_prefix_expressions" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
ca9023614eb09be1ae9a6d9bcff88741f9fec1f2
76f5095b440479958e7eafaa49731e9c419f34ee
v1.0
instruct
Taco
Taco_64648_I
A factory manufacturing all kinds of items wants to track the number of ways to construct different items using a specific method. Each item can be constructed using either one of the two processes over a sequence of steps. The steps can be either process A or process B. The overall sequence's length can be very large,...
MOD = 10**9 + 7 def matrix_mult(A, B, mod=MOD): """Multiplies two matrices A and B under modulo.""" return [[(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % mod, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % mod], [(A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod, (A[1][0] * B[0][1] + A[1][1] * B[1][1]) % mod]]...
from solution import count_sequences def test_count_sequences(): assert count_sequences(1) == 2 assert count_sequences(2) == 4 assert count_sequences(3) == 8 assert count_sequences(10) == 1024 def test_large_n(): assert count_sequences(10**8) == pow(2, 10**8, 10**9 + 7) % (10**9 + 7) def test_edg...
[ { "docstring": "Multiplies two matrices A and B under modulo.", "function_declaration": "def matrix_mult(A, B, mod=MOD):", "function_name": "matrix_mult", "parameter_list": "(A, B, mod=MOD)" }, { "docstring": "Computes the power of a matrix under modulo using exponentiation by squaring.", ...
[ 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": "MOD = 10**9 + 7\n\ndef matrix_multiply(A, B):\n return [\n [(A[0][0] * B[0][0] + A[0][1] * B[1][0]) % MOD, (A[0][0] * B[0][1] + A[0][1] * B[1][1]) % MOD]...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064648", "row_id": 64648, "seed_ids": "[7361]" }
0.648436
Taco_64648
I
[ "matrix_mult", "matrix_pow", "count_sequences" ]
3
[ [ "count_sequences", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1eb2c1d0469cef0f59b513fdf83807e54721c99b
46a88ba5d4e94a32f82edb0a25fa64bf2b01e8b1
v1.0
instruct
Taco
Taco_64692_I
# Summing Consecutive Prime Numbers Write a function that returns the sum of the first `n` consecutive prime numbers. Prime numbers are natural numbers greater than 1 that have no positive divisors other than 1 and itself. ## Examples ``` sumConsecutivePrimes(1) ==> 2 sumConsecutivePrimes(2) ==> 5 (because 2 + 3 = ...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6...
from solution import sumConsecutivePrimes def test_sumConsecutivePrimes_1(): assert sumConsecutivePrimes(1) == 2 def test_sumConsecutivePrimes_2(): assert sumConsecutivePrimes(2) == 5 def test_sumConsecutivePrimes_5(): assert sumConsecutivePrimes(5) == 28 def test_sumConsecutivePrimes_10(): assert s...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of the first n consecutive prime numbers.", "function_declaration": "def sumConsecutivePrimes(n):", "f...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064692", "row_id": 64692, "seed_ids": "[3654]" }
0.699763
Taco_64692
I
[ "is_prime", "sumConsecutivePrimes" ]
2
[ [ "sumConsecutivePrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3de6eb8a4881c1f77859c6d4516c2ac5583537a2
dcd7ecfb17364bfa4a25b58ba97eb0ced8a40cae
v1.0
instruct
Taco
Taco_64702_I
Madoka and Zen are playing a game with a string `s` consisting of lowercase English letters. The game proceeds as follows: 1. Initially, Zen writes down the string `s`. 2. Madoka can perform the following operation exactly once: - Replace any character in the string with any other lowercase English letter. 3. Madok...
def max_distinct_after_change(s): """ Returns the maximum number of distinct characters that can be achieved by changing any one character in the string s. """ distinct_chars = len(set(s)) # If the number of distinct characters is already the maximum possible (length of string), # changing o...
from solution import max_distinct_after_change, process_test_cases, solve def test_max_distinct_after_change(): assert max_distinct_after_change("abca") == 4 assert max_distinct_after_change("abcde") == 5 assert max_distinct_after_change("zzzzz") == 2 # Changed from 1 to 2 because we can change one 'z' to...
[ { "docstring": "Returns the maximum number of distinct characters that can be achieved\nby changing any one character in the string s.", "function_declaration": "def max_distinct_after_change(s):", "function_name": "max_distinct_after_change", "parameter_list": "(s)" }, { "docstring": null, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_distinct_characters(s):\n \"\"\"\n Given a string s, this function returns the maximum number of distinct characters\n Madoka can achieve by chang...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00064702", "row_id": 64702, "seed_ids": "[2485]" }
0.741988
Taco_64702
I
[ "max_distinct_after_change", "process_test_cases", "solve" ]
3
[ [ "process_test_cases", "max_distinct_after_change" ], [ "solve", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
9af42806d65e7b82ade9db05658e7882b947f010
23f7c177ca8373c3140ead7c41a276eed6aed48d
v1.0
instruct
Taco
Taco_64703_I
Write a function that takes an integer N and returns the smallest prime number that is greater than or equal to N. If N is less than or equal to 1, return 2. Note that the scope of this problem is to handle numbers up to 10^6 efficiently. -----Input----- An integer N. -----Output----- An integer, the smallest prime n...
def is_prime(number): if number <= 1: return False if number == 2 or number == 3: return True if number % 2 == 0 or number % 3 == 0: return False i = 5 while i * i <= number: if number % i == 0 or number % (i + 2) == 0: return False i += 6 retu...
from solution import is_prime, smallest_prime_ge 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(29) == True assert is_prime(10) == False assert is_prime(1) == False assert is_prime(0) == F...
[ { "docstring": null, "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def smallest_prime_ge(N):", "function_name": "smallest_prime_ge", "parameter_list": "(N)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064703", "row_id": 64703, "seed_ids": "[11265]" }
0.615073
Taco_64703
I
[ "is_prime", "smallest_prime_ge" ]
2
[ [ "smallest_prime_ge", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b95936411271832de166fb2ac9cf6cdde2b4e1a1
acc816e78023694ac82aed1b1db5c9ff56be5cc0
v1.0
instruct
Taco
Taco_64738_I
Given a binary search tree (BST) with N nodes, convert it into a balanced binary search tree (BST) with the same set of nodes. Example 1: Input: BST = 30 / \ 20 40 / \ \ 10 25 50 Output: Balanced BST = 30 / \ 20 40 / \ / \ 10 25 35 50 Explanation: T...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def inOrderTraversal(root, nodes): if root: inOrderTraversal(root.left, nodes) nodes.append(root) inOrderTraversal(root.right, nodes) def buildBa...
from solution import TreeNode, balanceBST def inOrderValues(root): if root is None: return [] return inOrderValues(root.left) + [root.val] + inOrderValues(root.right) def test_balance_already_balanced_bst(): root = TreeNode(30) root.left = TreeNode(20) root.right = TreeNode(40) root.le...
[]
[ 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=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064738", "row_id": 64738, "seed_ids": "[6464]" }
0.632692
Taco_64738
I
[ "inOrderTraversal", "buildBalancedBST", "balanceBST" ]
3
[ [ "balanceBST", "buildBalancedBST" ], [ "balanceBST", "inOrderTraversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
0d8881ab34630509b6f3847a410b507fdbbf66f9
35eb2b39046e985efbf7a19c06b7359f11afbc0b
v1.0
instruct
Taco
Taco_64837_I
In a certain country, street addresses follow a peculiar numbering pattern. The country uses an ordered list of numbers called prime indexes. Prime index numbers are defined as the position numbers within the ordered sequence of prime numbers starting from the smallest prime number, 2. Your task is to compute the addr...
def sieve_of_eratosthenes(n): """ Returns a list of first n prime numbers using the Sieve of Eratosthenes algorithm. """ limit = 20000 # Arbitrary large limit to ensure we get at least 1000 primes sieve = [True] * limit sieve[0] = sieve[1] = False primes = [] for num in range(2, li...
from solution import prime_address def test_prime_address_example_case(): assert prime_address([1, 2, 10]) == [2, 3, 29] def test_prime_address_single_case(): assert prime_address([5]) == [11] def test_prime_address_edge_case(): assert prime_address([1]) == [2] assert prime_address([1000]) == [7919] ...
[ { "docstring": "Returns a list of first n prime numbers using the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers corresponding to ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_num):\n \"\"\"\n Helper function to generate all prime numbers up to max_num using Sieve of Eratosthenes.\n \"\"\"\n is_p...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064837", "row_id": 64837, "seed_ids": "[3857]" }
0.5613
Taco_64837
I
[ "sieve_of_eratosthenes", "prime_address" ]
2
[ [ "prime_address", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c5620d68febc1a473d337c8e2de0af93a7e33a8b
4681a7f979ae6215b0a5ac72b5b82897ee47aa1d
v1.0
instruct
Taco
Taco_64881_I
Given a string s, you are allowed to remove at most one character from the string. You need to determine if it can become a palindrome by removing at most one character. A string is considered a palindrome if it reads the same forward and backward. -----Constraints----- - The length of the string s is between 1 and 1...
def is_palindrome(s): """ Helper function to check if a string is a palindrome. """ return s == s[::-1] def can_become_palindrome(s): """ Determines if the string can become a palindrome by removing at most one character. """ left, right = 0, len(s) - 1 while left < right: ...
from solution import can_become_palindrome def test_can_become_palindrome(): # Provided sample test case assert can_become_palindrome("abca") == True # YES # Case: Already a palindrome assert can_become_palindrome("racecar") == True # YES # Case: Not possible to become palindrome by rem...
[ { "docstring": "Helper function to check if a string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Determines if the string can become a palindrome by removing at most one character.", "fun...
[ 0, 0, 1, 1 ]
2
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_become_palindrome(s):\n \"\"\"\n Determines if the input string can become a palindrome by removing at most one character.\n \"\"\"\n def is_pa...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00064881", "row_id": 64881, "seed_ids": "[16416]" }
0.823458
Taco_64881
I
[ "is_palindrome", "can_become_palindrome" ]
2
[ [ "can_become_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6d1c4fefc4a495b01df6114b6e5764ac64425400
3351be7d52757ecd8f91beae8f6e1012446a7c4c
v1.0
instruct
Taco
Taco_64896_I
Given a grid of letters and a list of words, determine if each word in the list can be formed by a sequence of adjacent letters in the grid. The same letter cannot be used more than once in forming a word. Letters are considered adjacent if they are horizontally or vertically neighboring. **Parameters**: `grid` and `...
def is_word_in_grid(grid, word): rows = len(grid) cols = len(grid[0]) def dfs(x, y, word): if not word: return True if x < 0 or x >= rows or y < 0 or y >= cols or grid[x][y] != word[0]: return False temp = grid[x][y] grid[x][y] = '' ...
def test_find_words_in_grid(): grid = [ ['A', 'B', 'C', 'E'], ['S', 'F', 'C', 'S'], ['A', 'D', 'E', 'E'] ] words = ['ABCCED', 'SEE', 'ABCB'] expected = [True, True, False] assert find_words_in_grid(grid, words) == expected def test_find_words_in_grid_single_letter_words(): gr...
[ { "docstring": null, "function_declaration": "def is_word_in_grid(grid, word):", "function_name": "is_word_in_grid", "parameter_list": "(grid, word)" }, { "docstring": null, "function_declaration": "def find_words_in_grid(grid, words):", "function_name": "find_words_in_grid", "pa...
[ 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 exist_word(grid, word):\n rows, cols = len(grid), len(grid[0])\n \n def dfs(r, c, i):\n if i == len(word):\n return True\n if...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064896", "row_id": 64896, "seed_ids": "[22265]" }
0.709103
Taco_64896
I
[ "is_word_in_grid", "find_words_in_grid" ]
2
[ [ "find_words_in_grid", "is_word_in_grid" ] ]
1
[]
false
[]
false
pytest
false
[]
true
10dc7cf6347fc5e07de8ce627bdefeb3aca02689
0e16e3ebd5a6e25ba43925502fff7626f37fde3d
v1.0
instruct
Taco
Taco_64909_I
In a fictional land, there are $N$ castles connected by $M$ bidirectional roads. The king wants to ensure that every pair of castles is connected either directly by a road or indirectly through other castles. Additionally, the king prefers that the total number of roads used is minimal. Your task is to determine wheth...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot]...
def test_sample_cases(): input_data = '''2 4 3 1 2 2 3 3 4 5 2 1 2 4 5''' expected_output = [3, 'IMPOSSIBLE'] result = castle_connected_min_roads(input_data) assert result == expected_output def test_no_roads(): input_data = '''1 3 0''' expected_output = ['IMPOSSIBLE'] result = castle...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 1, 0, 1, 1, 0 ]
3
medium
0.333
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def solve(T, test_cases):\n results = []\n \n def find_components(N, edges):\n from collections import deque, defaultdict\...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00064909", "row_id": 64909, "seed_ids": "[7938]" }
0.762621
Taco_64909
I
[ "find", "union", "kruskal_minimum_roads_needed", "process_castle_connection", "castle_connected_min_roads" ]
5
[ [ "castle_connected_min_roads", "process_castle_connection" ], [ "kruskal_minimum_roads_needed", "find" ], [ "kruskal_minimum_roads_needed", "union" ], [ "process_castle_connection", "kruskal_minimum_roads_needed" ], [ "union", "find" ] ]
5
[]
false
[]
false
pytest
false
[]
true
4a43735e48d3ce40a0223c61612041078d1eed8b
723957c5b53dc366f355122cb8817b538015ecab
v1.0
instruct
Taco
Taco_64912_I
Given a positive integer N, determine whether it can be expressed as the sum of two prime numbers. If it can, return the two prime numbers in sorted order as a tuple. If multiple pairs exist, return any one of them. If it cannot be expressed as such, return -1. Example 1: Input: N=10 Output: (3, 7) Explanation: 10 can...
import math def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def sum_of_two_primes(N): for...
from solution import sum_of_two_primes def test_example1(): assert sum_of_two_primes(10) in [(3, 7), (7, 3)] def test_example2(): result = sum_of_two_primes(16) assert result in [(3, 13), (13, 3), (5, 11), (11, 5)] def test_example3(): assert sum_of_two_primes(11) == -1 def test_prime_sum_of_non_pri...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def sum_of_two_primes(N):", "function_name": "sum_of_two_primes", "parameter_list": "(N)" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00064912", "row_id": 64912, "seed_ids": "[5747]" }
0.757664
Taco_64912
I
[ "is_prime", "sum_of_two_primes" ]
2
[ [ "sum_of_two_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
73a441de38629ce95566f80786163e884207b511
1ddd1debf4bdaeb649a75980bb4dcfedffb5b330
v1.0
instruct
Taco
Taco_64917_I
Prime Concatenation You are given a list of distinct prime numbers, and your task is to determine if it is possible to concatenate any two distinct primes from the list to form a new prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. To concatenate two...
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 prime_concatenation_possible def test_example_1(): primes = [2, 3, 5, 11] assert prime_concatenation_possible(primes) == "YES" def test_example_2(): primes = [2, 5, 7] assert prime_concatenation_possible(primes) == "NO" def test_single_prime(): primes = [2] assert prime_c...
[ { "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 \"YES\" if it is possible to concatenate any two distinct primes from\nthe list to form a new prime num...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even prime number\n if n % 2 == 0:\n return ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00064917", "row_id": 64917, "seed_ids": "[2079]" }
0.704455
Taco_64917
I
[ "is_prime", "prime_concatenation_possible" ]
2
[ [ "prime_concatenation_possible", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
049c29cb4aa28f0a5b9634e568af43a7b5c42eca
3ffcfe5ca335fdd27b6c27284bded59299e6155d
v1.0
instruct
Taco
Taco_64958_I
Write a program that implements the Merge Sort algorithm to sort an array of integers in ascending order. The algorithm should be based on the following pseudocode: MergeSort(A, left, right) 1 if left < right 2 mid = (left + right) / 2 3 MergeSort(A, left, mid) 4 MergeSort(A, mid + 1, right) 5 Merge(A,...
def merge_sort(A, left, right): if left < right: mid = (left + right) // 2 merge_sort(A, left, mid) merge_sort(A, mid + 1, right) merge(A, left, mid, right) def merge(A, left, mid, right): n1 = mid - left + 1 n2 = right - mid L = [0] * n1 R = [0] * n2 for i in ...
def test_sort_array(): assert sort_array([38, 27, 43, 3, 9, 82, 10]) == [3, 9, 10, 27, 38, 43, 82] assert sort_array([12, 11, 13, 5, 6]) == [5, 6, 11, 12, 13] assert sort_array([4]) == [4] assert sort_array([5, 2]) == [2, 5] assert sort_array([1, 7, 3, 8, 5, 2, 6, 4]) == [1, 2, 3, 4, 5, 6, 7, 8] de...
[ { "docstring": null, "function_declaration": "def merge_sort(A, left, right):", "function_name": "merge_sort", "parameter_list": "(A, left, right)" }, { "docstring": null, "function_declaration": "def merge(A, left, mid, right):", "function_name": "merge", "parameter_list": "(A, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge(A, left, mid, right):\n n1 = mid - left + 1\n n2 = right - mid\n \n # Create temporary arrays\n L = [0] * n1\n R = [0] * n2\n \n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00064958", "row_id": 64958, "seed_ids": "[12140]" }
0.672625
Taco_64958
I
[ "merge_sort", "merge", "sort_array" ]
3
[ [ "merge_sort", "merge" ], [ "sort_array", "merge_sort" ] ]
2
[]
false
[]
false
pytest
false
[]
true
39c192fffbd2b64b3abd0bbeb370f16f76eedf78
75860bf130243aff1b8947aae29165332b37c1c4
v1.0
instruct
Taco
Taco_65006_I
In an imaginary city, traffic lights at every intersection follow a strange pattern. They have their own cycle lengths and durations, which are not necessarily the same. You are tasked with finding out the minimum amount of time required for all the lights at a given set of intersections to be green simultaneously for ...
import math def lcm(a, b): """ Returns the least common multiple of a and b. """ return abs(a * b) // math.gcd(a, b) def find_minimum_green_time(cycle_lengths): """ Given a list of cycle lengths, find the minimum time after t=0 when all traffic lights will be green simultaneously. """ ...
import pytest from solution import lcm, find_minimum_green_time, process_traffic_lights def test_lcm(): assert lcm(3, 4) == 12 assert lcm(6, 8) == 24 assert lcm(7, 5) == 35 assert lcm(21, 6) == 42 def test_find_minimum_green_time(): assert find_minimum_green_time([3, 4, 5]) == 60 assert find_m...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Given a list of cycle lengths, find the minimum time after t=0 when all\ntraffic lights will be green simultaneously...
[ 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 lcm(a, b):\n \"\"\"\n Computes the least common multiple of a and b.\n \"\"\"\n return abs(a * b) // math.gcd(a, b)\n\ndef find_min_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065006", "row_id": 65006, "seed_ids": "[1371]" }
0.669895
Taco_65006
I
[ "lcm", "find_minimum_green_time", "process_traffic_lights" ]
3
[ [ "find_minimum_green_time", "lcm" ], [ "process_traffic_lights", "find_minimum_green_time" ] ]
2
[]
false
[]
false
pytest
true
[]
true
85ebbbdd8aff0f4137a01d2a73384990d8651a71
bb98c7eb349e4484b3e94ccaad03dfb9f79c6085
v1.0
instruct
Taco
Taco_65015_I
Write a function to merge two sorted linked lists into one sorted linked list. Input: - The first line contains an integer n1, the number of elements in the first linked list. - The second line contains n1 space-separated integers, the elements of the first linked list. - The third line contains an integer n2, the nu...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def merge_two_sorted_lists(l1: ListNode, l2: ListNode) -> ListNode: dummy = current = ListNode() while l1 and l2: if l1.val < l2.val: current.next = l1 l1 = l1.next ...
from solution import merge_sorted_linked_lists def test_merge_sorted_linked_lists(): assert merge_sorted_linked_lists([1, 3, 5, 7, 9], [2, 4, 6, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9] def test_merge_with_empty_list(): assert merge_sorted_linked_lists([], [2, 4, 6, 8]) == [2, 4, 6, 8] assert merge_sorted_linke...
[]
[ 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 ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef mergeTwoLists(l1, l2):\n \"\"\"\n Merges ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00065015", "row_id": 65015, "seed_ids": "[11443]" }
0.541849
Taco_65015
I
[ "merge_two_sorted_lists", "linked_list_from_list", "list_from_linked_list", "merge_sorted_linked_lists" ]
4
[ [ "merge_sorted_linked_lists", "linked_list_from_list" ], [ "merge_sorted_linked_lists", "list_from_linked_list" ], [ "merge_sorted_linked_lists", "merge_two_sorted_lists" ] ]
3
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
18390f500a644cbb977be37dd07229b196f0fb96
d0efccd6e1971d4bc95403ee7eef90a24ab7fbd7
v1.0
instruct
Taco
Taco_65024_I
Arkady has a garden containing $n$ flowers. Each flower can be in one of $m$ different colors. The garden looks beautiful when there are at least $k$ consecutive flowers of the same color. However, due to harsh weather conditions, some flowers have lost their colors. You need to help Arkady determine if it's possible ...
def can_make_garden_beautiful(n, m, k, flowers): """ Determines if it's possible to repaint the faded flowers such that the garden contains at least k consecutive flowers of the same color. Args: n (int): number of flowers. m (int): number of different colors. k (int): minimum number o...
def test_can_make_garden_beautiful_example1(): assert solve_garden_problem(5, 3, 3, "a?a??") == "YES" def test_can_make_garden_beautiful_example2(): assert solve_garden_problem(4, 2, 4, "ab??") == "NO" def test_all_question_marks(): assert solve_garden_problem(4, 2, 2, "????") == "YES" assert solve_ga...
[ { "docstring": "Determines if it's possible to repaint the faded flowers such that the garden \ncontains at least k consecutive flowers of the same color.\n\nArgs:\nn (int): number of flowers.\nm (int): number of different colors.\nk (int): minimum number of consecutive flowers required to be of the same color....
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_beautiful_possible(n, m, k, garden):\n \"\"\"\n Determines if it's possible to repaint the faded flowers in the garden to make it beautiful.\n \n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00065024", "row_id": 65024, "seed_ids": "[16021]" }
0.657434
Taco_65024
I
[ "can_make_garden_beautiful", "solve_garden_problem" ]
2
[ [ "solve_garden_problem", "can_make_garden_beautiful" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7a2547203e081b99494159c4c08261d6a773857a
a356f806562d174e4fddd02daffcfdc4d61343a8
v1.0
instruct
Taco
Taco_65099_I
In a kingdom, there are N cities connected by M bidirectional roads. Each road has a certain time required to travel through it. The king wants to make travelling as efficient as possible, so he has mandated that there should be exactly one path between any two cities with the minimum travel time. In other words, the k...
def find(parent, i): while parent[i] != i: i = parent[i] return i def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] = xroot else: ...
from solution import total_travel_time_of_mst def test_example_case(): n = 4 m = 5 roads = [(1, 2, 1), (1, 3, 4), (2, 3, 2), (2, 4, 3), (3, 4, 5)] assert total_travel_time_of_mst(n, m, roads) == 6 def test_two_cities(): n = 2 m = 1 roads = [(1, 2, 10)] assert total_travel_time_of_mst(n...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065099", "row_id": 65099, "seed_ids": "[19648]" }
0.695539
Taco_65099
I
[ "find", "union", "kruskal_mst", "total_travel_time_of_mst", "main" ]
5
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "total_travel_time_of_mst", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
43fff5040e634b5cd1aed6eda69ec8a8b1b2994a
f863078aa42d77d12f970a240fddf5d75b872c92
v1.0
instruct
Taco
Taco_65115_I
Find the number of distinct islands in a given binary grid representation of a map. Constraints * 1 ≤ m, n ≤ 1000 * The grid contains only 0s and 1s * '1' represents land and '0' represents water * Two pieces of land are considered part of the same island if they are connected horizontally or vertically Input m n g...
def numDistinctIslands(grid): def dfs(x, y, direction, path): if x < 0 or x >= len(grid) or y < 0 or y >= len(grid[0]) or grid[x][y] == 0: return grid[x][y] = 0 path.append(direction) dfs(x + 1, y, 'D', path) dfs(x - 1, y, 'U', path) dfs(x, y + 1, 'R', pat...
from solution import countDistinctIslands def test_countDistinctIslands_case1(): assert countDistinctIslands(4, 5, "11000\n11000\n00100\n00011") == 3 def test_countDistinctIslands_case2(): assert countDistinctIslands(3, 4, "1110\n1100\n0001") == 2 def test_countDistinctIslands_single_island(): assert cou...
[ { "docstring": null, "function_declaration": "def numDistinctIslands(grid):", "function_name": "numDistinctIslands", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def countDistinctIslands(m, n, grid_str):", "function_name": "countDistinctIslands", "p...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def numDistinctIslands(grid):\n def dfs(r, c, direction, island):\n if r < 0 or r >= rows or c < 0 or c >= cols or grid[r][c] == '0':\n return...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00065115", "row_id": 65115, "seed_ids": "[3615]" }
0.526941
Taco_65115
I
[ "numDistinctIslands", "countDistinctIslands" ]
2
[ [ "countDistinctIslands", "numDistinctIslands" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed9f65447ab80bd2ea46baa54177e305d19cb496
42e4fa2879f12b53b09033ebf2595b19de5abc0b
v1.0
instruct
Taco
Taco_65147_I
You are tasked with arranging a series of events in a timeline such that no two events overlap. Each event has a start time and an end time. Given a list of events, your task is to determine the maximum number of non-overlapping events you can attend. Each event will be represented by a tuple of two integers (start_ti...
def max_non_overlapping_events(events): """ Determines the maximum number of non-overlapping events that can be attended. Parameters: events (List[Tuple[int, int]]): A list of tuples, each containing the start and end time of an event. Returns: int: The maximum number of non-overlappin...
from solution import get_max_events_from_input def test_case_1(): input_data = "3\n1 3\n2 4\n3 5" assert get_max_events_from_input(input_data) == 2 def test_case_2(): input_data = "4\n1 2\n2 3\n3 4\n1 3" assert get_max_events_from_input(input_data) == 3 def test_case_3(): input_data = "1\n1 2" ...
[ { "docstring": "Determines the maximum number of non-overlapping events that can be attended.\n\nParameters:\nevents (List[Tuple[int, int]]): A list of tuples, each containing the start and end time of an event.\n\nReturns:\nint: The maximum number of non-overlapping events that can be attended.", "function...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_non_overlapping_events(events):\n \"\"\"\n Determines the maximum number of non-overlapping events.\n \n Parameters:\n events (list of tuple...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065147", "row_id": 65147, "seed_ids": "[15993]" }
0.60556
Taco_65147
I
[ "max_non_overlapping_events", "get_max_events_from_input" ]
2
[ [ "get_max_events_from_input", "max_non_overlapping_events" ] ]
1
[]
false
[]
false
pytest
true
[]
true
42437164e45e6f94a22ab63450acf0fbf8589bc7
f0aad000f5ae72ca7cc9a7bda135ee9eb6d7ec19
v1.0
instruct
Taco
Taco_65165_I
Given an integer n, you are to construct a permutation of the numbers from 1 to n such that the sum of the absolute differences between consecutive elements is minimized and also the sum of the absolute differences between consecutive elements is maximized. A permutation of the numbers from 1 to n is a sequence of len...
def minimum_permutation(n): return list(range(1, n + 1)) def maximum_permutation(n): result = [] left = 1 right = n while left <= right: if len(result) % 2 == 0: result.append(left) left += 1 else: result.append(right) right -= 1 r...
from solution import minimum_permutation, maximum_permutation, solve def test_minimum_permutation(): assert minimum_permutation(5) == [1, 2, 3, 4, 5] assert minimum_permutation(3) == [1, 2, 3] assert minimum_permutation(4) == [1, 2, 3, 4] def test_maximum_permutation(): assert maximum_permutation(5) =...
[ { "docstring": null, "function_declaration": "def minimum_permutation(n):", "function_name": "minimum_permutation", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def maximum_permutation(n):", "function_name": "maximum_permutation", "parameter_list": "(n...
[ 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 min_max_permutations(t, test_cases):\n results = []\n for n in test_cases:\n min_perm = list(range(1, n+1))\n max_perm = []\n left =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065165", "row_id": 65165, "seed_ids": "[17564]" }
0.765648
Taco_65165
I
[ "minimum_permutation", "maximum_permutation", "solve" ]
3
[ [ "solve", "maximum_permutation" ], [ "solve", "minimum_permutation" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f167e9189ee98a19a708dd684576cae8836f6789
5e3bc8dc553d65808891c4a698309b7bcc37b0f6
v1.0
instruct
Taco
Taco_65195_I
Alice is an avid reader and has recently started a book club. She has a peculiar way of selecting books to read: she only reads books whose total page count is a prime number. To help her streamline her book selection process, she needs you to write a program that helps her determine if the total page count of a book i...
def is_prime(n): """ Determines if n is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def prime_book_selector(T, pa...
from solution import is_prime, prime_book_selector def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(15) == False assert is_prime(23) == True assert is_prime(1) == False assert is_prime(997)...
[ { "docstring": "Determines if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "For each page count, determines if it is a prime number.", "function_declaration": "def prime_book_selector(T, page_cou...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00065195", "row_id": 65195, "seed_ids": "[19634]" }
0.58209
Taco_65195
I
[ "is_prime", "prime_book_selector" ]
2
[ [ "prime_book_selector", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d8908e1e72383b3000aa35af839e80c32a95129e
b8386274f233b69534ac5cf860245956ddedb007
v1.0
instruct
Taco
Taco_65217_I
You are given a string s consisting of lowercase and uppercase Latin characters. Your task is to determine if it is possible to make the given string a palindrome by removing at most one character. -----Input----- The only line of input contains a string s of length between 1 and 10^5 consisting of lowercase and upp...
def is_almost_palindrome(s): """ Determines if it's possible to make the given string s a palindrome by removing at most one character. """ def is_palindrome_range(i, j): """ Helper function to check if the substring s[i:j+1] is a palindrome. """ return all(s[k] == s[j-k+i] for k in...
from solution import almost_palindrome def test_almost_palindrome(): assert almost_palindrome("abca") == "YES" assert almost_palindrome("racecar") == "YES" assert almost_palindrome("abcdef") == "NO" assert almost_palindrome("a") == "YES" assert almost_palindrome("aa") == "YES" assert almost_pal...
[ { "docstring": "Determines if it's possible to make the given string s a palindrome \nby removing at most one character.", "function_declaration": "def is_almost_palindrome(s):", "function_name": "is_almost_palindrome", "parameter_list": "(s)" }, { "docstring": "Outputs \"YES\" if it is poss...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_palindrome(s: str) -> str:\n def is_palindrome_range(i, j):\n return all(s[k] == s[j - k + i] for k in range(i, j))\n\n for i in range(len(...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00065217", "row_id": 65217, "seed_ids": "[221]" }
0.859176
Taco_65217
I
[ "is_almost_palindrome", "almost_palindrome" ]
2
[ [ "almost_palindrome", "is_almost_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
beca75d33506eaeba8e16296a8bf590f8bd17d00
f655db09ee3eb3497c40fe2b0b3eb35e4283bac1
v1.0
instruct
Taco
Taco_65248_I
A company is organizing a transport system for delivering packages using drones. There is a set of N routes, each connecting two checkpoints identified by integers. A route between checkpoint A and checkpoint B has an associated difficulty level D. The difficulty level determines the battery consumption of the drone wh...
import sys from itertools import permutations def find_minimum_difficulty(N, routes): graph = [[sys.maxsize]*N for _ in range(N)] for a, b, d in routes: graph[a-1][b-1] = d graph[b-1][a-1] = d min_difficulty = sys.maxsize checkpoints = list(range(1, N)) # Try every permutation to ...
def test_example_case(): from io import StringIO from unittest.mock import patch example_input = "2\n4\n5\n1 2 10\n2 3 10\n3 4 10\n4 1 10\n1 3 15\n3\n3\n1 2 7\n2 3 8\n1 3 12\n" expected_output = "40\n27\n" with patch('sys.stdin', StringIO(example_input)), patch('sys.stdout', new_callable=StringIO)...
[ { "docstring": null, "function_declaration": "def find_minimum_difficulty(N, routes):", "function_name": "find_minimum_difficulty", "parameter_list": "(N, routes)" }, { "docstring": null, "function_declaration": "def solve():", "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": "import sys\nimport itertools\n\ndef min_difficulty_for_all_checkpoints(T, test_cases):\n results = []\n for case in test_cases:\n N, M, edges = case\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00065248", "row_id": 65248, "seed_ids": "[20742]" }
0.689367
Taco_65248
I
[ "find_minimum_difficulty", "solve" ]
2
[ [ "solve", "find_minimum_difficulty" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b7d42b28b0f00353411f76e0de7060176e5241ec
8a200a5edf71c72957221cd6960020a57205a7ad
v1.0
instruct
Taco
Taco_65251_I
Write a program that reads two integers, n and m, and prints the least common multiple (LCM) of these two numbers. You can assume that 1 ≤ n, m ≤ 1000. Input Two integers n and m separated by a space in a line. Output Print the LCM of n and m in a line. Example Input 4 6 Output 12
def gcd(a, b): """ Calculate the greatest common divisor (GCD) of two numbers. """ while b: a, b = b, a % b return a def lcm(n, m): """ Calculate the least common multiple (LCM) of two numbers. """ return abs(n * m) // gcd(n, m)
from solution import gcd, lcm # Test GCD Function def test_gcd(): assert gcd(4, 6) == 2 assert gcd(6, 8) == 2 assert gcd(10, 15) == 5 assert gcd(21, 14) == 7 assert gcd(1, 1) == 1 # Test LCM Function def test_lcm(): assert lcm(4, 6) == 12 assert lcm(6, 8) == 24 assert lcm(10, 15) == 30...
[ { "docstring": "Calculate the greatest common divisor (GCD) of two numbers.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Calculate the least common multiple (LCM) of two numbers.", "function_declaration": "def lcm(n, m)...
[ 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 gcd(a, b):\n \"\"\"\n Returns the greatest common divisor (GCD) of a and b.\n \"\"\"\n while b != 0:\n a, b = b, a % b\n return a\n\ndef ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00065251", "row_id": 65251, "seed_ids": "[17604]" }
0.628774
Taco_65251
I
[ "gcd", "lcm" ]
2
[ [ "lcm", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13b3a4e6e44916b3307a5cb77c966f2311784468
987993c061496fad7e5c25397c3f5966f666b295
v1.0
instruct
Taco
Taco_65260_I
A tree T is an undirected graph with N nodes and N-1 edges such that there is a unique path between any pair of nodes. You are given a tree T and Q queries. In each query, you are given two nodes u and v, and you need to calculate the number of nodes on the unique path between u and v (inclusive of u and v). ### Input...
from collections import deque def bfs(tree, start, n): """ Perform BFS to calculate depth and parent arrays. """ depth = [-1] * (n + 1) parent = [-1] * (n + 1) queue = deque([start]) depth[start] = 0 while queue: node = queue.popleft() for neighbor in tree[node]: ...
from solution import count_nodes_on_path def test_example_case(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] queries = [(1, 4), (4, 5), (3, 5)] assert count_nodes_on_path(n, edges, queries) == [3, 3, 4] def test_single_node(): n = 1 edges = [] queries = [(1, 1)] assert count_nodes_...
[ { "docstring": "Perform BFS to calculate depth and parent arrays.", "function_declaration": "def bfs(tree, start, n):", "function_name": "bfs", "parameter_list": "(tree, start, n)" }, { "docstring": "Find the lowest common ancestor of u and v using depth and parent arrays.", "function_de...
[ 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 bfs_depth_and_parent(tree, N, start_node):\n depth = [-1] * (N + 1) # Depth of each node\n parent = [-1] *...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00065260", "row_id": 65260, "seed_ids": "[2508]" }
0.758251
Taco_65260
I
[ "bfs", "lca", "count_nodes_on_path" ]
3
[ [ "count_nodes_on_path", "bfs" ], [ "count_nodes_on_path", "lca" ] ]
2
[]
false
[]
false
pytest
true
[]
true
961e3740856bd09e7585ea344270290757c1cb0e
1e7177bd112d1c74c28a725005d6314547cd6a14
v1.0
instruct
Taco
Taco_65307_I
A popular video game requires players to solve puzzles to advance to the next level. One such puzzle involves navigating through a grid of rooms. Each room is marked with a number that indicates the cost of visiting that room. The player can move up, down, left, or right, but not diagonally. The goal is to find the pat...
import heapq def min_cost_path(grid): n = len(grid) m = len(grid[0]) # Priority queue to store (cost, (row, col)) pq = [(grid[0][0], (0, 0))] # Directions for movement: up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # 2D list to store the minimum cost t...
from solution import solve_puzzle def test_min_cost_path_3x3(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert solve_puzzle(3, 3, grid) == 7 def test_min_cost_path_1x1(): grid = [ [5] ] assert solve_puzzle(1, 1, grid) == 5 def test_min_cost_path_2x2(): g...
[ { "docstring": null, "function_declaration": "def min_cost_path(grid):", "function_name": "min_cost_path", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve_puzzle(n, m, grid):", "function_name": "solve_puzzle", "parameter_list": "(n, m, grid)"...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_cost_path(n, m, grid):\n \"\"\"\n Calculates the minimum cost path from the top-left corner to the bottom-right corner of a grid.\n \n :param n...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00065307", "row_id": 65307, "seed_ids": "[7447]" }
0.724541
Taco_65307
I
[ "min_cost_path", "solve_puzzle" ]
2
[ [ "solve_puzzle", "min_cost_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8eabf7ca4a3d856b714d6f30dbf870c435e7f379
7ca6a745e68e4f844032ddf4dc5cba876513e488
v1.0
instruct
Taco
Taco_65327_I
You are given an array of integers. In this challenge, your task is to implement the Merge Sort algorithm to sort the array in non-decreasing order. Merge Sort is a divide-and-conquer algorithm that works as follows: Step 1: Divide - Divide the unsorted array into two roughly equal smaller arrays. Step 2: Conquer - R...
def mergeSort(arr): if len(arr) <= 1: return arr # Divide the array into two halves mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] # Recursively sort each half left_sorted = mergeSort(left_half) right_sorted = mergeSort(right_half) # Merge the...
from solution import mergeSort def test_mergeSort_empty(): assert mergeSort([]) == [] def test_mergeSort_single_element(): assert mergeSort([1]) == [1] def test_mergeSort_sorted(): assert mergeSort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_mergeSort_reverse_sorted(): assert mergeSort([5, 4, 3, 2,...
[ { "docstring": null, "function_declaration": "def mergeSort(arr):", "function_name": "mergeSort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" } ]
[ 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 mergeSort(arr):\n if len(arr) <= 1:\n return arr\n \n def merge(left, right):\n sorted_array = []\n while left and right:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065327", "row_id": 65327, "seed_ids": "[261]" }
0.735971
Taco_65327
I
[ "mergeSort", "merge" ]
2
[ [ "mergeSort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
66fa53654ca7d4efae6ec3e92f3c5c331143166b
09a501b0e463ef97fcb45bfe37bb0d923af4fadf
v1.0
instruct
Taco
Taco_65341_I
During a recent city event, the mayor of Hackland was thrilled with a new transportation initiative: the Hackland Tram Network. The tram network consists of a number of stations connected by bidirectional tracks. Each track connects exactly two distinct stations and has a specific weight representing the travel time be...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] ...
from solution import minimal_connection_network def test_single_case(): T = 1 test_cases = [ [(4, 5), (1, 2, 1), (2, 3, 2), (3, 4, 4), (4, 1, 3), (1, 3, 5)] ] assert minimal_connection_network(T, test_cases) == [6] def test_multiple_cases(): T = 2 test_cases = [ [(4, 5), (1, 2,...
[ { "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 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def minimal_connection_network(T, test_cases):\n def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00065341", "row_id": 65341, "seed_ids": "[19438]" }
0.725983
Taco_65341
I
[ "find", "union", "kruskal_mst", "minimal_connection_network" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimal_connection_network", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
8896f2ffd6db3340bc35032e8cf0fae870573966
edd86a733f2f1b65ca934c7dfc919f05dedb644d
v1.0
instruct
Taco
Taco_65344_I
In a city, there is exactly one path between any two neighborhoods, forming a tree structure. Each neighborhood is represented as a node, and the path between two nodes is represented as an edge. Given this information, you are to determine the maximum distance between any two nodes in the tree (also known as the tree'...
from collections import deque def find_farthest_node(n, graph, start): # BFS to find the farthest node from the starting node "start" dist = [-1] * (n + 1) dist[start] = 0 queue = deque([start]) farthest_node = start while queue: node = queue.popleft() for neighbor in graph[nod...
import pytest from solution import tree_diameter def test_tree_diameter_single_node(): assert tree_diameter(1, []) == 0 def test_tree_diameter_linear_tree(): assert tree_diameter(5, [(1, 2), (2, 3), (3, 4), (4, 5)]) == 4 def test_tree_diameter_star_tree(): assert tree_diameter(4, [(1, 2), (1, 3), (1, 4)]...
[ { "docstring": null, "function_declaration": "def find_farthest_node(n, graph, start):", "function_name": "find_farthest_node", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def tree_diameter(n, edges):", "function_name": "tree_diameter", ...
[ 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 tree_diameter(n, edges):\n from collections import defaultdict, deque\n \n if n == 1:\n return 0\n \n def bfs(start):\n distance =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065344", "row_id": 65344, "seed_ids": "[11402]" }
0.74259
Taco_65344
I
[ "find_farthest_node", "tree_diameter" ]
2
[ [ "tree_diameter", "find_farthest_node" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3ec27a58ebd91d4bdba7deaad0351c975576d43a
4baa68826a7df74719a12746c612d8ac8d156fc2
v1.0
instruct
Taco
Taco_65406_I
## Task Write a function that takes a string containing a mathematical expression and returns a translated string where all the digits have been replaced with their English word equivalents. ### Inputs - A string representing a mathematical expression, which includes digits (0-9) and common operators (+, -, *, /). #...
def digit_to_word(digit): """ Helper function to convert a single digit to its corresponding English word. """ digit_words = { '0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine' } return digit_w...
from solution import translate_expression, digit_to_word def test_digit_to_word(): assert digit_to_word('0') == 'zero' assert digit_to_word('1') == 'one' assert digit_to_word('2') == 'two' assert digit_to_word('3') == 'three' assert digit_to_word('4') == 'four' assert digit_to_word('5') == 'fiv...
[ { "docstring": "Helper function to convert a single digit to its corresponding English word.", "function_declaration": "def digit_to_word(digit):", "function_name": "digit_to_word", "parameter_list": "(digit)" }, { "docstring": "Takes a string containing a mathematical expression and returns...
[ 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 digit_to_word(digit):\n \"\"\"\n Helper function to convert a single digit to its corresponding English word.\n \"\"\"\n digit_words = {\n '...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00065406", "row_id": 65406, "seed_ids": "[3932]" }
0.571386
Taco_65406
I
[ "digit_to_word", "translate_expression" ]
2
[ [ "translate_expression", "digit_to_word" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f72c312d6f98c8651fc5c4799953b3193f96e406
0c95260e4d0219707e103f268f2eb2a83d8d2f26
v1.0
instruct
Taco
Taco_65414_I
Zara is developing a new application that needs to handle various queries on arrays efficiently. She has designed a specific type of query called a "range sum query." Given an array of integers, each query will ask for the sum of a subarray defined by a range [L, R] inclusive. Zara is looking for an efficient way to pr...
def preprocess_array(arr): """ Preprocess the array to calculate the prefix sums. """ prefix_sums = [0] * (len(arr) + 1) for i in range(len(arr)): prefix_sums[i + 1] = prefix_sums[i] + arr[i] return prefix_sums def range_sum_query(prefix_sums, L, R): """ Returns the sum of the e...
from solution import preprocess_array, range_sum_query, process_queries def test_preprocess_array(): arr = [1, 2, 3, 4, 5] expected_prefix_sums = [0, 1, 3, 6, 10, 15] assert preprocess_array(arr) == expected_prefix_sums def test_range_sum_query(): prefix_sums = [0, 1, 3, 6, 10, 15] assert range_su...
[ { "docstring": "Preprocess the array to calculate the prefix sums.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" }, { "docstring": "Returns the sum of the elements in the subarray from index L to R inclusive.", "fun...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def range_sum_query(n, q, array, queries):\n \"\"\"\n Processes range sum queries efficiently using prefix sums.\n \n :param n: Number of elements in t...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065414", "row_id": 65414, "seed_ids": "[15927]" }
0.619812
Taco_65414
I
[ "preprocess_array", "range_sum_query", "process_queries" ]
3
[ [ "process_queries", "preprocess_array" ], [ "process_queries", "range_sum_query" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
00d7abc55e76155f51276899f7223f5e4f60f0f8
1397e9147e34e3c9e3de09a62d618e3ecb9186b9
v1.0
instruct
Taco
Taco_65482_I
Given a grid of size N x N where each cell is either '1' or '0', your task is to find the largest rectangle containing only '1's and return its area. Constraints: * 1≤N≤300 * Each cell in the grid is either '0' or '1' Input: The input is given from the standard input in the following format: ``` N grid[0][0] grid[0...
def max_histogram_area(histogram): stack = [] max_area = 0 index = 0 while index < len(histogram): if not stack or histogram[stack[-1]] <= histogram[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (histogram[...
def test_max_histogram_area(): assert max_histogram_area([2, 1, 5, 6, 2, 3]) == 10 assert max_histogram_area([2, 4]) == 4 assert max_histogram_area([6, 2, 5, 4, 5, 1, 6]) == 12 def test_maximal_rectangle_area(): grid1 = [['1', '0', '1', '0'], ['1', '0', '1', '1'], ['1', '1',...
[ { "docstring": null, "function_declaration": "def max_histogram_area(histogram):", "function_name": "max_histogram_area", "parameter_list": "(histogram)" }, { "docstring": null, "function_declaration": "def maximal_rectangle_area(grid):", "function_name": "maximal_rectangle_area", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(grid):\n if not grid:\n return 0\n\n N = len(grid)\n heights = [0] * N\n max_area = 0\n \n for row in range(N):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00065482", "row_id": 65482, "seed_ids": "[21414]" }
0.743256
Taco_65482
I
[ "max_histogram_area", "maximal_rectangle_area" ]
2
[ [ "maximal_rectangle_area", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
false
[]
true
9660ec20627a425f2be0539e368a1ef7201a8f22
a48493d62b9aae6ce0980229804ded6804c5731c
v1.0
instruct
Taco
Taco_65492_I
You are given an N x M grid where each cell contains a positive integer representing the number of coins in that cell. You start at the top-left corner (1, 1) and want to reach the bottom-right corner (N, M). You can move either to the cell directly to the right or directly below the current cell. Your goal is to maxim...
def max_coins(grid): """ Given a grid of integers, returns the maximum number of coins that can be collected from the top-left to the bottom-right corner. """ if not grid: return 0 N = len(grid) M = len(grid[0]) dp = [[0] * M for _ in range(N)] dp[0][0] = grid[0][0]...
def test_max_coins_simple(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert max_coins(grid) == 12 def test_max_coins_single_row(): grid = [ [2, 1, 3] ] assert max_coins(grid) == 6 def test_max_coins_single_column(): grid = [ [2], [1], ...
[ { "docstring": "Given a grid of integers, returns the maximum number of coins\nthat can be collected from the top-left to the bottom-right corner.", "function_declaration": "def max_coins(grid):", "function_name": "max_coins", "parameter_list": "(grid)" }, { "docstring": "Parses the input st...
[ 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 max_coins_collected(grids):\n results = []\n for grid in grids:\n N, M = len(grid), len(grid[0])\n dp = [[0] * M for _ in range(N)]\n\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065492", "row_id": 65492, "seed_ids": "[13364]" }
0.672652
Taco_65492
I
[ "max_coins", "parse_input", "solve" ]
3
[ [ "solve", "max_coins" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
9a9d3814970b4c50c9a0184b56ab1f5a14de4ea6
71cc6bb8d7673a1d5f2e8679a56a92b6f4486b96
v1.0
instruct
Taco
Taco_65512_I
You are designing a new database system called DigiLib for a digital library to manage books. Each book has several attributes including title, author, publication year, genre, and page count. Your system must support dynamic queries that allows users to retrieve a list of books based on different combinations of these...
class Book: def __init__(self, title, author, publication_year, genre, page_count): self.title = title self.author = author self.publication_year = int(publication_year) self.genre = genre self.page_count = int(page_count) def matches_filter(self, filters): ...
import pytest from solution import digital_library def test_single_query_single_filter(): input_str = """5 Harry_Potter_1 J.K.Rowling 1997 Fantasy 223 Harry_Potter_2 J.K.Rowling 1998 Fantasy 251 The_Hobbit J.R.R.Tolkien 1937 Fantasy 310 1984 George_Orwell 1949 Dystopian 328 To_Kill_a_Mockingbird Harper_Lee 1960 Fi...
[]
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def filter_and_sort_books(books, queries):\n def filter_books(book, conditions):\n for cond in conditions:\n key, value = cond.split('=')\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00065512", "row_id": 65512, "seed_ids": "[24926]" }
0.559994
Taco_65512
I
[ "parse_input", "parse_query", "process_queries", "digital_library" ]
4
[ [ "digital_library", "parse_input" ], [ "digital_library", "process_queries" ], [ "process_queries", "parse_query" ] ]
3
[ "parse_input", "process_queries" ]
false
[ "Book" ]
true
pytest
true
[]
true
7f3b6a9bf19f521885b2271dbf446eb13391ceb1
977d5d1d8c3ddecb054bbce97d5aa905078b1330
v1.0
instruct
Taco
Taco_65521_I
Given a binary tree, write a function to find the sum of all the leaf nodes. A leaf node is a node that does not have any child nodes. Input: The first line of input contains an integer T denoting the number of test cases. The first line of each test case consists of an integer N, the number of nodes in the tree. The ...
class Node: def __init__(self, key): self.data = key self.left = None self.right = None def build_binary_tree(elements): if not elements or elements[0] == "NULL": return None root = Node(elements[0]) queue = [root] i = 1 while queue and i < len(elements): ...
import pytest from solution import process_input, solve_test_case, build_binary_tree, sum_of_leaf_nodes def test_sum_of_leaf_nodes(): tree_elements1 = [1, 2, 3, 4, 5, 6, 7] assert solve_test_case(tree_elements1) == 22 tree_elements2 = [10, 20, 30] assert solve_test_case(tree_elements2) == 50 def test...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n \ndef build_tree(level_or...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00065521", "row_id": 65521, "seed_ids": "[23738]" }
0.65212
Taco_65521
I
[ "build_binary_tree", "sum_of_leaf_nodes", "solve_test_case", "process_input" ]
4
[ [ "process_input", "solve_test_case" ], [ "solve_test_case", "build_binary_tree" ], [ "solve_test_case", "sum_of_leaf_nodes" ] ]
3
[ "solve_test_case", "process_input" ]
false
[ "Node" ]
true
pytest
true
[]
true
cb32e60137e44c7c554a9b876c3595077ce69a19
3e1f75e89182494475004fc0eae0110cfaceef99
v1.0
instruct
Taco
Taco_65554_I
Farmer Alex has a rectangular field, divided into a grid of m rows and n columns. Each cell in the field can either contain a crop or be empty. The task is to find the largest rectangle in the grid that contains only crops. You are given a binary matrix where 1 represents a crop and 0 represents an empty cell. The la...
def largest_rectangle_area(matrix): if not matrix: return 0 max_area = 0 n = len(matrix[0]) heights = [0] * n for row in matrix: for i in range(n): if row[i] == 0: heights[i] = 0 else: heights[i] += 1 max_area ...
def test_example_1(): m, n = 4, 4 matrix = [ [1, 0, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1], [0, 1, 0, 0] ] assert solve(m, n, matrix) == 4 def test_example_2(): m, n = 3, 3 matrix = [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] assert solve(m, n,...
[ { "docstring": null, "function_declaration": "def largest_rectangle_area(matrix):", "function_name": "largest_rectangle_area", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def max_histogram_area(heights):", "function_name": "max_histogram_area", "...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if len(matrix) == 0:\n return 0\n \n n = len(matrix[0])\n heights = [0] * n\n max_area = 0\n \n def max...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065554", "row_id": 65554, "seed_ids": "[7256]" }
0.692759
Taco_65554
I
[ "largest_rectangle_area", "max_histogram_area", "solve" ]
3
[ [ "largest_rectangle_area", "max_histogram_area" ], [ "solve", "largest_rectangle_area" ] ]
2
[]
false
[]
false
pytest
false
[]
true
6568e6e7647b04f3c0ba440de4e9f596d63fcffc
6af56ce9d055fc35c60d2106295e3b098aa13630
v1.0
instruct
Taco
Taco_65560_I
Given a tree with N nodes and N-1 edges, where each node is associated with an integer value from 1 to N. You are allowed to perform the following operation as many times as you'd like: Select any two nodes u and v, and if u and v are directly connected, you can swap their values. You want to find out how many differen...
def count_unique_trees(T, testcases): MOD = 10**9 + 7 def find_components(n, edges): visited = [False] * n components = [] def dfs(node, component): stack = [node] while stack: curr = stack.pop() if not visited[curr]: ...
def test_count_unique_trees(): T = 2 testcases = [ (3, [1, 2, 3], [(1, 2), (2, 3)]), (4, [1, 2, 3, 4], [(1, 2), (1, 3), (1, 4)]), ] expected_output = [6, 24] # Adjusted as because for 4 nodes, it should be 24 -> 4 factorial (4!) assert count_unique_trees(T, testcases) == expected_out...
[ { "docstring": null, "function_declaration": "def count_unique_trees(T, testcases):", "function_name": "count_unique_trees", "parameter_list": "(T, testcases)" }, { "docstring": null, "function_declaration": "def factorial(x):", "function_name": "factorial", "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": "MOD = 10**9 + 7\n\ndef factorial(n):\n if n == 0 or n == 1:\n return 1\n result = 1\n for i in range(2, n + 1):\n result = result * i % MOD\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065560", "row_id": 65560, "seed_ids": "[14767]" }
0.690113
Taco_65560
I
[ "count_unique_trees", "factorial" ]
2
[ [ "count_unique_trees", "factorial" ] ]
1
[]
false
[]
false
pytest
false
[]
true
245c8cd88a196a07d4793483a1851b2612f0ed5a
ce455c5b4e0c7d6422412618bd4384468a6b12b4
v1.0
instruct
Taco
Taco_65573_I
A famous archaeologist has discovered an ancient map leading to a treasure hidden in a jungle. The jungle is represented as a rectangular grid of cells, each of which either contains an obstacle or is free to pass through. The map also shows the presence of traps in some cells, which decrease the archaeologist's stami...
import heapq def can_reach_treasure(S_init, S_max, grid, trap_penalty, energy_drinks): rows, cols = len(grid), len(grid[0]) start = (0, 0) goal = (rows - 1, cols - 1) stamina_drinks = sorted(energy_drinks, reverse=True) movement = [(0, 1), (1, 0), (0, -1), (-1, 0)] def in_bounds(r, c): ...
def test_example_case(): input_data = [ "15 20", "4 4", ".A..", "....", "..B.", "..C.", "3", "A 5", "B 8", "C 12", "3", "10", "15", "5", "10 10", "5 5", ".....", ".#B#.", ...
[ { "docstring": null, "function_declaration": "def can_reach_treasure(S_init, S_max, grid, trap_penalty, energy_drinks):", "function_name": "can_reach_treasure", "parameter_list": "(S_init, S_max, grid, trap_penalty, energy_drinks)" }, { "docstring": null, "function_declaration": "def nav...
[ 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": "from collections import deque\n\ndef can_reach_treasure(S_init, S_max, R, C, grid, trap_costs, drinks):\n dirs = [(0,1), (1,0), (0,-1), (-1,0)] # Right, Down, ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00065573", "row_id": 65573, "seed_ids": "[13407]" }
0.651373
Taco_65573
I
[ "can_reach_treasure", "navigate_jungle", "process_input" ]
3
[ [ "navigate_jungle", "can_reach_treasure" ] ]
1
[ "process_input" ]
false
[]
false
pytest
false
[]
true
bc452c960070e050325df9c1ad1afeb95617510b
f01058dfc48ca2bf86f6145b0c5001fa9f386800
v1.0
instruct
Taco
Taco_65599_I
A large-scale e-commerce company is preparing for its biggest sales event of the year. To avoid any potential system failures due to traffic spikes, the company's IT department wants to ensure the server's clock synchronization is accurate and precise. They have servers placed in different time zones. The local time fo...
from datetime import datetime, timedelta def synchronize_time(num_cases, cases): results = [] for case in cases: n = case[0] for i in range(n): local_time, timezone = case[1+i] time = datetime.strptime(local_time, '%H:%M:%S') adjusted_time = time - timedelta(...
def test_process_input(): input_str = """1 2 10:45:05 +5 23:59:59 -3""" expected_output = (1, [[2, ('10:45:05', 5), ('23:59:59', -3)]]) assert process_input(input_str) == expected_output def test_synchronize_time(): num_cases = 1 cases = [ [2, ('10:45:05', 5), ('23:59:59', -3)] ] ex...
[ { "docstring": null, "function_declaration": "def synchronize_time(num_cases, cases):", "function_name": "synchronize_time", "parameter_list": "(num_cases, cases)" }, { "docstring": null, "function_declaration": "def process_input(input_str):", "function_name": "process_input", "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime, timedelta\n\ndef convert_to_gmt(local_time, timezone_offset):\n \"\"\"\n Convert the given local time and timezone offset to G...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065599", "row_id": 65599, "seed_ids": "[8313]" }
0.586719
Taco_65599
I
[ "synchronize_time", "process_input", "synchronize_from_input" ]
3
[ [ "synchronize_from_input", "process_input" ], [ "synchronize_from_input", "synchronize_time" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
fed51c95d2f34d520bd3f40ee6d80de915556101
09f3de84c0e2dadd7f995c2b160e385b3caed3cb
v1.0
instruct
Taco
Taco_65640_I
Yuki is a computer science enthusiast who loves solving algorithmic puzzles. During a recent coding competition, she came across a fascinating problem involving sequences and prime numbers. You are given a sequence `S` of `N` integers and an integer `P`. Yuki needs to determine if there exists a non-empty subsequence ...
def is_prime(n): """Check if a number is prime.""" if n < 2: return False if n in (2, 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 ...
import pytest from solution import check_subsequence_sum_prime def test_example_case(): T = 2 test_cases = [ ((5, 10), [2, 3, 5, 7, 11]), ((3, 20), [10, 15, 20]) ] expected = ["YES", "NO"] assert check_subsequence_sum_prime(T, test_cases) == expected def test_all_elements_prime(): ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Check if there exists a subsequence sum that is a prime number >= P.", "function_declaration": "def check_subsequence_sum_prim...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065640", "row_id": 65640, "seed_ids": "[4251]" }
0.686547
Taco_65640
I
[ "is_prime", "check_subsequence_sum_prime" ]
2
[ [ "check_subsequence_sum_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aeb9794d0d5fda73cedd145e1c94e561ccc11aaa
5929e9f6d220b3b8917e1589bf4d2b2122d33230
v1.0
instruct
Taco
Taco_65664_I
Vani found two binary trees in the deep forest. She decides to traverse both trees in a unique way, first with an in-order traversal and then with a pre-order traversal. She then combined the results of both traversals to determine if by making some adjustments to the second tree, it can be made identical to the first ...
def inorder_traversal(tree, node, result): if node is None: return left, right = tree.get(node, (None, None)) inorder_traversal(tree, left, result) result.append(node) inorder_traversal(tree, right, result) def preorder_traversal(tree, node, result): if node is None: return ...
from solution import can_reorder def test_can_reorder_true(): tree1 = { 'A': ('B', 'C'), 'B': (None, None), 'C': (None, None) } tree3 = { 'A': ('C', 'B'), 'B': (None, None), 'C': (None, None) } assert can_reorder(tree1, tree3) == True def test_can_re...
[ { "docstring": null, "function_declaration": "def inorder_traversal(tree, node, result):", "function_name": "inorder_traversal", "parameter_list": "(tree, node, result)" }, { "docstring": null, "function_declaration": "def preorder_traversal(tree, node, result):", "function_name": "p...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def in_order_traversal(tree, node):\n if node is None:\n return []\n left, right = tree.get(node, (None, None))\n return in_order_traversal(tree, l...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00065664", "row_id": 65664, "seed_ids": "[13184]" }
0.518076
Taco_65664
I
[ "inorder_traversal", "preorder_traversal", "can_reorder" ]
3
[ [ "can_reorder", "inorder_traversal" ], [ "can_reorder", "preorder_traversal" ] ]
2
[]
false
[]
false
pytest
true
[]
true
13e3d286a945670ad51eaa6abe60159458e3d9cb
91adcd5d5c024b27500ccc3e96139e4713678678
v1.0
instruct
Taco
Taco_65683_I
You are given n pairs of integers where each pair represents the coordinates (x, y) of a point on a 2D plane. Your task is to determine if there exists a pair of points such that their Euclidean distance is exactly k. The Euclidean distance between two points (x1, y1) and (x2, y2) is defined as sqrt((x2 - x1)^2 + (y2 ...
import math def euclidean_distance_squared(point1, point2): x1, y1 = point1 x2, y2 = point2 return (x2 - x1) ** 2 + (y2 - y1) ** 2 def check_distances(points, k): k_squared = k * k for i in range(len(points)): for j in range(i + 1, len(points)): if euclidean_distance_squared(po...
from solution import euclidean_distance_squared, check_distances, process_input def test_euclidean_distance_squared(): assert euclidean_distance_squared((0, 0), (3, 4)) == 25 assert euclidean_distance_squared((1, 2), (1, 2)) == 0 assert euclidean_distance_squared((-1, -1), (1, 1)) == 8 def test_check_dist...
[ { "docstring": null, "function_declaration": "def euclidean_distance_squared(point1, point2):", "function_name": "euclidean_distance_squared", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def check_distances(points, k):", "function_name": "che...
[ 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 check_distance(points, k):\n k_squared = k * k\n n = len(points)\n \n for i in range(n):\n for j in range(i + 1, n):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00065683", "row_id": 65683, "seed_ids": "[5731]" }
0.773396
Taco_65683
I
[ "euclidean_distance_squared", "check_distances", "process_input", "solve" ]
4
[ [ "check_distances", "euclidean_distance_squared" ], [ "process_input", "check_distances" ], [ "solve", "process_input" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
03006b81ee1e4fafeb2624c4689ed5484f5f5b12
71ce1b6f9188f657c09bdd3948d77d1157a6b35a
v1.0
instruct
Taco
Taco_65777_I
A common type of data validation involves checking that a provided input adheres to a specified format. In this task, you are required to validate a sequence of strings to ensure they match a given format representing an IPv4 address. IPv4 addresses are written in the format `d.d.d.d`, where `d` represents a decimal n...
def is_valid_ipv4_address(ip): """ Validates if the given IP address string is a valid IPv4 address. """ parts = ip.split('.') if len(parts) != 4: return False for part in parts: if not part.isdigit(): return False num = int(part) if num < 0 or num > 2...
def test_is_valid_ipv4_address(): assert is_valid_ipv4_address("192.168.0.1") == True assert is_valid_ipv4_address("255.255.255.255") == True assert is_valid_ipv4_address("0.0.0.0") == True assert is_valid_ipv4_address("256.100.50.0") == False assert is_valid_ipv4_address("192.168.0.1.1") == False ...
[ { "docstring": "Validates if the given IP address string is a valid IPv4 address.", "function_declaration": "def is_valid_ipv4_address(ip):", "function_name": "is_valid_ipv4_address", "parameter_list": "(ip)" }, { "docstring": "Validates a list of IP addresses and prints 'VALID' or 'INVALID'...
[ 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 validate_ipv4_addresses(n, addresses):\n \"\"\"\n Check if each address in the list is a valid IPv4 address.\n \n Parameters:\n n (int): Number ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065777", "row_id": 65777, "seed_ids": "[21555]" }
0.569779
Taco_65777
I
[ "is_valid_ipv4_address", "validate_ipv4_addresses" ]
2
[ [ "validate_ipv4_addresses", "is_valid_ipv4_address" ] ]
1
[]
false
[]
false
pytest
false
[]
true
fb819807666261cd43440e63e7d881da37b69e8c
6b4558f032ce78c56d63ca3558e0121a34f7a8dd
v1.0
instruct
Taco
Taco_65788_I
You are given an undirected graph with N nodes and M edges. Each edge has a weight associated with it. Your task is to find the Minimum Spanning Tree (MST) of the graph using Kruskal’s algorithm and return the total weight of the MST. If the graph is not connected, return -1. Constraints * 1 ≤ N ≤ 10^5 * 0 ≤ M ≤ 2*10...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
def test_minimum_spanning_tree_connected_graph(): graph_data = [ "1 2 1", "1 3 4", "2 3 2", "2 4 3", "3 4 5" ] assert find_mst_weight(4, 5, graph_data) == 6 def test_minimum_spanning_tree_disconnected_graph(): graph_data = [ "1 2 3", "3 4 4" ]...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, u):\n if parent[u] != u:\n parent[u] = find(parent, parent[u])\n return parent[u]\n\ndef union(parent, rank, u, v):\n root_u = fin...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065788", "row_id": 65788, "seed_ids": "[15161]" }
0.78282
Taco_65788
I
[ "find", "union", "kruskal_mst", "find_mst_weight" ]
4
[ [ "find_mst_weight", "kruskal_mst" ], [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
241fd8ddcc66131dd128d54d0866629463fe3cc0
dd718bc5d943b5b91c53e7651f26cfe9052b0c7b
v1.0
instruct
Taco
Taco_65809_I
You are given an integer `n` and an `n x n` matrix consisting of only the values 0 and 1. Your task is to determine if all the 1s in the matrix form exactly one connected component. Two cells containing 1 are considered connected if they are adjacent horizontally or vertically. Input Input starts with an integer `n` (...
def is_connected_component(n, matrix): # Directions for moving up, right, down, and left directions = [(-1, 0), (0, 1), (1, 0), (0, -1)] # Helper function for Depth First Search def dfs(i, j): stack = [(i, j)] while stack: ci, cj = stack.pop() for di, dj in d...
from solution import check_connected_component def test_check_connected_component_single_component(): matrix_input = [ "1 0 0 1", "1 1 0 1", "0 1 1 0", "0 0 0 0" ] assert check_connected_component(4, matrix_input) == "NO" def test_check_connected_component_disconnected(): ...
[ { "docstring": null, "function_declaration": "def is_connected_component(n, matrix):", "function_name": "is_connected_component", "parameter_list": "(n, matrix)" }, { "docstring": null, "function_declaration": "def check_connected_component(n, matrix_input):", "function_name": "check...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_one_connected_component(matrix, n):\n \"\"\"\n Determines if all 1s in the given n x n matrix form exactly one connected component.\n \n Args:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065809", "row_id": 65809, "seed_ids": "[11747]" }
0.54982
Taco_65809
I
[ "is_connected_component", "check_connected_component" ]
2
[ [ "check_connected_component", "is_connected_component" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e2e0c2ab3470e5f28ab503ef093dd63a496b4a35
8bc45360f1baec0d63f811b7a5e49f79a49131b3
v1.0
instruct
Taco
Taco_65843_I
You are given the task of simulating the movements of a robot in a 2D grid. The robot starts at the top-left corner of the grid (0,0) and can move either right or down. The goal is to find the number of distinct paths the robot can take to reach the bottom-right corner of the grid (n-1, m-1). Additionally, some cells ...
def count_paths(grid): n = len(grid) m = len(grid[0]) if grid[0][0] == 1 or grid[n-1][m-1] == 1: return 0 dp = [[0]*m for _ in range(n)] dp[0][0] = 1 for i in range(n): for j in range(m): if grid[i][j] == 1: dp[i][j] = 0 ...
from solution import num_paths def test_example_1(): grid = [ [0, 0, 0], [0, 1, 0], [0, 0, 0] ] assert num_paths(3, 3, grid) == 2 def test_example_2(): grid = [ [0, 1, 0], [0, 1, 0], [0, 0, 0] ] assert num_paths(3, 3, grid) == 1 def test_example...
[ { "docstring": null, "function_declaration": "def count_paths(grid):", "function_name": "count_paths", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def num_paths(n, m, grid):", "function_name": "num_paths", "parameter_list": "(n, m, grid)" } ]
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_paths(grid):\n n = len(grid)\n m = len(grid[0])\n \n # If the starting point or the ending point is blocked, return 0\n if grid[0][0] == 1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065843", "row_id": 65843, "seed_ids": "[20910]" }
0.771239
Taco_65843
I
[ "count_paths", "num_paths" ]
2
[ [ "num_paths", "count_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e178cdfe3f3dce691bd606872996ed4fecb0912d
bce69aa6d7425102c8a242207b57d439968daa7a
v1.0
instruct
Taco
Taco_65903_I
A gardener is working in a linear garden with `n` flower beds arranged in a straight line. Each flower bed has a certain number of flowers, represented by an integer. The gardener wants to know how many different types of flowers are in each segment of the garden before and after performing some updates. The gardener ...
def update_flower_beds(flower_beds, i, x): flower_beds[i - 1] = x def query_flower_beds(flower_beds, l, r): return len(set(flower_beds[l - 1:r])) def process_operations(n, m, q, initial_flower_beds, operations): results = [] flower_beds = initial_flower_beds[:] for operation in operations: ...
from solution import process_operations def test_process_operations(): n = 5 m = 2 q = 3 initial_flower_beds = [1, 2, 3, 3, 2] operations = [ (2, 1, 5), (1, 3, 4), (2, 1, 5), (1, 2, 5), (2, 2, 4), ] expected_output = [3, 4, 3] assert process_opera...
[ { "docstring": null, "function_declaration": "def update_flower_beds(flower_beds, i, x):", "function_name": "update_flower_beds", "parameter_list": "(flower_beds, i, x)" }, { "docstring": null, "function_declaration": "def query_flower_beds(flower_beds, l, r):", "function_name": "que...
[ 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 process_garden_operations(n, m, q, initial_flowers, operations):\n from collections import defaultdict\n \n flower_beds = initial_flowers\n \n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065903", "row_id": 65903, "seed_ids": "[9040]" }
0.717941
Taco_65903
I
[ "update_flower_beds", "query_flower_beds", "process_operations" ]
3
[ [ "process_operations", "query_flower_beds" ], [ "process_operations", "update_flower_beds" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ce5e11fb2a160e157db0d6167ff37f59f47b3bc0
317153a4f8a913524a23bea7a0aa43fb7c0fb3c5
v1.0
instruct
Taco
Taco_65913_I
A country is planning to build a new network of highways to connect its cities. They have identified a set of cities and possible roads they could construct between pairs of cities, along with the cost of constructing each road. They want to ensure that every city is connected directly or indirectly to every other city...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif rank[root_x] < rank...
def test_example_1(): n, m = 4, 5 connections = [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 1, 2), (2, 4, 6)] assert minimum_cost_to_connect_cities(n, m, connections) == 9 def test_example_2(): n, m = 3, 3 connections = [(1, 2, 5), (1, 3, 6), (2, 3, 7)] assert minimum_cost_to_connect_cities(n, m, con...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00065913", "row_id": 65913, "seed_ids": "[3804]" }
0.77196
Taco_65913
I
[ "find", "union", "kruskal", "minimum_cost_to_connect_cities" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_cost_to_connect_cities", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
9e54d709be978895bc2424f550fe6115dea46b01
a254d965f15db5688aa2ecad9dcaef7f9f777e27
v1.0
instruct
Taco
Taco_65983_I
-----Problem Statement----- Bob is learning about binary trees in his data structures class. He is particularly interested in finding the lowest common ancestor (LCA) of two nodes in a binary tree. The LCA of two nodes p and q in a binary tree is defined as the lowest node in the tree that has both p and q as descendan...
class TreeNode: """ TreeNode represents a node in a binary tree. """ def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): """ Build a binary tree from the nodes representation. """ if not node...
import pytest from solution import lca_in_binary_tree def test_lca_case_1(): T = 2 test_cases = [ (5, [(2, 3), (-1, -1), (4, 5), (-1, -1), (-1, -1)], 4, 5), (6, [(2, 3), (-1, -1), (4, 5), (-1, 6), (-1, -1), (-1, -1)], 1, 5) ] expected = [3, 1] assert lca_in_binary_tree(T, test_cases...
[]
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.key = key\n self.left = None\n self.right = None\n\ndef build_tr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065983", "row_id": 65983, "seed_ids": "[11279]" }
0.636835
Taco_65983
I
[ "build_tree", "find_lca", "lca_in_binary_tree" ]
3
[ [ "lca_in_binary_tree", "build_tree" ], [ "lca_in_binary_tree", "find_lca" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
098a621059dd617e1b0fc4e6c5a6c60e14ce8b5c
b5baf4e105606c82caa7b1cd04a1cbce59bce48d
v1.0
instruct
Taco
Taco_65991_I
You are given a list of non-negative integers. For each integer in the list, you need to determine the length of the Collatz sequence starting with that integer. The Collatz sequence is defined as follows: - Start with any integer n. - If n is even, divide it by 2. - If n is odd, multiply it by 3 and add 1. - Repeat t...
def collatz_sequence_length(n): """ Returns the length of the Collatz sequence starting with n. """ length = 1 while n != 1: if n % 2 == 0: n = n // 2 else: n = 3 * n + 1 length += 1 return length def process_collatz_sequences(numbers): """ ...
from solution import collatz_sequence_length, process_collatz_sequences def test_collatz_sequence_length(): assert collatz_sequence_length(1) == 1 assert collatz_sequence_length(2) == 2 assert collatz_sequence_length(3) == 8 assert collatz_sequence_length(5) == 6 assert collatz_sequence_length(10) ...
[ { "docstring": "Returns the length of the Collatz sequence starting with n.", "function_declaration": "def collatz_sequence_length(n):", "function_name": "collatz_sequence_length", "parameter_list": "(n)" }, { "docstring": "Processes a list of numbers and returns list of lengths of their Col...
[ 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 collatz_sequence_length(n):\n \"\"\"\n Calculate the length of the Collatz sequence for a given integer n.\n \"\"\"\n if n <= 0:\n return 0\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00065991", "row_id": 65991, "seed_ids": "[21856]" }
0.749772
Taco_65991
I
[ "collatz_sequence_length", "process_collatz_sequences" ]
2
[ [ "process_collatz_sequences", "collatz_sequence_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4903fd537c1866a775bada117d84df6c5ab8961a
d795020e91b27280bccb41b27d97e115b732d6f6
v1.0
instruct
Taco
Taco_66048_I
There is a city with N intersections, numbered 1 through N. The i-th of the M roads connects intersections u_i and v_i. There are M courses available for delivery, and each course consists of starting at one intersection and ending at another. Delivery drivers need to know the shortest distance to complete each delive...
from collections import deque def shortest_path_bfs(graph, start, end): """ Returns the shortest path length between start and end using BFS. If no path exists, returns -1. """ if start == end: return 0 visited = set() queue = deque([(start, 0)]) while queue: n...
from solution import delivery_courses def test_case_1(): N = 5 M = 6 roads = [(1, 2), (2, 3), (3, 4), (4, 5), (2, 4), (1, 5)] Q = 3 queries = [(1, 3), (2, 5), (1, 6)] expected_output = [2, 2, -1] assert delivery_courses(N, M, roads, Q, queries) == expected_output def test_case_2(): N =...
[ { "docstring": "Returns the shortest path length between start and end using BFS.\nIf no path exists, returns -1.", "function_declaration": "def shortest_path_bfs(graph, start, end):", "function_name": "shortest_path_bfs", "parameter_list": "(graph, start, end)" }, { "docstring": null, "...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nfrom collections import deque\n\ndef find_shortest_paths(N, roads, queries):\n def bfs(start):\n dist = [-1] * (N + 1)\n dist[start] =...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00066048", "row_id": 66048, "seed_ids": "[11116]" }
0.797555
Taco_66048
I
[ "shortest_path_bfs", "delivery_courses" ]
2
[ [ "delivery_courses", "shortest_path_bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54640a65a1decc9d90cdbcd325f41e6b3efe7bbc
8cd47c7c3cd60b8c0bf1dd83834191d859d7f99f
v1.0
instruct
Taco
Taco_66058_I
Bertlandia is a vast country known for its extensive road network connecting all its cities. The country has n cities labeled from 1 to n and m bidirectional roads. Each road connects two distinct cities and has a distinct positive length. Recently, Bertlandia’s government has decided to build a new highway network suc...
import heapq def prim_mst(graph, n): """ Use Prim's algorithm to find the MST of the connected components of the graph. """ in_mst = [False] * (n + 1) # Priority queue to pick the smallest edge pq = [(0, 1)] # Weight, start from node 1 total_cost = 0 mst_edges = [] while pq: ...
def test_find_new_highways(): roads = [ (1, 2, 5), (2, 3, 7), (3, 4, 8) ] assert find_new_highways(4, 3, 2, roads) == [(1, 3, 4), (1, 4, 5)] roads = [ (1, 2, 1), (4, 5, 2) ] assert find_new_highways(5, 2, 3, roads) == [(1, 3, 4), (1, 4, 5), (1, 5, 6)] ...
[ { "docstring": "Use Prim's algorithm to find the MST of the connected components of the graph.", "function_declaration": "def prim_mst(graph, n):", "function_name": "prim_mst", "parameter_list": "(graph, n)" }, { "docstring": null, "function_declaration": "def find_new_highways(n, m, k, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef find_new_highways(n, m, k, roads):\n # Initialize the adjacency list for the graph\n adj = {i: [] for i in range(1, n + 1)}\n for a, b...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00066058", "row_id": 66058, "seed_ids": "[2953]" }
0.723118
Taco_66058
I
[ "prim_mst", "find_new_highways" ]
2
[ [ "find_new_highways", "prim_mst" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4abd2b6a85945be0aa48e9810524ab83cc298a8e
90f4e9de41805e474b7eecf5e852953013464ef7
v1.0
instruct
Taco
Taco_66131_I
You are managing a library's book collection system. The system tracks multiple books represented by unique IDs and their corresponding positions on the shelves. Each book has an ID and a position in the format (shelf_number, position_on_shelf), where shelf_number and position_on_shelf are both integers. Librarians fr...
def manage_library(operations): collection = {} for operation in operations: parts = operation.split() command = parts[0] if command == "ADD": book_id = int(parts[1]) shelf_number = int(parts[2]) position_on_shelf = int(parts[3]) ...
def test_run_library_system(): operations = [ "ADD 101 2 3", "ADD 102 1 1", "MOVE 101 2 5", "REMOVE 102", "ADD 103 1 2", ] expected_output = [ "101 (2, 5)", "103 (1, 2)", ] assert run_library_system(operations) == expected_output def test_run_...
[ { "docstring": null, "function_declaration": "def manage_library(operations):", "function_name": "manage_library", "parameter_list": "(operations)" }, { "docstring": null, "function_declaration": "def format_output(sorted_books):", "function_name": "format_output", "parameter_lis...
[ 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 manage_library(operations):\n \"\"\"\n Processes a series of operations to manage a library's book collection.\n \n :param operations: List of oper...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00066131", "row_id": 66131, "seed_ids": "[3340]" }
0.619246
Taco_66131
I
[ "manage_library", "format_output", "run_library_system" ]
3
[ [ "run_library_system", "format_output" ], [ "run_library_system", "manage_library" ] ]
2
[ "format_output" ]
false
[]
false
pytest
false
[]
true
e44cbe3d3e8e5f78696604f86db796b6d7593ff5
4736c800fb96ed78199807b591bf1868e5ea8d68
v1.0
instruct
Taco
Taco_66199_I
Maria operates a shipping company and wants to optimize the loading of cargo containers to maximize the total value of loaded goods. Each cargo container can carry a specific maximum weight, and you have a list of items, each with a specific weight and value. Maria needs a program to help her determine the maximum valu...
def knapsack(W, items): """ Determines the maximum value of items that can be loaded into a container without exceeding the weight capacity. Parameters: W (int): Maximum weight capacity of the container items (list of tuples): List of tuples where each tuple contains (weight, value) of the item ...
from solution import solve_knapsack_problem def test_example(): W = 50 N = 3 items = ["10 60", "20 100", "30 120"] assert solve_knapsack_problem(W, N, items) == 220 def test_single_item_fits(): W = 50 N = 1 items = ["50 100"] assert solve_knapsack_problem(W, N, items) == 100 def test_...
[ { "docstring": "Determines the maximum value of items that can be loaded into a container without exceeding the weight capacity.\n\nParameters:\nW (int): Maximum weight capacity of the container\nitems (list of tuples): List of tuples where each tuple contains (weight, value) of the item\n\nReturns:\nint: Maxim...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def knapsack(W, items):\n \"\"\"\n Finds the maximum total value of items that can be loaded into the container \n without exceeding the weight capacity W...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00066199", "row_id": 66199, "seed_ids": "[15034]" }
0.773371
Taco_66199
I
[ "knapsack", "solve_knapsack_problem" ]
2
[ [ "solve_knapsack_problem", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
397bbeee4653d8b70c303f9bec02b21ea6384d68
9c519575b0688c329da4dcc45a018d6767457651
v1.0
instruct
Taco
Taco_66207_I
Functional Area Mapping You are tasked with designing a system that maps several functionality components in a tech company to their respective teams. Each functionality component can only belong to one team. There are a fixed number of teams, and some functionality components have dependencies on other components, me...
from collections import defaultdict, deque def is_bipartite(graph, f): color = [-1] * (f + 1) # Color -1 indicates unvisited nodes for i in range(1, f + 1): if color[i] == -1: # Not yet visited node queue = deque([i]) color[i] = 0 # Start coloring this component with col...
from solution import map_functionalities_to_teams, assign_teams def test_no_solution(): test_cases = [ (2, 3, [(1, 2), (2, 3), (3, 1)]) ] result = map_functionalities_to_teams(test_cases) assert result == ["NO"] def test_valid_assignment(): test_cases = [ (3, 2, [(1, 2), (2, 1)]) ...
[ { "docstring": null, "function_declaration": "def is_bipartite(graph, f):", "function_name": "is_bipartite", "parameter_list": "(graph, f)" }, { "docstring": null, "function_declaration": "def assign_teams(t, f, dependencies):", "function_name": "assign_teams", "parameter_list": ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef is_bipartite(graph, f):\n color = [-1] * (f + 1)\n \n for start in range(1, f+1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00066207", "row_id": 66207, "seed_ids": "[2277]" }
0.662513
Taco_66207
I
[ "is_bipartite", "assign_teams", "map_functionalities_to_teams" ]
3
[ [ "assign_teams", "is_bipartite" ], [ "map_functionalities_to_teams", "assign_teams" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9256158b51d694b239b5210d3511faa877e2d961
0b8193d6b1e2fe7020a011fee23b532c4477e582
v1.0
instruct
Taco
Taco_66209_I
Aliens have now developed a liking for prime numbers encoded in Morse code. They want to know if a Morse code string represents a prime number. Write a program that receives a Morse code string and checks if the decoded number is prime. Use the same Morse code conventions provided: 1 .---- 2 ..--- 3 ...-- 4 ....- ...
def morse_to_number(morse_code): morse_dict = { '.----': '1', '..---': '2', '...--': '3', '....-': '4', '.....': '5', '-....': '6', '--...': '7', '---..': '8', '----.': '9', '-----': '0' } if morse_code in morse_dict: return int(morse_dict[morse_code]) return None def is_prime(n...
from solution import morse_to_number, is_prime, is_morse_prime import pytest def test_morse_to_number(): assert morse_to_number('.----') == 1 assert morse_to_number('..---') == 2 assert morse_to_number('...--') == 3 assert morse_to_number('....-') == 4 assert morse_to_number('.....') == 5 asser...
[ { "docstring": null, "function_declaration": "def morse_to_number(morse_code):", "function_name": "morse_to_number", "parameter_list": "(morse_code)" }, { "docstring": null, "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)"...
[ 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": "# Define Morse code dictionary\nmorse_code_to_digit = {\n '.----': '1',\n '..---': '2',\n '...--': '3',\n '....-': '4',\n '.....': '5',\n '-....'...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00066209", "row_id": 66209, "seed_ids": "[4217]" }
0.579383
Taco_66209
I
[ "morse_to_number", "is_prime", "is_morse_prime" ]
3
[ [ "is_morse_prime", "is_prime" ], [ "is_morse_prime", "morse_to_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a8e9098feff58568c6360b8720b8906bfe1c721f
747ccda0636a687e04f2ca6a71631e9932678163
v1.0
instruct
Taco
Taco_66255_I
Implement a function that takes an array of integers and a target sum. The function should return the number of unique quadruples (sets of four numbers) from the array that sum up to the target sum. The quadruples should not include duplicate sets, even if the numbers appear in a different order. Example: Input 6 1 0 ...
def fourSumCount(nums, target): """ Returns the count of unique quadruples that sum up to the target value. """ nums.sort() quadruples = set() n = len(nums) for i in range(n-3): for j in range(i+1, n-2): left, right = j+1, n-1 while left < right: ...
from solution import fourSumCount def test_fourSumCount_example_case(): assert fourSumCount([1, 0, -1, 0, -2, 2], 0) == 3 def test_fourSumCount_no_quadruple(): assert fourSumCount([1, 2, 3, 4], 100) == 0 def test_fourSumCount_all_zeros(): assert fourSumCount([0, 0, 0, 0, 0], 0) == 1 def test_fourSumCoun...
[ { "docstring": "Returns the count of unique quadruples that sum up to the target value.", "function_declaration": "def fourSumCount(nums, target):", "function_name": "fourSumCount", "parameter_list": "(nums, target)" }, { "docstring": null, "function_declaration": "def input_output_handl...
[ 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 four_sum_count(nums, target):\n \"\"\"\n Returns the count of unique quadruples that sum up to the target.\n \"\"\"\n nums.sort()\n quadruples =...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00066255", "row_id": 66255, "seed_ids": "[9456]" }
0.630045
Taco_66255
I
[ "fourSumCount", "input_output_handler" ]
2
[ [ "input_output_handler", "fourSumCount" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f597a044efe1800c98387c99df717595480d956b
1427a0d54319c6ecea61b332aba96a9c4ca14828
v1.0
instruct
Taco
Taco_66341_I
You are provided with a list of non-negative integers. Your task is to form the largest possible number by concatenating the integers in the list. Write a function `largest_number(nums)` that takes a list of non-negative integers and returns a string representing the largest number that can be formed by concatenating ...
from functools import cmp_to_key def compare(x, y): # Custom comparison function to decide the order based on concatenation if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_number(nums): """ Returns the largest possible number formed b...
from solution import largest_number def test_single_element(): assert largest_number([1]) == "1" assert largest_number([0]) == "0" assert largest_number([999]) == "999" def test_all_zeros(): assert largest_number([0, 0, 0]) == "0" def test_sample_cases(): assert largest_number([10, 2]) == "210" ...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Returns the largest possible number formed by concatenating\na list of non-negative integers.", "function_declaration": "def largest_number(nums):"...
[ 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 functools import cmp_to_key\n\ndef compare(x, y):\n if x + y > y + x:\n return -1\n elif x + y < y + x:\n return 1\n else:\n ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00066341", "row_id": 66341, "seed_ids": "[14705]" }
0.697455
Taco_66341
I
[ "compare", "largest_number" ]
2
[ [ "largest_number", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7e7cf2da97101fd2d621e816f8015a6a8bf53ec6
c39e69ea12322c2e313faa8f974ddc573bac7cc0
v1.0
instruct
Taco
Taco_66349_I
Given a list of N integers, determine the number of unique pairs (i, j) where i < j and the sum of the pair (nums[i] + nums[j]) is a prime number. INPUT: The first line contains an integer T, the number of test cases. Each test case consists of two lines: - The first line contains an integer N, the size of the list. ...
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 count_prime_pairs(test_cases): resul...
import pytest from solution import is_prime, count_prime_pairs, process_input, solve def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(15) == False def test_count_prime_pairs(): test_cases = [ ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_prime_pairs(test_cases):", "function_name": "count_prime_pairs", "parameter_list": "(test_cases)" }, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00066349", "row_id": 66349, "seed_ids": "[7856]" }
0.806111
Taco_66349
I
[ "is_prime", "count_prime_pairs", "process_input", "solve" ]
4
[ [ "count_prime_pairs", "is_prime" ], [ "solve", "count_prime_pairs" ], [ "solve", "process_input" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
799ef0aee487f94438c634278d3197ffde7bdeaf
319d9997b8e1cfdc902e689f81269eecbcba800c
v1.0
instruct
Taco
Taco_66378_I
You are given a list of words. Your task is to find all the unique anagrams in the list and return the groups of words that are anagrams of each other. An anagram of a word is a rearrangement of its letters to form another word. For example, the words "listen" and "silent" are anagrams of each other, as they contain t...
from collections import defaultdict def find_anagram_groups(words): """ Returns groups of anagram words from the given list of words. :param words: List of words (lowercase English letters only) :type words: List[str] :return: List of anagram groups :rtype: List[List[str]] """ anag...
from solution import find_anagram_groups, format_output, group_anagrams def test_find_anagram_groups(): words = ["listen", "silent", "enlist", "inlets", "stop", "tops", "pots"] result = find_anagram_groups(words) assert result == [['enlist', 'inlets', 'listen', 'silent'], ['pots', 'stop', 'tops']] def tes...
[ { "docstring": "Returns groups of anagram words from the given list of words.\n\n:param words: List of words (lowercase English letters only)\n:type words: List[str]\n:return: List of anagram groups\n:rtype: List[List[str]]", "function_declaration": "def find_anagram_groups(words):", "function_name": "f...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef find_anagram_groups(words):\n anagram_dict = defaultdict(list)\n \n for word in words:\n sorted_word = '...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00066378", "row_id": 66378, "seed_ids": "[2502]" }
0.652554
Taco_66378
I
[ "find_anagram_groups", "format_output", "group_anagrams" ]
3
[ [ "group_anagrams", "find_anagram_groups" ], [ "group_anagrams", "format_output" ] ]
2
[ "format_output" ]
false
[]
false
pytest
true
[]
true
4b01f723cc1eab50262fc41066a55ec0d011a7ab
1c2539a7f375bf3d789745c70790235f1056cfd3